@polycode-projects/the-mechanical-code-talker 3.0.8 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
- (()=>{var fb=Object.defineProperty;var L=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(s){throw n=[s],s}};var En=(e,t)=>{for(var n in t)fb(e,n,{get:t[n],enumerable:!0})};var et,u_,d_,p_,f_,m_,h_,g_,b_,w_,y_,v_,$_,x_,k_,S_,E_,Z,$e,qt,pu,j_,__,R_,De=L(()=>{et=e=>()=>{throw new Error(e+" unavailable in the browser ask bundle")},u_=et("createRequire"),d_=et("readFileSync"),p_=et("access"),f_=et("readFile"),m_=et("writeFile"),h_=et("appendFile"),g_=et("mkdir"),b_=et("mkdtemp"),w_=et("rename"),y_=et("unlink"),v_=et("rm"),$_=et("stat"),x_=et("copyFile"),k_=et("readdir"),S_=et("createReadStream"),E_=et("createWriteStream"),Z=(...e)=>e.join("/"),$e=e=>String(e).replace(/\/[^/]*$/,""),qt=(...e)=>e.join("/"),pu="/",j_=et("randomBytes"),__=et("spawnSync"),R_=et("createInterface")});var tt,T_,C_,fu,ze,Lo,mb,jn,hb,Or,ia,gb,bb,I_,wb,O_,L_,N_,M_,P_,vt=L(()=>{tt=e=>()=>{throw new Error(e+" unavailable in the browser ask bundle")},T_=tt("createRequire"),C_=tt("readFileSync"),fu=tt("access"),ze=tt("readFile"),Lo=tt("writeFile"),mb=tt("appendFile"),jn=tt("mkdir"),hb=tt("mkdtemp"),Or=tt("rename"),ia=tt("unlink"),gb=tt("rm"),bb=tt("stat"),I_=tt("copyFile"),wb=tt("readdir"),O_=tt("createReadStream"),L_=tt("createWriteStream"),N_=tt("randomBytes"),M_=tt("spawnSync"),P_=tt("createInterface")});function gs(e){return e.replace(yb,"").trim()}function Xt(e){let t=e;for(let n=0;n<2;n+=1){let s=t.replace($b,"").trim();if(s=s.replace(kb,"").trim(),s===t)break;t=s}return t}var mu,No,Mo,Yt,hu,an,aa,yb,vb,$b,xb,kb,de,Po,Sb,gu,Be,Gt,Hn,bu,ca,la,ua,wu,Fo,bs,yu,vu,ws,_n,Rn,Xs,Ve,$u,ys,vs,Kn,pn,xu,Do,Js,Lr,Qs,ku,An=L(()=>{mu=["is a superclass of","are a superclass of","is a parent class of","are a parent class of","superclass","superclasses"],No={imports:{bare:"import",comment:"Module -> Module: subject's import graph references object (usesComplexType).",verbs:["couples to","couple to","depends on","imports","import","relies on","rely on","requires","require","references","reference","pulls in","pull in","built on","builds on","build on","uses code from","grabs","grab","pulls from","pull from","leans on","lean on","is wired to","are wired to","is hooked up to","are hooked up to","importing"]},uses:{bare:"use",comment:"query-side union: imports (Module->Module) + calls (Module->Module) + callsSymbol (fn->fn).",verbs:["uses","use","makes use of","make use of","talks to","talk to","using"]},calls:{bare:"call",comment:"Function/Method -> Function/Class (symbol-grain) or Module -> Module (coarse): subject invokes object.",verbs:["invokes","invoke","calls","call","runs","run","executes","execute","hits","hit","triggers","trigger","fires","fire","kicks off","kick off","calling"]},defines:{bare:"define",comment:"Module -> top-level Function/Class/Method/Attribute: subject declares object.",verbs:["defines","define","declares","declare","has","have","holds","hold","defining"]},contains:{bare:"contain",comment:"Class -> Method/Attribute: subject's membership includes object.",verbs:["contains","contain","lives in","live in","is defined in","are defined in","is part of","are part of","sits in","sit in","sits inside","sit inside","containing"]},tests:{bare:"test",comment:"Module -> Module: subject is a test module importing/covering object.",verbs:["tests","test","covers","cover","verifies","verify","exercises","exercise","checks","check","makes sure of","make sure of","testing"]},inherits:{bare:"inherit from",comment:"Class -> Class: subject's declared base resolves to object (subclassOf).",verbs:["inherits from","inherit from","inherits","inherit","extends","extend","subclasses","subclass","derives from","derive from","is a subclass of","are a subclass of","is a kind of","are a kind of","is built off","are built off","is built on top of","are built on top of","extending","inheriting from","inheriting","subclassing","extends from",...mu]},touches:{bare:"touch",comment:"Commit -> Module (coarse) or Commit -> symbol (fine, touchesSymbol): a commit's changed-line-range intersects object.",verbs:["touched","touches","changed","change","modified","modifies","was changed in","were changed in","was edited in","were edited in","was modified by","were modified by","was tweaked in","were tweaked in","got changed in","got edited in","touch","changed in","landed in","land in","was in","were in","went into","included in","updated","edited","touching"]},cochange:{bare:"co-change with",comment:"Module -> Module: subject and object are frequently committed together (changeCoupledWith).",verbs:["changed with","co-changes with","co-change with","changes alongside","change alongside","shares commits with","share commits with","tends to change together with","tend to change together with","moves together with","move together with","changed together with","change together with","changes together with","changes with","change with","tends to change with","tend to change with","usually changes with"]},reexports:{bare:"re-export",comment:"Module -> exported symbol: subject's public API surface (__all__/export list).",verbs:["exports","export","re-exports","re-export","passes through","pass through","exposes","expose","exporting"]}},Mo=Object.freeze([...mu,"is the superclass of","are the superclass of","is the parent class of"]),Yt=Object.freeze(["defined","declared","located","implemented"]),hu=Object.freeze(["now","currently","right now","at the moment","these days","today"]),an=Object.freeze(["mentioned","referenced"]),aa=Object.freeze(["in this graph","in the graph","in this codebase","in the codebase","in this repo","in the repo","here"]),yb=new RegExp(`\\s+(?:${aa.join("|")})\\s*[?.!]*$`,"i");vb=Object.freeze(["then","though","too"]),$b=new RegExp(`\\s+(?:${vb.join("|")})\\s*[?.!]*$`,"i"),xb=Object.freeze(["please explain","explain"]),kb=new RegExp(`,\\s*(?:${xb.join("|")})\\s*[?.!]*$`,"i");de=Object.freeze(Object.fromEntries(Object.entries(No).flatMap(([e,{verbs:t}])=>t.map(n=>[n,e])))),Po=Object.freeze(new Set(["has","have","holds","hold"])),Sb=e=>!Mo.includes(e),gu=Object.freeze([...new Set(Object.keys(de).filter(Sb).map(e=>e.match(/^(?:is|are)\s+an?\s+(.+)$/i)).filter(Boolean).map(e=>e[1].toLowerCase()))]),Be=Object.freeze({function:"Function",functions:"Function",method:"Method",methods:"Method",class:"Class",classes:"Class",module:"Module",modules:"Module",mod:"Module",mods:"Module",file:"Module",files:"Module",package:"Package",packages:"Package",attribute:"Attribute",attributes:"Attribute",field:"Attribute",fields:"Attribute",variable:"GlobalVariable",variables:"GlobalVariable",global:"GlobalVariable",globals:"GlobalVariable",change:"Change",changes:"Change",commit:"Commit",commits:"Commit"}),Gt=Object.freeze({explicitly:"direct",directly:"direct",transitively:"transitive",indirectly:"transitive"}),Hn=Object.freeze({imported:"imports",called:"calls",used:"uses",tested:"tests",covered:"tests",verified:"tests",exercised:"tests",checked:"tests",defined:"defines",declared:"defines",inherited:"inherits",extended:"inherits",subclassed:"inherits",contained:"contains",exported:"reexports","re-exported":"reexports",exposed:"reexports",touched:"touches",changed:"touches",modified:"touches",edited:"touches",updated:"touches"}),bu=Object.freeze({"inherited from":{kind:"inherits",role:"object"},"extended from":{kind:"inherits",role:"object"},"subclassed from":{kind:"inherits",role:"object"},"defined in":{kind:"defines",role:"agent"},"declared in":{kind:"defines",role:"agent"},"contained in":{kind:"contains",role:"agent"},"imported by":{kind:"imports",role:"agent"},"called by":{kind:"calls",role:"agent"},"used by":{kind:"uses",role:"agent"},"tested by":{kind:"tests",role:"agent"},"covered by":{kind:"tests",role:"agent"},"touched by":{kind:"touches",role:"agent"},"changed by":{kind:"touches",role:"agent"},"exported by":{kind:"reexports",role:"agent"}}),ca=Object.freeze({"ain't":"is not",aint:"is not","isn't":"is not",isnt:"is not","aren't":"are not",arent:"are not","doesn't":"does not",doesnt:"does not","don't":"do not",dont:"do not","didn't":"did not",didnt:"did not","there's":"there is",theres:"there is","what's":"what is",whats:"what is","who's":"who is",whos:"who is",gonna:"going to",wanna:"want to",gotta:"got to",yer:"your",ur:"your",gimme:"give me"}),la=Object.freeze({funtion:"function",funtions:"functions",fucntion:"function",fucntions:"functions",functoin:"function",functoins:"functions",calss:"class",calsses:"classes",classs:"class",clases:"classes",modul:"module",moduls:"modules",moduel:"module",moduels:"modules",moudle:"module",moudles:"modules",methdo:"method",methdos:"methods",mehtod:"method",mehtods:"methods",comit:"commit",comits:"commits",commmit:"commit",commmits:"commits",varaible:"variable",varaibles:"variables",varibale:"variable",varibales:"variables",atribute:"attribute",atributes:"attributes",improt:"import",improts:"imports",imoprt:"import",imoprts:"imports",inherts:"inherits",inheirts:"inherits",extands:"extends",extneds:"extends",depnds:"depends",touchs:"touches",tuoches:"touches",touhced:"touched",touchd:"touched",defned:"defined",chagned:"changed",chnaged:"changed",chagnes:"changes",chnages:"changes",calles:"calls",exprot:"export",exprots:"exports",tets:"tests",whcih:"which",wich:"which",whihc:"which",wehre:"where",whre:"where",waht:"what",wat:"what",dat:"that",dose:"does",doess:"does",teh:"the",manyn:"many",mnay:"many",amny:"many",mnany:"many",hwo:"how",coutn:"count",conut:"count",cuont:"count",ocunt:"count",numer:"number",nubmer:"number",numbr:"number",nmuber:"number",lst:"list",lsit:"list",ilst:"list",shwo:"show",hsow:"show",dispaly:"display",dsiplay:"display",funtcions:"functions",funciton:"function",funcitons:"functions"}),ua=Object.freeze({folder:"module",folders:"modules",directory:"module",directories:"modules",func:"function",funcs:"functions",changeset:"commit",changesets:"commits",revision:"commit",revisions:"commits",property:"attribute",properties:"attributes"}),wu=/\b([a-z]{3,})in'/gi,Fo=Object.freeze(["um","uh","erm","so","like","yo","hey","bru","bro","fam","mate","please","could you","can you","would you","tell me","i wonder","just wondering","quickly","real quick","kinda","sorta","btw","by the way","you","quick q"]),bs=Object.freeze(["this","it","that","here","this one","that one"]),yu=Object.freeze([{re:/\bthere\s+is\s+not\s+(?:anything|nothing)\s+(?:that\s+)?(\S.*)$/i,to:e=>`what ${e[1]}`},{re:/\bthere\s+is\s+no\s+\S+\s+(?:that\s+)?(\S.*)$/i,to:e=>`what ${e[1]}`},{re:/\bis\s+not\s+there\s+(?:anything|nothing)\s+(?:that\s+)?(\S.*)$/i,to:e=>`what ${e[1]}`},{re:/\b(?:nobody|nothing|no one)\s+(\S.*?)(?:,?\s+does\s+it\??|,?\s+do\s+they\??)?$/i,to:e=>`what ${e[1]}`}]),vu=Object.freeze([{re:/^what\s+(?:is|was|were|are)\s+in\s+((?:commit\s+)?[0-9a-f]{7,40})\??$/i,to:e=>`what did ${e[1]} touch`},{re:/^what\s+(?:went|got)\s+into\s+((?:commit\s+)?[0-9a-f]{7,40})\??$/i,to:e=>`what did ${e[1]} touch`},{re:/^what\s+made\s+it\s+into\s+((?:commit\s+)?[0-9a-f]{7,40})\??$/i,to:e=>`what did ${e[1]} touch`}]),ws=Object.freeze(["mean","means","stand for","stands for","signify","signifies","represent","represents","refer to","refers to"]),_n=Object.freeze(["that","which","who"]),Rn=Object.freeze(["something","anything","everything","somethings","things","thing","entities","entity","nodes","node","stuff","code","symbol","symbols"]),Xs=Object.freeze({"but do not":"difference","but does not":"difference","and do not":"difference","and does not":"difference","but not":"difference","and not":"difference",except:"difference",without:"difference",and:"intersection",plus:"intersection",but:"intersection",or:"union"}),Ve=Object.freeze({public:{via:"visibility",value:"public"},private:{via:"visibility",value:"private"},protected:{via:"visibility",value:"protected"},static:{via:"attr",attr:"isStatic"},abstract:{via:"attr",attr:"isAbstract"},constant:{via:"attr",attr:"isConstant"},exported:{via:"exported"},"re-exported":{via:"exported"},tested:{via:"tested",value:!0},covered:{via:"tested",value:!0},untested:{via:"tested",value:!1},uncovered:{via:"tested",value:!1}}),$u=Object.freeze(new Set(["tests","test","anything","something","anyone","someone","any"])),ys=Object.freeze(["how many","how much","how many of","number of","total number of","quantity of","tally of","sum of","total of","amount of","count","count up","count of","tot up"]),vs=Object.freeze(["list","show","show me","show us","display","print","print out","dump","enumerate","name","give me","get me","spit out","rattle off","run down","run through","ls","what are","which are"]),Kn=Object.freeze({most:"most",greatest:"most",highest:"most",biggest:"most",largest:"most","most-connected":"most","most connected":"most",fewest:"fewest",least:"fewest",smallest:"fewest",lowest:"fewest"}),pn=Object.freeze({imports:{kind:"imports",dir:"out"},dependencies:{kind:"imports",dir:"out"},importers:{kind:"imports",dir:"in"},dependents:{kind:"imports",dir:"in"},callers:{kind:"calls",dir:"in",sibling:"callsSymbol"},callees:{kind:"calls",dir:"out",sibling:"callsSymbol"},calls:{kind:"calls",dir:"out",sibling:"callsSymbol"},methods:{kind:"contains",dir:"out",filter:"Method"},members:{kind:"contains",dir:"out"},tests:{kind:"tests",dir:"in"},test:{kind:"tests",dir:"in"},subclasses:{kind:"inherits",dir:"in"},connections:{kind:"*",dir:"both"},edges:{kind:"*",dir:"both"},connected:{kind:"*",dir:"both"},imported:{kind:"imports",dir:"in"},"depended-on":{kind:"imports",dir:"in"},depended:{kind:"imports",dir:"in"},used:{kind:"imports",dir:"in",sibling:"callsSymbol"},called:{kind:"calls",dir:"in",sibling:"callsSymbol"}}),xu=Object.freeze({tests:"Module",test:"Module"}),Do=Object.freeze(["those","them","these"]),Js=Object.freeze(["contains","defines"]),Lr=Object.freeze(["the","a","an","some","other","about","please","pls","plz","kindly","just","simply","maybe","perhaps","thanks","thank","ta","cheers","too","also","well","either","sorry","oops","actually","mean","meant","rather","hi","hello","hey","yo","hiya","howdy","ok","okay","matey","mate","buddy","pal","dude","man","bro","bru","fam","friend","sir","maam","folks","guys","everyone","dear","tmct","show","tell","give","list","find","me","us","lemme"]),Qs=Object.freeze({tally:"count",tallies:"count",sum:"count",total:"count",totals:"count"}),ku=Object.freeze(["help","help me","how do i ask","how do i use this","what can i ask","what can you ask","usage","commands","examples","syntax","options"])});var Jt,Su,Eu,da,ju,B_,U_,_u=L(()=>{An();Jt=e=>({type:"object",required:["symbol"],properties:{symbol:{type:"string",description:e}}}),Su=e=>({type:"object",required:["module"],properties:{module:{type:"string",description:e}}}),Eu=e=>({type:"object",required:["class"],properties:{class:{type:"string",description:e}}}),da=Object.freeze([{name:"tmct_context",tier:"hot",summary:"A sized edit bundle for one symbol \u2014 exemplar source, sibling signatures, registration anchor and the insertion region, in one call.",agentDescription:"START HERE to add/modify code: ONE call returns a sized edit bundle (exemplar source, sibling signatures, registration, insertion region) \u2014 then write directly, don't Read.",inputSchema:{type:"object",required:["symbol"],properties:{symbol:{type:"string",description:"Module path (e.g. path/to/module) or a sibling function/class name defined in it."},depth:{type:"string",enum:["min","auto","full"],default:"auto",description:"auto (sized to the task) | min (leanest) | full (every section)."}}},example:{symbol:"django/utils/text.py"}},{name:"tmct_snippet",tier:"hot",summary:"The exact source of one function, class or Class.method \u2014 its line span only, plus a one-line in-repo call hint.",agentDescription:"EXACT source of one function/class/Class.method by name (its line span only) + a one-line in-repo call hint. Prefer over Read for a single symbol.",inputSchema:{type:"object",required:["symbol"],properties:{symbol:{type:"string",description:"function/class name, Class.method, or fn:<path>#name."}}},example:{symbol:"Truncator.chars"}},{name:"tmct_ask",tier:"hot",summary:"A structural question in plain English, answered from the graph in one call \u2014 no model, and a clean miss instead of a guess.",agentDescription:'Ask a structural question in plain English: "which functions call X", "what uses X", "where is X defined", "when did X change". One call, no model. A clean miss beats a guess.',inputSchema:{type:"object",required:["query"],properties:{query:{type:"string",description:'A free-text question, e.g. "which functions explicitly couple to logging".'}}},example:{query:"which modules import src/core/model.mjs"},chat:{exampleRepo:"examples/mini-webapp",grammar:[{form:"which <things> <relation-verb> <entity>",example:"which modules import src/core/model.mjs",answers:"the imports edge, read forwards"},{form:"what is <relation-verb-passive> <entity>",example:"what is imported by src/core/store.mjs",answers:"the same edge, read backwards \u2014 a passive is the opposite direction, not a synonym"},{form:"what <relation-verb> <entity>",example:"what uses src/lib/http.mjs",answers:"the uses union: imports plus calls"},{form:"where is <entity> <where-marker>",example:"where is saveStore defined",answers:"the definition's file and line span"},{form:"when did <entity> change",example:"when did src/core/store.mjs change",answers:"the commits that touched it, newest first"}],whereMarkers:Yt}},{name:"tmct_describe",tier:"cold",summary:"Locate one symbol and list its typed edges (both directions) with provenance.",inputSchema:Jt("A module path, symbol name, or Class.method."),example:{symbol:"django/utils/text.py"}},{name:"tmct_signature",tier:"cold",summary:"One symbol's API surface (params, returns, raises/catches, flags, decorators, doc) without the body.",inputSchema:Jt("A function, method, or Class.method name."),example:{symbol:"Truncator.chars"}},{name:"tmct_impact",tier:"cold",summary:"Transitive reverse closure over imports/calls \u2014 what breaks if a module or symbol changes, by depth, with tests.",inputSchema:Su("The module (or a symbol it defines) whose dependents you want."),example:{module:"django/utils/text.py"}},{name:"tmct_search",tier:"cold",summary:"Free-text/ranked lookup over the code-map to find the right module or symbol.",inputSchema:{type:"object",required:[],properties:{query:{type:"string",description:"Free text to rank against the code-map. Required unless kind narrows the search on its own."},kind:{type:"string",description:"Restrict to an entity class, e.g. function, class, module."},decorator:{type:"string",description:"Restrict to definitions carrying this decorator."},name:{type:"string",description:"Restrict to definitions whose name matches."}}},example:{query:"template filters",kind:"function"}},{name:"tmct_members",tier:"cold",summary:"A class's methods + attributes (file:line, decorators) in one slice.",inputSchema:Eu("The class whose members you want."),example:{class:"Truncator"}},{name:"tmct_subclasses",tier:"cold",summary:"A class's base classes plus the transitive set of classes that extend it.",inputSchema:Eu("The class to walk the inheritance edges of."),example:{class:"Field"}},{name:"tmct_related",tier:"cold",summary:"A term's synonyms (skos:altLabel) and related concepts (skos:related), from the memory graph's relation facts.",inputSchema:{type:"object",required:["term"],properties:{term:{type:"string",description:"The term whose synonyms / related concepts you want."}}},example:{term:"sofa"}},{name:"tmct_architecture",tier:"cold",summary:"Package/module map + the most-imported hub modules (optionally scoped to a package).",inputSchema:{type:"object",required:[],properties:{package:{type:"string",description:"Scope the map to one package. Omit for the whole repository."}}},example:{package:"django/template"}},{name:"tmct_exports",tier:"cold",summary:"A module's public __all__ surface, each name resolved to the module that defines it.",inputSchema:Su("The module whose public API surface you want."),example:{module:"django/db/models/__init__.py"}},{name:"tmct_tests_for",tier:"cold",summary:"The test modules covering a symbol or module, from the typed test edges.",inputSchema:Jt("The symbol or module to find covering tests for."),example:{symbol:"django/utils/text.py"}},{name:"tmct_untested",tier:"cold",summary:"Source modules with no covering test module \u2014 a coverage-gap view (no arguments).",inputSchema:{type:"object",required:[],properties:{}},example:{}},{name:"tmct_history",tier:"cold",summary:"Recent commits that touched a symbol's module (newest first).",inputSchema:Jt("The symbol whose module's history you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_file_history",tier:"cold",summary:"Commits that touched a symbol's module, each with author / date / subject.",inputSchema:Jt("The symbol whose module's history you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_method_history",tier:"cold",summary:"Commits that touched a specific method symbol (fine-grained), with author / date / subject.",inputSchema:Jt("A Class.method name."),example:{symbol:"Truncator.chars"}},{name:"tmct_class_history",tier:"cold",summary:"Commits that touched a specific class symbol (fine-grained), with author / date / subject.",inputSchema:Jt("A class name."),example:{symbol:"Truncator"}},{name:"tmct_callers",tier:"cold",summary:"Modules that call into a symbol's module (one hop).",inputSchema:Jt("The symbol whose callers you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_callees",tier:"cold",summary:"Modules a symbol's module calls into (one hop).",inputSchema:Jt("The symbol whose callees you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_calls",tier:"cold",summary:"The in-repo symbols a function calls (fn\u2192fn), each with file:line.",inputSchema:Jt("The function whose in-repo call sites you want."),example:{symbol:"slugify"}},{name:"tmct_cochanges",tier:"cold",summary:"Modules that historically change in the same commit as a symbol's module (git co-change).",inputSchema:Jt("The symbol whose module's change-coupling you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_context_more",tier:"cold",summary:"The bundle sections a lean tmct_context omitted (siblings / tests / cochange / class members / re-exports).",inputSchema:Jt("The symbol a lean tmct_context bundle was built for."),example:{symbol:"django/utils/text.py"}},{name:"tmct_export",tier:"cold",summary:"Every stored memory fact as JSONL (subject/predicate/object/provenance) \u2014 the shape `tmct extract` emits, for backup or audit.",inputSchema:{type:"object",required:[],properties:{}},example:{}},{name:"tmct_ingest",tier:"cold",summary:"Ground plain text into memory facts with the same deterministic recognizer the chat teach lane uses \u2014 the strict tier, plus an optional lower-trust fuzzy tier \u2014 and report the canonical triples.",inputSchema:{type:"object",required:["text"],properties:{text:{type:"string",description:"The plain text to ground into facts."},optimistic:{type:"boolean",description:"Also run the lower-trust fuzzy tier over sentences the strict recognizer skips."}}},example:{text:"A kettle is a container. An otter is a mammal.",optimistic:!0}}]),ju=da.filter(e=>e.tier==="hot"),B_=da.filter(e=>e.tier==="cold"),U_=Object.freeze(da.map(e=>e.name))});var Ru,Oe,Lt=L(()=>{De();Ru=Z(".tmct","graph.json"),Oe=class extends Error{constructor(t){super(t),this.name="ToolError"}}});function Eb(e){let t=new Set;for(let n of Array.isArray(e?.individuals)?e.individuals:[])n&&n.id&&t.add(n.id);return t}function Au(e){let t=(Array.isArray(e)?e:[]).map((l,c)=>({file:l?.file,payload:l?.payload||{},name:l?.name!=null&&String(l.name).length?String(l.name):String(c)})),n=t.map(({payload:l})=>Eb(l)),s=new Map;for(let l of n)for(let c of l)s.set(c,(s.get(c)||0)+1);let o=new Set([...s.entries()].filter(([,l])=>l>1).map(([l])=>l)),r={generated_at:"",classes:[],vocabulary:[],objectProperties:[],individuals:[],proseIndex:{}},i="",a=t.length>0;for(let{payload:l,name:c}of t){a=a&&!!l.bootstrap,typeof l.generated_at=="string"&&l.generated_at>i&&(i=l.generated_at);let u=m=>o.has(m)?`${c}/${m}`:m;Array.isArray(l.classes)&&r.classes.push(...l.classes),Array.isArray(l.vocabulary)&&r.vocabulary.push(...l.vocabulary);for(let m of Array.isArray(l.individuals)?l.individuals:[]){if(!m)continue;let p={...m};p.id&&(p.id=u(p.id)),Array.isArray(p.derived_from)&&(p.derived_from=p.derived_from.map(f=>u(f))),Array.isArray(p.mentions)&&(p.mentions=p.mentions.map(f=>f&&f.id?{...f,id:u(f.id)}:f)),r.individuals.push(p)}for(let m of Array.isArray(l.objectProperties)?l.objectProperties:[]){if(!m)continue;let p={...m};Array.isArray(p.examples)&&(p.examples=p.examples.map(f=>{if(!f)return f;let g={...f};return g.subject&&(g.subject=u(g.subject)),g.object&&(g.object=u(g.object)),g})),r.objectProperties.push(p)}let d=l.proseIndex&&typeof l.proseIndex=="object"?l.proseIndex:{};for(let[m,p]of Object.entries(d)){let f=r.proseIndex[m]||(r.proseIndex[m]=[]);for(let g of Array.isArray(p)?p:[]){let h=u(g);f.includes(h)||f.push(h)}}}return r.generated_at=i,a&&(r.bootstrap=!0),r}var Tu=L(()=>{});var eo={};En(eo,{clearCache:()=>jb,emptyEntities:()=>pa,fetchEntities:()=>Tb,registerProvider:()=>_b});function jb(){Zs=null,zo=null}function _b(e){if(e!=null&&typeof e!="function")throw new TypeError("registerProvider expects a function (config) => entities payload, or null");let t=Nr;return Nr=e??null,Zs=null,t}function pa(){return{generated_at:"",bootstrap:!0,classes:[],vocabulary:[],objectProperties:[],individuals:[],proseIndex:{}}}async function Rb(e){let t;try{t=await ze(e,"utf8")}catch(n){if(n?.code==="ENOENT")return pa();throw new Oe(`cannot read graph artifact at ${e} (${n?.code||n?.message||n})`)}try{return JSON.parse(t)}catch{throw new Oe(`graph artifact ${e} is not valid JSON`)}}async function Ab(e){let t=e.graphFiles,n=[...t].map(String).sort().join("|");if(zo&&zo.key===n)return zo.payload;let s=[];for(let r=0;r<t.length;r++){let i=await Rb(t[r]);s.push({file:t[r],payload:i,name:e.graphNames?.[r]})}let o=Au(s);return zo={key:n,payload:o},o}async function Tb(e){if(Nr){let s;try{s=await Nr(e)}catch(o){throw o instanceof Oe?o:new Oe(`graph provider failed (${o?.message||o})`)}if(!s||typeof s!="object")throw new Oe("graph provider returned no entities payload");return s}if(Array.isArray(e.graphFiles)&&e.graphFiles.length>1)return Ab(e);if(Zs&&Zs.file===e.graphFile)return Zs.payload;let t;try{t=await ze(e.graphFile,"utf8")}catch(s){if(s?.code==="ENOENT")return pa();throw new Oe(`cannot read graph artifact at ${e.graphFile} (${s?.code||s?.message||s})`)}let n;try{n=JSON.parse(t)}catch{throw new Oe(`graph artifact ${e.graphFile} is not valid JSON`)}return Zs={file:e.graphFile,payload:n},n}var Zs,zo,Nr,Bo=L(()=>{vt();Lt();Tu();Zs=null,zo=null,Nr=null});function fn(e){if(!e)return[];let t=String(e).replace(/\.[A-Za-z0-9]+$/,"");return t=t.replace(/[/\\]/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([A-Za-z])([0-9])/g,"$1 $2").replace(/([0-9])([A-Za-z])/g,"$1 $2").replace(/[_\-.]+/g," "),t.split(/\s+/).map(n=>n.toLowerCase()).filter(n=>n.length>1&&n.length<=Cu)}function fa(e){if(!e)return[];let t=[],n=new Set;for(let s of String(e).toLowerCase().split(/[^a-z0-9]+/))if(!(s.length<2||s.length>Cu||Cb.has(s))&&!n.has(s)&&(n.add(s),t.push(s),t.length>=Ib))break;return t}function Mr({name:e,doc:t}={}){return[...new Set([...fn(e),...fa(t)])].sort()}function Iu(e){let t=Object.create(null);for(let n of e){let s=(n.attributes||[]).find(o=>o.key==="prose_tokens");if(s?.value)for(let o of s.value.split(" "))t[o]||(t[o]=[]),t[o].push(n.id)}for(let n of Object.keys(t))t[n].sort();return t}function $s(e,t,{limit:n=10}={}){let s=[...new Set([...fn(t),...fa(t)])];if(!s.length)return[];let o=new Map;for(let r of s)for(let i of e?.[r]||[])o.set(i,(o.get(i)||0)+1);return[...o.entries()].sort((r,i)=>i[1]-r[1]||String(r[0]).localeCompare(i[0])).slice(0,n).map(([r,i])=>({id:r,score:i}))}function Ou(e,t){let n=e&&(e["tmct:layers"]?e:e.proseIndex),s=n&&n["tmct:layers"],o=String(t||"").toLowerCase(),r={ids:[],via:null};if(!o||!s||typeof s!="object")return r;let i=new Set,a=new Set;for(let l of Object.keys(s)){let c=s[l];if(!c||typeof c!="object")continue;let u=c[o],d=Array.isArray(u)?u:Array.isArray(u?.ids)?u.ids:null;if(d?.length){for(let m of d)i.add(m);a.add(l)}}return i.size?{ids:[...i].sort(),via:[...a].sort().join("+")}:r}var Cb,Cu,Ib,Yn=L(()=>{Cb=new Set("a an and or but the of to in on at for with from by as is are was were be been being it its this that these those i you he she they we me my your our do does did not no yes if then else than so such can will would should could may might about into over under out up down off again more most some any all what which who whom whose when where why how".split(/\s+/)),Cu=40,Ib=120});function Lu(e){let t=e.indexOf("@"),n=t>=0?e.slice(0,t):e,s=t>=0?e.slice(t+1):"",o=n.indexOf(":"),r=o>=0?n.slice(o+1):"";return{createdAt:s,...r?{sessionId:r}:{}}}function Uo(e){let t=String(e||"").trim();if(!t)return null;if(t.startsWith("reference:")){let s=t.slice(10),o=s.indexOf(":");if(o<0)return{kind:"reference",pack:s||"unknown",article:""};let r=s.slice(0,o)||"unknown";return{kind:Lb(r),pack:r,article:s.slice(o+1)}}if(t.startsWith("research:")){let s=t.slice(9),o=s.lastIndexOf("@");return{kind:"referenceLive",pack:"research",article:(o>=0?s.slice(0,o):s).trim()||"unknown"}}let n=t.split(/\s+/)[0];return n.startsWith("corpus-weak:")?{kind:"corpusWeak",name:n.slice(12)||"unknown"}:n.startsWith("corpus:")?{kind:"corpus",name:n.slice(7)||"unknown"}:n.startsWith("child:")?{kind:"corpus",name:n.slice(6).split(":")[0]||"unknown"}:n.startsWith("world:")?{kind:"corpus",name:n.slice(6).split(":")[0]||"unknown"}:n.startsWith("ace:")?{kind:"operator",...Lu(n.slice(4))}:n.startsWith("teach:")?{kind:"teach",...Lu(n.slice(6))}:n.startsWith("web:")?{kind:"web",url:n.slice(4)}:n.startsWith("url:")?{kind:"web",url:n.slice(4)}:n.startsWith("optimistic-extract:")?{kind:"optimisticExtract",name:n.slice(19)||"unknown"}:n.startsWith("extracted:")?{kind:"extracted",name:n.slice(10)||"unknown"}:n.startsWith("entailed:")?{kind:"entailed",rule:n.slice(9)}:n.startsWith("chat:")||n.startsWith("session:")||n.startsWith("operator")?{kind:"operator"}:null}function Pb(e){let t=(e?.attributes||[]).find(s=>s.prop==="mgx:sourceReliability")?.value;if(t===void 0)return Mu;let n=Number(t);return Number.isFinite(n)?Math.max(ma,Math.min(Pu,n)):Mu}function Fb(e,t=Date.now(),n=Nb){let s=Date.parse(e);if(!Number.isFinite(s))return 1;let o=Math.max(0,t-s);return Nu+(1-Nu)*Math.pow(.5,o/n)}function Fu(e,t={},n={}){let s=typeof n.now=="number"?n.now:Date.now(),o=Array.isArray(e?.sourceIds)?e.sourceIds:[],r=new Set,i=[],a=[];for(let p of o){if(r.has(p))continue;r.add(p);let f=t[p],g=Mb(f);if(!g)continue;i.push(g);let h=(Wo[g]??0)*Pb(f);a.push(Math.max(0,Math.min(1,h)))}let l=0,c=1;for(let p of a)c*=1-p;if(a.length&&(l=Math.min(1,1-c)),i.includes("entailed")&&Array.isArray(n.premiseTrusts)&&n.premiseTrusts.length){let p=typeof n.ruleConfidence=="number"?n.ruleConfidence:1;l=Math.max(0,Math.min(1,Math.min(...n.premiseTrusts)*p))}let u=Fb(e?.createdAt,s,n.halfLifeMs),d=ha(Math.min(1,l*u)),m={sourceTypes:i.slice().sort(),corroboration:i.length,createdAt:e?.createdAt||"",recency:ha(u)};return{score:d,inputs:m}}function Du({factsAsserted:e=0,factsContradicted:t=0}={}){let n=Math.max(0,Number(e)||0),s=Math.max(0,Number(t)||0),o=Math.max(-1,Math.min(1,(n-2*s)/Math.max(1,n))),r=n/(n+Db),i=(o*r+1)/2;return ha(ma+(Pu-ma)*i)}var Pr,ga,Nt,xs,Ob,Lb,Wo,Nb,Nu,ma,Pu,Mu,ha,Mb,Db,ks=L(()=>{Pr="mgx:trustScore",ga="mgx:trustInputs",Nt="mgx:createdAt",xs="mgx:updatedAt";Ob="wikipedia-live",Lb=e=>e===Ob?"referenceLive":"reference";Wo=Object.freeze({operator:1,teach:.95,provider:.9,corpus:.7,reference:.6,corpusWeak:.55,referenceLive:.5,extracted:.45,web:.4,optimisticExtract:.35,entailed:.3}),Nb=720*60*60*1e3,Nu=.9,ma=.5,Pu=1.5,Mu=1,ha=(e,t=6)=>Number(e.toFixed(t)),Mb=e=>(e?.attributes||[]).find(t=>t.prop==="mgx:sourceType")?.value||"";Db=19});var Ss,ba=L(()=>{Ss=e=>/(^|\/)tests?\//.test(e)||/(^|\/)test_[^/]*\.py$/.test(e)||/\.tests(\.|$)/.test(e)});function wa(e,t){return Math.log(1+e/(1+t))}var qo=L(()=>{});var Dr={};En(Dr,{bfsLevels:()=>Fr,findActionPath:()=>ya,findReachableSet:()=>va});function zu(e){return e&&typeof e=="object"?JSON.stringify(e):String(e)}function Bu(e,t){let n=[];for(let{action:s,nextState:o}of t(e)||[])n.push({state:o,actions:[s],states:[e,o]});return n}function ya(e,t,n,{maxDepth:s=50,stateKey:o=zu}={}){if(t(e))return{actions:[],states:[e]};let r=Bu(e,n),i=new Set([o(e)]);for(let a=1;a<=s&&r.length;a+=1){for(let c of r)if(t(c.state))return{actions:c.actions,states:c.states};if(a===s)break;let l=[];for(let c of r){let u=o(c.state);if(!i.has(u)){i.add(u);for(let{action:d,nextState:m}of n(c.state)||[]){let p=o(m);i.has(p)||l.push({state:m,actions:[...c.actions,d],states:[...c.states,m]})}}}r=l}return null}function va(e,t,{maxDepth:n=50,stateKey:s=zu}={}){let o=Bu(e,t),r=new Set([s(e)]),i=[];for(let a=1;a<=n&&o.length;a+=1){let l=[];for(let c of o){let u=s(c.state);if(!r.has(u)&&(r.add(u),i.push({node:c.state,path:{actions:c.actions,states:c.states}}),a!==n))for(let{action:d,nextState:m}of t(c.state)||[]){let p=s(m);r.has(p)||l.push({state:m,actions:[...c.actions,d],states:[...c.states,m]})}}o=l}return i}function*Fr(e,t,{maxDepth:n=8,keyOf:s=o=>o}={}){let o=new Set([e]),r=[e];for(let i=1;i<=n&&r.length;i+=1){let a=[],l=[];for(let c of r)for(let u of t(c)||[]){let d=s(u);o.has(d)||(o.add(d),a.push(u),l.push(d))}r=l,yield a}}var Es=L(()=>{});function Br(e){let t=Array.isArray(e?.individuals)?e.individuals:[],n=new Map;for(let r of t)r&&r.id&&n.set(r.id,r);let s=(Array.isArray(e?.objectProperties)?e.objectProperties:[]).filter(r=>r&&(r.predicate||r.prop)).map(r=>{let i=(Array.isArray(r.examples)?r.examples:[]).filter(a=>a&&a.subject&&a.object);return{predicate:String(r.predicate||""),prop:r.prop||null,count:Number(r.count)||i.length,edges:i}}),o=s.filter(r=>r.count>r.edges.length).map(r=>({predicate:r.predicate,count:r.count,shown:r.edges.length}));return{individuals:t,byId:n,relations:s,truncated:o,generatedAt:e?.generated_at||null,proseIndex:e?.proseIndex||{}}}function ja(e){return!e||!Array.isArray(e.individuals)?0:e.individuals.filter(t=>(t.class||"")==="Module").length}function On(e){let t=String(e?.prop||"").toLowerCase();if(Uu[t])return Uu[t];let n=String(e?.predicate||"").toLowerCase();if(/symbol/.test(n)){if(/\b(call|invoke)/.test(n))return"callsSymbol";if(/(touch|chang|modif)/.test(n))return"touchesSymbol"}return/\bimport/.test(n)?"imports":/\b(call|invoke)/.test(n)?"calls":/\b(define|export|declare)/.test(n)?"defines":/\b(test|cover)/.test(n)?"tests":/\b(touch|chang|modif)/.test(n)?"touches":/\bcontain/.test(n)?"contains":/\b(inherit|subclass|extend|specializ)/.test(n)?"inherits":null}function Cn(e){return String(e||"").trim().toLowerCase().replace(/^\.\//,"").replace(/^\//,"")}function $a(e){let t=Cn(e).split("/");return t[t.length-1]}function zb(e){return(e?.derived_from||[]).filter(td).length}function Wu(e){return(e?.mentions||[]).reduce((n,s)=>n+(Number(s?.count)||0),0)+zb(e)}function Vt(e,t){let n=Cn(t);if(!n)return{match:null,candidates:[]};let s=$a(n),o=[];for(let r of e.individuals){let i=Cn(r.label),a=String(r.id||"").toLowerCase(),l=0;i===n||a===n?l=100:i.endsWith(`/${n}`)||$a(i)===s||$a(i).replace(/\.[a-z]+$/,"")===s?l=80:i.includes(n)&&(l=Math.max(10,50-(i.length-n.length))),l>0&&o.push({ind:r,score:l})}return o.sort((r,i)=>i.score-r.score||Wu(i.ind)-Wu(r.ind)||String(r.ind.label).length-String(i.ind.label).length),{match:o[0]?.ind||null,candidates:o.slice(1,5).map(r=>r.ind)}}function $t(e){let t=(e?.attributes||[]).find(s=>s.key==="site");if(!t)return null;let n=String(t.value).match(/^(.*):(\d+)(?:-(\d+))?$/);return n?{path:n[1],start:Number(n[2]),end:n[3]?Number(n[3]):Number(n[2])}:null}function Bb(e,t){let n=[],s=[];for(let o of e.relations){let r=o.edges.filter(a=>a.subject===t),i=o.edges.filter(a=>a.object===t);r.length&&n.push({group:o,edges:r}),i.length&&s.push({group:o,edges:i})}return{out:n,incoming:s}}function qu(e){return e.prop?`${e.predicate} [${e.prop}]`:e.predicate}function In(e){let t=e||"Entity",n=fn(t);return n.length<2?t:n.map(s=>s[0].toUpperCase()+s.slice(1)).join(" ")}function nt(e,t,n=", "){return e.length<=t?e.join(n):e.slice(0,t).join(n)+`, +${e.length-t} more`}function _a(e,t,{candidates:n=[]}={}){let s=[];s.push(`${t.label} \u2014 ${In(t.class)} (id: ${t.id})`);let o=(t.derived_from||[]).filter(td);o.length&&s.push(`attestation: touched by ${o.length} commit(s)`);for(let l of t.attributes||[])s.push(`attribute: ${l.key} = ${l.value}${l.prop?` [${l.prop}]`:""}`);let{out:r,incoming:i}=Bb(e,t.id);if(!r.length&&!i.length)s.push("edges: none in the current artifact");else{s.push("edges:");for(let{group:l,edges:c}of r)s.push(` ${qu(l)} (${c.length}) \u2192 ${nt(c.map(u=>u.objectLabel||u.object),Gu)}`);for(let{group:l,edges:c}of i)s.push(` \u2190 ${qu(l)} (${c.length}) by ${nt(c.map(u=>u.subjectLabel||u.subject),Gu)}`)}let a=t.derived_from||[];return a.length&&s.push(`provenance: ${nt(a,Ub)}`),n.length&&s.push(`other matches: ${n.map(l=>`${l.label} (${In(l.class)})`).join(", ")}`),e.truncated.length&&s.push(Wb(e)),s.join(`
1
+ (()=>{var fb=Object.defineProperty;var L=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(s){throw n=[s],s}};var En=(e,t)=>{for(var n in t)fb(e,n,{get:t[n],enumerable:!0})};var et,u_,d_,p_,f_,m_,h_,g_,b_,w_,y_,v_,$_,x_,k_,S_,E_,Z,$e,qt,pu,j_,__,R_,De=L(()=>{et=e=>()=>{throw new Error(e+" unavailable in the browser ask bundle")},u_=et("createRequire"),d_=et("readFileSync"),p_=et("access"),f_=et("readFile"),m_=et("writeFile"),h_=et("appendFile"),g_=et("mkdir"),b_=et("mkdtemp"),w_=et("rename"),y_=et("unlink"),v_=et("rm"),$_=et("stat"),x_=et("copyFile"),k_=et("readdir"),S_=et("createReadStream"),E_=et("createWriteStream"),Z=(...e)=>e.join("/"),$e=e=>String(e).replace(/\/[^/]*$/,""),qt=(...e)=>e.join("/"),pu="/",j_=et("randomBytes"),__=et("spawnSync"),R_=et("createInterface")});var tt,T_,C_,fu,ze,Lo,mb,jn,hb,Or,ia,gb,bb,I_,wb,O_,L_,N_,M_,P_,vt=L(()=>{tt=e=>()=>{throw new Error(e+" unavailable in the browser ask bundle")},T_=tt("createRequire"),C_=tt("readFileSync"),fu=tt("access"),ze=tt("readFile"),Lo=tt("writeFile"),mb=tt("appendFile"),jn=tt("mkdir"),hb=tt("mkdtemp"),Or=tt("rename"),ia=tt("unlink"),gb=tt("rm"),bb=tt("stat"),I_=tt("copyFile"),wb=tt("readdir"),O_=tt("createReadStream"),L_=tt("createWriteStream"),N_=tt("randomBytes"),M_=tt("spawnSync"),P_=tt("createInterface")});function gs(e){return e.replace(yb,"").trim()}function Xt(e){let t=e;for(let n=0;n<2;n+=1){let s=t.replace($b,"").trim();if(s=s.replace(kb,"").trim(),s===t)break;t=s}return t}var mu,No,Mo,Yt,hu,an,aa,yb,vb,$b,xb,kb,de,Po,Sb,gu,Be,Gt,Hn,bu,ca,la,ua,wu,Fo,bs,yu,vu,ws,_n,Rn,Xs,Ve,$u,ys,vs,Kn,fn,xu,Do,Js,Lr,Qs,ku,An=L(()=>{mu=["is a superclass of","are a superclass of","is a parent class of","are a parent class of","superclass","superclasses"],No={imports:{bare:"import",comment:"Module -> Module: subject's import graph references object (usesComplexType).",verbs:["couples to","couple to","depends on","imports","import","relies on","rely on","requires","require","references","reference","pulls in","pull in","built on","builds on","build on","uses code from","grabs","grab","pulls from","pull from","leans on","lean on","is wired to","are wired to","is hooked up to","are hooked up to","importing"]},uses:{bare:"use",comment:"query-side union: imports (Module->Module) + calls (Module->Module) + callsSymbol (fn->fn).",verbs:["uses","use","makes use of","make use of","talks to","talk to","using"]},calls:{bare:"call",comment:"Function/Method -> Function/Class (symbol-grain) or Module -> Module (coarse): subject invokes object.",verbs:["invokes","invoke","calls","call","runs","run","executes","execute","hits","hit","triggers","trigger","fires","fire","kicks off","kick off","calling"]},defines:{bare:"define",comment:"Module -> top-level Function/Class/Method/Attribute: subject declares object.",verbs:["defines","define","declares","declare","has","have","holds","hold","defining"]},contains:{bare:"contain",comment:"Class -> Method/Attribute: subject's membership includes object.",verbs:["contains","contain","lives in","live in","is defined in","are defined in","is part of","are part of","sits in","sit in","sits inside","sit inside","containing"]},tests:{bare:"test",comment:"Module -> Module: subject is a test module importing/covering object.",verbs:["tests","test","covers","cover","verifies","verify","exercises","exercise","checks","check","makes sure of","make sure of","testing"]},inherits:{bare:"inherit from",comment:"Class -> Class: subject's declared base resolves to object (subclassOf).",verbs:["inherits from","inherit from","inherits","inherit","extends","extend","subclasses","subclass","derives from","derive from","is a subclass of","are a subclass of","is a kind of","are a kind of","is built off","are built off","is built on top of","are built on top of","extending","inheriting from","inheriting","subclassing","extends from",...mu]},touches:{bare:"touch",comment:"Commit -> Module (coarse) or Commit -> symbol (fine, touchesSymbol): a commit's changed-line-range intersects object.",verbs:["touched","touches","changed","change","modified","modifies","was changed in","were changed in","was edited in","were edited in","was modified by","were modified by","was tweaked in","were tweaked in","got changed in","got edited in","touch","changed in","landed in","land in","was in","were in","went into","included in","updated","edited","touching"]},cochange:{bare:"co-change with",comment:"Module -> Module: subject and object are frequently committed together (changeCoupledWith).",verbs:["changed with","co-changes with","co-change with","changes alongside","change alongside","shares commits with","share commits with","tends to change together with","tend to change together with","moves together with","move together with","changed together with","change together with","changes together with","changes with","change with","tends to change with","tend to change with","usually changes with"]},reexports:{bare:"re-export",comment:"Module -> exported symbol: subject's public API surface (__all__/export list).",verbs:["exports","export","re-exports","re-export","passes through","pass through","exposes","expose","exporting"]}},Mo=Object.freeze([...mu,"is the superclass of","are the superclass of","is the parent class of"]),Yt=Object.freeze(["defined","declared","located","implemented"]),hu=Object.freeze(["now","currently","right now","at the moment","these days","today"]),an=Object.freeze(["mentioned","referenced"]),aa=Object.freeze(["in this graph","in the graph","in this codebase","in the codebase","in this repo","in the repo","here"]),yb=new RegExp(`\\s+(?:${aa.join("|")})\\s*[?.!]*$`,"i");vb=Object.freeze(["then","though","too"]),$b=new RegExp(`\\s+(?:${vb.join("|")})\\s*[?.!]*$`,"i"),xb=Object.freeze(["please explain","explain"]),kb=new RegExp(`,\\s*(?:${xb.join("|")})\\s*[?.!]*$`,"i");de=Object.freeze(Object.fromEntries(Object.entries(No).flatMap(([e,{verbs:t}])=>t.map(n=>[n,e])))),Po=Object.freeze(new Set(["has","have","holds","hold"])),Sb=e=>!Mo.includes(e),gu=Object.freeze([...new Set(Object.keys(de).filter(Sb).map(e=>e.match(/^(?:is|are)\s+an?\s+(.+)$/i)).filter(Boolean).map(e=>e[1].toLowerCase()))]),Be=Object.freeze({function:"Function",functions:"Function",method:"Method",methods:"Method",class:"Class",classes:"Class",module:"Module",modules:"Module",mod:"Module",mods:"Module",file:"Module",files:"Module",package:"Package",packages:"Package",attribute:"Attribute",attributes:"Attribute",field:"Attribute",fields:"Attribute",variable:"GlobalVariable",variables:"GlobalVariable",global:"GlobalVariable",globals:"GlobalVariable",change:"Change",changes:"Change",commit:"Commit",commits:"Commit"}),Gt=Object.freeze({explicitly:"direct",directly:"direct",transitively:"transitive",indirectly:"transitive"}),Hn=Object.freeze({imported:"imports",called:"calls",used:"uses",tested:"tests",covered:"tests",verified:"tests",exercised:"tests",checked:"tests",defined:"defines",declared:"defines",inherited:"inherits",extended:"inherits",subclassed:"inherits",contained:"contains",exported:"reexports","re-exported":"reexports",exposed:"reexports",touched:"touches",changed:"touches",modified:"touches",edited:"touches",updated:"touches"}),bu=Object.freeze({"inherited from":{kind:"inherits",role:"object"},"extended from":{kind:"inherits",role:"object"},"subclassed from":{kind:"inherits",role:"object"},"defined in":{kind:"defines",role:"agent"},"declared in":{kind:"defines",role:"agent"},"contained in":{kind:"contains",role:"agent"},"imported by":{kind:"imports",role:"agent"},"called by":{kind:"calls",role:"agent"},"used by":{kind:"uses",role:"agent"},"tested by":{kind:"tests",role:"agent"},"covered by":{kind:"tests",role:"agent"},"touched by":{kind:"touches",role:"agent"},"changed by":{kind:"touches",role:"agent"},"exported by":{kind:"reexports",role:"agent"}}),ca=Object.freeze({"ain't":"is not",aint:"is not","isn't":"is not",isnt:"is not","aren't":"are not",arent:"are not","doesn't":"does not",doesnt:"does not","don't":"do not",dont:"do not","didn't":"did not",didnt:"did not","there's":"there is",theres:"there is","what's":"what is",whats:"what is","who's":"who is",whos:"who is",gonna:"going to",wanna:"want to",gotta:"got to",yer:"your",ur:"your",gimme:"give me"}),la=Object.freeze({funtion:"function",funtions:"functions",fucntion:"function",fucntions:"functions",functoin:"function",functoins:"functions",calss:"class",calsses:"classes",classs:"class",clases:"classes",modul:"module",moduls:"modules",moduel:"module",moduels:"modules",moudle:"module",moudles:"modules",methdo:"method",methdos:"methods",mehtod:"method",mehtods:"methods",comit:"commit",comits:"commits",commmit:"commit",commmits:"commits",varaible:"variable",varaibles:"variables",varibale:"variable",varibales:"variables",atribute:"attribute",atributes:"attributes",improt:"import",improts:"imports",imoprt:"import",imoprts:"imports",inherts:"inherits",inheirts:"inherits",extands:"extends",extneds:"extends",depnds:"depends",touchs:"touches",tuoches:"touches",touhced:"touched",touchd:"touched",defned:"defined",chagned:"changed",chnaged:"changed",chagnes:"changes",chnages:"changes",calles:"calls",exprot:"export",exprots:"exports",tets:"tests",whcih:"which",wich:"which",whihc:"which",wehre:"where",whre:"where",waht:"what",wat:"what",dat:"that",dose:"does",doess:"does",teh:"the",manyn:"many",mnay:"many",amny:"many",mnany:"many",hwo:"how",coutn:"count",conut:"count",cuont:"count",ocunt:"count",numer:"number",nubmer:"number",numbr:"number",nmuber:"number",lst:"list",lsit:"list",ilst:"list",shwo:"show",hsow:"show",dispaly:"display",dsiplay:"display",funtcions:"functions",funciton:"function",funcitons:"functions"}),ua=Object.freeze({folder:"module",folders:"modules",directory:"module",directories:"modules",func:"function",funcs:"functions",changeset:"commit",changesets:"commits",revision:"commit",revisions:"commits",property:"attribute",properties:"attributes"}),wu=/\b([a-z]{3,})in'/gi,Fo=Object.freeze(["um","uh","erm","so","like","yo","hey","bru","bro","fam","mate","please","could you","can you","would you","tell me","i wonder","just wondering","quickly","real quick","kinda","sorta","btw","by the way","you","quick q"]),bs=Object.freeze(["this","it","that","here","this one","that one"]),yu=Object.freeze([{re:/\bthere\s+is\s+not\s+(?:anything|nothing)\s+(?:that\s+)?(\S.*)$/i,to:e=>`what ${e[1]}`},{re:/\bthere\s+is\s+no\s+\S+\s+(?:that\s+)?(\S.*)$/i,to:e=>`what ${e[1]}`},{re:/\bis\s+not\s+there\s+(?:anything|nothing)\s+(?:that\s+)?(\S.*)$/i,to:e=>`what ${e[1]}`},{re:/\b(?:nobody|nothing|no one)\s+(\S.*?)(?:,?\s+does\s+it\??|,?\s+do\s+they\??)?$/i,to:e=>`what ${e[1]}`}]),vu=Object.freeze([{re:/^what\s+(?:is|was|were|are)\s+in\s+((?:commit\s+)?[0-9a-f]{7,40})\??$/i,to:e=>`what did ${e[1]} touch`},{re:/^what\s+(?:went|got)\s+into\s+((?:commit\s+)?[0-9a-f]{7,40})\??$/i,to:e=>`what did ${e[1]} touch`},{re:/^what\s+made\s+it\s+into\s+((?:commit\s+)?[0-9a-f]{7,40})\??$/i,to:e=>`what did ${e[1]} touch`}]),ws=Object.freeze(["mean","means","stand for","stands for","signify","signifies","represent","represents","refer to","refers to"]),_n=Object.freeze(["that","which","who"]),Rn=Object.freeze(["something","anything","everything","somethings","things","thing","entities","entity","nodes","node","stuff","code","symbol","symbols"]),Xs=Object.freeze({"but do not":"difference","but does not":"difference","and do not":"difference","and does not":"difference","but not":"difference","and not":"difference",except:"difference",without:"difference",and:"intersection",plus:"intersection",but:"intersection",or:"union"}),Ve=Object.freeze({public:{via:"visibility",value:"public"},private:{via:"visibility",value:"private"},protected:{via:"visibility",value:"protected"},static:{via:"attr",attr:"isStatic"},abstract:{via:"attr",attr:"isAbstract"},constant:{via:"attr",attr:"isConstant"},exported:{via:"exported"},"re-exported":{via:"exported"},tested:{via:"tested",value:!0},covered:{via:"tested",value:!0},untested:{via:"tested",value:!1},uncovered:{via:"tested",value:!1}}),$u=Object.freeze(new Set(["tests","test","anything","something","anyone","someone","any"])),ys=Object.freeze(["how many","how much","how many of","number of","total number of","quantity of","tally of","sum of","total of","amount of","count","count up","count of","tot up"]),vs=Object.freeze(["list","show","show me","show us","display","print","print out","dump","enumerate","name","give me","get me","spit out","rattle off","run down","run through","ls","what are","which are"]),Kn=Object.freeze({most:"most",greatest:"most",highest:"most",biggest:"most",largest:"most","most-connected":"most","most connected":"most",fewest:"fewest",least:"fewest",smallest:"fewest",lowest:"fewest"}),fn=Object.freeze({imports:{kind:"imports",dir:"out"},dependencies:{kind:"imports",dir:"out"},importers:{kind:"imports",dir:"in"},dependents:{kind:"imports",dir:"in"},callers:{kind:"calls",dir:"in",sibling:"callsSymbol"},callees:{kind:"calls",dir:"out",sibling:"callsSymbol"},calls:{kind:"calls",dir:"out",sibling:"callsSymbol"},methods:{kind:"contains",dir:"out",filter:"Method"},members:{kind:"contains",dir:"out"},tests:{kind:"tests",dir:"in"},test:{kind:"tests",dir:"in"},subclasses:{kind:"inherits",dir:"in"},connections:{kind:"*",dir:"both"},edges:{kind:"*",dir:"both"},connected:{kind:"*",dir:"both"},imported:{kind:"imports",dir:"in"},"depended-on":{kind:"imports",dir:"in"},depended:{kind:"imports",dir:"in"},used:{kind:"imports",dir:"in",sibling:"callsSymbol"},called:{kind:"calls",dir:"in",sibling:"callsSymbol"}}),xu=Object.freeze({tests:"Module",test:"Module"}),Do=Object.freeze(["those","them","these"]),Js=Object.freeze(["contains","defines"]),Lr=Object.freeze(["the","a","an","some","other","about","please","pls","plz","kindly","just","simply","maybe","perhaps","thanks","thank","ta","cheers","too","also","well","either","sorry","oops","actually","mean","meant","rather","hi","hello","hey","yo","hiya","howdy","ok","okay","matey","mate","buddy","pal","dude","man","bro","bru","fam","friend","sir","maam","folks","guys","everyone","dear","tmct","show","tell","give","list","find","me","us","lemme"]),Qs=Object.freeze({tally:"count",tallies:"count",sum:"count",total:"count",totals:"count"}),ku=Object.freeze(["help","help me","how do i ask","how do i use this","what can i ask","what can you ask","usage","commands","examples","syntax","options"])});var Jt,Su,Eu,da,ju,B_,U_,_u=L(()=>{An();Jt=e=>({type:"object",required:["symbol"],properties:{symbol:{type:"string",description:e}}}),Su=e=>({type:"object",required:["module"],properties:{module:{type:"string",description:e}}}),Eu=e=>({type:"object",required:["class"],properties:{class:{type:"string",description:e}}}),da=Object.freeze([{name:"tmct_context",tier:"hot",summary:"A sized edit bundle for one symbol \u2014 exemplar source, sibling signatures, registration anchor and the insertion region, in one call.",agentDescription:"START HERE to add/modify code: ONE call returns a sized edit bundle (exemplar source, sibling signatures, registration, insertion region) \u2014 then write directly, don't Read.",inputSchema:{type:"object",required:["symbol"],properties:{symbol:{type:"string",description:"Module path (e.g. path/to/module) or a sibling function/class name defined in it."},depth:{type:"string",enum:["min","auto","full"],default:"auto",description:"auto (sized to the task) | min (leanest) | full (every section)."}}},example:{symbol:"django/utils/text.py"}},{name:"tmct_snippet",tier:"hot",summary:"The exact source of one function, class or Class.method \u2014 its line span only, plus a one-line in-repo call hint.",agentDescription:"EXACT source of one function/class/Class.method by name (its line span only) + a one-line in-repo call hint. Prefer over Read for a single symbol.",inputSchema:{type:"object",required:["symbol"],properties:{symbol:{type:"string",description:"function/class name, Class.method, or fn:<path>#name."}}},example:{symbol:"Truncator.chars"}},{name:"tmct_ask",tier:"hot",summary:"A structural question in plain English, answered from the graph in one call \u2014 no model, and a clean miss instead of a guess.",agentDescription:'Ask a structural question in plain English: "which functions call X", "what uses X", "where is X defined", "when did X change". One call, no model. A clean miss beats a guess.',inputSchema:{type:"object",required:["query"],properties:{query:{type:"string",description:'A free-text question, e.g. "which functions explicitly couple to logging".'}}},example:{query:"which modules import src/core/model.mjs"},chat:{exampleRepo:"examples/mini-webapp",grammar:[{form:"which <things> <relation-verb> <entity>",example:"which modules import src/core/model.mjs",answers:"the imports edge, read forwards"},{form:"what is <relation-verb-passive> <entity>",example:"what is imported by src/core/store.mjs",answers:"the same edge, read backwards \u2014 a passive is the opposite direction, not a synonym"},{form:"what <relation-verb> <entity>",example:"what uses src/lib/http.mjs",answers:"the uses union: imports plus calls"},{form:"where is <entity> <where-marker>",example:"where is saveStore defined",answers:"the definition's file and line span"},{form:"when did <entity> change",example:"when did src/core/store.mjs change",answers:"the commits that touched it, newest first"}],whereMarkers:Yt}},{name:"tmct_describe",tier:"cold",summary:"Locate one symbol and list its typed edges (both directions) with provenance.",inputSchema:Jt("A module path, symbol name, or Class.method."),example:{symbol:"django/utils/text.py"}},{name:"tmct_signature",tier:"cold",summary:"One symbol's API surface (params, returns, raises/catches, flags, decorators, doc) without the body.",inputSchema:Jt("A function, method, or Class.method name."),example:{symbol:"Truncator.chars"}},{name:"tmct_impact",tier:"cold",summary:"Transitive reverse closure over imports/calls \u2014 what breaks if a module or symbol changes, by depth, with tests.",inputSchema:Su("The module (or a symbol it defines) whose dependents you want."),example:{module:"django/utils/text.py"}},{name:"tmct_search",tier:"cold",summary:"Free-text/ranked lookup over the code-map to find the right module or symbol.",inputSchema:{type:"object",required:[],properties:{query:{type:"string",description:"Free text to rank against the code-map. Required unless kind narrows the search on its own."},kind:{type:"string",description:"Restrict to an entity class, e.g. function, class, module."},decorator:{type:"string",description:"Restrict to definitions carrying this decorator."},name:{type:"string",description:"Restrict to definitions whose name matches."}}},example:{query:"template filters",kind:"function"}},{name:"tmct_members",tier:"cold",summary:"A class's methods + attributes (file:line, decorators) in one slice.",inputSchema:Eu("The class whose members you want."),example:{class:"Truncator"}},{name:"tmct_subclasses",tier:"cold",summary:"A class's base classes plus the transitive set of classes that extend it.",inputSchema:Eu("The class to walk the inheritance edges of."),example:{class:"Field"}},{name:"tmct_related",tier:"cold",summary:"A term's synonyms (skos:altLabel) and related concepts (skos:related), from the memory graph's relation facts.",inputSchema:{type:"object",required:["term"],properties:{term:{type:"string",description:"The term whose synonyms / related concepts you want."}}},example:{term:"sofa"}},{name:"tmct_architecture",tier:"cold",summary:"Package/module map + the most-imported hub modules (optionally scoped to a package).",inputSchema:{type:"object",required:[],properties:{package:{type:"string",description:"Scope the map to one package. Omit for the whole repository."}}},example:{package:"django/template"}},{name:"tmct_exports",tier:"cold",summary:"A module's public __all__ surface, each name resolved to the module that defines it.",inputSchema:Su("The module whose public API surface you want."),example:{module:"django/db/models/__init__.py"}},{name:"tmct_tests_for",tier:"cold",summary:"The test modules covering a symbol or module, from the typed test edges.",inputSchema:Jt("The symbol or module to find covering tests for."),example:{symbol:"django/utils/text.py"}},{name:"tmct_untested",tier:"cold",summary:"Source modules with no covering test module \u2014 a coverage-gap view (no arguments).",inputSchema:{type:"object",required:[],properties:{}},example:{}},{name:"tmct_history",tier:"cold",summary:"Recent commits that touched a symbol's module (newest first).",inputSchema:Jt("The symbol whose module's history you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_file_history",tier:"cold",summary:"Commits that touched a symbol's module, each with author / date / subject.",inputSchema:Jt("The symbol whose module's history you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_method_history",tier:"cold",summary:"Commits that touched a specific method symbol (fine-grained), with author / date / subject.",inputSchema:Jt("A Class.method name."),example:{symbol:"Truncator.chars"}},{name:"tmct_class_history",tier:"cold",summary:"Commits that touched a specific class symbol (fine-grained), with author / date / subject.",inputSchema:Jt("A class name."),example:{symbol:"Truncator"}},{name:"tmct_callers",tier:"cold",summary:"Modules that call into a symbol's module (one hop).",inputSchema:Jt("The symbol whose callers you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_callees",tier:"cold",summary:"Modules a symbol's module calls into (one hop).",inputSchema:Jt("The symbol whose callees you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_calls",tier:"cold",summary:"The in-repo symbols a function calls (fn\u2192fn), each with file:line.",inputSchema:Jt("The function whose in-repo call sites you want."),example:{symbol:"slugify"}},{name:"tmct_cochanges",tier:"cold",summary:"Modules that historically change in the same commit as a symbol's module (git co-change).",inputSchema:Jt("The symbol whose module's change-coupling you want."),example:{symbol:"django/utils/text.py"}},{name:"tmct_context_more",tier:"cold",summary:"The bundle sections a lean tmct_context omitted (siblings / tests / cochange / class members / re-exports).",inputSchema:Jt("The symbol a lean tmct_context bundle was built for."),example:{symbol:"django/utils/text.py"}},{name:"tmct_export",tier:"cold",summary:"Every stored memory fact as JSONL (subject/predicate/object/provenance) \u2014 the shape `tmct extract` emits, for backup or audit.",inputSchema:{type:"object",required:[],properties:{}},example:{}},{name:"tmct_ingest",tier:"cold",summary:"Ground plain text into memory facts with the same deterministic recognizer the chat teach lane uses \u2014 the strict tier, plus an optional lower-trust fuzzy tier \u2014 and report the canonical triples.",inputSchema:{type:"object",required:["text"],properties:{text:{type:"string",description:"The plain text to ground into facts."},optimistic:{type:"boolean",description:"Also run the lower-trust fuzzy tier over sentences the strict recognizer skips."}}},example:{text:"A kettle is a container. An otter is a mammal.",optimistic:!0}}]),ju=da.filter(e=>e.tier==="hot"),B_=da.filter(e=>e.tier==="cold"),U_=Object.freeze(da.map(e=>e.name))});var Ru,Oe,Lt=L(()=>{De();Ru=Z(".tmct","graph.json"),Oe=class extends Error{constructor(t){super(t),this.name="ToolError"}}});function Eb(e){let t=new Set;for(let n of Array.isArray(e?.individuals)?e.individuals:[])n&&n.id&&t.add(n.id);return t}function Au(e){let t=(Array.isArray(e)?e:[]).map((l,c)=>({file:l?.file,payload:l?.payload||{},name:l?.name!=null&&String(l.name).length?String(l.name):String(c)})),n=t.map(({payload:l})=>Eb(l)),s=new Map;for(let l of n)for(let c of l)s.set(c,(s.get(c)||0)+1);let o=new Set([...s.entries()].filter(([,l])=>l>1).map(([l])=>l)),r={generated_at:"",classes:[],vocabulary:[],objectProperties:[],individuals:[],proseIndex:{}},i="",a=t.length>0;for(let{payload:l,name:c}of t){a=a&&!!l.bootstrap,typeof l.generated_at=="string"&&l.generated_at>i&&(i=l.generated_at);let u=m=>o.has(m)?`${c}/${m}`:m;Array.isArray(l.classes)&&r.classes.push(...l.classes),Array.isArray(l.vocabulary)&&r.vocabulary.push(...l.vocabulary);for(let m of Array.isArray(l.individuals)?l.individuals:[]){if(!m)continue;let p={...m};p.id&&(p.id=u(p.id)),Array.isArray(p.derived_from)&&(p.derived_from=p.derived_from.map(f=>u(f))),Array.isArray(p.mentions)&&(p.mentions=p.mentions.map(f=>f&&f.id?{...f,id:u(f.id)}:f)),r.individuals.push(p)}for(let m of Array.isArray(l.objectProperties)?l.objectProperties:[]){if(!m)continue;let p={...m};Array.isArray(p.examples)&&(p.examples=p.examples.map(f=>{if(!f)return f;let g={...f};return g.subject&&(g.subject=u(g.subject)),g.object&&(g.object=u(g.object)),g})),r.objectProperties.push(p)}let d=l.proseIndex&&typeof l.proseIndex=="object"?l.proseIndex:{};for(let[m,p]of Object.entries(d)){let f=r.proseIndex[m]||(r.proseIndex[m]=[]);for(let g of Array.isArray(p)?p:[]){let h=u(g);f.includes(h)||f.push(h)}}}return r.generated_at=i,a&&(r.bootstrap=!0),r}var Tu=L(()=>{});var eo={};En(eo,{clearCache:()=>jb,emptyEntities:()=>pa,fetchEntities:()=>Tb,registerProvider:()=>_b});function jb(){Zs=null,zo=null}function _b(e){if(e!=null&&typeof e!="function")throw new TypeError("registerProvider expects a function (config) => entities payload, or null");let t=Nr;return Nr=e??null,Zs=null,t}function pa(){return{generated_at:"",bootstrap:!0,classes:[],vocabulary:[],objectProperties:[],individuals:[],proseIndex:{}}}async function Rb(e){let t;try{t=await ze(e,"utf8")}catch(n){if(n?.code==="ENOENT")return pa();throw new Oe(`cannot read graph artifact at ${e} (${n?.code||n?.message||n})`)}try{return JSON.parse(t)}catch{throw new Oe(`graph artifact ${e} is not valid JSON`)}}async function Ab(e){let t=e.graphFiles,n=[...t].map(String).sort().join("|");if(zo&&zo.key===n)return zo.payload;let s=[];for(let r=0;r<t.length;r++){let i=await Rb(t[r]);s.push({file:t[r],payload:i,name:e.graphNames?.[r]})}let o=Au(s);return zo={key:n,payload:o},o}async function Tb(e){if(Nr){let s;try{s=await Nr(e)}catch(o){throw o instanceof Oe?o:new Oe(`graph provider failed (${o?.message||o})`)}if(!s||typeof s!="object")throw new Oe("graph provider returned no entities payload");return s}if(Array.isArray(e.graphFiles)&&e.graphFiles.length>1)return Ab(e);if(Zs&&Zs.file===e.graphFile)return Zs.payload;let t;try{t=await ze(e.graphFile,"utf8")}catch(s){if(s?.code==="ENOENT")return pa();throw new Oe(`cannot read graph artifact at ${e.graphFile} (${s?.code||s?.message||s})`)}let n;try{n=JSON.parse(t)}catch{throw new Oe(`graph artifact ${e.graphFile} is not valid JSON`)}return Zs={file:e.graphFile,payload:n},n}var Zs,zo,Nr,Bo=L(()=>{vt();Lt();Tu();Zs=null,zo=null,Nr=null});function mn(e){if(!e)return[];let t=String(e).replace(/\.[A-Za-z0-9]+$/,"");return t=t.replace(/[/\\]/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/([A-Za-z])([0-9])/g,"$1 $2").replace(/([0-9])([A-Za-z])/g,"$1 $2").replace(/[_\-.]+/g," "),t.split(/\s+/).map(n=>n.toLowerCase()).filter(n=>n.length>1&&n.length<=Cu)}function fa(e){if(!e)return[];let t=[],n=new Set;for(let s of String(e).toLowerCase().split(/[^a-z0-9]+/))if(!(s.length<2||s.length>Cu||Cb.has(s))&&!n.has(s)&&(n.add(s),t.push(s),t.length>=Ib))break;return t}function Mr({name:e,doc:t}={}){return[...new Set([...mn(e),...fa(t)])].sort()}function Iu(e){let t=Object.create(null);for(let n of e){let s=(n.attributes||[]).find(o=>o.key==="prose_tokens");if(s?.value)for(let o of s.value.split(" "))t[o]||(t[o]=[]),t[o].push(n.id)}for(let n of Object.keys(t))t[n].sort();return t}function $s(e,t,{limit:n=10}={}){let s=[...new Set([...mn(t),...fa(t)])];if(!s.length)return[];let o=new Map;for(let r of s)for(let i of e?.[r]||[])o.set(i,(o.get(i)||0)+1);return[...o.entries()].sort((r,i)=>i[1]-r[1]||String(r[0]).localeCompare(i[0])).slice(0,n).map(([r,i])=>({id:r,score:i}))}function Ou(e,t){let n=e&&(e["tmct:layers"]?e:e.proseIndex),s=n&&n["tmct:layers"],o=String(t||"").toLowerCase(),r={ids:[],via:null};if(!o||!s||typeof s!="object")return r;let i=new Set,a=new Set;for(let l of Object.keys(s)){let c=s[l];if(!c||typeof c!="object")continue;let u=c[o],d=Array.isArray(u)?u:Array.isArray(u?.ids)?u.ids:null;if(d?.length){for(let m of d)i.add(m);a.add(l)}}return i.size?{ids:[...i].sort(),via:[...a].sort().join("+")}:r}var Cb,Cu,Ib,Yn=L(()=>{Cb=new Set("a an and or but the of to in on at for with from by as is are was were be been being it its this that these those i you he she they we me my your our do does did not no yes if then else than so such can will would should could may might about into over under out up down off again more most some any all what which who whom whose when where why how".split(/\s+/)),Cu=40,Ib=120});function Lu(e){let t=e.indexOf("@"),n=t>=0?e.slice(0,t):e,s=t>=0?e.slice(t+1):"",o=n.indexOf(":"),r=o>=0?n.slice(o+1):"";return{createdAt:s,...r?{sessionId:r}:{}}}function Uo(e){let t=String(e||"").trim();if(!t)return null;if(t.startsWith("reference:")){let s=t.slice(10),o=s.indexOf(":");if(o<0)return{kind:"reference",pack:s||"unknown",article:""};let r=s.slice(0,o)||"unknown";return{kind:Lb(r),pack:r,article:s.slice(o+1)}}if(t.startsWith("research:")){let s=t.slice(9),o=s.lastIndexOf("@");return{kind:"referenceLive",pack:"research",article:(o>=0?s.slice(0,o):s).trim()||"unknown"}}let n=t.split(/\s+/)[0];return n.startsWith("corpus-weak:")?{kind:"corpusWeak",name:n.slice(12)||"unknown"}:n.startsWith("corpus:")?{kind:"corpus",name:n.slice(7)||"unknown"}:n.startsWith("child:")?{kind:"corpus",name:n.slice(6).split(":")[0]||"unknown"}:n.startsWith("world:")?{kind:"corpus",name:n.slice(6).split(":")[0]||"unknown"}:n.startsWith("ace:")?{kind:"operator",...Lu(n.slice(4))}:n.startsWith("teach:")?{kind:"teach",...Lu(n.slice(6))}:n.startsWith("web:")?{kind:"web",url:n.slice(4)}:n.startsWith("url:")?{kind:"web",url:n.slice(4)}:n.startsWith("optimistic-extract:")?{kind:"optimisticExtract",name:n.slice(19)||"unknown"}:n.startsWith("extracted:")?{kind:"extracted",name:n.slice(10)||"unknown"}:n.startsWith("entailed:")?{kind:"entailed",rule:n.slice(9)}:n.startsWith("chat:")||n.startsWith("session:")||n.startsWith("operator")?{kind:"operator"}:null}function Pb(e){let t=(e?.attributes||[]).find(s=>s.prop==="mgx:sourceReliability")?.value;if(t===void 0)return Mu;let n=Number(t);return Number.isFinite(n)?Math.max(ma,Math.min(Pu,n)):Mu}function Fb(e,t=Date.now(),n=Nb){let s=Date.parse(e);if(!Number.isFinite(s))return 1;let o=Math.max(0,t-s);return Nu+(1-Nu)*Math.pow(.5,o/n)}function Fu(e,t={},n={}){let s=typeof n.now=="number"?n.now:Date.now(),o=Array.isArray(e?.sourceIds)?e.sourceIds:[],r=new Set,i=[],a=[];for(let p of o){if(r.has(p))continue;r.add(p);let f=t[p],g=Mb(f);if(!g)continue;i.push(g);let h=(Wo[g]??0)*Pb(f);a.push(Math.max(0,Math.min(1,h)))}let l=0,c=1;for(let p of a)c*=1-p;if(a.length&&(l=Math.min(1,1-c)),i.includes("entailed")&&Array.isArray(n.premiseTrusts)&&n.premiseTrusts.length){let p=typeof n.ruleConfidence=="number"?n.ruleConfidence:1;l=Math.max(0,Math.min(1,Math.min(...n.premiseTrusts)*p))}let u=Fb(e?.createdAt,s,n.halfLifeMs),d=ha(Math.min(1,l*u)),m={sourceTypes:i.slice().sort(),corroboration:i.length,createdAt:e?.createdAt||"",recency:ha(u)};return{score:d,inputs:m}}function Du({factsAsserted:e=0,factsContradicted:t=0}={}){let n=Math.max(0,Number(e)||0),s=Math.max(0,Number(t)||0),o=Math.max(-1,Math.min(1,(n-2*s)/Math.max(1,n))),r=n/(n+Db),i=(o*r+1)/2;return ha(ma+(Pu-ma)*i)}var Pr,ga,Nt,xs,Ob,Lb,Wo,Nb,Nu,ma,Pu,Mu,ha,Mb,Db,ks=L(()=>{Pr="mgx:trustScore",ga="mgx:trustInputs",Nt="mgx:createdAt",xs="mgx:updatedAt";Ob="wikipedia-live",Lb=e=>e===Ob?"referenceLive":"reference";Wo=Object.freeze({operator:1,teach:.95,provider:.9,corpus:.7,reference:.6,corpusWeak:.55,referenceLive:.5,extracted:.45,web:.4,optimisticExtract:.35,entailed:.3}),Nb=720*60*60*1e3,Nu=.9,ma=.5,Pu=1.5,Mu=1,ha=(e,t=6)=>Number(e.toFixed(t)),Mb=e=>(e?.attributes||[]).find(t=>t.prop==="mgx:sourceType")?.value||"";Db=19});var Ss,ba=L(()=>{Ss=e=>/(^|\/)tests?\//.test(e)||/(^|\/)test_[^/]*\.py$/.test(e)||/\.tests(\.|$)/.test(e)});function wa(e,t){return Math.log(1+e/(1+t))}var qo=L(()=>{});var Dr={};En(Dr,{bfsLevels:()=>Fr,findActionPath:()=>ya,findReachableSet:()=>va});function zu(e){return e&&typeof e=="object"?JSON.stringify(e):String(e)}function Bu(e,t){let n=[];for(let{action:s,nextState:o}of t(e)||[])n.push({state:o,actions:[s],states:[e,o]});return n}function ya(e,t,n,{maxDepth:s=50,stateKey:o=zu}={}){if(t(e))return{actions:[],states:[e]};let r=Bu(e,n),i=new Set([o(e)]);for(let a=1;a<=s&&r.length;a+=1){for(let c of r)if(t(c.state))return{actions:c.actions,states:c.states};if(a===s)break;let l=[];for(let c of r){let u=o(c.state);if(!i.has(u)){i.add(u);for(let{action:d,nextState:m}of n(c.state)||[]){let p=o(m);i.has(p)||l.push({state:m,actions:[...c.actions,d],states:[...c.states,m]})}}}r=l}return null}function va(e,t,{maxDepth:n=50,stateKey:s=zu}={}){let o=Bu(e,t),r=new Set([s(e)]),i=[];for(let a=1;a<=n&&o.length;a+=1){let l=[];for(let c of o){let u=s(c.state);if(!r.has(u)&&(r.add(u),i.push({node:c.state,path:{actions:c.actions,states:c.states}}),a!==n))for(let{action:d,nextState:m}of t(c.state)||[]){let p=s(m);r.has(p)||l.push({state:m,actions:[...c.actions,d],states:[...c.states,m]})}}o=l}return i}function*Fr(e,t,{maxDepth:n=8,keyOf:s=o=>o}={}){let o=new Set([e]),r=[e];for(let i=1;i<=n&&r.length;i+=1){let a=[],l=[];for(let c of r)for(let u of t(c)||[]){let d=s(u);o.has(d)||(o.add(d),a.push(u),l.push(d))}r=l,yield a}}var Es=L(()=>{});function Br(e){let t=Array.isArray(e?.individuals)?e.individuals:[],n=new Map;for(let r of t)r&&r.id&&n.set(r.id,r);let s=(Array.isArray(e?.objectProperties)?e.objectProperties:[]).filter(r=>r&&(r.predicate||r.prop)).map(r=>{let i=(Array.isArray(r.examples)?r.examples:[]).filter(a=>a&&a.subject&&a.object);return{predicate:String(r.predicate||""),prop:r.prop||null,count:Number(r.count)||i.length,edges:i}}),o=s.filter(r=>r.count>r.edges.length).map(r=>({predicate:r.predicate,count:r.count,shown:r.edges.length}));return{individuals:t,byId:n,relations:s,truncated:o,generatedAt:e?.generated_at||null,proseIndex:e?.proseIndex||{}}}function ja(e){return!e||!Array.isArray(e.individuals)?0:e.individuals.filter(t=>(t.class||"")==="Module").length}function On(e){let t=String(e?.prop||"").toLowerCase();if(Uu[t])return Uu[t];let n=String(e?.predicate||"").toLowerCase();if(/symbol/.test(n)){if(/\b(call|invoke)/.test(n))return"callsSymbol";if(/(touch|chang|modif)/.test(n))return"touchesSymbol"}return/\bimport/.test(n)?"imports":/\b(call|invoke)/.test(n)?"calls":/\b(define|export|declare)/.test(n)?"defines":/\b(test|cover)/.test(n)?"tests":/\b(touch|chang|modif)/.test(n)?"touches":/\bcontain/.test(n)?"contains":/\b(inherit|subclass|extend|specializ)/.test(n)?"inherits":null}function Cn(e){return String(e||"").trim().toLowerCase().replace(/^\.\//,"").replace(/^\//,"")}function $a(e){let t=Cn(e).split("/");return t[t.length-1]}function zb(e){return(e?.derived_from||[]).filter(td).length}function Wu(e){return(e?.mentions||[]).reduce((n,s)=>n+(Number(s?.count)||0),0)+zb(e)}function Vt(e,t){let n=Cn(t);if(!n)return{match:null,candidates:[]};let s=$a(n),o=[];for(let r of e.individuals){let i=Cn(r.label),a=String(r.id||"").toLowerCase(),l=0;i===n||a===n?l=100:i.endsWith(`/${n}`)||$a(i)===s||$a(i).replace(/\.[a-z]+$/,"")===s?l=80:i.includes(n)&&(l=Math.max(10,50-(i.length-n.length))),l>0&&o.push({ind:r,score:l})}return o.sort((r,i)=>i.score-r.score||Wu(i.ind)-Wu(r.ind)||String(r.ind.label).length-String(i.ind.label).length),{match:o[0]?.ind||null,candidates:o.slice(1,5).map(r=>r.ind)}}function $t(e){let t=(e?.attributes||[]).find(s=>s.key==="site");if(!t)return null;let n=String(t.value).match(/^(.*):(\d+)(?:-(\d+))?$/);return n?{path:n[1],start:Number(n[2]),end:n[3]?Number(n[3]):Number(n[2])}:null}function Bb(e,t){let n=[],s=[];for(let o of e.relations){let r=o.edges.filter(a=>a.subject===t),i=o.edges.filter(a=>a.object===t);r.length&&n.push({group:o,edges:r}),i.length&&s.push({group:o,edges:i})}return{out:n,incoming:s}}function qu(e){return e.prop?`${e.predicate} [${e.prop}]`:e.predicate}function In(e){let t=e||"Entity",n=mn(t);return n.length<2?t:n.map(s=>s[0].toUpperCase()+s.slice(1)).join(" ")}function nt(e,t,n=", "){return e.length<=t?e.join(n):e.slice(0,t).join(n)+`, +${e.length-t} more`}function _a(e,t,{candidates:n=[]}={}){let s=[];s.push(`${t.label} \u2014 ${In(t.class)} (id: ${t.id})`);let o=(t.derived_from||[]).filter(td);o.length&&s.push(`attestation: touched by ${o.length} commit(s)`);for(let l of t.attributes||[])s.push(`attribute: ${l.key} = ${l.value}${l.prop?` [${l.prop}]`:""}`);let{out:r,incoming:i}=Bb(e,t.id);if(!r.length&&!i.length)s.push("edges: none in the current artifact");else{s.push("edges:");for(let{group:l,edges:c}of r)s.push(` ${qu(l)} (${c.length}) \u2192 ${nt(c.map(u=>u.objectLabel||u.object),Gu)}`);for(let{group:l,edges:c}of i)s.push(` \u2190 ${qu(l)} (${c.length}) by ${nt(c.map(u=>u.subjectLabel||u.subject),Gu)}`)}let a=t.derived_from||[];return a.length&&s.push(`provenance: ${nt(a,Ub)}`),n.length&&s.push(`other matches: ${n.map(l=>`${l.label} (${In(l.class)})`).join(", ")}`),e.truncated.length&&s.push(Wb(e)),s.join(`
2
2
  `)}function Wb(e){return`note: partial edge lists for: ${e.truncated.map(n=>`${n.predicate} (${n.shown}/${n.count})`).join(", ")}. Counts are complete; the lists are not.`}function no(e,t,{maxDepth:n=8}={}){let s=new Map,o=new Map,r=(a,l,c,u)=>{!a||!l||a===l||(s.has(a)||s.set(a,[]),s.get(a).push({id:l,label:c,via:u}))};for(let a of e.relations){let l=On(a);if(l==="imports"||l==="calls")for(let c of a.edges)r(c.object,c.subject,c.subjectLabel||c.subject,a.predicate);else if(l==="callsSymbol")for(let c of a.edges){let u=Tn(e,c.subject),d=Tn(e,c.object);if(!u||!d)continue;let m=e.byId.get(u)?.label||u;r(d,u,m,a.predicate),u!==d&&r(c.object,u,m,a.predicate)}else if(l==="tests")for(let c of a.edges)o.has(c.object)||o.set(c.object,[]),o.get(c.object).push(c.subjectLabel||c.subject)}let i=[];for(let a of Fr(t.id,l=>s.get(l)||[],{maxDepth:n,keyOf:l=>l.id})){if(!a.length)continue;let l=a.map(c=>({...c,tests:o.get(c.id)||[]})).sort((c,u)=>String(c.label).localeCompare(String(u.label)));i.push(l)}return i}function nd(e,t,{maxDepth:n=8}={}){let s=no(e,t,{maxDepth:n}),o=[`Impact of changing ${t.label} (reverse closure over imports/calls edges, module- and function-level):`];s.length||o.push("no dependents found in the current artifact \u2014 nothing imports or calls it (or its edges are not in the extracted graph yet).");let r=s.reduce((a,l)=>a+l.length,0);s.length&&o.push(`total: ${r} dependent(s) across ${s.length} depth level(s) (lists capped for brevity).`),s.forEach((a,l)=>{if(l>=qb){o.push(`depth ${l+1}: ${a.length} more dependent(s) (not listed)`);return}o.push(l===0?`depth 1 (${a.length} direct dependents):`:`depth ${l+1} (${a.length}):`);for(let c of a.slice(0,xa)){let u=c.tests.length?`tests: ${nt(c.tests,Gb)}`:"tests: none recorded",d=l===0?`${c.via} it`:"reaches it through an intermediary";o.push(` - ${c.label} (${d}) \u2014 ${u}`)}a.length>xa&&o.push(` \u2026+${a.length-xa} more at depth ${l+1}`)});let i=e.truncated.filter(a=>{let l=On({predicate:a.predicate});return l==="imports"||l==="calls"||l==="callsSymbol"||l==="tests"});return i.length&&o.push("warning: partial edge lists ("+i.map(a=>`${a.predicate}: ${a.shown}/${a.count}`).join(", ")+") \u2014 this closure may be missing edges. Cross-check critical results with a lexical search (/find <term>)."),o.join(`
3
- `)}function sd(e){let t=new Map;for(let n of e.relations)if(On(n)==="defines")for(let s of n.edges)t.has(s.subject)||t.set(s.subject,[]),t.get(s.subject).push(s.objectLabel||s.object);return t}function Hu(e){return new Set(String(e).replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean))}function cd(e,t,n=null){let s=n||(i=>Tn(e,i)),o=new Map,r=(i,a)=>{!i||!a||i===a||(o.has(i)||o.set(i,new Set),o.has(a)||o.set(a,new Set),o.get(i).add(a),o.get(a).add(i))};for(let i of t)for(let a of Se(e,i))r(s(a.subject),s(a.object));return o}function _w(e,t,n){if(t.length<2)return;let s=new Map(t.map(c=>[c.ind.id,c])),o=new Map(t.map(c=>[c.ind.id,c.score])),r=c=>{if(!c.size)return[[],[]];let u=0;for(let f of c.values())u=Math.max(u,f);let d=[...c.entries()].sort((f,g)=>g[1]-f[1]),m=[],p=[];for(let[f,g]of d)g>=u*bw&&m.length<n?m.push([f,g]):p.length<Vu&&p.push([f,g]);return[m,p]},[i,a]=r(new Map(t.map(c=>[c.ind.id,c.score]))),l=new Set(i.map(([c])=>c));for(let c=0;c<vw&&i.length;c++){let u=new Map,d=[];for(let m of $w){let p=cd(e,m),f=new Map;for(let[b,w]of i)for(let v of p.get(b)||[])o.has(v)&&f.set(v,Math.max(f.get(v)||0,w));let[g,h]=r(f);for(let[b,w]of g)u.set(b,Math.max(u.get(b)||0,w));d.push(...h)}a.push(...d);for(let[m,p]of u){if(l.has(m))continue;let f=s.get(m);f&&(f.score+=Math.min(p*ww,f.score*yw),l.add(m))}i=[...u.entries()],!i.length&&a.length&&(i=a.splice(0,Vu).filter(([m])=>!l.has(m)))}}function Rw(e,t=[],{depth:n=rd,q:s=ad,nodeLimit:o=id,kinds:r=xw,classPredicate:i=u=>(u.class||"")==="Module",idNormalizer:a=null,seeds:l=null,hubDegree:c=1/0}={}){let u=new Map(t.map(_=>[_.ind.id,_])),d=0;for(let _ of t)d=Math.max(d,_.score);let m=t.length>0&&d>0,p=new Set(l??u.keys());if(!p.size)return[];let f=cd(e,r,a),g=_=>f.get(_)?.size||0,h=[],b=(_,R)=>_.hop!==R.hop?_.hop<R.hop:_.deg!==R.deg?_.deg<R.deg:_.id<R.id,w=(_,R)=>{let S=h[_];h[_]=h[R],h[R]=S},v=_=>{h.push(_);let R=h.length-1;for(;R>0;){let S=R-1>>1;if(b(h[R],h[S]))w(R,S),R=S;else break}},$=()=>{let _=h[0],R=h.pop();if(h.length){h[0]=R;let S=0;for(;;){let A=2*S+1,M=2*S+2,T=S;if(A<h.length&&b(h[A],h[T])&&(T=A),M<h.length&&b(h[M],h[T])&&(T=M),T===S)break;w(S,T),S=T}}return _},k=new Set(p);for(let _ of p)v({id:_,hop:0,deg:g(_)});let y=null,j=0,E=[];for(;h.length&&j<o;){let _=$();if(E.push({id:_.id,hop:_.hop}),!p.has(_.id)){if(m){let A=d*kw*Math.pow(Sw,_.hop-1),M=u.get(_.id);if(M)M.score+=Math.min(A*Ew,M.score*jw);else{let T=e.byId?.get?.(_.id);if(T&&i(T)){y||(y=sd(e));let P=y.get(T.id)||[],G={ind:T,score:A,defineCount:P.length,matching:[],density:0};t.push(G),u.set(_.id,G)}}}j++}if(_.hop>=n||_.hop>0&&g(_.id)>c)continue;let R=[];for(let A of f.get(_.id)||[]){if(k.has(A))continue;let M=e.byId?.get?.(A);!M||!i(M)||R.push({id:A,deg:g(A)})}if(!R.length)continue;R.sort((A,M)=>A.deg-M.deg||(A.id<M.id?-1:A.id>M.id?1:0));let S=Math.max(1,Math.floor(s*R.length));for(let A=0;A<S;A++){let M=R[A];k.add(M.id),v({id:M.id,hop:_.hop+1,deg:M.deg})}}return E}function ld(e,t,n={}){let{demoteNonProd:s=!1,callAdjacency:o=!1,implOfInterface:r=!1,beamSearch:i=!1,spiral:a=!1,proseBoost:l=!1,proseLayers:c=!1,literalMention:u=!1,rawQuery:d=""}=n,m=Number.isFinite(n.beamWidth)&&n.beamWidth>0?n.beamWidth:8,p=sd(e),f=[];for(let $ of e.individuals){if(($.class||"")!=="Module")continue;let k=String($.label),y=k.toLowerCase(),j=p.get($.id)||[],E=new Set(j.map(S=>S.toLowerCase())),_=new Set;for(let S of j)for(let A of Hu(S))_.add(A);let R=u?String(($.attributes||[]).find(S=>S.key==="dotted")?.value||"").toLowerCase():"";f.push({ind:$,label:k,labelLc:y,defines:j,symSet:E,symComps:_,dotted:R})}let g=f.length||1,h=new Map,b=$=>{let k=0;for(let y of f)(y.labelLc.includes($)||y.symComps.has($)||y.symSet.has($))&&k++;return k},w=$=>(h.has($)||h.set($,wa(g,b($))),h.get($));for(let $ of t)w($);let v=[];for(let $ of f){let k=0,y=0,j=0,E=[];for(let M of t){let T=h.get(M)||0;T&&($.symSet.has(M)?(k+=T*od,j++):$.symComps.has(M)&&(E.push(T),j++),$.labelLc.includes(M)&&(y+=T*Hb))}E.sort((M,T)=>T-M);let _=0;for(let M=0;M<Math.min(E.length,Yb);M++)_+=E[M]*Kb;let R=k+y+_;if(!R)continue;s&&(Ss($.labelLc)||Zb($.labelLc))?R*=Qb:Ss($.labelLc)&&(R*=.4);let S=$.defines.filter(M=>{let T=M.toLowerCase(),P=Hu(M);return t.some(G=>T===G||P.has(G))}),A=$.defines.length?j/$.defines.length:0;v.push({ind:$.ind,score:R,defineCount:$.defines.length,matching:S,density:A})}if(u&&d&&v.length){let $=String(d).toLowerCase(),k=_=>_!=null&&/[a-z0-9_./]/.test(_),y=_=>{for(let R=$.indexOf(_);R!==-1;R=$.indexOf(_,R+1))if(!k($[R-1])&&!k($[R+_.length]))return!0;return!1},j=new Map(f.map(_=>[_.ind.id,_])),E=0;for(let _ of v)E=Math.max(E,_.score);for(let _ of v){let R=j.get(_.ind.id);if(!R)continue;let S=0;for(let A of new Set([R.dotted,R.labelLc])){if(!A||A.split(/[./]+/).filter(Boolean).length<fw||!y(A))continue;let M=[...new Set(A.split(/[^a-z0-9_]+/).filter(Boolean))].map(w).sort((P,G)=>G-P),T=0;for(let P=0;P<Math.min(M.length,mw);P++)T+=M[P]*pw;S=Math.max(S,T)}S&&(_.score+=Math.min(S*hw,E*gw))}}if(v.length>1){let $=new Map(v.map(y=>[y.ind.id,y.score])),k=new Map;for(let y of Se(e,"imports"))!$.has(y.subject)&&!$.has(y.object)||(k.has(y.subject)||k.set(y.subject,new Set),k.has(y.object)||k.set(y.object,new Set),k.get(y.subject).add(y.object),k.get(y.object).add(y.subject));for(let y of v){let j=0;for(let E of k.get(y.ind.id)||[])j=Math.max(j,$.get(E)||0);y.score+=Math.min(j*Xb,y.score*Jb)}}if(o&&v.length>1){let $=new Map(v.map(y=>[y.ind.id,y.score])),k=new Map;for(let y of["calls","callsSymbol"])for(let j of Se(e,y)){let E=Tn(e,j.subject),_=Tn(e,j.object);!E||!_||E===_||!$.has(E)&&!$.has(_)||(k.has(E)||k.set(E,new Set),k.has(_)||k.set(_,new Set),k.get(E).add(_),k.get(_).add(E))}for(let y of v){let j=0;for(let E of k.get(y.ind.id)||[])j=Math.max(j,$.get(E)||0);y.score+=Math.min(j*ew,y.score*tw)}}if(r&&v.length>1){let $=new Map(v.map(y=>[y.ind.id,y.score])),k=new Map;for(let y of e.individuals)(y.class||"")==="Class"&&y.label&&k.set(String(y.label),y);for(let y of v){if(!ow(y.ind.label))continue;let j=0;for(let E of Se(e,"inherits")){if(Tn(e,E.subject)!==y.ind.id||!rw(E.objectLabel))continue;let R=Tn(e,E.object);if(!R){let S=k.get(String(E.objectLabel||""));S&&(R=mn(e,S))}R&&(j=Math.max(j,$.get(R)||0))}y.score+=Math.min(j*nw,y.score*sw)}}if(l&&v.length&&e.proseIndex){let $=$s(e.proseIndex,t.join(" "),{limit:cw});if($.length){let k=new Map;for(let{id:y,score:j}of $){let E=Tn(e,y);E&&k.set(E,(k.get(E)||0)+j)}for(let y of v){let j=k.get(y.ind.id)||0;j&&(y.score+=Math.min(j*iw,y.score*aw))}}}if(c&&v.length&&e.proseIndex){let $=new Map(v.map(j=>[j.ind.id,j])),k=new Map(f.map(j=>[j.ind.id,j])),y=new Map;for(let j of new Set(t)){let E=h.get(j)||0;if(!E)continue;let{ids:_}=Ou(e.proseIndex,j);if(!_.length)continue;let R=new Set;for(let S of _){let A=Tn(e,S);if(!A||R.has(A)||(R.add(A),!$.has(A)))continue;let M=k.get(A);M&&(M.symSet.has(j)||M.symComps.has(j)||M.labelLc.includes(j))||y.set(A,(y.get(A)||0)+E*dw)}}for(let j of v){let E=y.get(j.ind.id)||0;E&&(j.score+=Math.min(E*lw,j.score*uw))}}return i&&v.length>1&&_w(e,v,m),a&&v.length&&Rw(e,v,{depth:Number.isFinite(n.spiralDepth)&&n.spiralDepth>0?n.spiralDepth:rd,q:Number.isFinite(n.mostDistinctiveBeams)&&n.mostDistinctiveBeams>0?n.mostDistinctiveBeams:ad,nodeLimit:Number.isFinite(n.spiralNodeLimit)&&n.spiralNodeLimit>0?n.spiralNodeLimit:id}),v.sort(($,k)=>k.score-$.score||k.density-$.density||$.defineCount-k.defineCount||String($.ind.label).length-String(k.ind.label).length),v}function ud(e,t,n={}){let s=String(t||""),o=s.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean);if(!o.length)return[];let r=n.literalMention?{...n,rawQuery:s}:n;return ld(e,o,r).map(i=>({path:String(i.ind.label),score:i.score}))}function Tw(e){let t=0,n=!1,s=!1,o=!1,r="",i=!1,a=()=>{t+=1,r===")"&&(n=!0),i=!0};for(let l=0;l<e.length;l++){let c=e[l];if(c==="\\"){let u=e[l+1]||"";!o&&u>="1"&&u<="9"&&(s=!0),l+=1,r="",i=!1;continue}if(o){c==="]"&&(o=!1,r="]",i=!1);continue}if(c==="["){o=!0,r="[",i=!1;continue}if(c==="?"&&(r==="("||i)){r="?",i=!1;continue}if(c==="*"||c==="+"||c==="?"){a(),r=c;continue}if(c==="{"){let u=e.indexOf("}",l),d=u===-1?"":e.slice(l+1,u);if(u!==-1&&/^\d+(,\d*)?$/.test(d)){a(),l=u,r="}";continue}r="{",i=!1;continue}r=c,i=!1}return{quantifiers:t,quantifiedGroup:n,backreference:s}}function Ra(e,{now:t=Date.now}={}){let n=String(e);if(n.length>Ku)return{error:`name pattern is ${n.length} characters; the limit is ${Ku}.`};let{quantifiers:s,quantifiedGroup:o,backreference:r}=Tw(n);if(o)return{error:`name pattern "${n}" quantifies a group, which can backtrack for minutes on one label. Quantify a character or a class instead.`};if(r)return{error:`name pattern "${n}" uses a back-reference, which can backtrack for minutes on one label.`};if(s>Yu)return{error:`name pattern "${n}" has ${s} quantifiers; the limit is ${Yu}.`};let i;try{i=new RegExp(n,"i")}catch{return{error:`invalid name pattern: ${n}`}}let a=null;return{test(l){if(a===null)a=t()+Xu;else if(t()>a)throw new zr(`name pattern "${n}" exceeded its ${Xu}ms matching budget.`);return i.test(String(l).slice(0,Aw))}}}function dd(e,t,{limit:n=Ur,kind:s="",decorator:o="",name:r=""}={}){let i=String(t||"").toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean),a=String(s||"").trim().toLowerCase(),l=String(o||"").trim().toLowerCase(),c=null;if(r){let p=Ra(r);if(p.error)return p.error;c=p}if(a&&a!=="module")try{return Nw(e,i,{limit:n,kind:a,decFilter:l,nameRe:c})}catch(p){if(p instanceof zr)return p.message;throw p}if(!i.length&&!c&&!l)return"empty query";let u=ld(e,i);if(!u.length)return`no module matches "${t}". Try broader keywords, or tmct_describe <path> if you know where it lives.`;let d=u.slice(0,n),m=[`${u.length} module(s) match "${t}" (top ${d.length}):`];for(let{ind:p,defineCount:f,matching:g}of d){let h=g.length?` \u2014 matching: ${nt([...new Set(g)],Vb)}`:"";m.push(`- ${p.label} (defines ${f} symbol(s))${h}`)}return m.push("Then tmct_describe <path> for the full sibling list + typed edges, or tmct_impact <path> for dependents."),m.join(`
4
- `)}function Se(e,t){let n=Ju.get(e);n||(n=new Map,Ju.set(e,n));let s=n.get(t);if(s)return s;let o=[];for(let r of e.relations)if(On(r)===t)for(let i of r.edges)o.push(i);return n.set(t,o),o}function Tn(e,t){let n=e.byId?.get?.(t);if(n)return mn(e,n);let s=String(t||"").match(/^fn:(.+)#/);return s?`mod:${s[1]}`:null}function mn(e,t){if((t?.class||"")==="Module")return t.id;let n=$t(t);if(n)return`mod:${n.path}`;let s=String(t?.id||"").match(/^fn:(.+)#/);return s?`mod:${s[1]}`:null}function Aa(e){if(!e)return"";let t=e.end>e.start?`${e.start}-${e.end}`:`${e.start}`;return` [${e.path}:${t}]`}function to(e){return(e?.attributes||[]).find(t=>t.key==="decorators")?.value||""}function pd(e,t){let n=[`${t.label} \u2014 ${In(t.class)} (id: ${t.id})`],s=Se(e,"contains").filter(i=>i.subject===t.id);if(!s.length)return n.push("members: none recorded (empty class, or members not in the extracted graph). Use tmct_describe for its edges."),n.join(`
3
+ `)}function sd(e){let t=new Map;for(let n of e.relations)if(On(n)==="defines")for(let s of n.edges)t.has(s.subject)||t.set(s.subject,[]),t.get(s.subject).push(s.objectLabel||s.object);return t}function Hu(e){return new Set(String(e).replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean))}function cd(e,t,n=null){let s=n||(i=>Tn(e,i)),o=new Map,r=(i,a)=>{!i||!a||i===a||(o.has(i)||o.set(i,new Set),o.has(a)||o.set(a,new Set),o.get(i).add(a),o.get(a).add(i))};for(let i of t)for(let a of Se(e,i))r(s(a.subject),s(a.object));return o}function _w(e,t,n){if(t.length<2)return;let s=new Map(t.map(c=>[c.ind.id,c])),o=new Map(t.map(c=>[c.ind.id,c.score])),r=c=>{if(!c.size)return[[],[]];let u=0;for(let f of c.values())u=Math.max(u,f);let d=[...c.entries()].sort((f,g)=>g[1]-f[1]),m=[],p=[];for(let[f,g]of d)g>=u*bw&&m.length<n?m.push([f,g]):p.length<Vu&&p.push([f,g]);return[m,p]},[i,a]=r(new Map(t.map(c=>[c.ind.id,c.score]))),l=new Set(i.map(([c])=>c));for(let c=0;c<vw&&i.length;c++){let u=new Map,d=[];for(let m of $w){let p=cd(e,m),f=new Map;for(let[b,w]of i)for(let v of p.get(b)||[])o.has(v)&&f.set(v,Math.max(f.get(v)||0,w));let[g,h]=r(f);for(let[b,w]of g)u.set(b,Math.max(u.get(b)||0,w));d.push(...h)}a.push(...d);for(let[m,p]of u){if(l.has(m))continue;let f=s.get(m);f&&(f.score+=Math.min(p*ww,f.score*yw),l.add(m))}i=[...u.entries()],!i.length&&a.length&&(i=a.splice(0,Vu).filter(([m])=>!l.has(m)))}}function Rw(e,t=[],{depth:n=rd,q:s=ad,nodeLimit:o=id,kinds:r=xw,classPredicate:i=u=>(u.class||"")==="Module",idNormalizer:a=null,seeds:l=null,hubDegree:c=1/0}={}){let u=new Map(t.map(_=>[_.ind.id,_])),d=0;for(let _ of t)d=Math.max(d,_.score);let m=t.length>0&&d>0,p=new Set(l??u.keys());if(!p.size)return[];let f=cd(e,r,a),g=_=>f.get(_)?.size||0,h=[],b=(_,R)=>_.hop!==R.hop?_.hop<R.hop:_.deg!==R.deg?_.deg<R.deg:_.id<R.id,w=(_,R)=>{let S=h[_];h[_]=h[R],h[R]=S},v=_=>{h.push(_);let R=h.length-1;for(;R>0;){let S=R-1>>1;if(b(h[R],h[S]))w(R,S),R=S;else break}},$=()=>{let _=h[0],R=h.pop();if(h.length){h[0]=R;let S=0;for(;;){let A=2*S+1,M=2*S+2,T=S;if(A<h.length&&b(h[A],h[T])&&(T=A),M<h.length&&b(h[M],h[T])&&(T=M),T===S)break;w(S,T),S=T}}return _},k=new Set(p);for(let _ of p)v({id:_,hop:0,deg:g(_)});let y=null,j=0,E=[];for(;h.length&&j<o;){let _=$();if(E.push({id:_.id,hop:_.hop}),!p.has(_.id)){if(m){let A=d*kw*Math.pow(Sw,_.hop-1),M=u.get(_.id);if(M)M.score+=Math.min(A*Ew,M.score*jw);else{let T=e.byId?.get?.(_.id);if(T&&i(T)){y||(y=sd(e));let P=y.get(T.id)||[],G={ind:T,score:A,defineCount:P.length,matching:[],density:0};t.push(G),u.set(_.id,G)}}}j++}if(_.hop>=n||_.hop>0&&g(_.id)>c)continue;let R=[];for(let A of f.get(_.id)||[]){if(k.has(A))continue;let M=e.byId?.get?.(A);!M||!i(M)||R.push({id:A,deg:g(A)})}if(!R.length)continue;R.sort((A,M)=>A.deg-M.deg||(A.id<M.id?-1:A.id>M.id?1:0));let S=Math.max(1,Math.floor(s*R.length));for(let A=0;A<S;A++){let M=R[A];k.add(M.id),v({id:M.id,hop:_.hop+1,deg:M.deg})}}return E}function ld(e,t,n={}){let{demoteNonProd:s=!1,callAdjacency:o=!1,implOfInterface:r=!1,beamSearch:i=!1,spiral:a=!1,proseBoost:l=!1,proseLayers:c=!1,literalMention:u=!1,rawQuery:d=""}=n,m=Number.isFinite(n.beamWidth)&&n.beamWidth>0?n.beamWidth:8,p=sd(e),f=[];for(let $ of e.individuals){if(($.class||"")!=="Module")continue;let k=String($.label),y=k.toLowerCase(),j=p.get($.id)||[],E=new Set(j.map(S=>S.toLowerCase())),_=new Set;for(let S of j)for(let A of Hu(S))_.add(A);let R=u?String(($.attributes||[]).find(S=>S.key==="dotted")?.value||"").toLowerCase():"";f.push({ind:$,label:k,labelLc:y,defines:j,symSet:E,symComps:_,dotted:R})}let g=f.length||1,h=new Map,b=$=>{let k=0;for(let y of f)(y.labelLc.includes($)||y.symComps.has($)||y.symSet.has($))&&k++;return k},w=$=>(h.has($)||h.set($,wa(g,b($))),h.get($));for(let $ of t)w($);let v=[];for(let $ of f){let k=0,y=0,j=0,E=[];for(let M of t){let T=h.get(M)||0;T&&($.symSet.has(M)?(k+=T*od,j++):$.symComps.has(M)&&(E.push(T),j++),$.labelLc.includes(M)&&(y+=T*Hb))}E.sort((M,T)=>T-M);let _=0;for(let M=0;M<Math.min(E.length,Yb);M++)_+=E[M]*Kb;let R=k+y+_;if(!R)continue;s&&(Ss($.labelLc)||Zb($.labelLc))?R*=Qb:Ss($.labelLc)&&(R*=.4);let S=$.defines.filter(M=>{let T=M.toLowerCase(),P=Hu(M);return t.some(G=>T===G||P.has(G))}),A=$.defines.length?j/$.defines.length:0;v.push({ind:$.ind,score:R,defineCount:$.defines.length,matching:S,density:A})}if(u&&d&&v.length){let $=String(d).toLowerCase(),k=_=>_!=null&&/[a-z0-9_./]/.test(_),y=_=>{for(let R=$.indexOf(_);R!==-1;R=$.indexOf(_,R+1))if(!k($[R-1])&&!k($[R+_.length]))return!0;return!1},j=new Map(f.map(_=>[_.ind.id,_])),E=0;for(let _ of v)E=Math.max(E,_.score);for(let _ of v){let R=j.get(_.ind.id);if(!R)continue;let S=0;for(let A of new Set([R.dotted,R.labelLc])){if(!A||A.split(/[./]+/).filter(Boolean).length<fw||!y(A))continue;let M=[...new Set(A.split(/[^a-z0-9_]+/).filter(Boolean))].map(w).sort((P,G)=>G-P),T=0;for(let P=0;P<Math.min(M.length,mw);P++)T+=M[P]*pw;S=Math.max(S,T)}S&&(_.score+=Math.min(S*hw,E*gw))}}if(v.length>1){let $=new Map(v.map(y=>[y.ind.id,y.score])),k=new Map;for(let y of Se(e,"imports"))!$.has(y.subject)&&!$.has(y.object)||(k.has(y.subject)||k.set(y.subject,new Set),k.has(y.object)||k.set(y.object,new Set),k.get(y.subject).add(y.object),k.get(y.object).add(y.subject));for(let y of v){let j=0;for(let E of k.get(y.ind.id)||[])j=Math.max(j,$.get(E)||0);y.score+=Math.min(j*Xb,y.score*Jb)}}if(o&&v.length>1){let $=new Map(v.map(y=>[y.ind.id,y.score])),k=new Map;for(let y of["calls","callsSymbol"])for(let j of Se(e,y)){let E=Tn(e,j.subject),_=Tn(e,j.object);!E||!_||E===_||!$.has(E)&&!$.has(_)||(k.has(E)||k.set(E,new Set),k.has(_)||k.set(_,new Set),k.get(E).add(_),k.get(_).add(E))}for(let y of v){let j=0;for(let E of k.get(y.ind.id)||[])j=Math.max(j,$.get(E)||0);y.score+=Math.min(j*ew,y.score*tw)}}if(r&&v.length>1){let $=new Map(v.map(y=>[y.ind.id,y.score])),k=new Map;for(let y of e.individuals)(y.class||"")==="Class"&&y.label&&k.set(String(y.label),y);for(let y of v){if(!ow(y.ind.label))continue;let j=0;for(let E of Se(e,"inherits")){if(Tn(e,E.subject)!==y.ind.id||!rw(E.objectLabel))continue;let R=Tn(e,E.object);if(!R){let S=k.get(String(E.objectLabel||""));S&&(R=hn(e,S))}R&&(j=Math.max(j,$.get(R)||0))}y.score+=Math.min(j*nw,y.score*sw)}}if(l&&v.length&&e.proseIndex){let $=$s(e.proseIndex,t.join(" "),{limit:cw});if($.length){let k=new Map;for(let{id:y,score:j}of $){let E=Tn(e,y);E&&k.set(E,(k.get(E)||0)+j)}for(let y of v){let j=k.get(y.ind.id)||0;j&&(y.score+=Math.min(j*iw,y.score*aw))}}}if(c&&v.length&&e.proseIndex){let $=new Map(v.map(j=>[j.ind.id,j])),k=new Map(f.map(j=>[j.ind.id,j])),y=new Map;for(let j of new Set(t)){let E=h.get(j)||0;if(!E)continue;let{ids:_}=Ou(e.proseIndex,j);if(!_.length)continue;let R=new Set;for(let S of _){let A=Tn(e,S);if(!A||R.has(A)||(R.add(A),!$.has(A)))continue;let M=k.get(A);M&&(M.symSet.has(j)||M.symComps.has(j)||M.labelLc.includes(j))||y.set(A,(y.get(A)||0)+E*dw)}}for(let j of v){let E=y.get(j.ind.id)||0;E&&(j.score+=Math.min(E*lw,j.score*uw))}}return i&&v.length>1&&_w(e,v,m),a&&v.length&&Rw(e,v,{depth:Number.isFinite(n.spiralDepth)&&n.spiralDepth>0?n.spiralDepth:rd,q:Number.isFinite(n.mostDistinctiveBeams)&&n.mostDistinctiveBeams>0?n.mostDistinctiveBeams:ad,nodeLimit:Number.isFinite(n.spiralNodeLimit)&&n.spiralNodeLimit>0?n.spiralNodeLimit:id}),v.sort(($,k)=>k.score-$.score||k.density-$.density||$.defineCount-k.defineCount||String($.ind.label).length-String(k.ind.label).length),v}function ud(e,t,n={}){let s=String(t||""),o=s.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean);if(!o.length)return[];let r=n.literalMention?{...n,rawQuery:s}:n;return ld(e,o,r).map(i=>({path:String(i.ind.label),score:i.score}))}function Tw(e){let t=0,n=!1,s=!1,o=!1,r="",i=!1,a=()=>{t+=1,r===")"&&(n=!0),i=!0};for(let l=0;l<e.length;l++){let c=e[l];if(c==="\\"){let u=e[l+1]||"";!o&&u>="1"&&u<="9"&&(s=!0),l+=1,r="",i=!1;continue}if(o){c==="]"&&(o=!1,r="]",i=!1);continue}if(c==="["){o=!0,r="[",i=!1;continue}if(c==="?"&&(r==="("||i)){r="?",i=!1;continue}if(c==="*"||c==="+"||c==="?"){a(),r=c;continue}if(c==="{"){let u=e.indexOf("}",l),d=u===-1?"":e.slice(l+1,u);if(u!==-1&&/^\d+(,\d*)?$/.test(d)){a(),l=u,r="}";continue}r="{",i=!1;continue}r=c,i=!1}return{quantifiers:t,quantifiedGroup:n,backreference:s}}function Ra(e,{now:t=Date.now}={}){let n=String(e);if(n.length>Ku)return{error:`name pattern is ${n.length} characters; the limit is ${Ku}.`};let{quantifiers:s,quantifiedGroup:o,backreference:r}=Tw(n);if(o)return{error:`name pattern "${n}" quantifies a group, which can backtrack for minutes on one label. Quantify a character or a class instead.`};if(r)return{error:`name pattern "${n}" uses a back-reference, which can backtrack for minutes on one label.`};if(s>Yu)return{error:`name pattern "${n}" has ${s} quantifiers; the limit is ${Yu}.`};let i;try{i=new RegExp(n,"i")}catch{return{error:`invalid name pattern: ${n}`}}let a=null;return{test(l){if(a===null)a=t()+Xu;else if(t()>a)throw new zr(`name pattern "${n}" exceeded its ${Xu}ms matching budget.`);return i.test(String(l).slice(0,Aw))}}}function dd(e,t,{limit:n=Ur,kind:s="",decorator:o="",name:r=""}={}){let i=String(t||"").toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean),a=String(s||"").trim().toLowerCase(),l=String(o||"").trim().toLowerCase(),c=null;if(r){let p=Ra(r);if(p.error)return p.error;c=p}if(a&&a!=="module")try{return Nw(e,i,{limit:n,kind:a,decFilter:l,nameRe:c})}catch(p){if(p instanceof zr)return p.message;throw p}if(!i.length&&!c&&!l)return"empty query";let u=ld(e,i);if(!u.length)return`no module matches "${t}". Try broader keywords, or tmct_describe <path> if you know where it lives.`;let d=u.slice(0,n),m=[`${u.length} module(s) match "${t}" (top ${d.length}):`];for(let{ind:p,defineCount:f,matching:g}of d){let h=g.length?` \u2014 matching: ${nt([...new Set(g)],Vb)}`:"";m.push(`- ${p.label} (defines ${f} symbol(s))${h}`)}return m.push("Then tmct_describe <path> for the full sibling list + typed edges, or tmct_impact <path> for dependents."),m.join(`
4
+ `)}function Se(e,t){let n=Ju.get(e);n||(n=new Map,Ju.set(e,n));let s=n.get(t);if(s)return s;let o=[];for(let r of e.relations)if(On(r)===t)for(let i of r.edges)o.push(i);return n.set(t,o),o}function Tn(e,t){let n=e.byId?.get?.(t);if(n)return hn(e,n);let s=String(t||"").match(/^fn:(.+)#/);return s?`mod:${s[1]}`:null}function hn(e,t){if((t?.class||"")==="Module")return t.id;let n=$t(t);if(n)return`mod:${n.path}`;let s=String(t?.id||"").match(/^fn:(.+)#/);return s?`mod:${s[1]}`:null}function Aa(e){if(!e)return"";let t=e.end>e.start?`${e.start}-${e.end}`:`${e.start}`;return` [${e.path}:${t}]`}function to(e){return(e?.attributes||[]).find(t=>t.key==="decorators")?.value||""}function pd(e,t){let n=[`${t.label} \u2014 ${In(t.class)} (id: ${t.id})`],s=Se(e,"contains").filter(i=>i.subject===t.id);if(!s.length)return n.push("members: none recorded (empty class, or members not in the extracted graph). Use tmct_describe for its edges."),n.join(`
5
5
  `);let o=[],r=[];for(let i of s){let a=e.byId.get(i.object),l=Aa(a?$t(a):null),c=a?to(a):"",u=`${i.objectLabel||i.object}${l}${c?` @${c}`:""}`;((a?.class||"")==="Attribute"?r:o).push(u)}return o.length&&n.push(`methods (${o.length}): ${nt(o,Qu)}`),r.length&&n.push(`attributes (${r.length}): ${nt(r,Qu)}`),n.push("Use tmct_snippet <Class.member> for an exact body."),n.join(`
6
6
  `)}function fd(e,t){let n=$t(t),s=[`${t.label} \u2014 ${In(t.class)}${Aa(n)}`],o=Me(t,"params"),r=Me(t,"returns");(o||r||(t.class||"")==="Method"||(t.class||"")==="Function")&&s.push(`signature: ${t.label}(${o})${r?` -> ${r}`:""}`);let i=[];Me(t,"isStatic")&&i.push("static"),Me(t,"isAbstract")&&i.push("abstract"),Me(t,"isConstant")&&i.push("constant");let a=Me(t,"visibility");a&&i.push(a),i.length&&s.push(`flags: ${i.join(", ")}`);let l=to(t);l&&s.push(`decorators: @${l.split(", ").join(", @")}`);let c=Me(t,"raises");c&&s.push(`raises: ${c}`);let u=Me(t,"catches");u&&s.push(`catches: ${u}`);let d=Me(t,"self_fields");d&&s.push(`self fields: ${d}`);let m=Me(t,"value");m&&s.push(`value: ${m}`);let p=Me(t,"doc");return p&&s.push(`doc: ${p}`),s.length===1&&s.push("(no signature detail recorded for this symbol \u2014 likely a module or attribute; use tmct_snippet for its source.)"),s.push("Use tmct_snippet for the exact body."),s.join(`
7
7
  `)}function md(e,t){let n=Se(e,"inherits"),s=n.filter(l=>l.subject===t.id).map(l=>l.objectLabel||l.object),o=new Map;for(let l of n)o.has(l.object)||o.set(l.object,[]),o.get(l.object).push({id:l.subject,label:l.subjectLabel||l.subject});let r=[`${t.label} \u2014 ${In(t.class)} (id: ${t.id})`];r.push(s.length?`extends: ${nt(s,Zu)}`:"extends: (no internal/recorded base classes)");let i=[];for(let l of Fr(t.id,c=>o.get(c)||[],{maxDepth:8,keyOf:c=>c.id}))l.length&&i.push(l.map(c=>c.label).sort((c,u)=>String(c).localeCompare(String(u))));let a=i.reduce((l,c)=>l+c.length,0);return a?(r.push(`subclasses: ${a} total across ${i.length} level(s).`),i.forEach((l,c)=>r.push(` depth ${c+1} (${l.length}): ${nt(l,Zu)}`))):r.push("subclasses: none recorded \u2014 nothing extends it in the extracted graph."),r.join(`
8
8
  `)}function Wr(e){let t=new Map;for(let n of e){let s=n.label.includes("/")?n.label.slice(0,n.label.lastIndexOf("/")):"(root)";t.set(s,(t.get(s)||0)+1)}return t}function qr(e,t=""){let n=Cn(t);return e.individuals.filter(s=>(s.class||"")==="Module"&&(!n||Cn(s.label).startsWith(n)))}function hd(e,{pkg:t=""}={}){let n=Cn(t),s=qr(e,t);if(!s.length)return n?`no modules under "${t}".`:"no modules in the graph.";let o=Wr(s),r=new Map;for(let u of Se(e,"imports"))r.set(u.object,(r.get(u.object)||0)+1);let i=new Set(s.map(u=>u.id)),a=[...r.entries()].filter(([u])=>i.has(u)).sort((u,d)=>d[1]-u[1]).slice(0,Iw).map(([u,d])=>`${e.byId.get(u)?.label||u} (${d} importers)`),l=[...o.entries()].sort((u,d)=>d[1]-u[1]),c=[`Architecture${n?` of ${t}`:""}: ${s.length} module(s) in ${l.length} package(s).`];return c.push(`packages (by module count): ${nt(l.map(([u,d])=>`${u} (${d})`),Cw)}`),c.push(a.length?`hub modules (most imported): ${a.join(", ")}`:"hub modules: none (no internal imports recorded)."),c.join(`
9
- `)}function bd(e,t){let n=mn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||$t(t)?.path||n,o=[...new Set(Se(e,"tests").filter(a=>a.object===n).map(a=>a.subjectLabel||a.subject))],r=o.length>0,i=r?`covered by ${o.length} test module(s):
9
+ `)}function bd(e,t){let n=hn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||$t(t)?.path||n,o=[...new Set(Se(e,"tests").filter(a=>a.object===n).map(a=>a.subjectLabel||a.subject))],r=o.length>0,i=r?`covered by ${o.length} test module(s):
10
10
  ${nt(o,gd,`
11
11
  `)}`:"no covering tests recorded (no test module imports it).";return n===t.id?`${s}: ${i}`:`${t.label} is defined in ${s}, which ${r?"is":"has"} ${i}
12
12
  ${Ow}`}function wd(e){let t=new Set,n=new Set;for(let o of Se(e,"tests"))t.add(o.object),n.add(o.subject);let s=e.individuals.filter(o=>(o.class||"")==="Module"&&!n.has(o.id)&&!Ss(String(o.label).toLowerCase())&&!t.has(o.id)).map(o=>o.label).sort();return s.length?`${s.length} source module(s) with no covering test module:
13
13
  ${nt(s,gd,`
14
- `)}`:"every source module has at least one covering test module."}function yd(e,t){let n=mn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=Se(e,"touches").filter(r=>r.object===n).map(r=>r.subjectLabel||r.subject);return o.length?`${s}: touched by ${o.length} recent commit(s): ${nt(o,Mt)}`:`${s}: no commit history recorded (outside the git-log window or unmodified).`}function $d(e,t){if(vd.has(t.class)){let r=[...new Set(Se(e,"callsSymbol").filter(i=>i.object===t.id).map(i=>i.subjectLabel||i.subject))];return r.length?`${t.label} \u2014 called by ${r.length} symbol(s):
14
+ `)}`:"every source module has at least one covering test module."}function yd(e,t){let n=hn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=Se(e,"touches").filter(r=>r.object===n).map(r=>r.subjectLabel||r.subject);return o.length?`${s}: touched by ${o.length} recent commit(s): ${nt(o,Mt)}`:`${s}: no commit history recorded (outside the git-log window or unmodified).`}function $d(e,t){if(vd.has(t.class)){let r=[...new Set(Se(e,"callsSymbol").filter(i=>i.object===t.id).map(i=>i.subjectLabel||i.subject))];return r.length?`${t.label} \u2014 called by ${r.length} symbol(s):
15
15
  ${nt(r,Go,`
16
- `)}`:`${t.label}: no recorded callers (fine-grained call edges are conservative \u2014 absence is not proof). Try tmct_impact for the full reverse closure.`}let n=mn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=[...new Set(Se(e,"calls").filter(r=>r.object===n).map(r=>r.subjectLabel||r.subject))];return o.length?`${s} \u2014 called by ${o.length} module(s):
16
+ `)}`:`${t.label}: no recorded callers (fine-grained call edges are conservative \u2014 absence is not proof). Try tmct_impact for the full reverse closure.`}let n=hn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=[...new Set(Se(e,"calls").filter(r=>r.object===n).map(r=>r.subjectLabel||r.subject))];return o.length?`${s} \u2014 called by ${o.length} module(s):
17
17
  ${nt(o,Go,`
18
18
  `)}`:`${s}: no recorded callers (calls are coarse/import-backed \u2014 absence is not proof). Try tmct_impact for the full reverse closure.`}function xd(e,t){if(vd.has(t.class)){let r=[...new Set(Se(e,"callsSymbol").filter(i=>i.subject===t.id).map(i=>i.objectLabel||i.object))];return r.length?`${t.label} \u2014 calls into ${r.length} symbol(s):
19
19
  ${nt(r,Go,`
20
- `)}`:`${t.label}: no recorded callees (calls only stdlib/external, or fine-grained call edges are not in the extracted graph).`}let n=mn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=[...new Set(Se(e,"calls").filter(r=>r.subject===n).map(r=>r.objectLabel||r.object))];return o.length?`${s} \u2014 calls into ${o.length} module(s):
20
+ `)}`:`${t.label}: no recorded callees (calls only stdlib/external, or fine-grained call edges are not in the extracted graph).`}let n=hn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=[...new Set(Se(e,"calls").filter(r=>r.subject===n).map(r=>r.objectLabel||r.object))];return o.length?`${s} \u2014 calls into ${o.length} module(s):
21
21
  ${nt(o,Go,`
22
22
  `)}`:`${s}: no recorded callees.`}function kd(e,t){let n=e.byId.get(t.object),s=n?$t(n):null;return`${t.objectLabel||n?.label||t.object}${s?` [${s.path}:${s.start}]`:""}`}function Ta(e,t){if(!t?.id)return"";let n=Se(e,"callsSymbol").filter(s=>s.subject===t.id);return n.length?`calls in-repo: ${nt(n.map(s=>kd(e,s)),Lw)}`:""}function Sd(e,t){let n=Se(e,"callsSymbol").filter(o=>o.subject===t.id);if(!n.length)return`${t.label} \u2014 ${In(t.class)}: no in-repo calls recorded (calls only stdlib/external, or fine-grained call edges are not in the extracted graph).`;let s=n.map(o=>kd(e,o));return`${t.label} \u2014 ${In(t.class)} calls ${n.length} in-repo symbol(s):
23
23
  ${nt(s,Go,`
24
- `)}`}function Ed(e,t,n){let s=e.byId.get(t),o=s?.label||n||t,r=Me(s,"commitDate")||Me(s,"date"),i=Me(s,"commitAuthor")||Me(s,"author"),a=Me(s,"commitMessage")||Me(s,"message"),l=[o,r,i].filter(Boolean).join(" ");return a?`${l} \u2014 ${a}`:l}function jd(e,t){let n=mn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=Se(e,"touches").filter(a=>a.object===n);if(!o.length)return`${s}: no commit history recorded (outside the git-log window or unmodified).`;let r=o.slice(0,Mt).map(a=>` ${Ed(e,a.subject,a.subjectLabel)}`),i=o.length>Mt?`
24
+ `)}`}function Ed(e,t,n){let s=e.byId.get(t),o=s?.label||n||t,r=Me(s,"commitDate")||Me(s,"date"),i=Me(s,"commitAuthor")||Me(s,"author"),a=Me(s,"commitMessage")||Me(s,"message"),l=[o,r,i].filter(Boolean).join(" ");return a?`${l} \u2014 ${a}`:l}function jd(e,t){let n=hn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=Se(e,"touches").filter(a=>a.object===n);if(!o.length)return`${s}: no commit history recorded (outside the git-log window or unmodified).`;let r=o.slice(0,Mt).map(a=>` ${Ed(e,a.subject,a.subjectLabel)}`),i=o.length>Mt?`
25
25
  \u2026+${o.length-Mt} more`:"";return`${s}: touched by ${o.length} recent commit(s):
26
26
  ${r.join(`
27
27
  `)}${i}`}function _d(e,t){let n=Se(e,"touchesSymbol").filter(r=>r.object===t.id);if(!n.length)return`${t.label} \u2014 ${In(t.class)}: no symbol-level commit history recorded (outside the git-log window, or fine-grained history is not in the extracted graph).`;let s=n.slice(0,Mt).map(r=>` ${Ed(e,r.subject,r.subjectLabel)}`),o=n.length>Mt?`
28
28
  \u2026+${n.length-Mt} more`:"";return`${t.label} \u2014 ${In(t.class)}: touched by ${n.length} commit(s):
29
29
  ${s.join(`
30
30
  `)}${o}`}function Rd(e,t){return _d(e,t)}function Ad(e,t){return _d(e,t)}function Ca(e,t,{kind:n,decFilter:s="",nameRe:o=null}={}){let r=Td[n];if(!r)return[];let i=[];for(let a of e.individuals){if((a.class||"")!==r||o&&!o.test(a.label)||s&&!to(a).toLowerCase().includes(s))continue;let l=String(a.label).toLowerCase(),c=t.length?0:1;for(let u of t)l.includes(u)&&(c+=5);t.length&&!c||i.push({ind:a,score:c})}return i.sort((a,l)=>l.score-a.score||String(a.ind.label).length-String(l.ind.label).length),i}function Nw(e,t,{limit:n=Ur,kind:s,decFilter:o,nameRe:r}){if(!Td[s])return`unknown kind "${s}" (use function, class, method, attribute, or module).`;let a=Ca(e,t,{kind:s,decFilter:o,nameRe:r});if(!a.length)return`no ${s} matches the given filters.`;let l=a.slice(0,n),c=[`${a.length} ${s}(s) match (top ${l.length}):`];for(let{ind:u}of l)c.push(`- ${u.label}${Aa($t(u))}`);return c.push("Then tmct_snippet <name> for the exact body, or tmct_describe for its edges."),c.join(`
31
- `)}function Gw(e){return{paramCount:Gr(e?.params),hasReturns:!!e?.returns,hasRaises:!!e?.raises,callees:e?.callees instanceof Set?e.callees:new Set}}function Vw(e){if(!e.length)return{paramCount:0,hasReturns:!1,hasRaises:!1,callees:new Set};let t=e.map(i=>Gr(i.params)),n=e.filter(i=>!!i.returns).length,s=e.filter(i=>!!i.raises).length,o=new Map;for(let i of e)for(let a of i.callees||[])o.set(a,(o.get(a)||0)+1);let r=new Set([...o.entries()].filter(([,i])=>i>=2).map(([i])=>i));return{paramCount:qw(t),hasReturns:n*2>=e.length,hasRaises:s*2>=e.length,callees:r}}function Hw(e,t){if(!t)return 0;let n=Math.max(0,4-Math.abs(Gr(e.params)-t.paramCount));!!e.returns===t.hasReturns&&(n+=2),!!e.raises===t.hasRaises&&(n+=2);let s=[...e.callees||[]].filter(o=>t.callees.has(o)).length;return n+Math.min(s,4)*2}function Kw(e,{decorators:t="",label:n="",site:s=null}={},o=null){let r=new Map;for(let m of e)for(let p of ka(m.decorators))r.set(p,(r.get(p)||0)+1);let i="",a=1;for(let[m,p]of r)p>a&&(a=p,i=m);let l=new Set(ka(t)),c=l.size?l:new Set(i?[i]:[]),u=new Set(ed(n)),d=s?.start??null;for(let m of e){let p=ka(m.decorators).some(b=>c.has(b))?1:0,f=ed(m.label).filter(b=>u.has(b)).length,g=Hw(m,o),h=d!=null&&m.site?1/(1+Math.abs(m.site.start-d)):0;m._score=p*1e3+f*50+g+h}return[...e].sort((m,p)=>p._score-m._score||(m.site?.start||0)-(p.site?.start||0))}function so(e,t){let n=mn(e,t),s=e.byId.get(n)?.label||String(n||"").replace(/^mod:/,""),o=Se(e,"defines").filter(S=>S.subject===n),r=new Map;for(let S of Se(e,"callsSymbol"))r.has(S.subject)||r.set(S.subject,new Set),r.get(S.subject).add(S.object);let i=[],a=[],l=0;for(let S of o){let A=e.byId.get(S.object);if(!A)continue;let M=A.class||"",T=$t(A);M==="GlobalVariable"?(a.push({label:A.label,value:(A.attributes||[]).find(P=>P.key==="value")?.value||"",site:T}),T&&(l=Math.max(l,T.end))):(M==="Function"||M==="Class")&&(i.push({id:A.id,label:A.label,class:M,site:T,decorators:to(A),raises:Me(A,"raises"),doc:Me(A,"doc"),params:Me(A,"params"),returns:Me(A,"returns"),callees:r.get(A.id)||new Set}),T&&(l=Math.max(l,T.end)))}let c=$t(t),u=c&&(t.class||"")!=="Module"?{id:t.id,label:t.label,class:t.class||"",site:c,decorators:to(t),raises:Me(t,"raises"),params:Me(t,"params"),returns:Me(t,"returns"),callees:r.get(t.id)||new Set}:null,d=i.length,m=u?Gw(u):Vw(i);i=Kw(i,u||{label:t.label},m);let p=u?null:i.find(S=>S.site&&S.label!==t.label)||null,f=[...new Set(Se(e,"tests").filter(S=>S.object===n).map(S=>S.subjectLabel||S.subject))].slice(0,Dw),g=Ld(e,n).slice(0,Fw),h=Se(e,"reexports").filter(S=>S.subject===n).map(S=>S.objectLabel||S.object).slice(0,20),b=Me(e.byId.get(n),"all"),w=Se(e,"contains"),v=null;(t.class||"")==="Class"?v=t.id:(t.class||"")==="Method"&&(v=w.find(S=>S.object===t.id)?.subject||null);let $=null;if(v){let S=e.byId.get(v),A=w.filter(M=>M.subject===v).map(M=>{let T=e.byId.get(M.object);return{label:M.objectLabel||T?.label||M.object,class:T?.class||"",site:T?$t(T):null,decorators:T?to(T):"",params:T?Me(T,"params"):"",returns:T?Me(T,"returns"):"",raises:T?Me(T,"raises"):""}}).slice(0,Pw);$={className:S?.label||String(v).replace(/^fn:.*#/,""),members:A,total:w.filter(M=>M.subject===v).length}}let k=null;for(let S of[...i,...a])S.site&&(!k||S.site.start>k.start)&&(k=S.site);let y=k?{start:k.start,end:k.end}:null,j=u||p,E=j?.id?e.byId.get(j.id):null,_=E?Ta(e,E):"",R=[];if(j?.callees)for(let S of j.callees){let A=e.byId.get(S),M=A?$t(A):null;if(M&&R.push({label:A.label,site:M}),R.length>=Ww)break}return{modId:n,moduleLabel:s,anchor:u,siblings:i,totalSiblings:d,exemplar:p,globals:a,tests:f,cochange:g,exports:h,allExports:b,classMembers:$,insertion:l,insertionRegion:y,calleeBodies:R,callHint:_,siblingCap:Mw}}function js(e){let t={anchor:!0,exemplar:!0,registration:!0,insertionRegion:!0,allExports:!0,classMembers:!0,siblings:!0,reexports:!0,tests:!0,cochange:!0,inlinedCallees:!1};return e==="TINY"?{...t,classMembers:!1,siblings:!1,reexports:!1,tests:!1,cochange:!1}:e==="LARGE"||e==="FULL"?{...t,inlinedCallees:!0}:t}function Cd(e){return{...e,anchor:!1,exemplar:!1,inlinedCallees:!1,classMembers:!1,reexports:!1,tests:!1,cochange:!1,registration:!0,siblings:!0,insertionRegion:!0,allExports:!0}}function Vr(e,t,{untuned:n=!1}={}){let s=e.anchor||e.exemplar,o="TINY";if(e.anchor&&e.anchor.site||e.exemplar&&e.exemplar.site||(o="MID"),e.classMembers&&e.classMembers.members&&e.classMembers.members.length&&(o="MID"),s){let i=s.site?s.site.end-s.site.start+1:1/0,a=Gr(s.params);(i>zw||a>Bw||s.raises)&&(o="MID");let l=!1;if(e.anchor)for(let u of s.callees||[]){let d=t.byId.get(u),m=d?$t(d):null;if(m&&m.path!==e.moduleLabel){l=!0;break}}let c=(e.anchor?.class||"")==="Method"&&Number(e.classMembers?.total||e.classMembers?.members?.length||0)>=Uw;(l||c)&&(o="LARGE")}else o="MID";return{tier:o,mask:js(o),topup:o!=="TINY"}}function Id(e){let t=[`Additional context for ${e.moduleLabel} (sections omitted from the lean bundle):`];if(e.classMembers&&e.classMembers.members.length){t.push(`
31
+ `)}function Gw(e){return{paramCount:Gr(e?.params),hasReturns:!!e?.returns,hasRaises:!!e?.raises,callees:e?.callees instanceof Set?e.callees:new Set}}function Vw(e){if(!e.length)return{paramCount:0,hasReturns:!1,hasRaises:!1,callees:new Set};let t=e.map(i=>Gr(i.params)),n=e.filter(i=>!!i.returns).length,s=e.filter(i=>!!i.raises).length,o=new Map;for(let i of e)for(let a of i.callees||[])o.set(a,(o.get(a)||0)+1);let r=new Set([...o.entries()].filter(([,i])=>i>=2).map(([i])=>i));return{paramCount:qw(t),hasReturns:n*2>=e.length,hasRaises:s*2>=e.length,callees:r}}function Hw(e,t){if(!t)return 0;let n=Math.max(0,4-Math.abs(Gr(e.params)-t.paramCount));!!e.returns===t.hasReturns&&(n+=2),!!e.raises===t.hasRaises&&(n+=2);let s=[...e.callees||[]].filter(o=>t.callees.has(o)).length;return n+Math.min(s,4)*2}function Kw(e,{decorators:t="",label:n="",site:s=null}={},o=null){let r=new Map;for(let m of e)for(let p of ka(m.decorators))r.set(p,(r.get(p)||0)+1);let i="",a=1;for(let[m,p]of r)p>a&&(a=p,i=m);let l=new Set(ka(t)),c=l.size?l:new Set(i?[i]:[]),u=new Set(ed(n)),d=s?.start??null;for(let m of e){let p=ka(m.decorators).some(b=>c.has(b))?1:0,f=ed(m.label).filter(b=>u.has(b)).length,g=Hw(m,o),h=d!=null&&m.site?1/(1+Math.abs(m.site.start-d)):0;m._score=p*1e3+f*50+g+h}return[...e].sort((m,p)=>p._score-m._score||(m.site?.start||0)-(p.site?.start||0))}function so(e,t){let n=hn(e,t),s=e.byId.get(n)?.label||String(n||"").replace(/^mod:/,""),o=Se(e,"defines").filter(S=>S.subject===n),r=new Map;for(let S of Se(e,"callsSymbol"))r.has(S.subject)||r.set(S.subject,new Set),r.get(S.subject).add(S.object);let i=[],a=[],l=0;for(let S of o){let A=e.byId.get(S.object);if(!A)continue;let M=A.class||"",T=$t(A);M==="GlobalVariable"?(a.push({label:A.label,value:(A.attributes||[]).find(P=>P.key==="value")?.value||"",site:T}),T&&(l=Math.max(l,T.end))):(M==="Function"||M==="Class")&&(i.push({id:A.id,label:A.label,class:M,site:T,decorators:to(A),raises:Me(A,"raises"),doc:Me(A,"doc"),params:Me(A,"params"),returns:Me(A,"returns"),callees:r.get(A.id)||new Set}),T&&(l=Math.max(l,T.end)))}let c=$t(t),u=c&&(t.class||"")!=="Module"?{id:t.id,label:t.label,class:t.class||"",site:c,decorators:to(t),raises:Me(t,"raises"),params:Me(t,"params"),returns:Me(t,"returns"),callees:r.get(t.id)||new Set}:null,d=i.length,m=u?Gw(u):Vw(i);i=Kw(i,u||{label:t.label},m);let p=u?null:i.find(S=>S.site&&S.label!==t.label)||null,f=[...new Set(Se(e,"tests").filter(S=>S.object===n).map(S=>S.subjectLabel||S.subject))].slice(0,Dw),g=Ld(e,n).slice(0,Fw),h=Se(e,"reexports").filter(S=>S.subject===n).map(S=>S.objectLabel||S.object).slice(0,20),b=Me(e.byId.get(n),"all"),w=Se(e,"contains"),v=null;(t.class||"")==="Class"?v=t.id:(t.class||"")==="Method"&&(v=w.find(S=>S.object===t.id)?.subject||null);let $=null;if(v){let S=e.byId.get(v),A=w.filter(M=>M.subject===v).map(M=>{let T=e.byId.get(M.object);return{label:M.objectLabel||T?.label||M.object,class:T?.class||"",site:T?$t(T):null,decorators:T?to(T):"",params:T?Me(T,"params"):"",returns:T?Me(T,"returns"):"",raises:T?Me(T,"raises"):""}}).slice(0,Pw);$={className:S?.label||String(v).replace(/^fn:.*#/,""),members:A,total:w.filter(M=>M.subject===v).length}}let k=null;for(let S of[...i,...a])S.site&&(!k||S.site.start>k.start)&&(k=S.site);let y=k?{start:k.start,end:k.end}:null,j=u||p,E=j?.id?e.byId.get(j.id):null,_=E?Ta(e,E):"",R=[];if(j?.callees)for(let S of j.callees){let A=e.byId.get(S),M=A?$t(A):null;if(M&&R.push({label:A.label,site:M}),R.length>=Ww)break}return{modId:n,moduleLabel:s,anchor:u,siblings:i,totalSiblings:d,exemplar:p,globals:a,tests:f,cochange:g,exports:h,allExports:b,classMembers:$,insertion:l,insertionRegion:y,calleeBodies:R,callHint:_,siblingCap:Mw}}function js(e){let t={anchor:!0,exemplar:!0,registration:!0,insertionRegion:!0,allExports:!0,classMembers:!0,siblings:!0,reexports:!0,tests:!0,cochange:!0,inlinedCallees:!1};return e==="TINY"?{...t,classMembers:!1,siblings:!1,reexports:!1,tests:!1,cochange:!1}:e==="LARGE"||e==="FULL"?{...t,inlinedCallees:!0}:t}function Cd(e){return{...e,anchor:!1,exemplar:!1,inlinedCallees:!1,classMembers:!1,reexports:!1,tests:!1,cochange:!1,registration:!0,siblings:!0,insertionRegion:!0,allExports:!0}}function Vr(e,t,{untuned:n=!1}={}){let s=e.anchor||e.exemplar,o="TINY";if(e.anchor&&e.anchor.site||e.exemplar&&e.exemplar.site||(o="MID"),e.classMembers&&e.classMembers.members&&e.classMembers.members.length&&(o="MID"),s){let i=s.site?s.site.end-s.site.start+1:1/0,a=Gr(s.params);(i>zw||a>Bw||s.raises)&&(o="MID");let l=!1;if(e.anchor)for(let u of s.callees||[]){let d=t.byId.get(u),m=d?$t(d):null;if(m&&m.path!==e.moduleLabel){l=!0;break}}let c=(e.anchor?.class||"")==="Method"&&Number(e.classMembers?.total||e.classMembers?.members?.length||0)>=Uw;(l||c)&&(o="LARGE")}else o="MID";return{tier:o,mask:js(o),topup:o!=="TINY"}}function Id(e){let t=[`Additional context for ${e.moduleLabel} (sections omitted from the lean bundle):`];if(e.classMembers&&e.classMembers.members.length){t.push(`
32
32
  ## members of ${e.classMembers.className}:`);for(let n of e.classMembers.members){let s=String(n.label).split(".").pop(),o=n.params!=null&&n.params!==""?`(${n.params})${n.returns?` -> ${n.returns}`:""}`:"",r=n.decorators?`@${n.decorators} `:"",i=n.raises?` raises=${n.raises}`:"";t.push(` ${n.class} ${s}${n.site?` :${n.site.start}`:""} ${r}${s}${o}${i}`)}}if(e.siblings.length){t.push(`
33
33
  ## sibling symbols (most relevant first; ${e.siblings.length} total):`);for(let n of e.siblings.slice(0,e.siblingCap)){let s=n.decorators?`@${n.decorators} `:"",o=n.raises?` raises=${n.raises}`:"";t.push(` ${n.class} ${n.label}${n.site?` :${n.site.start}`:""} ${s}${o}`)}e.siblings.length>e.siblingCap&&t.push(` \u2026+${e.siblings.length-e.siblingCap} more`)}return e.allExports&&t.push(`
34
34
  ## module __all__: ${e.allExports}`),e.exports&&e.exports.length&&t.push(`
@@ -45,27 +45,27 @@ ${s.join(`
45
45
  ## insert the new sibling after line ~${e.insertion} (end of the last top-level definition).`)),t.tests&&e.tests.length&&n.push(`
46
46
  ## covering tests: ${e.tests.join(", ")}`),t.cochange&&e.cochange&&e.cochange.length&&n.push(`
47
47
  ## usually changed together (consider editing these too): ${e.cochange.map(s=>`${s.label} (\xD7${s.weight})`).join(", ")}`),n.join(`
48
- `)}function Ld(e,t){let n=[];for(let s of Se(e,"cochange"))s.subject===t?n.push({label:s.objectLabel||s.object,weight:s.weight||0}):s.object===t&&n.push({label:s.subjectLabel||s.subject,weight:s.weight||0});return n.sort((s,o)=>o.weight-s.weight)}function Nd(e,t){let n=mn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=Ld(e,n);if(!o.length)return`${s}: no change-coupling recorded (rarely co-committed, or outside the git-log window).`;let r=o.slice(0,Sa).map(i=>`${i.label} (\xD7${i.weight})`);return`${s} \u2014 usually changes together with ${o.length} module(s) (edit these too):
48
+ `)}function Ld(e,t){let n=[];for(let s of Se(e,"cochange"))s.subject===t?n.push({label:s.objectLabel||s.object,weight:s.weight||0}):s.object===t&&n.push({label:s.subjectLabel||s.subject,weight:s.weight||0});return n.sort((s,o)=>o.weight-s.weight)}function Nd(e,t){let n=hn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=Ld(e,n);if(!o.length)return`${s}: no change-coupling recorded (rarely co-committed, or outside the git-log window).`;let r=o.slice(0,Sa).map(i=>`${i.label} (\xD7${i.weight})`);return`${s} \u2014 usually changes together with ${o.length} module(s) (edit these too):
49
49
  ${r.join(`
50
50
  `)}`+(o.length>Sa?`
51
- \u2026+${o.length-Sa} more`:"")}function Md(e,t){let n=mn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=Se(e,"reexports").filter(i=>i.subject===n);if(!o.length)return`${s}: no public exports recorded (no export list / __all__ found, or none resolved).`;let r=o.slice(0,Ea).map(i=>{let a=e.byId.get(i.object),l=a?$t(a):null,c=l?` \u2190 ${l.path}`:"";return`${i.objectLabel||i.object}${c}`});return`${s} \u2014 public API (${o.length} export(s)):
51
+ \u2026+${o.length-Sa} more`:"")}function Md(e,t){let n=hn(e,t);if(!n)return`cannot map ${t.label} to a module.`;let s=e.byId.get(n)?.label||n,o=Se(e,"reexports").filter(i=>i.subject===n);if(!o.length)return`${s}: no public exports recorded (no export list / __all__ found, or none resolved).`;let r=o.slice(0,Ea).map(i=>{let a=e.byId.get(i.object),l=a?$t(a):null,c=l?` \u2190 ${l.path}`:"";return`${i.objectLabel||i.object}${c}`});return`${s} \u2014 public API (${o.length} export(s)):
52
52
  ${r.join(`
53
53
  `)}`+(o.length>Ea?`
54
- \u2026+${o.length-Ea} more`:"")}var Uu,td,Gu,Ub,qb,xa,Gb,Ur,Vb,Hb,Kb,od,Yb,Xb,Jb,Qb,Zb,ew,tw,nw,sw,ow,rw,iw,aw,cw,lw,uw,dw,pw,fw,mw,hw,gw,bw,ww,yw,Vu,vw,$w,rd,id,ad,xw,kw,Sw,Ew,jw,Ku,Yu,Aw,Xu,zr,Ju,Qu,Zu,Go,Me,Cw,Iw,gd,Ow,Mt,vd,Lw,Td,Mw,Pw,Fw,Dw,zw,Bw,Uw,Ww,ka,ed,Gr,qw,Sa,Ea,Ce=L(()=>{Yn();ks();ba();qo();Es();Uu={"mgx:importsnamespace":"imports","mgx:callscoarse":"calls","seon:declaresmethod":"defines","mgx:testscoverage":"tests","mgx:touchedbycommit":"touches","seon:containscodeentity":"contains","seon:hassupertype":"inherits","mgx:changecoupledwith":"cochange","mgx:reexports":"reexports","mgx:touchessymbol":"touchesSymbol","mgx:callssymbol":"callsSymbol","seon:usescomplextype":"imports","seon:invokesmethod":"calls","seon:history":"touches","mgx:subclassof":"inherits","mg:imports":"imports","mg:calls":"calls","mg:defines":"defines","mg:tests":"tests","mg:touches":"touches","mgx:saidinsession":"saidInSession","mgx:inreplyto":"inReplyTo","mgx:statedby":"statedBy","mgx:canonicalisedfrom":"canonicalisedFrom"};td=e=>/^(git|turn):/.test(String(e||""));Gu=30,Ub=8;qb=2,xa=25,Gb=3;Ur=10,Vb=8,Hb=3,Kb=2,od=5,Yb=4,Xb=.2,Jb=.35,Qb=.15,Zb=e=>/(^|\/)(examples?|fixtures?|samples?|demos?|benchmarks?|test-[^/]+)(\/|$)/.test(e),ew=.2,tw=.35,nw=.2,sw=.35,ow=e=>/\.cs$/i.test(e),rw=e=>/^I[A-Z]/.test(String(e||"")),iw=.2,aw=.35,cw=50,lw=.2,uw=.35,dw=.5,pw=od,fw=3,mw=4,hw=1,gw=.9,bw=.5,ww=.2,yw=.35,Vu=4,vw=2,$w=[["imports"],["calls","callsSymbol"],["inherits"],["cochange"]],rd=3,id=12,ad=.9,xw=["imports","calls","callsSymbol","inherits"],kw=.5,Sw=.6,Ew=.2,jw=.35;Ku=128,Yu=4,Aw=64,Xu=250,zr=class extends Error{};Ju=new WeakMap;Qu=40,Zu=40,Go=30;Me=(e,t)=>(e?.attributes||[]).find(n=>n.key===t)?.value||"";Cw=25,Iw=15;gd=40,Ow="tests edges are recorded module to module, so this is module-grain coverage.";Mt=15;vd=new Set(["Function","Method"]);Lw=8;Td={function:"Function",class:"Class",method:"Method",attribute:"Attribute"};Mw=8,Pw=16,Fw=4,Dw=6,zw=12,Bw=2,Uw=8,Ww=3,ka=e=>String(e||"").split(",").map(t=>t.trim()).filter(Boolean),ed=e=>String(e||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean),Gr=e=>{let t=String(e||"").trim();return t?t.split(",").map(n=>n.trim()).filter(Boolean).length:0},qw=e=>{let t=new Map,n=e[0]??0,s=0;for(let o of e){let r=(t.get(o)||0)+1;t.set(o,r),r>s&&(s=r,n=o)}return n};Sa=20;Ea=40});function He(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wd(e){let t=String(e||"");return Pd&&(t=t.replace(Pd," ")),t.replace(/\s+/g," ").trim()}function qd(e){let t=String(e||"");t=t.replace(dy," ").replace(/\s+/g," ").trim();for(let n=0;n<3;n++){let s=t,o=t.match(cy);if(o&&(t=o[1].trim()),o=t.match(ly),o&&(t=o[1].trim()),o=t.match(Fd),o&&(t=o[1].trim()),o=t.match(Dd),o&&(t=o[1].trim()),o=t.match(zd),o&&(t=o[1].trim()),o=t.match(uy),o&&(t=o[1].trim()),o=t.match(Bd),o&&(t=o[1].trim()),o=t.match(py),o&&(t=o[1].trim()),o=t.match(fy),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(my),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(hy),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(gy),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(by),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(wy),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(yy),o&&(t=`what ${o[2].toLowerCase()} ${o[1].trim()}`),o=t.match(vy),o&&(t=`what does ${o[1].trim()} mean`),o=t.match($y),o){let r=o[1].trim();ay(r)||(t=oy.test(r)||Xn.test(r)?r:`describe ${r}`)}if(o=t.match(xy),o){let r=o[1].trim();(Xn.test(r)||ky.test(r)||Bd.test(r)||Fd.test(r)||zd.test(r)||Dd.test(r))&&(t=r)}if(t===s)break}return t}function jy(e){let t=String(e||"");for(let n=0;n<3;n++){let s=t,o=t.match(Sy);if(o&&(t=o[1].trim()),o=t.match(Ey),o&&(t=o[1].trim()),t===s)break}return t}function Ry(e){let t=String(e||"");for(let n=0;n<3;n++){let s=t.match(_y);if(!s)break;let o=s[1].trim();if(!o||o===t)break;t=o}return t}function Cy(e){let t=String(e||""),n=t.match(Ty);if(n){let o=Vd[n[1].toLowerCase()],r=Gd[n[2].toLowerCase()];return`${o} ${r} ${n[3].trim()} and ${n[4].toLowerCase()}`}let s=t.match(Hd);return s?`which modules transitively import ${s[1].trim()}`:t}function Hr(e){return String(e||"").replace(Xw,t=>ca[t.toLowerCase()])}function _s(e){let t=Hr(e);return t=t.replace(Jw,n=>la[n.toLowerCase()]),t=t.replace(Qw,n=>ua[n.toLowerCase()]),t=t.replace(Zw,"with"),t=t.replace(ey,(n,s)=>`${s} for`),t=t.replace(ty,(n,s)=>`for ${s}`),t=t.replace(ny,(n,s)=>s),t=t.replace(Iy,"$1$2"),t=t.replace(wu,"$1ing"),t=qd(t),t=Ry(t),t=jy(t),t=Cy(t),t=Wd(t),t=Xt(t),t=t.replace(/\?{2,}\s*$/,"?"),t.replace(/\s+/g," ").trim()}function Vo(e){for(let t of[...vu,...yu]){let n=e.match(t.re);if(n)return t.to(n).replace(/\s+/g," ").trim()}return e}function Ia(e){for(let t of Oy){let n=e.match(t.re);if(n)return t.to(n).replace(/\s+/g," ").trim()}return e}function Kd(e){let t=String(e||"").match(Ly);if(!t)return null;let n=t[1].toLowerCase(),s=t[2].trim();return s?{entWord:n,predicate:s}:null}var Yw,Xw,Ud,Jw,Qw,Zw,ey,ty,ny,sy,Pd,oy,Xn,ry,iy,ay,cy,ly,Fd,Dd,zd,uy,dy,py,fy,my,hy,gy,by,wy,yy,vy,$y,xy,ky,Bd,Sy,Ey,_y,Gd,Vd,Ay,Ty,Hd,Iy,Oy,Ly,st,Qt,me,Jn=L(()=>{An();Yw=e=>new RegExp("\\b("+Object.keys(e).sort((t,n)=>n.length-t.length).map(He).join("|")+")\\b","gi"),Xw=Yw(ca),Ud=e=>new RegExp("\\b("+Object.keys(e).sort((t,n)=>n.length-t.length).map(He).join("|")+")\\b(?!\\.[a-z0-9])","gi"),Jw=Ud(la),Qw=Ud(ua),Zw=/(?<=^|\s)w\/(?=\s|$)/gi,ey=/\b(thx|thanks|thank\s+you|many\s+thanks|ty|cheers)\s+4\b/gi,ty=/\b4\s+(example|instance)\b(?!\s*[a-z])/gi,ny=/\b(this|that)\s+(class|module|function|method|attribute|variable|file|commit)\b/gi,sy=Object.keys(de).sort((e,t)=>t.length-e.length).map(He).join("|"),Pd=Fo.length?new RegExp("\\b("+[...Fo].sort((e,t)=>t.length-e.length).map(He).join("|")+")\\b\\s*,?","gi"):null;oy=new RegExp("\\b(?:"+Object.keys(de).sort((e,t)=>t.length-e.length).map(He).join("|")+")\\b","i"),Xn=/^(?:which|what|who|whose|where|when|why|how)\b/i,ry=new Set(["modules","files","packages","functions","methods","classes","attributes","fields","properties","variables","globals","commits","changes","tests","members"]),iy=/^(?:all\s+|the\s+)?(?:module|file|package|function|method|class|attribute|field|property|variable|global|commit|change|test|member)\??$/i,ay=e=>{if(iy.test(e))return!0;let t=e.replace(/\?+\s*$/,"").trim().split(/\s+/);return ry.has((t[t.length-1]||"").toLowerCase())},cy=/^(?:hi|hiya|hello|hey|yo|howdy|g'?day|yeah\s+nah|good\s+(?:morning|afternoon|evening|day)|greetings|salutations)(?:\s+(?:there|pardner|folks|friend|mate))?\s*[,.—–-]\s*(?:(?:just\s+a\s+)?quick\s+question\s*[,:—–-]?\s*)?(.+)$/i,ly=/^(?:thanks|thank\s+you|many\s+thanks|thx|ty|cheers)(?:\s+(?:so\s+much|a\s+lot|very\s+much|a\s+bunch))?\s*[,—–-]\s*(?:(?:just\s+a\s+)?quick\s+question\s*[,:—–-]?\s*)?(.+)$/i,Fd=/^(?:(?:ok(?:ay)?|aight|cool|alright|sure|right|fine|great|nice|got it|gotcha|sounds good|no worries|no problem|(?:just\s+)?(?:one|another)\s+more|another\s+one)[\s,]+)+(.+)$/i,Dd=/^(?:just\s+(?:poking\s+around|looking\s+around|browsing|exploring|checking\s+(?:this|it)\s+out)|first\s+time\s+(?:trying\s+this\s+out|using\s+this|here)|i'?m\s+new\s+(?:here|around\s+here|to\s+(?:this|all\s+this)(?:\s+(?:repo|codebase|project|app|tool|thing))?))\s*[,.—–-]\s*(.+)$/i,zd=/^(?:(?:maybe|possibly|perhaps)\s+)+(.+)$/i,uy=/^(?:please[\s,]+)+(.+)$/i,dy=/,?\s*if\s+(?:it'?s|it\s+is|that'?s|that\s+is)\s+not\s+too\s+much\s+(?:trouble|bother|hassle)\s*,?\s*/i,py=/^(?:can|could|would|will)\s+you\s+(?:please\s+)?(.+?)(?:[,\s]+please)?\??$/i,fy=/^explain\s+(?:to\s+me\s+|please\s+)*(.+?)\??$/i,my=/^tell\s+me\s+(?:please\s+)?(.+?)\??$/i,hy=/^(?:(?:would|do)\s+you\s+)?mind\s+telling\s+(?:me|us)\s+(?:please\s+)?(.+?)\??$/i,gy=/^do\s+you\s+know\s+(.+?)\??$/i,by=/^i(?:'d|\s+would)?\s+(?:(?:like|want|need)\s+to|wanna)\s+know\s+(.+?)\??$/i,wy=/^i(?:\s+was|\s+am|'m)?\s+(?:just\s+)?(?:wonder(?:ing|ed)?|curious)(?:\s+(?:if|whether|about))?\s+(.+?)\??$/i,yy=/^what\s+((?:an?\s+|the\s+)?[\w'-]+(?:\s+[\w'-]+){0,2})\s+(is|are)\??$/i,vy=/^what\s+((?:an?\s+|the\s+)?[\w'-]+(?:\s+[\w'-]+){0,2})\s+means\??$/i,$y=/^(?:show|give)\s+me\s+(?:the\s+)?(.+?)\??$/i,xy=/^(?:and|also|so|then|now|but)\s+(.+)$/i,ky=/^(?:does|do|did|is|are|was|were|has|have|had|can|could|will|would|should)\b/i,Bd=/^(?:(?:actually|no\s+wait|wait|hold\s+on|never\s+mind|scratch\s+that|on\s+second\s+thought|i\s+mean(?:t)?)[\s,.]+)+(.+)$/i;Sy=/^(?:since|although|(?:even\s+)?though|while|because|whereas|given\s+that|now\s+that)\s+.+?,\s*(.+)$/i,Ey=/^(.+?),\s*(?:since|although|(?:even\s+)?though|while|because|whereas|given\s+that|now\s+that)\s+.+$/i;_y=/^.+?(?:\s*(?:--|—|-)\s*)?\b(?:sorry|i\s+mean)\b\s*(?:--|—|-|,|:)\s*(.+)$/i;Gd=Object.freeze({imports:"importing",calls:"calling",touches:"touching",tests:"testing",exports:"exporting",contains:"containing",defines:"defining",uses:"using","inherits from":"inheriting from"}),Vd=Object.freeze({module:"modules",class:"classes",function:"functions",method:"methods",attribute:"attributes",variable:"variables",commit:"commits",file:"files"}),Ay="public|private|protected|static|abstract|constant|re-?exported|exported|tested|covered|untested|uncovered",Ty=new RegExp("^if\\s+(?:a|an|the)?\\s*("+Object.keys(Vd).join("|")+")\\s+("+Object.keys(Gd).join("|")+")\\s+(.+?),\\s*(?:is|are)\\s+(?:it|that|they|this)\\s+("+Ay+")\\??$","i"),Hd=/^if\s+(.+?)\s+(?:were|was)\s+(?:deleted|removed),?\s*what\s+(?:would|might|could)\s+(?:break|fail|be\s+affected)\??$/i;Iy=new RegExp(`^(where\\s+(?:is|are|was|were)\\s+.+?)\\s+(?:${hu.map(He).join("|")})(\\s*[?.!]*)$`,"i");Oy=Object.freeze([{re:/^what\s+(?:functions?|methods?|members?|attributes?|fields?|properties)\s+(?:are|is)\s+(?:in|inside|within)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+(?:functions?|methods?|members?|attributes?|fields?|properties)\s+(?:does|do)\s+(.+?)\s+have\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+are\s+(?:the\s+)?(?:functions?|methods?|members?|attributes?|fields?|properties)\s+(?:of|in|inside|within)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^(?:the\s+)?(?:members?|methods?|attributes?|contents)\s+of\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+is\s+(?:in|inside)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+else\s+is\s+(?:in|inside)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+(?:defined|declared)\s+(?:the\s+)?(?:function\s+|method\s+|class\s+|module\s+|variable\s+|constant\s+)?(.+?)\??$/i,to:e=>`where is ${e[1]} defined`},{re:/^where'?s\s+(?:the\s+)?(.+?)\s+(defined|declared|located|implemented)\??$/i,to:e=>`where is ${e[1]} ${e[2]}`},{re:/^were\s+is\s+(?:the\s+)?(.+?)\s+(defined|declared|located|implemented)\??$/i,to:e=>`where is ${e[1]} ${e[2]}`},{re:/^what\s+is\s+the\s+purpose\s+of\s+(?:the\s+)?(?!(?:an?|it|this|that|these|those)\s)(.+?)\??$/i,to:e=>`what is a ${e[1]}`},{re:new RegExp(`^what\\s+does\\s+(?:the\\s+)?(?!(?:an?|it|this|that|these|those)\\s)(.+?)\\s+do\\s+(?:${aa.map(He).join("|")})\\??$`,"i"),to:e=>`what is a ${e[1]}`},{re:/^(?:which|what)\s+(?:the\s+|all\s+)?([a-z][a-z-]*?)\s+(?:are|is)\s+(public|private|protected|static|abstract|constant|exported|re-?exported|tested|covered|untested|uncovered)\??$/i,to:e=>`${e[2].toLowerCase()} ${e[1].toLowerCase()}`},{re:/^what\s+(?:is|are)\s+(not\s+)?(tested|untested|covered|uncovered)\??$/i,to:e=>{let t=e[2].toLowerCase();return`${e[1]?t==="tested"?"untested":t==="covered"?"uncovered":t:t} modules`}},{re:/^what\s+does\s+(.+?)\s+changes?\s+together\s+with\??$/i,to:e=>`what co-changes with ${e[1]}`},{re:/^what\s+changes?\s+together\s+with\s+(.+?)\??$/i,to:e=>`what co-changes with ${e[1]}`},{re:/^how\s+many\s+commits\s+(?:are|were)\s+(?:recorded|logged)\s+(?:for|against)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`how many commits touched ${e[1]}`},{re:/^who\s+(?:wrote|authored)\s+(?:the\s+)?(?!(?:commit\s+)?[0-9a-f]{7,40}\??$)(.+?)\??$/i,to:e=>`who touched ${e[1]}`},{re:/^who\s+is\s+the\s+authors?\s+of\s+(?:the\s+)?(?!(?:commit\s+)?[0-9a-f]{7,40}\??$)(.+?)\??$/i,to:e=>`who touched ${e[1]}`},{re:/^(?:does|do)\s+(?!.*\bnot\b)(.+?)\s+have\s+(?:any\s+)?(?:tests?|test\s+coverage|coverage)\??$/i,to:e=>`what tests ${e[1]}`},{re:/^(?:is|are)\s+(?!.*\bnot\b)(.+?)\s+tested\??$/i,to:e=>`what tests ${e[1]}`},{re:/^what\s+needs\s+(?:to\s+be\s+)?(?:a\s+)?(?:tested|tests?|testing|coverage|covering)\??$/i,to:()=>"untested modules"},{re:/^(?:which|what|list|show(?:\s+me)?|find)?\s*(?:the\s+|all\s+)?([a-z][a-z-]*?)\s+(?:(?:that|which)\s+)?(?:have|has|having|with)\s+no\s+tests?\??$/i,to:e=>`untested ${e[1].toLowerCase()}`},{re:/^(?:which|what|list|show(?:\s+me)?|find)?\s*(?:the\s+|all\s+)?([a-z][a-z-]*?)\s+without\s+(?:any\s+)?tests?\??$/i,to:e=>`untested ${e[1].toLowerCase()}`},{re:new RegExp(`^(?:do|does)\\s+(.+?)\\s+(${sy})\\s+(?:anything|something)(?:\\s+else)?\\??$`,"i"),to:e=>`what does ${e[1]} ${e[2]}`}]);Ly=new RegExp("^(?:which|what|who|list|show(?:\\s+me)?|find|give\\s+me)?\\s*(?:the\\s+|all\\s+)?([a-z][a-z-]*)\\s+(?:(?:that|which|who)\\s+)?(?:(?:do|does|did|are|is|was|were|have|has|can|could|will|would|should)\\s+not|cannot|can't|won't|couldn't|shouldn't|wouldn't|not)\\s+(.+)$","i");st=new Set(["what","who","which","where","when","why","how","does","do","did","is","are","was","were","the","a","an","of","to","from","at","in","on","there","something","anything","nothing","one","any","anywhere","last","usually","typically","generally","normally","often","commonly","mostly","should","would","could","can","will","shall","might","must"]),Qt=e=>String(e).replace(/\?+\s*$/,"").replace(/,/g," ").split(/\s+/).filter(Boolean),me=e=>e.flatMap(t=>String(t).toLowerCase().split(" "))});var Xd,Yd=L(()=>{Xd={source:"corpus/wordnet/*.jsonl lemmas, expanded through the regular -s/-ed/-ing inflections",generator:"scripts/generate-real-word-collisions.mjs",targets:["alongside","build","builds","built","call","calling","calls","change","changed","changes","check","checks","class","co-change","co-changes","code","commits","contain","containing","contains","couple","couples","cover","covers","declare","declares","define","defined","defines","defining","depends","derive","derives","directly","edited","execute","executes","exercise","exercises","explicitly","export","exporting","exports","expose","exposes","extend","extending","extends","fire","fires","from","grab","grabs","have","hits","hold","holds","hooked","import","importing","imports","included","indirectly","inherit","inheriting","inherits","inside","into","invoke","invokes","kick","kicks","kind","land","landed","lean","leans","live","lives","make","makes","modified","modifies","move","moves","parent","part","pass","passes","pull","pulls","re-export","re-exports","reference","references","relies","rely","require","requires","runs","share","shares","sits","subclass","subclasses","subclassing","superclass","superclasses","sure","talk","talks","tend","tends","test","testing","tests","through","together","touch","touched","touches","touching","transitively","trigger","triggers","tweaked","updated","uses","using","usually","verifies","verify","went","were","wired","with"],words:["aalging","aasing","aave","ablies","abling","aboves","absing","abuses","abusing","acauling","achinged","acolds","acquire","acquires","acyling","adelies","adenine","adenined","adenines","adenining","aditted","aerides","aerified","aerifies","aerify","affine","affined","affines","affining","afire","afires","afling","agalling","ailing","aired","airied","airies","airport","airporting","airports","airsed","airses","airted","alaing","alases","albing","alecks","aleves","aliaes","alikes","alines","alive","alives","allaing","allies","alling","alls","allying","alongsided","alongsides","alping","alting","altogether","amasses","amazes","amends","amorting","amorts","amuses","amusing","analling","anded","anoded","ansing","anuses","apart","aparts","apises","apparent","appends","appose","apposes","apsing","apsises","arab","arabis","arabs","ardent","argent","arpent","arrive","arrives","arsing","asaing","asding","aseans","ases","ashing","ashore","ashores","asing","asking","asping","asring","asses","assess","assets","assing","assure","attending","attest","attesting","attests","audited","aufing","auging","auking","aurifies","aurify","avouch","avouched","avouches","avouching","awaked","awakes","awared","awares","awling","awried","axling","baases","badded","bailed","bailing","baited","bake","bakeds","bakers","bakes","balded","balding","baling","balk","balking","balks","ball","balling","balls","ballsing","ballying","balming","band","banded","bandeds","bandied","bandsed","banked","banned","barded","barelies","barely","barses","bart","baseses","bashes","basing","basises","bass","bassed","basses","basset","bassets","bassos","bastes","basting","batses","bauded","baulks","bawded","bawling","bbsing","beaked","bean","beanos","beans","beasting","beasts","beating","beeting","begild","begilds","behave","behold","beholds","belied","belief","beliefs","belies","belikes","belizes","belles","bellies","belling","belting","bend","bended","bends","bent","benting","besets","besots","besses","bessing","best","besting","bests","beting","betting","bevies","bhanged","biered","bigger","biggers","billing","bind","binded","birded","birled","birles","biroed","birred","bising","bjsing","bladed","blanced","bland","blanda","blandaed","blanded","blands","blanked","blares","blases","blasts","bleaked","bleaks","blears","bleats","blended","blends","blesting","blests","blinded","blinds","blited","blites","bloked","blonded","bmuses","bnsing","boched","boches","boching","bocked","bode","bodilied","bodilies","boiled","boileds","bokked","bold","bolds","bolling","bonded","boners","bonked","boobed","booked","bookeds","bookend","booker","bookied","booksed","boomed","booned","boored","booted","boozed","borers","borough","bosked","bosses","botched","botches","botching","boucheed","bouchees","boucle","boucled","boucling","boughed","boughing","boules","boulle","boulles","bouses","bousing","bowers","boxers","bpsing","bragger","braggers","brakes","branded","brasses","breaked","bricks","brigged","brills","broked","brooked","bruins","brunts","brunus","bses","bsing","bugled","bugles","buhled","builders","buildups","bull","bulled","bullet","bulling","bulls","buns","bunses","bunsing","buried","burieds","burled","burleds","buses","bushes","bushing","busied","busies","busking","bussing","busying","buyied","buying","bypass","bypasses","caballing","cabals","cabbing","cabers","cabged","cabging","cables","cablin","cabling","cablins","caching","cackling","cadded","cadding","cadent","cadged","cadges","cadging","cadring","cafers","caffing","cafing","cagers","caging","cagying","caining","cajoling","cake","cakes","cakiling","caking","calcine","calean","caleans","caleying","caleys","calf","calfing","calfs","califs","calkin","calking","calkins","callaing","callas","callers","callinged","callings","callous","callowing","callows","calluna","callus","calm","calming","calmings","calmlying","calms","calquing","calvaing","calvas","calves","calving","calvings","calx","calxes","calxing","calycling","calyxing","camass","camelling","camels","camming","camoing","camping","canaing","canalling","canals","candid","candied","candled","candling","cangue","cangued","cangues","caning","canning","canoes","canting","cantling","capers","caping","caplin","caplins","capoing","capping","captain","captaining","captains","carded","carding","caring","carking","carlina","carline","carling","carlings","carlos","carning","caroling","carolling","carols","carping","carring","cart","carting","carver","carvers","carving","casaing","cashes","cashing","casking","cassies","castes","castling","casually","casuses","caters","catling","catlings","catses","catsing","catting","cattling","caul","cauline","cauling","caulking","cauls","cavaing","cave","caverns","cavilling","cavils","caving","cavying","cawing","caying","ceases","cecalling","cede","cedied","ceiling","cell","celling","celloing","cellos","cells","cellsing","cent","centing","cercises","cere","cerise","cerises","certain","certaining","certains","certifies","certify","certing","cfling","cgsing","chadded","chafed","chaffed","chafinged","chagaed","chagas","chagga","chaggaed","chaggas","chained","chainsed","chainses","chaired","chaise","chaised","chaises","chaited","chaits","chajaed","chalked","chalking","challis","champed","chanal","chanals","chanar","chanars","chance","chanced","chancels","chances","chancied","chancies","chancre","chancred","chancres","chancy","changers","channels","chanted","chanters","chanteys","chantied","chanties","chanty","chaosed","chaoses","chapped","charded","chards","charge","charged","chargers","charges","charied","charmed","charms","charred","charrs","charted","charts","chased","chasmed","chasms","chassed","chaste","chasted","chastes","chatted","chaunaed","chaused","chauses","chawed","cheaps","cheats","checkeds","checkers","checksum","checkups","cheek","cheeks","cheeps","chelas","chenned","cheops","cherts","chesting","chewas","chianed","chick","chicks","chigger","chiggers","chiling","chilling","chills","chinaed","chined","chines","chinked","chinks","chinned","chinoed","chirks","chits","chives","choanaed","chock","chocked","chocks","choked","choker","chokers","choler","cholers","chonned","choosed","chords","chores","chough","chuaned","chuck","chucks","chugged","chunga","chungaed","chungas","chunked","chunks","chyling","cialis","cicers","ciders","circed","circes","cive","cives","civies","cladded","claded","clades","clading","clads","claims","clamps","clams","clamses","clanged","clangers","clanks","clans","claps","clarks","claros","clash","clashes","clasp","clasps","classed","classic","classy","clast","clasts","clausa","clausas","clause","clauses","claver","clavers","clavus","clawing","claws","claying","clays","clean","cleans","cleanse","clerks","clever","clevers","cliing","climes","clinged","cloaks","clocks","closer","closers","closes","cloved","cloven","clovens","clover","clovers","clucks","cluing","clving","clxing","cnsing","coached","coaches","coaching","coaling","coasts","coaxer","coaxers","cobber","cobbers","cobble","cobbles","cocain","cocaining","cocains","cocked","cocker","cockers","cockle","cockles","coda","codaed","codded","coddles","coded","coders","codes","codex","codgers","codified","codifies","codling","cods","coed","coeurs","coffer","coffers","coggle","coggles","coheres","coiling","coiner","coiners","coired","coke","colaing","cold","colded","colding","colds","cole","coleus","coliing","coling","colling","collins","collying","colors","coltan","coltanning","coltans","colter","colters","colting","comalling","combats","comber","combers","come","comer","comers","comfies","comfit","comfits","comics","comints","comity","commas","comments","commes","commie","commied","commies","comming","commit","commix","commixes","commons","commute","commutes","compel","compels","compile","compiles","complies","comply","comport","comporting","comports","conched","conches","conching","concluded","cone","coneys","confer","confers","confining","confits","conged","conger","congers","conges","conjoin","conjoining","conjoins","conked","conker","conkers","constrain","constraining","constrains","contact","contacting","contacts","contadinoing","contadinos","contagion","contagioning","contagions","containeds","containers","contemn","contemning","contemns","continuing","contrail","contrailing","contrails","contriting","contriving","converse","converso","converts","convex","convey","conveys","convoke","convokes","cooked","cookeds","cookers","cookied","cooled","cooler","coolers","cooling","cooned","cooped","cooper","coopers","cooted","cooter","cooters","copalling","cope","copeck","copecks","copier","copiers","copies","copper","coppers","copses","copula","copulas","coralling","corded","core","coreference","coreferences","corer","corers","corked","corker","corkers","corner","corners","corpse","corpses","corvee","corvees","cosecs","cosher","coshers","cosmics","cosmids","cosses","costing","cotanning","cotans","cote","cotter","cotters","couch","couched","couches","couching","coude","couded","coue","coughed","coughing","coupe","coupes","coupleds","couplers","couplets","coupon","coupons","course","courses","couthed","couthing","coved","coven","covens","covereds","coverts","covet","covets","covey","coveys","cower","cowers","cowling","cowpie","cowpies","cozens","cpsing","crab","crabs","cracks","cradling","cragged","crakes","craned","cranes","cranked","cranned","crass","crasses","crawling","crawls","creaked","creaks","credited","creeks","cresting","crests","criers","cringe","cringed","cringes","crocks","crooked","crouch","crouched","crouches","crouching","croupe","croupes","crumple","crumples","cruses","crusing","cses","csing","ctened","ctenes","cubing","cuking","culling","culming","culting","cupalling","cupels","cupsing","cupule","cupules","cure","curing","curling","curses","cursing","curtain","curtaining","curtains","cusking","cusping","cussing","cuting","cutlass","cutses","cutsing","cxling","cxlving","cyanned","cyanoed","cycling","cyders","cymling","cysting","dadded","dahling","dailing","daises","daling","dall","dalliing","dalling","dallis","dalls","dallying","daloing","danced","dander","dandied","dandled","danked","dansed","danses","darded","darling","dart","dashes","dassed","dassies","dative","datives","dayses","ddsing","deafened","deafening","deafing","deaing","dean","deaned","deaning","deans","dearie","dearies","debiled","debiling","debone","deboned","debones","deboning","debrises","debted","debting","decade","decades","decalling","decease","deceases","deceive","deceives","decents","decided","deciding","deciled","deciling","declaim","declaims","declareds","declarers","declaw","declined","declining","decode","decouple","decouples","decries","deepens","deface","defaced","defaces","defacing","defame","defamed","defames","defaming","defang","defanged","defanging","defangs","defence","defenced","defences","defencing","defended","defending","defends","defensed","defenses","defensing","deference","deferences","deferenses","defiance","defianced","defiances","defiancing","defiant","defianted","defianting","defiants","defied","defies","defile","defiled","defilers","defiles","defiling","defininged","definings","definited","definites","definiting","deflate","deflates","deftness","defuse","defused","defuses","defusing","deglaze","deglazes","deicing","deified","deifying","deigned","deigning","deisted","deisting","deists","deitied","delfing","deliing","delivers","delling","demands","demised","demising","denied","denned","denning","dent","dented","dentine","dentined","dentines","denting","dentining","depart","depend","depended","deplane","deplanes","deplore","deplores","depone","deponed","deponing","depose","deposes","deprave","depraves","deprive","depriveds","deprives","derate","derates","derbies","deride","derides","deriding","derisive","derisives","deriveds","deriving","dermises","derpies","derrises","descends","designed","designing","desired","desiring","desking","desponds","dessing","destined","destines","destining","destiny","detained","detaining","detents","detest","detesting","detests","detinue","detinued","detinues","detinuing","deuses","deusing","deveined","deveining","deviced","devicing","deviled","devised","devising","dewied","dewiness","dewing","dexone","dexoned","dexones","dexoning","dhalling","dholed","dholes","dick","dicks","dieted","digger","diggers","dilling","dining","dinted","dire","direct","directed","director","directory","directs","dired","dires","dirged","dirges","dirked","disport","disporting","disports","disses","ditaed","ditted","dive","dives","divest","divine","divined","divines","divining","dmuses","docked","doleds","dolling","domine","domined","domines","domining","doobed","doomed","doored","dopeds","dories","dorked","dosing","dosses","double","doubles","douched","douches","douching","doughed","doughing","douses","dousing","dove","doves","dowers","dozers","drab","drabas","drabs","dragger","draggers","drained","draining","drakes","dranged","drecks","drilies","drive","drivels","drivens","drivers","drives","drover","drovers","drunks","druses","drusing","drylies","dses","dsing","dsling","dtsing","ducing","duding","dudses","dudsing","duking","dulies","dull","dulling","dulls","dulses","dulsing","duning","duns","duoing","duping","duples","during","dusking","eagling","earling","earses","easies","easing","easted","easting","eating","eatses","ebitted","ebooked","ebsing","echted","eclats","ecting","eddaed","eddied","eddoed","edgied","edibled","edicted","editeds","editor","editted","edsing","edtaed","educed","eduled","eelses","eerilies","eerily","effort","efforting","efforts","efting","egesting","egests","eidoses","eiraed","elan","eland","elanded","elanned","elans","elanus","elated","elegans","elided","elinted","elited","elling","elocute","elocutes","elopses","elsing","eluted","elvers","emending","emiled","emitted","emoted","emotes","emsing","enated","encode","endived","ends","energise","energises","enquire","enquires","ensile","ensure","entendring","ententing","enting","epopses","eposes","equally","equine","equines","erectly","eroses","ersing","ersted","ersting","erting","erudited","escort","escorting","escorts","eses","esing","esports","esportsing","espouse","espouses","esquire","esquires","esting","ests","eternise","eternises","ethoses","evicted","evoked","evokes","exceed","exceeding","exceeds","exchange","exchanged","exchanges","excite","excited","excites","excluded","execrate","execrates","executeds","executive","executives","executors","exegete","exegetes","exercisers","exerciseses","exerting","exerts","exhort","exhorting","exhorts","exiled","existed","exitted","exodes","exorcise","exorcisers","exorcises","exorcism","exorcisms","exorcist","exorcists","exorcize","exorcizes","expand","expanding","expands","expanse","expanses","expats","expatting","expect","expecting","expects","expend","expending","expendings","expends","expense","expenses","expensing","expert","experting","expertise","expertises","experts","expiating","expiring","expiry","expirying","explicit","explicits","explode","explodes","exploit","exploiting","exploits","exploring","expoing","exporters","exportinged","exportings","expos","exposeds","exposing","exposure","exposures","express","exsert","exserting","exserts","extant","extanting","extants","extendeds","extent","extented","extenting","extents","extern","externa","externaing","externas","externed","externing","externus","extort","extorting","extorts","extruding","fabling","fadded","failing","failling","faire","faires","fairies","faited","fake","fakers","fakes","fall","falling","fallings","falls","fallsing","falses","falsing","fanned","farces","fare","fares","fart","fasces","fassed","fasting","fawkes","fcsing","feasting","feasts","feating","fecalling","feeting","feined","feining","feisting","feists","felids","feline","felined","felining","felises","fellies","felling","felting","fend","fended","fends","feres","ferined","ferining","fesses","fessing","feting","fetting","fevers","fibers","fibre","fibres","fice","fices","fide","fides","fiends","fierce","fierces","fieries","fieris","fife","fifes","figure","figures","file","filers","files","filets","filles","filling","filses","find","finded","fine","finers","fines","fining","fiords","fireds","firm","firmas","firmers","firms","firmus","firsts","firths","fishes","fisting","fitses","fixe","fixeds","fixers","fixes","fizzes","flakes","flange","flanges","flanked","flanned","flasks","flecks","flicks","fliers","flirts","focalling","fold","folds","folies","folked","fonded","fooded","fooled","footed","forces","fore","fores","forest","forges","forked","form","fortes","fosses","fountain","fountaining","fountains","foyers","fpsing","freaked","frieds","friers","fries","frigged","frog","froms","frores","fros","frsing","fsbing","fshing","full","fulling","fulls","fuming","funded","funs","furies","furzes","fuseds","fusees","fusels","fuses","fusing","fussing","fuzing","fwsing","gabling","gabs","gadded","gaeling","gaited","galaing","galing","gall","galliing","gallina","galling","gallings","gallis","galls","gallus","gand","ganded","gander","gandied","ganked","gaoling","garb","garbs","garded","garment","garnet","gaseses","gashes","gassed","gassies","gatling","gauched","gauches","gauching","gauded","gauling","gausses","gcsing","gean","geans","gelids","gellies","gelling","gelting","genies","gent","genting","gestaing","gestes","gesting","getting","gilling","girded","girled","giroed","gisting","give","givens","gives","gladded","gladed","glanced","gland","glanded","glands","glandsed","glansed","glares","glass","glasses","glassy","gleams","glean","gleans","glides","glises","gofers","gold","golds","gonded","goners","gooded","goofed","gooked","gooned","gooped","goosed","gorals","gouached","gouaches","gouaching","governs","gpsing","graces","grad","grades","grads","graf","grafs","grafts","grails","grains","gram","gramas","gramps","grams","gran","granded","grands","grange","granged","granges","grans","grants","grapes","graphs","grases","grasps","grass","grasses","grassy","gratas","grates","gratis","graves","gravis","gray","grays","grazes","greats","grebes","greylies","greyly","groaks","groans","groats","grouch","grouched","grouches","grouching","groves","grub","grubs","grunts","gruses","gsaing","gsring","guesting","guests","guiing","guild","guilds","guiled","guiles","guilt","guilty","guises","guising","gull","gulling","gulls","guns","guses","gushes","gushing","gussing","gutses","gutsing","guying","gyrans","habits","hacked","hadded","hagged","haicks","haiked","hailing","haired","haje","hakeas","hakes","halals","hale","halfing","haling","hall","halling","halls","halming","haloing","halting","halve","halved","halves","halving","hame","hand","handed","handeds","handel","hander","handied","handled","handsed","hanged","hangers","harded","harems","hares","harked","harold","harolds","hart","harvey","hashes","hassles","hastes","hasting","hate","hats","hauling","haved","haven","havens","haves","hawked","hawses","haze","heating","heave","heaved","heaven","heaver","heaves","hectare","hectares","hefting","heired","heisting","held","helds","helixes","helling","helves","here","hets","hetting","hexine","hexined","hexines","hexining","hexose","hexoses","hhsing","hiatus","hick","hicked","hicks","hies","hilling","hilts","hind","hinded","hinged","hinges","hins","hints","hips","hire","hired","hirers","hires","hirtas","hiss","hisses","hives","hivs","hoards","hoared","hoaxed","hobbed","hoboed","hocced","hocked","hockey","hodded","hods","hoed","hogged","hoists","hokaed","holcus","holders","holdups","hole","holed","holes","holeys","holism","hollas","hollos","holm","holms","holy","homers","homied","homoed","honied","honked","honker","honkey","honkied","honored","hooches","hooching","hood","hooded","hoodeds","hoods","hooeyed","hoofed","hoofeds","hoofer","hookah","hookeds","hooker","hookeri","hookers","hookied","hookies","hooksed","hookses","hookup","hooped","hoopoed","hoopsed","hooted","hooter","hooved","hooveds","hoovers","hopers","hopied","hopped","hopple","hopples","hopsed","horded","hordes","horned","horsed","hosing","hosted","hosting","hotbed","hots","hotsed","hotted","hounds","houred","housed","houses","housing","hover","hovers","hoyaed","hrts","hses","hsing","hucked","huging","hulked","hull","hulling","hullos","hulls","hunged","hunked","huns","huoned","hushes","hushing","husked","husking","husoing","huts","hyoids","ictalling","idioted","idlies","iising","ileals","illing","images","impact","impacting","impacts","impart","imparting","impartings","imparts","impasses","impends","implore","implores","imploring","impoliting","important","importeds","importeeing","importees","importers","importinged","importings","importune","importuning","imposing","impost","imposting","imposts","improving","impure","impures","impuring","imputing","inbuilt","incise","incite","inclined","inclosed","include","includeds","includes","income","incomes","indied","indirect","indirected","indirects","indite","indited","indole","indoles","inerting","inerts","inference","inferences","infidel","influxed","info","inhabit","inhabits","inhere","inhered","inherent","inherenting","inherents","inheriteds","inheritinged","inheritings","inheritors","inheritting","inhibit","inhibits","initio","inkied","inland","inlanded","inline","inosine","inquire","inquires","insane","insert","inserting","inserts","insided","insider","insiders","insides","insist","insoles","inspire","insted","insting","intake","intakes","intending","interim","interims","intermit","intermits","inti","intied","intoed","intones","intos","intro","intron","intros","intruded","invades","invert","inverting","inverts","invites","invoice","invoices","involve","involves","iodide","ipsing","ired","ires","ironside","irsing","iruses","ises","isiing","ising","island","islanded","isling","isming","isning","isring","itsing","iuding","jailing","jakes","janned","jawses","jean","jeans","jellies","jelling","jest","jesting","jestings","jests","jetting","jigger","jiggers","jirded","jive","jives","jocked","jokers","jooked","josing","josses","joules","jove","joves","juking","julies","juning","jure","juring","juses","jussing","justes","juting","kailing","kakkes","kalaing","kaliing","kaling","kalkas","karens","karling","kelpies","kelting","kepting","kerite","kerited","kerites","khanned","kianged","kickers","kied","killing","kilned","kina","kinaed","kinda","kindas","kindle","kindly","kinds","kine","kined","king","kinged","kinked","kinks","kinned","kino","kinoed","kins","kiosks","kirk","kirked","kirks","kisses","kith","kleins","klick","klicks","knacks","knocks","knucks","koined","kooked","kookied","kuiing","kvasses","kweeked","kylies","labbed","lacced","lacied","lacked","ladded","ladder","laddied","laded","ladied","ladled","ladling","laed","lagans","lagend","lagended","lagged","lahhed","lahued","laiced","laid","laided","lairded","lake","lakes","lakhed","lallying","lamaed","lambed","lament","lammed","lamnaed","lamped","lanaied","lanated","lanced","lancer","lances","lancet","landaued","landeds","lander","landers","landler","lands","lane","lang","langed","langued","lank","lankaed","lanked","lankied","lanned","lansaed","lanseh","lanset","lapped","lapsed","lapses","lard","larded","larder","larged","laried","larked","larred","lashed","lashes","lassas","lasses","lassies","lassos","lasted","lasting","latent","latest","latesting","latests","lathed","latked","latkes","latsed","latses","latted","lauans","laud","lauded","lauder","laudes","launced","launder","lavaed","laves","lavved","lawsed","lawses","laxaed","lazied","lead","leaded","leaden","leadens","leads","leaf","leafs","leak","leaked","leaks","leal","leals","leaners","leap","leaps","learn","learns","leases","leasting","leaven","leavens","ledded","lefting","legals","legends","lemnas","lemons","lended","lender","lends","lenifies","lenify","lens","lensed","lent","lented","lenting","leon","leones","leons","lesses","lessing","letting","levants","levees","levels","levited","lewded","lianaed","lianas","liared","libels","libred","lice","lices","lick","licks","lidded","lieded","lieges","lies","life","lifers","lifes","ligand","liganded","ligans","ligers","lignes","like","likeds","likens","likes","limans","lime","limens","limes","limeys","linden","lindied","line","lineds","linens","liners","lines","linged","linied","linked","linoed","linted","liraed","lirred","lises","lisles","listes","listing","lite","liters","lites","lithes","litred","livedos","livens","livers","livias","livids","llanoed","llanos","loached","loaches","loaching","loaded","loan","loans","localling","loched","loches","loching","locked","lode","lohans","loired","lolling","loners","longed","looked","looker","looksed","loomed","looned","looped","loosed","looted","lorded","losers","losing","losses","losting","louched","louches","louching","louded","loughed","loughing","loupes","louses","lousing","louver","louvers","lover","lovers","lowans","lowers","lsding","lubing","lueses","luesing","luging","lull","lulling","lulls","lunaed","lundaed","lunged","lunned","luoing","lure","luring","lushes","lushing","luting","luxing","lynxed","mace","macers","maces","maches","mackems","mackle","mackles","madake","madakes","madded","made","mades","maes","magens","mahoes","maided","mailing","maines","maired","maizes","makers","makeups","mako","makos","male","maleos","males","maliing","maliks","maling","mall","malling","malls","malsing","malting","mameys","mandaed","manded","mane","maneds","manes","manied","manies","mankies","manned","mansed","manxed","manxes","maples","mapling","mare","mares","marges","maries","markeds","markers","markets","marling","mart","martes","masers","mases","maskeds","maskers","mass","massed","masseds","masses","masting","mate","mateds","maters","mates","mateys","mattes","mauling","maunded","maxes","maybes","maze","mazeds","mazers","mazes","mazies","mealies","mean","means","meating","mediaed","mediated","medicied","meeting","meined","meining","melees","melias","melics","melting","mend","mended","mends","mere","merelies","merely","merited","mesaing","meshing","mesning","messes","messing","meting","metrifies","metrify","mick","micks","mike","mikes","milling","mind","minded","minified","minifies","minkes","mire","mired","mires","miried","miries","miroed","mising","misses","misting","mitred","mitres","mlsing","mocked","models","modems","modes","modest","modifieded","modifiered","modifiers","modished","modishes","modisted","modistes","modses","mogens","mohaves","mohses","moired","mojave","mojaves","mold","molds","mole","moles","molest","molles","mollified","mollifies","molling","molvas","mommies","monded","mondes","monels","moneys","monked","monses","montan","montanning","montans","montes","mooched","mooches","mooching","mooded","mooned","moored","moosed","mooses","mooted","mope","mopeds","mopes","more","morels","mores","morses","mortified","mortifies","moses","moseys","moshes","mosting","mote","motels","motes","motets","motiffed","motive","motives","moue","moues","moulds","mountain","mountaining","mountains","mousing","mouthed","mouthing","moveds","movie","movies","moxies","mpsing","mrsing","msbing","mscing","mses","msging","mshing","msing","muanged","muched","muches","muching","muling","mull","mullas","mulling","mulls","mullus","muming","musaing","musding","musers","muses","mushes","mushing","musing","musings","musking","mussing","muting","mutually","myalling","myalls","myopes","nadded","nailing","naives","nakeds","nalline","nanaed","nanced","nand","nanded","nandued","nanned","narded","nashes","nasuses","nauched","nauches","nauching","nave","neating","nemine","nemined","nemines","nemining","nerves","nervies","nesses","nessing","nest","nesting","nestings","nestling","nests","netting","nevers","newlies","newting","nexted","nexting","nick","nicks","nigger","niggers","nilling","nisied","nisting","nitred","nitres","niveas","nivose","nivoses","nocked","node","noired","noires","nolling","nonuple","nonuples","nooked","nookied","nooksed","nooned","noosed","nosing","notched","notches","notching","notified","notifies","nouses","nousing","nsaing","nscing","nsfing","nsuing","nswing","nuding","nuited","nuking","null","nulling","nulls","nuns","nurses","nursing","nutses","nutsing","nuxing","oakens","oasing","oasises","oasting","oatses","obtain","obtaining","obtains","occluded","oceans","ochers","octalling","octuple","octuples","odisted","ogives","oilies","oising","olds","olefine","olefined","olefines","olefining","oleins","olive","olives","onlies","onto","onuses","opalling","opiated","oppose","opposes","opulus","opuses","oralling","orange","oranged","oranges","oses","osing","otuses","ouring","ousels","outclass","outclasses","outclassing","outdated","outing","outrigger","outriggers","ovalling","over","overs","overts","pacoses","pacs","pact","padded","padres","pads","paduses","paeans","pageant","pageses","paided","pailing","painses","paired","paks","palases","paliing","paling","palling","pallying","palming","palmses","paloing","pals","palsies","pandaed","pander","pangses","panned","pans","pansies","pant","panted","pantses","paps","para","parang","pare","parental","parented","parents","parers","pareve","pari","paries","paring","parises","parity","park","parr","parsec","parsecs","parsed","parsee","parsees","parser","parsers","parses","parted","parti","partis","partly","parts","partses","party","paruses","parvenu","parves","pasches","paso","pasoed","pasos","pasques","passages","passed","passeds","passee","passeed","passees","passel","passels","passer","passers","passims","passives","passkey","passkeys","passu","passued","passus","pasted","pasteds","pastel","pastels","paster","pasters","pastes","pasties","pasting","pastises","pasts","patases","patens","patent","patents","patient","pats","patsies","pauling","paulis","paused","pauses","pausing","pave","pavises","pawling","paws","payees","payment","pays","pbsing","peaked","pean","peans","peated","peating","pecans","pecses","pekans","pelling","pelting","pent","penting","percent","pere","pert","perting","perves","pesoing","pessed","pessing","pest","pesting","pestis","pestling","pestoing","pestos","pests","petited","petrifies","petrify","petting","phaged","pharos","pholis","phsing","pick","picks","piered","pigses","pill","pilling","pills","pinses","pinto","pintos","pisces","piss","pissed","pisseds","pisser","pissers","pisses","pistes","pisting","pith","pitses","plaided","planaed","planked","planned","planted","plashes","plated","pleads","pleats","plover","plovers","pmsing","poached","poaches","poaching","pocked","poises","pokers","polers","polies","poll","polling","pollos","polls","pommies","ponded","ponses","pooched","pooches","pooching","pooded","poofed","pooled","pooned","pooped","poored","pooved","pooves","porched","porches","porching","porked","port","portent","posers","poshes","posies","posing","posits","possed","posses","possess","posset","possets","postes","posting","potent","pouch","pouched","pouches","pouching","powers","praises","pranged","prat","prated","preference","preferences","prelims","premies","preses","presses","prexies","pricks","prigged","prises","prom","proses","proves","prunes","prunos","prunus","psaing","psas","pses","psiing","psing","pucing","puking","pula","pulas","pule","pules","puling","pullers","pullets","pulleys","pulling","pulp","pulps","pulsing","puns","pupals","pupated","pupils","pure","purelies","purely","purifies","purify","puring","purl","purls","pursing","puses","pushing","puss","pussed","pusses","pussies","pussing","pyrene","qianged","quaing","quakes","quares","quells","questing","quests","quicks","quiing","quilt","quired","quited","quoing","quolls","rabies","racies","radded","raided","railing","raises","rake","rakes","raling","rallies","rallying","ramies","ranaed","rand","randed","randied","raneed","ranges","ranied","ranked","ranted","rarelies","rarely","rarifies","rarify","rashes","rasing","rassed","rave","ravers","readies","realines","realise","realises","realizes","reallies","really","realties","realty","reaves","rebuild","rebuilds","reburies","recall","recalling","recalls","recces","reccies","recipes","recited","recites","reclines","recode","recommits","recover","recovers","redefine","redefined","redefines","redefining","redlines","reedies","reefies","reeves","referee","referees","referenceds","referent","refine","refined","refiners","refines","refining","refinings","refits","regias","regimes","regius","reined","reining","reited","reiting","rejigs","relaces","relates","relaxes","relay","relics","relict","relicts","relied","relief","reliefs","relieve","relieves","relievo","relievos","relines","relining","relish","relishes","relived","relives","remake","remakes","remise","remises","remiss","remits","remove","removes","rend","rended","rends","renins","renises","rent","rentes","renting","repands","repens","repents","repine","repined","repining","replay","replied","replies","reply","repose","reposes","requiems","requireds","requite","requites","requote","requotes","reruns","resets","reshes","reshing","reside","resides","resids","resiles","resins","resizes","respire","respires","ressing","rest","resting","restings","rests","retied","reties","reting","retire","retouch","retouched","retouches","retouching","retries","retting","reusing","reverence","reverences","revers","review","reviews","reviles","revise","revises","revive","revoke","revokes","revues","rewire","rewired","rhuses","rick","ricks","rigged","riggeds","rigger","riggers","rilling","rimies","rind","rinded","ringer","ringers","ringside","rising","risses","rive","rives","rivets","roached","roaches","roaching","rocked","rogers","roilies","rolling","rons","rooded","roofed","rooked","rookied","roomed","rooted","ropers","ropies","rosies","rosing","rouble","roubles","roughed","roughing","rounds","rouses","rousing","rove","rover","rovers","roves","rowers","rubens","rubies","rubing","rubins","rubs","rudelies","rudely","ruding","rues","rugger","ruggers","rugs","ruins","rulied","rulies","ruling","ruly","rumens","rums","rune","runes","rung","rungs","runics","runing","runt","runts","runups","ruses","rushes","rushing","rusing","rusking","russing","ruts","saales","saaling","saames","sabling","sabres","sadded","saided","sailing","saints","saises","sake","sakes","salals","saling","salk","salking","salks","salling","sallying","salols","salping","salting","salving","sand","sanded","sander","sandied","sandsed","sanned","sansed","sanses","sapling","sarded","sarees","sashes","sass","sassed","sasses","sassies","sats","saurel","save","savers","scalding","scalds","scaling","scalping","scalps","scalying","scapes","scarce","scarces","scare","scareds","scarers","scares","scarfs","scaries","scarps","scends","schick","schicks","scired","scoked","scolds","scorer","scorers","scores","scoter","scoters","scruple","scruples","sculling","seaport","seaporting","seaports","seareds","seases","seating","seaxes","secluded","secting","secure","sedans","seined","seines","seining","selling","semited","send","sended","sends","sent","senting","septing","sequine","sequines","serifs","serined","serining","serves","sesses","sessing","sets","setting","severs","sexies","sexpot","sexpots","sexpotting","sexted","sexting","shabus","shade","shadeds","shades","shadies","shafts","shagged","shake","shakens","shakers","shakes","shakies","shakos","shale","shales","shame","shameds","shames","shamus","shanged","shanked","shanks","shanned","shape","shapeds","shapers","shapes","shard","shards","shareds","sharers","shareses","sharias","shark","sharks","sharons","sharp","sharpens","sharpers","sharpie","sharpies","sharps","shart","sharts","shaveds","shavens","shavers","shaves","shawls","shawms","sheareds","shearers","shearses","sheers","sheiks","sherds","shines","shinto","shire","shires","shirks","shirrs","shited","shnooked","shocked","shocks","shoeds","shooed","shooked","shooted","shore","shoreas","shores","shorns","shorts","shotes","shover","shovers","shreds","shrews","shrive","shrives","shucks","sibs","sick","sicks","sics","sids","sieves","sifts","sights","silling","silts","sind","sinded","sing","sins","sips","sirced","sired","sirens","sires","sirred","sirs","sising","siss","sisses","sitars","site","sites","sitkas","sittas","situ","situs","sitz","sitzes","sixths","skates","skinks","skints","skirts","skits","skives","skulls","slander","slanted","slates","slices","slicks","slides","slimes","slits","slivers","slouch","slouched","slouches","slouching","slsing","smalling","smalls","smarms","smarts","smited","smites","smiths","smoked","snare","snarers","snares","snarfs","snarls","sneaked","snicks","snigger","sniggers","snits","snooked","snores","soaked","sobers","socked","solare","solares","sold","solds","solids","solling","solver","solvers","solves","sooned","sooted","sore","sorelies","sorely","sots","souchong","soughed","soughing","souked","soupies","source","soured","souses","sousing","southed","southing","sowers","spaces","spades","spalling","spanged","spare","sparers","spares","sparge","sparges","sparks","spasms","spated","spates","spazes","speaked","specks","spells","sphere","spheres","spicks","spills","spinto","spired","spirts","spited","spites","spits","splits","spoked","spooked","spores","sprigger","spriggers","sprits","spurge","squally","squares","squires","ssaing","sses","ssing","ssping","sssing","sswing","stacks","stages","stalk","stalks","stalling","standed","stands","stanks","stapes","stare","starers","stares","starets","starses","starts","starve","starves","states","staves","steads","steaked","steeds","stenting","stetting","sticks","stilts","stints","stoked","stores","stover","stovers","stoves","streaked","stringer","stringers","strive","strives","suaves","subclassed","suched","suches","suching","sucre","sucred","sudated","sudses","sudsing","suer","suered","sues","suiing","suing","suited","suites","suits","sullas","summits","sundated","sunglass","sunglasses","sunglassing","suns","superclassed","supergrass","supergrasses","sura","suraed","surd","surded","sured","surelies","sures","surety","surf","surfed","surfer","surge","surged","surges","suring","surrey","survey","suses","sussing","suture","swages","swales","swards","swarms","swarts","sweared","sweated","swerve","swifts","swined","swiped","swirled","switch","taaling","tables","tabling","tabses","tached","taches","taching","tack","tacks","tacting","tadded","taeling","tagger","taggers","tailing","tajiks","take","takens","takers","takes","tala","talaing","talas","talc","talcing","talcs","tale","talent","tales","taling","talkers","talkies","talking","talksed","talkses","talling","tallying","talons","talus","tandem","tank","tankas","tanked","tanks","tanned","taoses","tapses","tart","tarting","task","tasking","tasks","tassed","tassel","tassels","tasses","tasset","tassets","tassing","tasting","tastings","tastying","tatting","tauting","tawses","tdting","teached","teaches","teaching","teaing","teaked","teaking","tealed","tealing","teamed","teaming","teared","tearing","teased","teases","teasing","teasling","teat","teated","teating","teats","tebets","teccing","teched","teches","tectaing","tectas","tedding","teds","teed","teeing","teeming","teened","teening","teething","teeths","teffing","tegging","teiids","tejuing","tellies","temming","temping","tempting","tempts","tenched","tenches","tenching","tendeds","tenders","tendons","tenens","tenged","tenges","tenging","tenias","tenned","tenning","tennis","tennos","tenons","tenors","tensed","tenseds","tensing","tented","tenthing","tenting","tentings","tenuis","tepids","teraing","tercing","tereting","terming","terned","terning","terrifies","terrify","terses","tersing","teslaing","teslas","testaing","testas","testating","testeds","testeeing","testees","testers","testes","testied","testify","testily","testinged","testings","testis","testying","tether","tething","tetting","tevets","texans","text","texted","textes","texting","textings","texts","thaned","thanked","thanks","thanned","thecas","thefting","thefts","theist","theisting","theists","theres","thesis","thinged","tholed","tholes","thonged","thorough","thoroughs","thought","thrive","thrives","throng","throngs","throughed","throughs","thrush","thuses","ticalling","tick","ticks","tiered","tigers","tilling","tilting","tineds","tinting","tire","tired","tires","tiroed","titred","titres","titting","tnting","toasting","toasts","toeaed","toeses","toesing","togethers","told","tolds","tolling","tommies","tomtits","toneds","toners","tontining","tooled","tooned","tooted","toothed","toothing","tooting","topers","toposes","topple","topples","torch","torched","torches","torching","torting","toshed","toshes","tosked","tosking","tosses","tossing","toters","toting","totting","toucan","toucans","touchers","touchied","touchies","touchinged","touchingly","touchings","touchline","touchy","touchying","tough","toughed","toughens","toughied","toughies","toughing","toughying","touped","toupee","toupeed","touping","toured","touring","tousle","tousled","tousling","touted","towers","tracks","transitive","transitived","transitives","transitivity","treaded","treads","treated","treating","treats","treeds","trekked","trend","trends","trenting","tressing","trestling","triage","triaged","tricker","trickers","tricks","triers","trifler","triflers","trigged","trimer","trimers","trimmer","trimmers","tripper","trippers","trited","triting","troched","troches","troching","trough","troughed","troughing","troughs","troves","truced","truces","trucing","trucked","trucking","trudger","trudgers","trulies","trunks","trusting","trusts","truthed","truthing","trysting","trysts","tsetse","tsetsing","tubing","tucked","tucking","tufting","tugger","tuggers","tuling","tulles","tulling","tumses","tumsing","tuning","tuns","turing","tushed","tutting","tuxing","twanged","tweaks","tweeded","tweeds","tweeped","tweeted","tweeting","tweets","tweezed","twelved","twenty","twerked","twerped","twiced","twigged","twined","twirled","twirped","twisting","twists","twitch","ufoing","uglies","uhfing","uing","ukases","ukasing","ukes","uking","ulls","ulting","umaing","umping","unchanged","unclouded","uncouple","uncouples","uncover","uncovers","undated","undateds","undefined","unding","unedited","unhooked","uniated","uning","united","unkind","unlive","unlives","unmake","unmakes","unmated","unmodified","unqing","unsated","unsees","unsung","unsure","untouched","unusually","unwired","unyoke","unyokes","upbeated","upcasted","update","updates","updrafted","uphold","upholds","uping","upland","uplanded","upsets","upside","uptaked","upvoted","urated","urging","urling","urning","urns","ursine","uruses","usages","usaging","usaing","usas","usbegs","usbeks","uscbing","usdaed","usdaing","used","useds","user","users","ushers","usinged","usings","usmcing","usneas","usning","usns","usps","uspses","uspsing","usss","usssing","usualed","usuals","usurer","utaing","utcing","utes","uting","utning","uubing","uuhing","uuping","uuqing","uuting","uving","uziing","valiing","valing","valling","valses","valsing","valuing","valving","vandaed","vanned","varment","vasing","vassed","vasting","vedisted","vegans","veined","veines","veining","vend","vended","vends","vent","venting","verbified","verbifies","verbify","veridis","veridises","veried","verified","verifieds","verifier","verifiers","verited","veritied","verities","verity","versified","versifier","versifiers","versifies","versify","versting","versts","verting","verves","vest","vesting","vests","vetting","vianded","vilifies","vilify","vinifies","vinify","virens","vireos","vising","visits","visually","vitrifies","vitrify","vive","vives","vivifies","vivify","vivred","vocalling","vomers","vomits","voters","vouch","vouched","voucheed","vouchees","vouchers","vouches","vouching","vowers","wadded","wadses","waifed","wailed","wailing","wained","waived","waives","wake","wakens","wakers","wakes","waling","walk","walking","walks","wall","walling","wallings","walls","wallying","wand","wanded","wander","wanked","wanned","want","wanted","ware","wared","waried","warmed","warned","warped","warred","warsed","warses","wart","warted","washes","wassed","wastes","wasting","watses","wauling","wave","wavers","wawling","wayses","wbsing","weaked","weaken","wealed","wean","weaned","weans","wearer","weaved","weeked","weft","wefting","weirded","weired","wekaed","welling","welt","welting","wended","wends","wens","weres","westing","wests","wetting","whacks","whales","whanged","wharfs","whelks","whiled","whined","whirled","whirred","whists","whites","whits","wholed","wholes","whooped","whored","whores","wick","wicked","wicks","wided","width","widths","wifed","wified","wigged","wilded","wiled","wilied","wilies","willed","willing","wilted","wimped","winced","wind","wined","winged","winied","winked","winned","winoed","wiped","wipeds","wireds","wirer","wiried","wised","wisent","wish","wished","wising","wisped","witch","withal","withe","wither","withes","within","withs","withy","witsed","witted","wive","wived","wives","wizzed","wlanned","wokked","wold","wolds","wonked","wont","wooded","wooers","woofed","wooled","worded","worlds","wormed","worned","worsed","worted","woulds","wove","woves","wraith","wrasses","wreaked","wrecks","wresting","wrests","wricks","wried","wriggler","wrigglers","wringer","wringers","writhe","wswing","wussing","wyrded","xmases","yanaed","yanked","yarded","yawling","yawses","yearns","yeasting","yeasts","yelling","yessing","yetting","yolked","yorked","youthed","youthing","yuling","yuses","yussing","zaired","zaires","zanied","zend","zended","zends","zest","zesting","zests","zestying","zeuses","zeusing","zhuanged","zilling","zonked","zoomed","zooted"]}});function Ln(e,t,n){if(e===t)return 0;if(Math.abs(e.length-t.length)>n)return n+1;let s=null,o=Array.from({length:t.length+1},(r,i)=>i);for(let r=1;r<=e.length;r+=1){let i=[r],a=r;for(let l=1;l<=t.length;l+=1){let c=e[r-1]===t[l-1]?0:1,u=Math.min(o[l]+1,i[l-1]+1,o[l-1]+c);r>1&&l>1&&e[r-1]===t[l-2]&&e[r-2]===t[l-1]&&(u=Math.min(u,s[l-2]+c)),i[l]=u,u<a&&(a=u)}if(a>n)return n+1;s=o,o=i}return o[t.length]}function La(e){return/^[a-z]+$/.test(e)&&!st.has(e)&&!Oa.has(e)}function Jd(e){return zy(e)?null:Na(e,Fy,Qn(e))}function Na(e,t,n=Qn(e)){let s=n+1,o=null,r=!1;for(let i of t){let a=Ln(e,i,Math.min(s,n));a<s?(s=a,o=i,r=!1):a===s&&a<=n&&i!==o&&(r=!0)}return s<=n&&!r?o:null}var My,Qn,Oa,Py,Fy,Dy,zy,Ho=L(()=>{An();Yd();Jn();My=["used"];Qn=e=>e.length<=5?1:2,Oa=new Set([...Object.keys(de),...Object.keys(Be),...Object.keys(Gt),...My].flatMap(e=>e.split(" "))),Py=4,Fy=[...new Set([...Object.keys(de),...Object.keys(Gt)].flatMap(e=>e.split(" ")).filter(e=>e.length>=Py))],Dy=new Set(Xd.words),zy=e=>Dy.has(e)});function oo(e){for(let t of qy){let n=e.match(t.re);if(n){let s=t.build(n);if(s)return s}}return null}var Kr,By,Uy,Wy,Ma,qy,Qd,Yr=L(()=>{An();Jn();Kr=Object.keys(de).sort((e,t)=>t.length-e.length).map(He).join("|"),By=Object.keys(Be).sort((e,t)=>t.length-e.length).map(He).join("|"),Uy=Object.keys(Gt).sort((e,t)=>t.length-e.length).map(He).join("|"),Wy=ws.slice().sort((e,t)=>t.length-e.length).map(He).join("|"),Ma=(e,t)=>e==="defines"&&Po.has(t),qy=[{name:"ask",re:new RegExp(`^(?:does|do|did)\\s+(.+?)\\s+(${Kr})\\s+(.+?)\\??$`,"i"),build:e=>{let t=e[2].toLowerCase(),n=de[t];if(Ma(n,t))return null;let s=e[1].trim(),o=e[3].trim();return Mo.includes(t)&&([s,o]=[o,s]),{shape:"ask",entityType:null,modifier:"direct",kind:n,subject:s,object:o}}},{name:"reverse",re:new RegExp(`^which\\s+(${By})\\s+(?:(${Uy})\\s+)?(${Kr})\\s+(.+?)\\??$`,"i"),build:e=>{let t=e[3].toLowerCase(),n=de[t];return Ma(n,t)?null:{shape:"reverse",entityType:Be[e[1].toLowerCase()],modifier:e[2]?Gt[e[2].toLowerCase()]:"direct",kind:n,object:e[4].trim()}}},{name:"forward",re:new RegExp(`^what\\s+(?:does|do|did)\\s+(.+?)\\s+(${Kr})\\??$`,"i"),build:e=>{let t=e[2].toLowerCase(),n=de[t];return Ma(n,t)?null:{shape:"forward",entityType:null,modifier:"direct",kind:n,object:e[1].trim()}}},{name:"meta-mean",re:new RegExp(`^what\\s+(?:does|do|is|are)\\s+(.+?)\\s+(?:${Wy})\\??$`,"i"),build:e=>({shape:"meta",entityType:null,modifier:"direct",kind:"meta",object:e[1].trim()})},{name:"meta-whatis",re:new RegExp("^what\\s+(?:is|are)\\s+(?:(an?|the)\\s+)?(.+?)\\??$","i"),build:e=>{let t=e[1]?e[1].toLowerCase():null,n=Xt(e[2].trim()),s=!/\s/.test(n);if(t==="the"&&!s||!t&&!Be[n.toLowerCase()])return null;let o=n.toLowerCase();return t&&t!=="the"&&gu.some(r=>o===r||o.startsWith(`${r} `))?null:{shape:"meta",entityType:null,modifier:"direct",kind:"meta",object:gs(n)}}},{name:"mention",re:new RegExp(`^where\\s+(?:is|are|was|were)\\s+(.+?)\\s+(?:${an.map(He).join("|")})\\??$`,"i"),build:e=>({shape:"mentions",entityType:null,modifier:"direct",kind:"mentions",object:e[1].trim()})},{name:"where",re:new RegExp(`^where\\s+(?:is|are|was|were)\\s+(.+?)(?:\\s+(?:${Yt.map(He).join("|")}))?\\??$`,"i"),build:e=>({shape:"where",entityType:null,modifier:"direct",kind:"where",object:e[1].trim()})},{name:"when",re:new RegExp(`^when\\s+(?:did|does|do|was|were|is)\\s+(.+?)\\s+(?:last\\s+)?(${Kr})\\??$`,"i"),build:e=>de[e[2].toLowerCase()]==="touches"?{shape:"when",entityType:null,modifier:"direct",kind:"touches",object:e[1].trim()}:null},{name:"commit-history",re:/^(?:the\s+)?commit\s+history\s+(?:of|for)\s+(.+?)\??$/i,build:e=>({shape:"when",entityType:null,modifier:"direct",kind:"touches",object:e[1].trim()})},{name:"cochange-partners",re:/^co-?change\s+partners\s+(?:of|for|with)\s+(.+?)\??$/i,build:e=>({shape:"reverse",entityType:"Module",modifier:"direct",kind:"cochange",object:e[1].trim()})}];Qd={id:"grammar",class:"graph-query",run(e){let t=oo(e);return t?{strategyId:"grammar",class:"graph-query",candidates:[{parsed:t,confidence:.9}]}:null}}});function xt(e,t,n=null){let s=Object.keys(t).sort((o,r)=>r.split(" ").length-o.split(" ").length);for(let o of s){let r=o.split(" ");for(let i=0;i<=e.length-r.length;i+=1)if(!(n&&r.some((a,l)=>n.has(i+l)))&&r.every((a,l)=>e[i+l]===a))return{kind:t[o],start:i,end:i+r.length}}return null}function Yo(e,t=null){let n=e.replace(/\?+\s*$/,"").replace(/,/g," ").split(/\s+/).filter(Boolean),s=n.map(E=>E.toLowerCase());if(s.includes("where")&&!xt(s,de)){let E=s.some(S=>an.includes(S)),_=new Set([...Yt,...an]),R=n.filter((S,A)=>!st.has(s[A])&&!_.has(s[A])).join(" ").trim();if(R){let S=E?"mentions":"where";return{shape:S,entityType:null,modifier:"direct",kind:S,object:R}}}if(new Set(["has","have","had"]).has(s[0])){let E=s.length;for(;E>1&&(s[E-1]==="ever"||s[E-1]==="been");)E-=1;if((E>1?de[s[E-1]]:null)==="touches"){let R=n.slice(1,E-1).filter((S,A)=>!st.has(s[1+A])).join(" ").trim();if(R)return{shape:"when",entityType:null,modifier:"direct",kind:"touches",object:R}}}let r=s,i=xt(s,de);if(!i&&t){let E=s.map(_=>{if(!La(_))return _;let R=t.lemma(_);return Oa.has(R)?R:_});i=xt(E,de),i&&(r=E)}let a=null;if(!i){let E=s.map(_=>_.length>=4&&La(_)&&Jd(_)||_);if(i=xt(E,de),i){r=E;let _=s.slice(i.start,i.end).findIndex((S,A)=>S!==E[i.start+A]),R=i.start+Math.max(_,0);a={from:s[R],to:E[R]}}}let l=!1;if(!i)for(let E=0;E<s.length;E+=1){let _=Hn[s[E]];if(!(_&&s[E]==="used"&&s[E+1]==="for")&&_&&s.slice(0,E).some(R=>Ko.has(R))){i={kind:_,start:E,end:E+1},l=!0;break}}if(!i)return null;!l&&i.end-i.start===1&&Hn[s[i.start]]&&s.slice(0,i.start).some(E=>Ko.has(E))&&(l=!0);let c=E=>a?{...E,fuzzyVerb:a}:E;if(t&&i.end-i.start===1){let E=i.start,_=s[E-1];if((_==="the"||_==="these"||_==="those")&&s[E+1]==="of"&&t.posTags(n)[E]==="NOUN"){let S=n.slice(E+2).filter((A,M)=>!st.has(s[E+2+M])).join(" ").trim();if(S)return c({shape:"forward",entityType:null,modifier:"direct",kind:i.kind,object:S})}}let u=new Set,d=E=>{if(E)for(let _=E.start;_<E.end;_+=1)u.add(_)};d(i);for(let[E,_]of Object.entries(de)){if(_!==i.kind)continue;let R=E.split(" "),S=i.end;if(R.every((A,M)=>r[S+M]===A)){d({start:S,end:S+R.length});break}}let m=xt(r,Be,u);d(m);let p=xt(r,Gt,u);d(p);let f=(E,_)=>n.slice(E,_).filter((R,S)=>!u.has(E+S)&&!st.has(s[E+S])).join(" ").trim(),g=f(0,i.start),h=f(i.end,n.length);l&&!s.includes("by")&&Hy.has(h.toLowerCase())&&(h="");let b=i.kind,w=m?Be[r.slice(m.start,m.end).join(" ")]:null,v=p?Gt[r.slice(p.start,p.end).join(" ")]:"direct";if(b==="touches"&&s.includes("when")){let E=g||h;if(E)return c({shape:"when",entityType:null,modifier:"direct",kind:"touches",object:E})}if(b==="touches"&&s.includes("who")&&s.includes("last")){let E=g||h;if(E)return c({shape:"whoLast",entityType:null,modifier:"direct",kind:"touches",object:E})}let $=s.indexOf("by"),k=s.slice(0,i.start).findIndex(E=>Ko.has(E)),y=k>=0,j=y&&k>$;if($>=0&&!u.has($)&&y){let E=(S,A)=>n.slice(S,A).filter((M,T)=>{let P=S+T,G=s[P];return!u.has(P)&&!st.has(G)&&G!=="by"&&!Ko.has(G)&&!Gy.has(G)&&!Vy.has(G)}).join(" ").trim(),[_,R]=j?[E(k+1,n.length),E($+1,k)]:[E(0,$),E($+1,n.length)];if(_&&R)return b==="defines"&&Po.has(r.slice(i.start,i.end).join(" "))?null:c({shape:"ask",entityType:null,modifier:"direct",kind:b,subject:R,object:_});if(R)return c({shape:"forward",entityType:w,modifier:v,kind:b,object:R});if(_)return c({shape:"reverse",entityType:w,modifier:v,kind:b,object:_})}if(l&&$<0&&h&&s[i.start]==="called")return null;if(g&&h){let E=r.slice(i.start,i.end).join(" ");if(b==="defines"&&Po.has(E))return null;let _=g,R=h;return Mo.includes(E)&&([_,R]=[R,_]),c({shape:"ask",entityType:null,modifier:"direct",kind:b,subject:_,object:R})}if(h){let E=m&&m.start>=i.end?null:w;return c({shape:"reverse",entityType:E,modifier:v,kind:b,object:h})}if(b==="inherits"&&!g&&m&&m.start===i.end){let E=r.slice(m.start,m.end).join(" ");if(E)return c({shape:"reverse",entityType:null,modifier:v,kind:b,object:E})}if(g&&!h&&y&&i.end-i.start===1&&Hn[s[i.start]]){if(g.split(/\s+/).length>1)return null;if(b==="touches")return c({shape:"when",entityType:null,modifier:"direct",kind:b,object:g});let E=Ko.has(s[0]);return c({shape:"reverse",entityType:w,modifier:v,kind:b,object:g,...E?{polar:!0}:{}})}return g?c({shape:"forward",entityType:w,modifier:"direct",kind:b,object:g}):null}var Ko,Gy,Vy,Hy,Zd,Xr=L(()=>{An();Jn();Ho();Ko=new Set(["is","are","was","were","be","been","being","get","gets","got"]),Gy=new Set(["which","what","who","whom","whose"]),Vy=new Set(Rn.map(e=>e.toLowerCase())),Hy=new Set(["recently","lately","yet","already","ever","again"]);Zd={id:"keyword-spot",class:"graph-query",run(e,t={}){let n=Yo(e,t.nlp||null);return n?{strategyId:"keyword-spot",class:"graph-query",candidates:[{parsed:n,confidence:.7}]}:null}}});function Yy(e,t,n){if(!n||typeof n.posTags!="function"||!t.length)return[];let s=new Set(t.map(i=>i.toLowerCase())),o;try{o=n.posTags(e)}catch{return[]}let r=[];for(let i=0;i<e.length;i+=1){let a=e[i],l=a.toLowerCase();!/^[a-z]+$/.test(a)||ep.has(l)||!s.has(l)||o[i]==="VERB"&&r.push(l)}return r}function Xy(e,t=null){let n=Qt(e),s=[],o=[];for(let i of n){let a=i.toLowerCase();/^[a-z]+$/.test(i)&&!ep.has(a)&&(Ky.has(a)||t&&typeof t.isStopWord=="function"&&t.isStopWord(a))?o.push(i):s.push(i)}let r=Yy(n,s,t);return{text:s.join(" "),dropped:o,maybeNoise:r}}var ep,Ky,tp,np=L(()=>{An();Jn();Yr();Xr();ep=new Set([...st,...me(bs),...me(Object.keys(de)),...me(Object.keys(Be)),...me(Object.keys(Gt)),...me(Object.keys(Ve)),...me(ys),...me(vs),...me(Object.keys(Kn)),...me(Object.keys(pn)),...me(Object.keys(Xs)),...me(Rn),...me(Do),...me(ws),...me(Yt),...me(an),...me(_n),...me(Object.keys(Qs))]),Ky=new Set([...me(Fo),...me(Lr)]);tp={id:"noise-strip",class:"noise-stripped",run(e,t={}){if(oo(e))return null;let{text:n,dropped:s,maybeNoise:o}=Xy(e,t.nlp||null);if(!s.length||!n)return null;let r=oo(n)||Yo(n,t.nlp||null);if(!r)return null;if(o.length&&(r.shape==="where"||r.shape==="mentions")&&r.object){let i=r.object.split(/\s+/).filter(a=>!o.includes(a.toLowerCase())).join(" ").trim();i&&i!==r.object&&(r.altObject=i)}return{strategyId:"noise-strip",class:"noise-stripped",candidates:[{parsed:r,confidence:.75,note:`noise-stripped to "${n}"`}]}}}});var sp=L(()=>{});var Jr,Qr=L(()=>{Jr=()=>{}});function rp(e,t){return e.shape!==t.shape||e.kind!==t.kind?!1:e.shape==="ask"?ro(e.subject)===ro(t.subject)&&ro(e.object)===ro(t.object):ro(e.object)===ro(t.object)}function Pa(e){let t=(e||[]).filter(c=>c&&Array.isArray(c.candidates)&&c.candidates.length);if(!t.length)return null;let n=[];for(let c of t)for(let u of c.candidates)!u||!u.parsed||n.push({parsed:u.parsed,confidence:typeof u.confidence=="number"?u.confidence:.5,note:u.note||null,via:u.via||null,strategyId:c.strategyId,class:c.class});if(n.some(c=>!ip(c))&&(n=n.filter(c=>!ip(c))),!n.length)return null;let s=new Map;for(let c of n)s.has(c.class)||s.set(c.class,[]),s.get(c.class).push(c);let o=[];for(let[c,u]of s){let d=[];for(let m of u){let p=d.find(f=>rp(f.parsed,m.parsed)&&f.via===m.via);if(p){p.agreed+=1,p.confidence=Math.max(p.confidence,m.confidence),op(m.parsed)<op(p.parsed)&&(p.parsed=m.parsed);continue}d.push({...m,agreed:1})}d.length&&o.push({class:c,candidates:d})}if(!o.length)return null;let r=c=>Math.max(...c.candidates.map(u=>u.confidence)),i=o[0];for(let c of o)r(c)>r(i)&&(i=c);let a=i.candidates.length===1?i.candidates[0].parsed:{ambiguousParse:!0,candidates:i.candidates.map(c=>c.parsed)},l=o.filter(c=>c!==i).map(c=>c.candidates[0]).filter(c=>!i.candidates.some(u=>rp(u.parsed,c.parsed)));return{class:i.class,parsed:a,winner:i.candidates[0],alternates:l}}function Zy(e){if(!e)return"something else";if(e.ambiguousParse)return"one of several readings";let t=e.object??e.subject??"?";return`${e.kind} "${t}"`}function ap(e,{describe:t=Zy,answerFor:n=null}={}){return(e||[]).map(s=>{let o=s.note||t(s.parsed),r=n&&n(s)||"ask it that way";return`if you mean ${o} then ${r}`})}var ro,Jy,op,Qy,ip,Fa=L(()=>{ro=e=>String(e||"").trim().toLowerCase().replace(/\s+/g," ").replace(/^(?:the|a|an)\s+/,"").replace(/^commit\s+(?=[0-9a-f]{7,40}$)/,""),Jy=/^\s*(?:the|a|an)\s+/i,op=e=>[e?.subject,e?.object].filter(t=>Jy.test(String(t||""))).length;Qy=new Set(["fuzzy","lemma","spell"]),ip=e=>Qy.has(e.via)});function Zr(e){Da=e}function ei(){return typeof Da=="function"?Da():null}var Da,io=L(()=>{Da=null});function up(e,t={},n=tv){let s=[];for(let o of n)try{let r=o.run(e,t);r&&typeof r.then!="function"&&s.push(r)}catch{}return s}var ev,tv,dp=L(()=>{Jn();Yr();Xr();np();sp();Qr();Fa();io();ev=[...typeof void 0<"u"?[void 0]:[],...typeof void 0<"u"?[void 0]:[]],tv=[Qd,Zd,tp,...ev]});var Xo,za=L(()=>{Xo=(e,t,n)=>n});var Zp={};En(Zp,{DYNAMIC_TAIL_OK_RE:()=>lc,applyNegationFrames:()=>Vo,ask:()=>ss,classDisplayName:()=>es,degreeMetric:()=>qp,metaFallbackEntityAnswer:()=>Pp,normalizeQuery:()=>_s,parseQuery:()=>er,parseQueryFull:()=>Qa,render:()=>gn,rephraseHint:()=>rc,resolveObject:()=>cn,traverse:()=>Ht});function We(e,t){let n=pp.get(e);n||(n=new Map,pp.set(e,n));let s=n.get(t);if(s)return s;let o=[];for(let r of e.relations)if(On(r)===t)for(let i of r.edges)o.push(i);return n.set(t,o),o}function Pe(e,t){let[n,s]=jp[e]||["result","results"];return t===1?n:s}function nr(e,t,n,s={}){return!e||!t.length?[]:[{kind:"set",class:e,label:`${t.length} ${Pe(e,t.length)}`,ids:t.map(o=>o.id),attrs:{count:t.length},lane:n,...s}]}function es(e){let t=String(e||"");if(typeof fn=="function"){let n=fn(t).join(" ");if(n)return n}return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase()}function Rs(e){return sv[e]||e}function cv(e){if(!e?.ambiguousParse||!Array.isArray(e.candidates)||e.candidates.length!==2)return e;let t=e.candidates.find(r=>r?.shape==="meta"),n=e.candidates.find(r=>r!==t);if(!t||!n)return e;let s=String(t.object||"").trim().toLowerCase();if(!s||av.has(s))return e;let o=String(n.object||"").trim().toLowerCase();return me(ws).includes(o)?t:e}function er(e,{nlp:t=void 0}={}){return Qa(e,{nlp:t}).parsed}function Qa(e,{nlp:t=void 0}={}){let n=t===void 0?ei():t,s=String(e||"").trim().replace(/\s+/g," ");if(!s)return{parsed:null,alternates:[],class:null};let o=Ia(Vo(_s(s)));if(!o)return{parsed:null,alternates:[],class:null};let r=uv(o,n);if(r)return{parsed:r,alternates:[],class:null};let i=Pa(up(o,{nlp:n,raw:s}));return i?{parsed:cv(i.parsed),alternates:i.alternates||[],class:i.class||null}:{parsed:null,alternates:[],class:null}}function Va(e,t){return t.length&&Rp.has(t[0])?{bw:e.slice(1),blc:t.slice(1)}:{bw:e,blc:t}}function lo(e,t){return oo(e)||Yo(e,t)}function uv(e,t){let n=Qt(e),s=n.map(o=>o.toLowerCase());return Tv(n,s)||Iv(n,s)||mv(n,s,t)||Tp(e,t,0)||Ov(n,s,t)||gv(n,s,t)||kv(n,s,t,0)||Ev(n,s)||Rv(n,s,t)||Lv(n,s,t)||Fv(n,s,t)||zv(n,s,t,0)||Pv(n,s,t,0)||ec(n,s,t,0)||wv(n,s,t)||pv(n,s)||Np(n,s,t,0)}function pv(e,t){let n=0;dv.has(t[n])&&(n+=1);let s=kt(t[n]);if(!s||s.placeholder||!s.entityType)return null;let o=s.entityType;n+=1;let r=f=>f+1<t.length?bu[`${t[f]} ${t[f+1]}`]:void 0,i=r(n);if(!i)return null;let a=n+2,l=-1,c;for(let f=a;f+1<t.length;f+=1){let g=r(f);if(g){l=f,c=g;break}}if(l<0)return null;let u=e.slice(a,l).join(" ").trim(),d=e.slice(l+2).join(" ").trim();if(!u||!d)return null;let m=(f,g)=>f.role==="object"?{shape:"reverse",kind:f.kind,entityType:o,modifier:"direct",object:g}:{shape:"forward",kind:f.kind,modifier:"direct",object:g},p=m(i,u);return p.entityType=o,{node:"boolean",entityType:o,atoms:[{op:"seed",kind:"set",ast:{node:"clause",clause:p}},{op:"intersection",kind:"set",ast:{node:"clause",clause:m(c,d)}}]}}function ni(e,t){return{node:"boolean",entityType:e,atoms:[{op:"seed",kind:"set",ast:{node:"allOfClass",entityType:e}},t]}}function mv(e,t,n){if(!["do","does","did"].includes(t[0])||!fv.has(t[1]))return null;let s=kt(t[2]);if(!s||s.placeholder||!s.entityType)return null;let o=s.entityType;if(o==="Change")return{node:"miss",reason:`"${t[2]}" isn't an enumerable kind \u2014 a universal check needs a concrete kind (functions, classes, modules, \u2026)`};let r=t[2],i=e.slice(3),a=t.slice(3);if(!i.length)return null;let l=xt(a,de);if(!l)return{node:"miss",reason:"a universal check needs a known relation verb (import, call, inherit from, test, \u2026)"};let u=i.filter((m,p)=>(p<l.start||p>=l.end)&&!st.has(a[p])&&a[p]!=="from").join(" ").trim();if(!u)return null;let d=uo(`which ${r} ${i.join(" ")}`,n,1);return!d||d.node==="miss"?{node:"miss",reason:d&&d.reason||"the universal clause didn't parse"}:{node:"universal",entityType:o,kind:l.kind,object:u,complement:ni(o,{op:"difference",kind:"set",ast:d})}}function Tp(e,t,n=0){let s=Kd(e);if(!s)return null;let o=kt(s.entWord);if(!o||o.placeholder||!o.entityType)return null;let r=o.entityType;if(r==="Change")return{node:"miss",reason:`"${s.entWord}" isn't an enumerable kind \u2014 a set complement needs a concrete kind (functions, classes, modules, \u2026)`};let i=Qt(s.predicate),a=i.map(d=>d.toLowerCase());if(a.length&&a.every(d=>Ve[d]))return ni(r,{op:"difference",kind:"qual",filters:a});let l=xt(a,de);if(!l)return{node:"miss",reason:"a negated set query needs a known relation verb (import, call, inherit from, test, \u2026)"};if(!i.filter((d,m)=>(m<l.start||m>=l.end)&&!st.has(a[m])&&a[m]!=="from").length)return ni(r,{op:"difference",kind:"set",ast:{node:"existsEdge",entityType:r,kind:l.kind}});let u=uo(`which ${s.entWord} ${s.predicate}`,t,n+1);return!u||u.node==="miss"?{node:"miss",reason:u&&u.reason||"the negated clause didn't parse"}:ni(r,{op:"difference",kind:"set",ast:u})}function gv(e,t,n){let s=0;for(;s<t.length&&hv.has(t[s]);)s+=1;if(!["do","does","did"].includes(t[s]))return null;s+=1;let o=e.slice(s),r=t.slice(s),i=r.indexOf("not");if(i<0)return null;let a=xt(r,de);if(!a)return null;let c=o.filter((u,d)=>d!==i&&(d<a.start||d>=a.end)&&r[d]!=="from"&&!st.has(r[d])).join(" ").trim();return c?{node:"forwardComplement",kind:a.kind,subjectTerm:c}:null}function Cp(e,t){let n=new Set;for(let s of t)for(let o of We(e,s)){let r=e.byId.get(o.object);r&&r.class&&n.add(r.class)}return n}function Ip(e,t){let n=Rt(t),s=n.filter(r=>!Ep.has(r)),o=Cp(e,s.length?s:n);return o.size===1?[...o][0]:null}function uo(e,t,n){if(n>_p)return{node:"miss",reason:"too deep to resolve"};let s=Tp(e,t,n);if(s)return s;let o=Qt(e),r=o.map(c=>c.toLowerCase()),i=ec(o,r,t,n);if(i)return i;let a=Np(o,r,t,n);if(a)return a;let l=lo(e,t);return l?{node:"clause",clause:l}:null}function ec(e,t,n,s){for(let o=1;o<t.length;o+=1){let r=_n.includes(t[o]),i=!r&&Ap(t[o]);if(!r&&!i||r&&o+1>=t.length||!kt(t[o-1]))continue;let l=e.slice(0,o-1);if(!l.length||l.every(m=>Ve[m.toLowerCase()]))continue;let c=lo([...l,Ga].join(" "),n);if(!c||c.shape!=="reverse"&&c.shape!=="forward"||c.modifier&&c.modifier!=="direct")continue;let u=`which ${t[o-1]} ${e.slice(r?o+1:o).join(" ")}`,d=uo(u,n,s+1);return!d||d.node==="miss"?d?{node:"miss",reason:d.reason||"inner clause didn't parse"}:{node:"miss",reason:"inner clause didn't parse"}:{node:c.shape==="reverse"?"reverseSet":"forwardSet",kind:c.kind,entityType:c.entityType,inner:d}}return null}function wv(e,t,n){for(let s=0;s<t.length;s+=1){if(!bv.has(t[s])||t[s-1]==="of")continue;let o=s===t.length-1,r=s+1<t.length&&!!de[t[s+1]];if(!o&&!r)continue;let i=[...e.slice(0,s),Ga,...e.slice(s+1)],a=lo(i.join(" "),n);if(!(!a||a.shape!=="reverse"&&a.shape!=="forward")&&a.object===Ga&&!(a.modifier&&a.modifier!=="direct"))return{node:a.shape==="reverse"?"reverseSet":"forwardSet",kind:a.kind,entityType:a.entityType,inner:{node:"prevSet"}}}return null}function kv(e,t,n,s=0){if(t[0]!=="when")return null;let o=1;if(!yv.has(t[o]))return null;o+=1;let r=-1;for(let d=t.length-1;d>=o;d-=1)if(vv.has(t[d])){r=d;break}if(r<0)return null;let i=e.slice(o,r),a=t.slice(o,r);for(;a.length&&$v.has(a[a.length-1]);)i=i.slice(0,-1),a=a.slice(0,-1);for(;a.length&&xv.has(a[0]);)i=i.slice(1),a=a.slice(1);if(!i.length||!a.some(d=>_n.includes(d)))return null;let l=Za.has(a[0])?i.join(" "):`which ${i.join(" ")}`,c=uo(l,n,s+1);if(!c||c.node==="miss")return c?{node:"miss",reason:c.reason||"the inner set of the temporal query didn't parse"}:{node:"miss",reason:"the inner set of the temporal query didn't parse"};let u=kt(a[0]);return{node:"temporal",inner:c,entityType:u&&u.entityType||null}}function Ev(e,t){if(t[0]!=="what"||t[1]!=="changed")return null;let n=2;if(t[n]==="ever"&&(n+=1),!Sv.has(t[n]))return null;let s=t[n],o=e.slice(n+1).join(" ").trim();return o?{node:"commitFilter",op:s,pivotRaw:o}:{node:"miss",reason:`"what changed ${s}" needs a date or commit afterward`}}function _v(e){let t=new Set,n=[];for(let s of e){if(!s||!jv.test(s))continue;let o=s.toLowerCase();t.has(o)||(t.add(o),n.push(s))}return n}function Rv(e,t,n){if(t.length===2&&t[0]==="which"&&(t[1]==="ones"||t[1]==="one"))return{node:"anaphora",mode:"list",filter:{type:"all"}};let s=-1,o=!1;for(let d=1;d<t.length;d+=1){if(!Do.includes(t[d]))continue;if(t[d-1]==="of"){s=d,o=!0;break}let m=t.slice(0,d).join(" ");if(d===t.length-1&&(ys.includes(m)||vs.includes(m))){s=d;break}}if(s<0)return null;let r=(o?t.slice(0,s-1):t.slice(0,s)).join(" "),i=ys.includes(r)||/^(how many|how much|count|number|quantity|total)\b/.test(r)?"count":"list",a=Av(e.slice(s+1),n);if(a===void 0)return{node:"miss",reason:"the follow-up filter didn't parse"};let l=o?s-1:s,c=_v(e.slice(0,l)),u={node:"anaphora",mode:i,filter:a};return c.length>=2&&(u.candidateTerms=c),u}function Av(e,t){let n=0,s=e.map(a=>a.toLowerCase());for(;n<s.length&&lv.has(s[n]);)n+=1;let o=e.slice(n),r=s.slice(n);if(!o.length)return{type:"all"};if(r.every(a=>Ve[a]))return{type:"qual",filters:r};if(o.length===1){let a=kt(r[0]);if(a&&!a.placeholder&&a.entityType)return{type:"entity",entityType:a.entityType}}let i=lo(`what ${o.join(" ")}`,t);if(i&&(i.shape==="reverse"||i.shape==="forward")&&i.object)return{type:"clause",clause:i}}function Tv(e,t){let n;if(t[0]==="is"&&t[1]==="there")n=2;else if(t[0]==="are"&&t[1]==="there")n=2;else return null;let s=t[n];if(s==="a"||s==="an"||s==="any")n+=1;else return null;let o=n<t.length?kt(t[n]):null;if(!o||o.placeholder||!o.entityType)return null;let r=o.entityType;n+=1;let i=t.slice(n),a=e.slice(n);if(i.length&&i[i.length-1]==="anywhere"?(i=i.slice(0,-1),a=a.slice(0,-1)):i.length>=2&&i[i.length-2]==="at"&&i[i.length-1]==="all"&&(i=i.slice(0,-2),a=a.slice(0,-2)),!i.length)return{node:"exists",entityType:r,term:null,scopeModule:null};if(i[0]==="called"||i[0]==="named"){if(i.length<2)return{node:"miss",reason:`"${i[0]}" needs a name afterward`};let l=i.indexOf("in",1);if(l>0){let u=a.slice(1,l).join(" ").trim(),d=a.slice(l+1).join(" ").trim();return!u||!d?{node:"miss",reason:'a named existence check needs both a name and a module after "in"'}:{node:"exists",entityType:r,term:u,scopeModule:d}}let c=a.slice(1).join(" ").trim();return c?{node:"exists",entityType:r,term:c,scopeModule:null}:{node:"miss",reason:`"${i[0]}" needs a name afterward`}}if(i[0]==="in"){let l=a.slice(1).join(" ").trim();return l?{node:"exists",entityType:r,term:null,scopeModule:l}:{node:"miss",reason:'"in" needs a module afterward'}}return null}function Cv(e,t){if(!t.length)return null;let n=`${e} ${t.join(" ")}`,s=gs(n).slice(e.length).trim(),o=Qt(s),r=o.findIndex(a=>a.toLowerCase()==="in");if(r<0)return null;let i=o.slice(r+1).join(" ").trim();return i?{scope:i}:{node:"miss",reason:'"in" needs a scope afterward'}}function Iv(e,t){if(t[0]!=="is"&&t[0]!=="are"||t[1]==="there")return null;let n=-1,s=!1;for(let c=1;c<t.length;c+=1)if(Ve[t[c]]){n=c,s=t[c-1]==="not";break}if(n<0)return null;let o=t.indexOf("by",n+1);if(o>0&&Hn[t[n]]){let c=o+1;for(;c<t.length&&(t[c]==="the"||t[c]==="a"||t[c]==="an");)c+=1;let u=t[c];if(u&&!$u.has(u))return null}let r=Cv(t[n],e.slice(n+1));if(r?.node==="miss")return r;let i=1;t[i]==="the"&&(i+=1);let a=s?n-1:n;a>i&&(t[a-1]==="a"||t[a-1]==="an")&&(a-=1);let l=a>i?e.slice(i,a).join(" ").trim():"";return l?{node:"qualCheck",term:l,qualifier:t[n],negated:s,scope:r?.scope||null}:{node:"miss",reason:'"is/are <qualifier>" needs a named thing to check first'}}function Ov(e,t,n){if(!["do","does","did","is","are","was","were"].includes(t[0]))return null;let s=t.indexOf("not",1);if(s<0)return null;let o=lo(e.filter((r,i)=>i!==s).join(" "),n);return!o||o.shape!=="ask"?null:{...o,negated:!0}}function Lv(e,t,n){let s=ys.find(d=>t.slice(0,d.split(" ").length).join(" ")===d);if(!s)return null;let o=s.split(" ").length;for(;o<t.length&&(t[o]==="the"||t[o]==="a"||t[o]==="all");)o+=1;let r=[];for(;o<t.length&&Ve[t[o]];)r.push(t[o]),o+=1;let i=o<t.length?kt(t[o]):null;if(!i)return{node:"miss",reason:"count needs a known entity kind (functions, classes, modules, \u2026)"};let a=t[o];o+=1;let l=e.slice(o),c=t.slice(o).some(d=>!st.has(d)&&!Op.has(d)),u;if(c){let d=uo(`which ${a} ${l.join(" ")}`,n,1);if(!d||d.node==="miss")return{node:"miss",reason:"the count restrictor didn't parse"};u=d}else u={node:"allOfClass",entityType:i.entityType};return r.length&&(u={node:"qualifier",filters:r,inner:u}),{node:"count",entityType:i.entityType,base:u}}function Pv(e,t,n,s){let o=0,r=!1,i=null;for(let w of Nv){let v=w.split(" ");if(t.slice(0,v.length).join(" ")===w){i=w,o=v.length;break}}if(!i)if(t[0]==="what"||t[0]==="which")r=!0,o=1;else return null;for(;o<t.length&&tc.has(t[o]);)o+=1;let a=[];for(;o<t.length&&Ve[t[o]];)a.push(t[o]),o+=1;let l=o<t.length?kt(t[o]):null;if(!l||l.placeholder||l.entityType==="Change")return!r&&o<t.length&&o===t.length-1&&/^[a-z]+$/.test(t[o])&&!de[t[o]]&&!Rn.includes(t[o])?{node:"miss",reason:`"${t[o]}" isn't a listable kind \u2014 try ${Lp}`}:null;let c=l.entityType,u=t[o];o+=1;let d=e.slice(o),m=t.slice(o).some(w=>!st.has(w)&&!Op.has(w)),p=t.slice(o),f=d;(p[0]==="is"||p[0]==="are")&&(p=p.slice(1),f=f.slice(1));let g=r&&Mv.has(p[0]);if(r&&(m&&!g||d.length===0))return null;let h,b=!1;if(m){let w=g?f:d,v=uo(`which ${[...a,u,...w].join(" ")}`,n,(s||0)+1);if(!v||v.node==="miss")return{node:"miss",reason:v&&v.reason||"the list filter didn't parse"};h=v,b=!0}else h={node:"allOfClass",entityType:c},a.length&&(h={node:"qualifier",filters:a,inner:h});return{node:"list",entityType:c,base:h,scoped:b}}function Fv(e,t,n){let s=null,o=-1;for(let f=0;f<t.length;f+=1){let g=t.slice(f,f+2).join(" ");if(Kn[g]){s=Kn[g],o=f;break}if(Kn[t[f]]){s=Kn[t[f]],o=f;break}}if(!s)return null;let r=null,i=null;for(let f=o;f<t.length;f+=1)if(pn[t[f]]){r=pn[t[f]],i=t[f];break}if(!r){for(let f=o-1;f>=0;f-=1)if(pn[t[f]]){r=pn[t[f]],i=t[f];break}}let a=t.includes("connected")||t.slice(o,o+2).join(" ")==="most connected"||["largest","biggest","smallest"].includes(t[o]),l=["important","significant","central","key","core","essential","critical","principal"],c=t.some(f=>l.includes(f));!r&&(a||c)&&(r=pn.connections,i="connections");let u,d=null;for(let f of t){let g=kt(f);if(g&&!g.placeholder){u=g.entityType,d=f;break}}if(!d&&(u=i?xu[i]:void 0,!u))return{node:"miss",reason:"a superlative needs an entity kind (module, class, function, \u2026)"};if(!r)return{node:"miss",reason:"name what to rank by (imports, callers, methods, tests, or connections)"};let m=["needs","need","needing","lacks","lack","lacking","misses","missing"],p=t.some(f=>m.includes(f))?s==="most"?"fewest":"most":s;return{node:"superlative",entityType:u,metric:r,metricNoun:i,extreme:p}}function zv(e,t,n,s){if(t[0]!=="find")return null;let o=1;for(;o<t.length&&tc.has(t[o]);)o+=1;if(o>=t.length)return null;let r=kt(t[o]);if(r&&!r.placeholder&&r.entityType!=="Change"&&o+1<t.length&&Dv.has(t[o+1])){let a=e.slice(o+2).join(" ").trim();if(a)return{node:"find",entityType:r.entityType,term:a}}let i=kt(t[t.length-1]);if(i&&!i.placeholder&&i.entityType!=="Change"){let a=e.slice(o,t.length-1).join(" ").trim();if(a)return{node:"find",entityType:i.entityType,term:a}}return t.some(a=>_n.includes(a))?null:o===t.length-1&&/^[a-z]+$/.test(t[o])&&!de[t[o]]&&!Rn.includes(t[o])?{node:"miss",reason:`"${t[o]}" isn't a listable kind \u2014 try ${Lp}`}:null}function Bv(e,t){if(t[0]!=="find")return null;let n=1;for(;n<t.length&&tc.has(t[n]);)n+=1;let s=-1;for(let i=n+1;i<t.length;i+=1)if(_n.includes(t[i])){s=i;break}if(s<0)return null;let o=kt(t[s-1]);if(!o||o.placeholder||o.entityType==="Change")return null;let r=e.slice(n,s-1).join(" ").trim();return r?{entityType:o.entityType,term:r,relIdx:s}:null}function Uv(e,t,n,s,o,r){let{branches:i,ops:a}=si(n,s),l=null,c=[];for(let u=0;u<i.length;u+=1){let d=i[u],m=d.map(w=>w.toLowerCase()),p=u===0?"intersection":a[u-1],f=Va(d,m);if(f.blc.length&&f.blc.every(w=>Ve[w])){c.push({op:p,kind:"qual",filters:f.blc});continue}if(m[0]==="of"||m[0]==="in"){c.push({op:p,kind:"set",ast:{node:"membership",entityType:e,term:d.slice(1).join(" ")}});continue}let g=d,h=xt(m,de);h?l=d.slice(h.start,h.end):l&&(g=[...l,...d]);let b=Mp(`${t} ${g.join(" ")}`,o,r);if(!b||b.node==="miss")return{miss:b&&b.reason||"a clause in the combination didn't parse"};c.push({op:p,kind:"set",ast:b})}return{atoms:c}}function Np(e,t,n,s){let o=Bv(e,t);if(o){let{entityType:R,term:S,relIdx:A}=o,M=t.slice(A+1),T=e.slice(A+1);if(!M.length)return{node:"miss",reason:`a relative clause needs a predicate after "${t[A]}"`};let P=Uv(R,`which ${t[A-1]}`,M,T,n,s+1);if(P.miss)return{node:"miss",reason:P.miss};let G=[{op:"seed",kind:"set",ast:{node:"find",entityType:R,term:S}},...P.atoms];return G.length===1?G[0].ast:{node:"boolean",entityType:R,atoms:G}}let r=0;for(;r<t.length&&Za.has(t[r]);)r+=1;let i=r>0,a=[];for(;r<t.length&&Ve[t[r]];)a.push(t[r]),r+=1;let l=r<t.length?kt(t[r]):null;if(!l){let R=r+1<t.length?kt(t[r+1]):null;if(fp.has(t[r])&&R&&R.entityType==="Commit"&&r+2===t.length)return{node:"recentCommits"};if(Rp.has(t[r])){let S=r+1;S<t.length&&(t[S]==="the"||t[S]==="a"||t[S]==="an")&&(S+=1);let A=S+1<t.length?kt(t[S+1]):null;if(fp.has(t[S])&&A&&A.entityType==="Commit"&&S+2===t.length)return{node:"recentCommits"}}return(i||a.length)&&R&&/^[a-z]+$/.test(t[r])&&!de[t[r]]&&!st.has(t[r])&&!cc.has(t[r])?{node:"find",entityType:R.entityType,term:e[r]}:null}let c=l.entityType,u=t[r];r+=1;let d=t.slice(r),m=e.slice(r),p=!1;d.length&&_n.includes(d[0])&&(p=!0,d=d.slice(1),m=m.slice(1));let f=d[0]==="of"||d[0]==="in",g=d.length>0&&Ap(d[0]),h=m.length>0&&si(d,m).branches.some(R=>{let{blc:S}=Va(R,R.map(A=>A.toLowerCase()));return S.length&&S.every(A=>Ve[A])}),b=m.length>0?si(d,m).branches:[],w=!1;if(b.length>1){let R=b[0].map(A=>A.toLowerCase()),S=xt(R,de);S&&S.start===0&&(w=b.slice(1).every(A=>{let M=A.map(P=>P.toLowerCase()),T=xt(M,de);return T&&T.start===0?T.kind===S.kind:!T}))}let v=!1;if(b.length>1){let R=b[0].map(A=>A.toLowerCase()),S=xt(R,de);S&&S.start===0&&(v=b.slice(1).every(A=>{let M=A.map(P=>P.toLowerCase()),T=xt(M,de);return!!T&&T.start===0&&T.end-T.start===1}))}if(!(a.length||p||f||g||h||w||v))return null;if(!m.length){let R={node:"allOfClass",entityType:c};return a.length?{node:"qualifier",filters:a,inner:R,entityType:c}:{node:"miss",reason:"nothing to filter or traverse"}}let $=l.placeholder?"what":`which ${u}`,{branches:k,ops:y}=si(d,m),j=null,E=[];for(let R=0;R<k.length;R+=1){let S=k[R],A=S.map(te=>te.toLowerCase()),M=R===0?"seed":y[R-1],T=Va(S,A);if(T.blc.length&&T.blc.every(te=>Ve[te])){E.push({op:M,kind:"qual",filters:T.blc});continue}if(A[0]==="of"||A[0]==="in"){E.push({op:M,kind:"set",ast:{node:"membership",entityType:c,term:S.slice(1).join(" ")}});continue}let P=S,G=xt(A,de);G?j=S.slice(G.start,G.end):j&&(P=[...j,...S]);let K=Mp(`${$} ${P.join(" ")}`,n,s+1);if(!K||K.node==="miss")return{node:"miss",reason:K&&K.reason||"a clause in the combination didn't parse"};E.push({op:M,kind:"set",ast:K})}if(E[0].kind!=="set")return{node:"miss",reason:"start with a clause, then combine with and/or/but-not"};let _;return E.length===1?_=E[0].ast:_={node:"boolean",entityType:c,atoms:E},a.length&&(_={node:"qualifier",filters:a,inner:_,entityType:c}),_}function Mp(e,t,n){if(n>_p)return{node:"miss",reason:"too deep to resolve"};let s=Qt(e),o=s.map(a=>a.toLowerCase()),r=ec(s,o,t,n);if(r)return r;let i=lo(e,t);return i?{node:"clause",clause:i}:null}function si(e,t){let n=Object.keys(Xs).sort((a,l)=>l.split(" ").length-a.split(" ").length),s=[],o=[],r=0,i=0;for(;i<e.length;){let a=null;for(let l of n){let c=l.split(" ");if(e.slice(i,i+c.length).join(" ")===l){a={c:l,len:c.length};break}}a&&i>r?(s.push(t.slice(r,i)),o.push(Xs[a.c]),i+=a.len,r=i):a?(i+=a.len,r=i):i+=1}return s.push(t.slice(r)),{branches:s,ops:o}}function nc(e,t,n,s){let o=ao[t];if(o&&ns.has(n)){let u=We(e,o).filter(d=>s.has(d.object));return Mn(u.map(d=>e.byId.get(d.subject)).filter(d=>d&&d.class===n))}let a=(!!o&&[...s].some(u=>ns.has(e.byId.get(u)?.class))?[...Rt(t),o]:Rt(t)).flatMap(u=>We(e,u)).filter(u=>s.has(u.object)),l=Mn(a.map(u=>e.byId.get(u.subject)).filter(Boolean));if(!n||n==="Change")return l;let c=l.filter(u=>u.class===n);return c.length?c:n!=="Module"&&l.some(u=>u.class==="Module")?ic(e,new Set(l.filter(u=>u.class==="Module").map(u=>u.id)),n):[]}function qv(e,t){let n=new Set(nc(e,"touches","Commit",t).map(s=>String(s.label||"").toLowerCase()));for(let s of t)for(let o of e.byId.get(s)?.derived_from||[]){let r=Wv.exec(String(o||""));r&&n.add(r[1].toLowerCase())}return n.size}function Zo(e,t,n){let s=Rt(t).flatMap(o=>We(e,o)).filter(o=>n.has(o.subject));return Mn(s.map(o=>e.byId.get(o.object)).filter(Boolean))}function Mn(e){let t=new Set,n=[];for(let s of e)s&&!t.has(s.id)&&(t.add(s.id),n.push(s));return n}function Gv(e,t){let n=Cn(t);if(!n)return[];let s=`${n}/`;return e.individuals.filter(o=>o.class==="Module"&&Cn(o.label).startsWith(s))}function Ha(e){let t=mp.get(e);if(t)return t;let n=new Set;for(let i of We(e,"reexports")){n.add(String(i.object).toLowerCase());let a=e.byId.get(i.object);a&&n.add(String(a.label).toLowerCase())}let s=new Set,o=new Set;for(let i of We(e,"tests"))s.add(i.object),o.add(i.subject);let r=new Map;for(let i of We(e,"defines"))r.set(i.object,i.subject);return t={exported:n,testedModules:s,testModules:o,moduleOfSymbol:r},mp.set(e,t),t}function co(e,t){return t?t.class==="Module"?t.id:Ha(e).moduleOfSymbol.get(t.id)||null:null}function Pp(e,t){let n=String(t||"").trim().toLowerCase();if(!n)return null;let s=(e?.individuals||[]).filter(d=>Vv.has(d.class)&&String(d.label).toLowerCase()===n);if(s.length!==1)return null;let o=s[0],r=co(e,o),i=r&&e.byId.get(r)?.label||String((o.attributes||[]).find(d=>d.key==="site")?.value||"").split(":")[0]||null,a=Pe(o.class,1),l=a==="attribute"?"an":"a",c=i?`, ${Xo("defined-in",o.id,"defined in")} ${i}`:"",u=o.class==="Class"?` or "which classes inherit from ${o.label}"`:"";return{text:`${o.label} is ${l} ${a} in this codebase${c} \u2014 try "describe ${o.label}"${u}.`,hit:o,modLabel:i}}function Ka(e,t,n){let s=Mn(Js.flatMap(o=>Zo(e,o,new Set([t]))));return n?s.filter(o=>o.class===n):s}function sc(e,t,n=null){let s=Nn(e,t,n);if(!(s.match&&s.tier===1)){let o=Gv(e,t);if(o.length)return{kind:"dir",mods:o}}return s.match?{kind:"single",id:s.match.id,entityClass:s.match.class,label:s.match.label}:{kind:"miss"}}function Fp(e,t,n,s,o){let r=o||(()=>!0),i=Ka(e,t,s).filter(r);if(i.length||!zp(e,n))return{own:i,inherited:[],viaId:null,viaLabel:null};for(let a of Dp(e,t)){let l=e.byId.get(a);if(!l)continue;let c=Ka(e,a,s).filter(r);if(c.length)return{own:i,inherited:c,viaId:a,viaLabel:l.label}}return{own:i,inherited:[],viaId:null,viaLabel:null}}function As(e,t,n){if(!n)return!1;switch(n.via){case"visibility":return String((t.attributes||[]).find(o=>o.key==="visibility")?.value||"public").toLowerCase()===n.value;case"attr":return!!(t.attributes||[]).find(s=>s.key===n.attr)?.value;case"exported":{let s=Ha(e).exported;return s.has(String(t.label).toLowerCase())||s.has(String(t.id).toLowerCase())}case"tested":{let s=co(e,t),o=Ha(e),r=s?e.byId?.get?.(s):null;return s&&(o.testModules.has(s)||r&&Ss(String(r.label).toLowerCase()))?!1:(!!s&&o.testedModules.has(s))===n.value}default:return!1}}function oc(e){return We(e,"inherits")}function Ya(e,t){return oc(e).filter(n=>n.object===t).map(n=>n.subject)}function hp(e,t){return oc(e).filter(n=>n.subject===t).map(n=>n.object)}function Hv(e,t){let n=new Set,s=[...Ya(e,t)];for(;s.length;){let o=s.shift();if(!n.has(o)){n.add(o);for(let r of Ya(e,o))n.has(r)||s.push(r)}}return n}function Dp(e,t){let n=new Set,s=[...hp(e,t)];for(;s.length;){let o=s.shift();if(!n.has(o)){n.add(o);for(let r of hp(e,o))n.has(r)||s.push(r)}}return n}function zp(e,t){let n=gp.get(e);if(n||(n=new Map,gp.set(e,n)),n.has(t))return n.get(t);let s=oc(e).some(o=>{let r=e.byId.get(o.subject),i=e.byId.get(o.object);return!!r&&!!i&&r.class===t&&i.class===t});return n.set(t,s),s}function bp(e,t){let n=String(e.label||"").toLowerCase();if(t.every(o=>n.includes(o)))return"label";let s=(e.attributes||[]).map(o=>String(o.value??"").toLowerCase());return t.every(o=>s.some(r=>r.includes(o)))?"attr":null}function yp(e){return e.slice().sort((t,n)=>wp[n.via]-wp[t.via]||String(t.ind.label).length-String(n.ind.label).length).map(t=>t.ind)}function vp(e,t){let n=String(t||"").trim().toLowerCase();if(n.length<4)return!1;let s=Qn(n);if(Ln(String(e.label||"").toLowerCase(),n,s)<=s)return!0;for(let o of Ts(e.label))if(Ln(o,n,s)<=s)return!0;return!1}function Bp(e,t,n){let s=e.individuals.filter(l=>l.class===t),o=[...Ts(n)];if(!o.length||!s.length)return{narrow:[],broad:[]};let r=zp(e,t),i=[];for(let l of s){let c=bp(l,o);if(c){i.push({ind:l,via:c});continue}if(!r)continue;[...Hv(e,l.id)].some(d=>{let m=e.byId.get(d);return!!m&&!!bp(m,o)})&&i.push({ind:l,via:"chain"})}if(i.length||!r)return{narrow:yp(i),broad:[]};let a=new Map;for(let l of s)for(let c of Dp(e,l.id)){if(!a.has(c)){let u=e.byId.get(c);u&&u.class===t&&vp(u,n)&&a.set(c,{ind:u,via:"chain"})}for(let u of Ya(e,c)){if(u===l.id||a.has(u))continue;let d=e.byId.get(u);d&&d.class===t&&vp(d,n)&&a.set(u,{ind:d,via:"chain"})}}return{narrow:[],broad:yp([...a.values()])}}function Kv(e){return[...Wr(qr(e)).entries()].sort((t,n)=>n[1]-t[1]||t[0].localeCompare(n[0])).map(([t])=>({id:`pkg:${t}`,label:t,class:"Package"}))}function Zt(e,t,n){switch(t.node){case"clause":return Ht(e,t.clause,n).matches||[];case"allOfClass":return t.entityType==="Package"?Kv(e):e.individuals.filter(s=>s.class===t.entityType);case"find":{let{narrow:s,broad:o}=Bp(e,t.entityType,t.term);return s.length?s:o}case"existsEdge":{let s=new Set(Rt(t.kind).flatMap(o=>We(e,o)).map(o=>o.subject));return e.individuals.filter(o=>s.has(o.id)&&(!t.entityType||o.class===t.entityType))}case"forwardComplement":{let s=Nn(e,t.subjectTerm,n&&n.contextId);if(!s.match)return[];let o=Ip(e,t.kind);if(!o)return[];let r=new Set(Zo(e,t.kind,new Set([s.match.id])).map(i=>i.id));return e.individuals.filter(i=>i.class===o&&!r.has(i.id))}case"reverseSet":{let s=new Set(Zt(e,t.inner,n).map(o=>o.id));return nc(e,t.kind,t.entityType,s)}case"forwardSet":{let s=new Set(Zt(e,t.inner,n).map(o=>o.id));return Zo(e,t.kind,s)}case"prevSet":{let s=n&&n.prev;return Array.isArray(s)?s.map(o=>e.byId.get(o)).filter(Boolean):[]}case"membership":{let s=sc(e,t.term,n&&n.contextId);if(s.kind==="dir"){if(!t.entityType||t.entityType==="Module")return s.mods;let i=new Set(s.mods.map(l=>l.id));return Mn(Js.flatMap(l=>Zo(e,l,i))).filter(l=>l.class===t.entityType)}if(s.kind==="miss")return[];let{own:o,inherited:r}=Fp(e,s.id,s.entityClass,t.entityType);return o.length?o:r}case"qualifier":return t.inner.node==="membership"?Gp(e,t,n).matches:Zt(e,t.inner,n).filter(o=>t.filters.every(r=>As(e,o,Ve[r])));case"boolean":return Up(e,t,n);case"anaphora":return Wp(e,t,n).matches;default:return[]}}function Up(e,t,n){let s=[];for(let o of t.atoms){if(o.op==="seed"){s=Zt(e,o.ast,n);continue}if(o.kind==="qual"){let i=l=>o.filters.every(c=>As(e,l,Ve[c])),a=l=>o.filters.every(c=>{let u=Yv(Ve[c]);return u?As(e,l,u):!As(e,l,Ve[c])});s=o.op==="difference"?s.filter(a):s.filter(i);continue}let r=new Set(Zt(e,o.ast,n).map(i=>i.id));if(o.op==="intersection")s=s.filter(i=>r.has(i.id));else if(o.op==="difference")s=s.filter(i=>!r.has(i.id));else if(o.op==="union"){let i=new Set(s.map(a=>a.id));for(let a of Zt(e,o.ast,n))i.has(a.id)||(i.add(a.id),s.push(a))}}return s}function Xv(e,t){if(!Array.isArray(t)||t.length<2)return null;let n=new Set,s=[];for(let o of t){let r=cn(e,o);r&&r.match&&!n.has(r.match.id)&&(n.add(r.match.id),s.push(r.match))}return s.length>=2?s:null}function Wp(e,t,n){let o=Xv(e,t.candidateTerms);if(!o){let d=n&&n.prev;if(!Array.isArray(d)||!d.length)return{compositeMiss:!0,reason:"no-prev",matches:[]};o=d.map(m=>e.byId.get(m)).filter(Boolean)}let r=o,i=t.filter;if(i&&i.type==="qual")r=r.filter(d=>i.filters.every(m=>As(e,d,Ve[m])));else if(i&&i.type==="entity")r=r.filter(d=>d.class===i.entityType);else if(i&&i.type==="clause"){let d=cn(e,i.clause.object);if(!d.match)r=[];else{let m=ao[i.clause.kind],p=[...Rt(i.clause.kind),...m?[m]:[]],f=new Set(p.flatMap(g=>We(e,g)).filter(g=>g.object===d.match.id).map(g=>g.subject));r=r.filter(g=>f.has(g.id))}}let a=d=>d.length&&d.every(m=>m.class===d[0].class)?d[0].class:null,l=i&&i.type==="entity"?i.entityType:a(o),c=r.length?a(r):l;if(t.mode==="count")return{compositeKind:"count",count:r.length,entityType:c,matches:[]};let u=nr(c,r,"anaphora",{bound:!0});return{compositeKind:"set",matches:r,entityType:c,referents:u}}function qp(e,t,n){let s=n.kind==="*"?Jv:[n.kind,...n.sibling?[n.sibling]:[]],o=0;for(let r of s)for(let i of We(e,r)){let a=i.subject===t.id,l=i.object===t.id;if(n.dir==="out"&&a){if(n.filter){let c=e.byId.get(i.object);if(!c||c.class!==n.filter)continue}o+=1}else(n.dir==="in"&&l||n.dir==="both"&&(a||l))&&(o+=1)}return o}function Qv(e){let t=e.individuals.filter(s=>s.class==="Commit"),n=s=>String((s.attributes||[]).find(o=>o.key==="date")?.value||"");return t.sort((s,o)=>n(o).localeCompare(n(s))),{compositeKind:"recentCommits",matches:t}}function e$(e,t){let{op:n,pivotRaw:s}=t,o=u=>String((u.attributes||[]).find(d=>d.key==="date")?.value||"").slice(0,10),r=null,i=null,a=null;if(Zv.test(s))r=s;else{let{match:u,ambiguous:d}=cn(e,s,{expectedClass:"Commit"});u&&!d&&u.class==="Commit"&&o(u)&&(i=u.id,a=u.label,r=o(u))}if(!r)return{compositeKind:"commitFilter",op:n,pivotRaw:s,pivotResolved:!1,matches:[]};let l=e.individuals.filter(u=>u.class==="Commit"&&u.id!==i&&o(u)).filter(u=>{let d=o(u);return n==="since"?d>=r:n==="before"?d<r:n==="after"?d>r:d===r}).sort((u,d)=>o(d).localeCompare(o(u))),c=[];return l.length&&c.push({kind:"set",class:"Commit",label:`${l.length} commit${l.length===1?"":"s"} ${n} ${s}`,ids:l.map(u=>u.id),attrs:{count:l.length,op:n,...i?{pivot:i}:{}},lane:"commitFilter"}),i&&c.push({kind:"event",class:"Commit",label:a,ids:[i],attrs:{date:r},lane:"commitFilter"}),{compositeKind:"commitFilter",op:n,pivotRaw:s,pivotDate:r,pivotResolved:!0,matches:l,referents:c}}function t$(e,t,n){let s=Zt(e,t.inner,n),o=new Set(s.map(a=>a.id));if(!o.size)return{compositeKind:"temporal",matches:[],entityType:t.entityType,innerCount:0};let r=nc(e,"touches","Commit",o),i=a=>String((a.attributes||[]).find(l=>l.key==="date")?.value||"");return r.sort((a,l)=>i(l).localeCompare(i(a))),{compositeKind:"temporal",matches:r,entityType:t.entityType,innerCount:s.length}}function n$(e,t){let n=e.individuals.filter(a=>a.class===t.entityType);if(t.metric?.kind==="tests"&&t.entityType==="Module"){let a=new Set(We(e,"tests").map(l=>l.subject));n=n.filter(l=>!a.has(l.id)&&!Ss(String(l.label).toLowerCase()))}let s=n.map(a=>({ind:a,score:qp(e,a,t.metric)})).sort((a,l)=>t.extreme==="most"?l.score-a.score:a.score-l.score);if(!s.length)return{compositeKind:"superlative",entityType:t.entityType,matches:[]};let o=s[0].score,r=s.filter(a=>a.score===o).map(a=>a.ind),i=r.length>=2?nr(t.entityType,r,"superlative"):[{kind:"entity",class:t.entityType,label:r[0].label,ids:[r[0].id],attrs:{},lane:"superlative"}];return i.push({kind:"measure",label:`${o} ${t.metricNoun}`,ids:[],attrs:{metric:o},lane:"superlative"}),{compositeKind:"superlative",entityType:t.entityType,metricNoun:t.metricNoun,extreme:t.extreme,score:o,matches:r,referents:i}}function Gp(e,t,n){let s=t.node==="qualifier"&&t.inner.node==="membership"?t:null,o=s?s.inner:t,r=o.entityType,i=s?f=>s.filters.every(g=>As(e,f,Ve[g])):null,a=f=>nr(r,f,"membership"),l=sc(e,o.term,n&&n.contextId);if(l.kind==="dir"){let f;if(!r||r==="Module")f=l.mods;else{let g=new Set(l.mods.map(h=>h.id));f=Mn(Js.flatMap(h=>Zo(e,h,g))).filter(h=>h.class===r)}return i&&(f=f.filter(i)),{compositeKind:"set",matches:f,entityType:r,referents:a(f)}}if(l.kind==="miss")return{compositeKind:"set",matches:[],entityType:r};let{own:c,inherited:u,viaLabel:d}=Fp(e,l.id,l.entityClass,r,i),m=!c.length&&u.length>0,p=m?u:c;return{compositeKind:"membership",entityType:r,matches:p,inheritedNotOwn:m,viaLabel:d,ownerLabel:l.label,referents:a(p)}}function s$(e,t){let{entityType:n,term:s,scopeModule:o}=t,r=null;if(o){let a=cn(e,o,{expectedClass:"Module"});if(!a.match)return{compositeKind:"exists",entityType:n,term:s,scopeModule:o,scopeMiss:!0,matches:[]};r=a.match}if(s){let a=cn(e,s,{expectedClass:n}),l=!r||a.match&&co(e,a.match)===r.id,c=a.match&&l;return{compositeKind:"exists",entityType:n,term:s,scopeModule:o,scopeMatch:r,matches:c?[a.match]:[]}}let i=r?ic(e,new Set([r.id]),n):e.individuals.filter(a=>a.class===n);return{compositeKind:"exists",entityType:n,term:null,scopeModule:o,scopeMatch:r,matches:i}}function o$(e,t,n){let s=co(e,t);return n.kind==="dir"?n.mods.some(o=>o.id===t.id||o.id===s):s===n.id||Ka(e,n.id).some(o=>o.id===t.id)}function r$(e,t,n){let{term:s,qualifier:o,negated:r,scope:i}=t,a=Nn(e,s,n.contextId);if(a.unresolvedPronoun)return{compositeKind:"qualCheck",qualCheckMiss:"pronoun",term:s,matches:[]};if(!a.match)return{compositeKind:"qualCheck",qualCheckMiss:"unresolved",term:s,matches:[]};if(i){let d=sc(e,i,n.contextId);if(d.kind==="miss")return{compositeKind:"qualCheck",qualCheckMiss:"scope",term:s,scope:i,matches:[]};if(!o$(e,a.match,d))return{compositeKind:"qualCheck",qualCheckMiss:"outsideScope",term:s,scope:i,subjectLabel:a.match.label,scopeLabel:d.kind==="dir"?i:d.label,matches:[]}}let l=As(e,a.match,Ve[o]),c=r?!l:l,u=[{kind:"entity",class:a.match.class,label:a.match.label,ids:[a.match.id],attrs:{},lane:"qualCheck"}];return{compositeKind:"qualCheck",subject:a.match,qualifier:o,negated:r,holds:c,matches:[a.match],referents:u}}function i$(e,t,n){let s=cn(e,t.object);if(!s||!s.match)return{compositeKind:"universal",universalMiss:"unresolved",object:t.object,matches:[]};let o=Zt(e,{node:"allOfClass",entityType:t.entityType},n),r=Up(e,t.complement,n),i=r.length===0;return{compositeKind:"universal",entityType:t.entityType,kind:t.kind,object:s.match.label,holds:i,total:o.length,counter:r,matches:i?o:r}}function a$(e,t,n){if(t.node==="reverseSet"&&t.kind==="touches"&&t.entityType==="Commit")return new Set(Zt(e,t.inner,n).map(s=>s.id));if(t.node==="clause"&&t.clause?.shape==="reverse"&&t.clause.kind==="touches"&&t.clause.entityType==="Commit"){let{objMatch:s,ambiguous:o}=Ht(e,t.clause,n);return s&&!o?new Set([s.id]):null}return null}function c$(e,t,n={}){if(t.node==="miss")return{compositeMiss:!0,reason:t.reason||null,matches:[]};if(t.node==="exists")return s$(e,t);if(t.node==="qualCheck")return r$(e,t,n);if(t.node==="universal")return i$(e,t,n);if(t.node==="count"){let i=a$(e,t.base,n);return i?{compositeKind:"count",count:qv(e,i),entityType:t.entityType,matches:[]}:{compositeKind:"count",count:Zt(e,t.base,n).length,entityType:t.entityType,matches:[]}}if(t.node==="list")return{compositeKind:"list",matches:Zt(e,t.base,n),entityType:t.entityType,scoped:t.scoped};if(t.node==="superlative")return n$(e,t);if(t.node==="temporal")return t$(e,t,n);if(t.node==="recentCommits")return Qv(e);if(t.node==="commitFilter")return e$(e,t);if(t.node==="anaphora")return Wp(e,t,n);if(t.node==="membership"||t.node==="qualifier"&&t.inner.node==="membership")return Gp(e,t,n);if(t.node==="find"){let{narrow:i,broad:a}=Bp(e,t.entityType,t.term);return{compositeKind:"find",entityType:t.entityType,term:t.term,matches:i.length?i:a,broad:!i.length&&a.length>0}}if((t.node==="reverseSet"||t.node==="forwardSet")&&t.inner.node==="prevSet"&&!(Array.isArray(n.prev)&&n.prev.length))return{compositeMiss:!0,reason:"no-prev",matches:[]};let s=Zt(e,t,n),o=t.entityType||null,r=nr(o,s,t.node==="qualifier"?"qualifierListing":"compositeSet");return{compositeKind:"set",matches:s,entityType:o,referents:r}}function Vp(){return'compositional queries also work: "which functions call X and call Y", "what calls something that imports X", "public methods of X", "list functions" / "show me the classes", "how many classes", "which module has the most imports", "find me the payment class", or (after a listing) "which of those are tested"'}function l$(e){let t=["Function","Method"].includes(e.class)?`${e.label}()`:e.label;if(e.class==="Module")return t;let n=tr(e);return n&&n!=="(unknown module)"?`${t} in ${n}`:t}function u$(e,t,n){if(t.compositeMiss)return t.reason==="no-prev"?{content:'"those"/"them" needs a previous answer to refer to \u2014 ask a listing question first, then follow up.',miss:!0,ambiguous:!1}:{content:`couldn't compile this compositional question${t.reason?` (${t.reason})`:""}. ${Vp()}.`,miss:!0,ambiguous:!1};if(t.compositeKind==="exists"){if(t.scopeMiss)return{content:`no module matching "${t.scopeModule}" found in the index.`,miss:!0,ambiguous:!1};let s=Pe(t.entityType,1),o=Pe(t.entityType,2),r=t.scopeMatch?` in ${t.scopeMatch.label}`:"";if(t.term){if(!t.matches.length)return{content:`No \u2014 no ${s} named "${t.term}" found${r}.`,miss:!0,ambiguous:!1};let i=t.matches[0],a=tr(i),l=i.class==="Module"?"":a&&a!=="(unknown module)"?`, ${Xo("defined-in",i.id,"defined in")} ${a}`:"";return{content:`Yes \u2014 ${i.label} is a ${s}${l}.`,miss:!1,ambiguous:!1,matches:t.matches}}return t.matches.length?{content:`Yes \u2014 ${Zn(t.matches)}${r}.`,miss:!1,ambiguous:!1,matches:t.matches}:{content:`No \u2014 no ${o} found${r}.`,miss:!0,ambiguous:!1}}if(t.compositeKind==="qualCheck"){if(t.qualCheckMiss==="pronoun")return{content:`"${t.term}" needs a selected node to refer to \u2014 click a node first, or name it directly.`,miss:!0,ambiguous:!1};if(t.qualCheckMiss==="unresolved")return{content:`couldn't find "${t.term}" in the index to check.`,miss:!0,ambiguous:!1};if(t.qualCheckMiss==="scope")return{content:`couldn't find "${t.scope}" in the index to check inside.`,miss:!0,ambiguous:!1};if(t.qualCheckMiss==="outsideScope")return{content:`No \u2014 ${t.subjectLabel} isn't in ${t.scopeLabel}.`,miss:!0,ambiguous:!1};let s=t.subject.label,o=t.negated?`not ${t.qualifier}`:t.qualifier,r=t.negated?t.qualifier:`not ${t.qualifier}`;return{content:`${t.holds?"Yes":"No"} \u2014 ${s} is ${t.holds?o:r}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="universal"){if(t.universalMiss==="unresolved")return{content:`couldn't find "${t.object}" in the index to check.`,miss:!0,ambiguous:!1,matches:[]};let s=Pe(t.entityType,t.total),o=rv(t.kind);return t.holds?{content:`Yes \u2014 all ${t.total} ${s} ${o} ${t.object}.`,miss:!1,ambiguous:!1,matches:t.matches}:{content:`No \u2014 ${t.counter.length} of ${t.total} ${s} do not ${o} ${t.object}: ${Zn(t.counter)}.`,miss:!1,ambiguous:!1,matches:t.counter}}if(t.compositeKind==="count"){let s=t.entityType?Pe(t.entityType,t.count):t.count===1?"result":"results";return{content:`${t.count} ${s}.`,miss:!1,ambiguous:!1,matches:[]}}if(t.compositeKind==="list"){if(!t.matches.length)return{content:`no ${Pe(t.entityType,2)} in this index.`,miss:!0,ambiguous:!1,matches:[]};let s=!["Module","Package","Commit","Fact","Utterance","Session","Source","Rule"].includes(t.entityType),o=!t.scoped&&s&&t.matches.length>Ue?` \u2014 narrow with "${Pe(t.entityType,2)} in <module>"`:"";return{content:`${Zn(t.matches)}${o}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="membership"){if(!t.matches.length)return{content:`nothing in the index matches that${t.entityType?` (${Pe(t.entityType,2)})`:""}. ${ts(n)}`,miss:!0,ambiguous:!1,matches:[]};if(t.inheritedNotOwn){let s=Pe(t.entityType,2);return{content:`${t.ownerLabel?`${t.ownerLabel} has no own ${s}`:`no own ${s}`} \u2014 inherited from ${t.viaLabel}: ${Zn(t.matches)}.`,miss:!1,ambiguous:!1,matches:t.matches,inheritedNotOwn:!0}}return{content:`${Zn(t.matches)}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="find"){let s=Pe(t.entityType,1);if(!t.matches.length)return{content:`no ${Pe(t.entityType,2)} found matching "${t.term}".`,miss:!0,ambiguous:!1,matches:[]};let o=t.matches.length===1?l$(t.matches[0]):Zn(t.matches);return t.broad?{content:`no exact ${s} named "${t.term}", but found a related ${t.matches.length===1?s:Pe(t.entityType,2)}: ${o}.`,miss:!1,ambiguous:!1,matches:t.matches,relatedNotExact:!0}:{content:`${o}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="recentCommits"){if(!t.matches.length)return{content:"no commits recorded in this index.",miss:!0,ambiguous:!1,matches:[]};let s=i=>String((i.attributes||[]).find(a=>a.key==="date")?.value||""),o=t.matches.slice(0,Mt).map(i=>{let a=s(i).slice(0,10),l=(i.attributes||[]).find(c=>c.key==="message")?.value||"";return`${i.label}${a?` (${a})`:""}${l?` \u2014 ${l}`:""}`}),r=t.matches.length>Mt?` \u2026+${t.matches.length-Mt} more`:"";return{content:`${t.matches.length} recent commit(s): ${o.join(", ")}${r}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="commitFilter"){if(!t.pivotResolved)return{content:`"${t.pivotRaw}" isn't a recognized date (yyyy-mm-dd) or a known commit \u2014 try "what changed since 2026-06-01" or "what changed before <commit>".`,miss:!0,ambiguous:!1,matches:[]};if(!t.matches.length)return{content:`no commits recorded ${t.op} ${t.pivotRaw}.`,miss:!0,ambiguous:!1,matches:[]};let s=i=>String((i.attributes||[]).find(a=>a.key==="date")?.value||""),o=t.matches.slice(0,Mt).map(i=>{let a=s(i).slice(0,10),l=(i.attributes||[]).find(c=>c.key==="message")?.value||"";return`${i.label}${a?` (${a})`:""}${l?` \u2014 ${l}`:""}`}),r=t.matches.length>Mt?` \u2026+${t.matches.length-Mt} more`:"";return{content:`${t.matches.length} commit(s) changed ${t.op} ${t.pivotRaw}: ${o.join(", ")}${r}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="superlative"){if(!t.matches.length)return{content:`no ${Pe(t.entityType,2)} to rank in this index.`,miss:!0,ambiguous:!1};let s=t.extreme==="most"?"the most":"the fewest",o=t.matches.length>1?` (${t.matches.length}-way tie)`:"";return{content:`${Zn(t.matches)} \u2014 ${s} ${t.metricNoun} (${t.score})${o}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="temporal"){let s=t.innerCount||0,o=t.entityType?Pe(t.entityType,s||2):s===1?"entity":"entities",r=s===1?"was":"were";if(!s)return{content:`nothing in the index matches the inner set, so there is no change history to date. ${ts(n)}`,miss:!0,ambiguous:!1,matches:[]};if(!t.matches.length)return{content:`no recorded commit touched the ${s} ${o} in that set in this index. ${ts(n)}`,miss:!0,ambiguous:!1,matches:[]};let i=t.matches[0],a=(i.attributes||[]).find(d=>d.key==="date")?.value||"";if(!a)return{content:`the ${o} in that set ${r} last touched by commit ${i.label}, but this index records no commit dates \u2014 regenerate the graph to attach mgx:commitDate.`,miss:!0,ambiguous:!1,matches:t.matches};let l=(i.attributes||[]).find(d=>d.key==="message")?.value||"",c=String(a).slice(0,10),u=t.matches.length-1;return{content:`the ${o} in that set ${r} last touched by commit ${i.label} on ${c}${l?` ("${l}")`:""}${u?`; ${u} earlier commit${u===1?"":"s"} recorded`:""}.`,miss:!1,ambiguous:!1,matches:t.matches}}return t.matches.length?{content:`${Zn(t.matches)}.`,miss:!1,ambiguous:!1,matches:t.matches}:{content:`nothing in the index matches that${t.entityType?` (${Pe(t.entityType,2)})`:""}. ${ts(n)}`,miss:!0,ambiguous:!1,matches:[]}}function rc(){return`"which <functions|classes|modules> <imports|calls|uses|inherits from|tests> <name>" or "what does <name> <import|call|export>" or "what uses <name>" or "where is <name> defined" / "where is <name> mentioned" or "when did <name> change" or "which commits touched <name>" or "which changes touch commit <sha>"/"what did commit <sha> touch" (a commit's own changes) or plainly "what calls this" (about a selected node) or "what does <term> mean"/"what is a <ClassName>" (about the graph's own vocabulary). `+Vp()}function ts(e=null){return e&&ja(e)===0?"This store holds no code index, so it records no modules or commits to look through.":`Try "who touched <a module that actually has commits>" or "/describe <module>" to see what's in the index.`}function Ts(e){return new Set(String(e).toLowerCase().split(/[^a-z0-9]+/).filter(Boolean))}function ri(e){if(e.length<5)return e;let t=e.replace(/(ing|ers|ors|er|or)$/,"");return t===e?e:t.length>=3&&t[t.length-1]===t[t.length-2]?t.slice(0,-1):t}function Hp(e){return String(e||"").replace(/\.[a-z0-9]+$/i,"").toLowerCase().replace(/[/\-_.]+/g,"")}function d$(e){return String(e||"").trim().replace(/^(?:the|a|an)\s+/i,"").toLowerCase().replace(/[\s\-_]+/g,"")}function Jo(e,t,{expectedClass:n=null}={}){let s=String(t||"").trim();if(!s)return{match:null,candidates:[],tier:null,ambiguous:!1};let o=s.toLowerCase(),r=n?e.individuals.filter(h=>h.class===n):e.individuals,i=o.match(/^(commit[:\s])?([0-9a-f]{7,40})$/);if(i){let h=i[2],b=r.filter(w=>w.class==="Commit"&&(String(w.id).toLowerCase().startsWith(`commit:${h}`)||String(w.label).toLowerCase().startsWith(h)));if(b.length===1)return{match:b[0],candidates:[],tier:1,ambiguous:!1};if(b.length>1)return{match:b[0],candidates:b.slice(1,5),tier:1,ambiguous:!0};if(i[1])return{match:null,candidates:[],tier:null,ambiguous:!1}}let a=r.find(h=>String(h.label).toLowerCase()===o||String(h.id).toLowerCase()===o);if(a)return{match:a,candidates:[],tier:1,ambiguous:!1};let l=`ext:${o}`,c=null;e:for(let h of e.relations)for(let b of h.edges)if(String(b.object).toLowerCase()===l){c=b.object;break e}if(c&&!n)return{match:{id:c,label:s,class:null},candidates:[],tier:2,ambiguous:!1};let u=s.split(/\s+and\s+/i).map(h=>h.trim()).filter(Boolean);if(u.length>1){let h=new Set;for(let b of u){let w=Jo(e,b,{expectedClass:n});w.match&&!w.ambiguous&&h.add(w.match.id)}if(h.size>1)return{match:null,candidates:[],tier:null,ambiguous:!1}}let d=[],m=!o.includes("/")&&/^[\w$]+(\.[\w$]+)+$/.test(o);if(m){let h=o.split(".").pop();for(let b of r){let w=String(b.label||"").toLowerCase();b.class==="Module"?w.split("/").pop()===o&&d.push({ind:b,score:1e3-Math.abs(w.length-o.length)}):w.includes(o)?d.push({ind:b,score:2e3-Math.abs(w.length-o.length)}):w.endsWith(`.${h}`)&&d.push({ind:b,score:1500-Math.abs(w.length-o.length)})}}else{let h=[...Ts(s)],b=o.split(/\s+/).find(y=>y.includes("/")),w=b?b.split("/").pop().replace(/\.[a-z0-9]+$/,""):null,$=s.trim().replace(/^(?:the|a|an)\s+/i,"").trim().split(/\s+/).filter(Boolean).length>=2,k=$?d$(s):null;for(let y of r){let j=String(y.label||"").toLowerCase(),E=j.split("/").pop().replace(/\.[a-z0-9]+$/,"");if(E===o){d.push({ind:y,score:5e3});continue}if(o.length>=4&&(E.startsWith(o)||E.endsWith(o))){d.push({ind:y,score:4e3-Math.abs(E.length-o.length)});continue}if($){let S=Hp(y.label);if(S&&S===k){d.push({ind:y,score:5e3});continue}let A=/[/_-]/.test(y.label)||/\.[a-z0-9]+$/i.test(String(y.label||""));if(S&&A&&k.length>=4&&S.includes(k)){d.push({ind:y,score:2e3-Math.abs(S.length-k.length)});continue}}if(y.class==="Module"){let S=ri(o);if(S!==o&&S===ri(E)){let A=Qn(o);if(Ln(E,o,A)>A){d.push({ind:y,score:3e3-Math.abs(E.length-o.length)});continue}}}if(o.length>=4&&j.includes(o)){d.push({ind:y,score:1e3-Math.abs(j.length-o.length)});continue}let _=Ts(y.label),R=h.filter(S=>_.has(S)).length;R>0&&(!w||_.has(w))&&d.push({ind:y,score:R/h.length*Ua})}}if(d.sort((h,b)=>b.score-h.score),d.length){let[h,...b]=d,w=b.filter($=>$.score===h.score),v=h.score>=Ua?b.filter($=>$.score>=Ua):b;return{match:h.ind,candidates:v.slice(0,4).map($=>$.ind),tier:3,ambiguous:w.length>0}}let p=m||o.includes("/"),f=null,g=!p&&typeof $s=="function"?$s(e.proseIndex,s).filter(h=>!n||e.byId.get(h.id)?.class===n):[];if(g.length){let[h,...b]=g,w=e.byId.get(h.id);if(w){let v=b.filter($=>$.score===h.score);if(f={match:w,candidates:b.slice(0,4).map($=>e.byId.get($.id)).filter(Boolean),tier:4,ambiguous:v.length>0,matchedVia:"prose"},!f.ambiguous&&h.via!=="spell")return f}}if(!i&&o.length>=4){let h=Qn(o),b=h+1,w=[];for(let v of r){let $=Ln(String(v.label||"").toLowerCase(),o,h);if($>0)for(let k of Ts(v.label)){if($<=0)break;$=Math.min($,Ln(k,o,h))}$<b?(b=$,w=[v]):$===b&&$<=h&&w.push(v)}if(b<=h&&w.length===1)return{match:w[0],candidates:[],tier:5,ambiguous:!1,matchedVia:"fuzzy"};if(b<=h&&w.length>1&&!f){let[v,...$]=w;return{match:v,candidates:$.slice(0,4),tier:5,ambiguous:!0,matchedVia:"fuzzy"}}}return f||{match:null,candidates:[],tier:null,ambiguous:!1}}function Wa(e,t){let n=Hp(t),s=[...Ts(t)],o=[];for(let r of Ts(e))n.includes(r)||s.some(i=>ri(i)===ri(r))||oi.has(r)||Xp.has(r)||o.push(r);return o}function ti(e,t){if(!e?.match||e.tier!==3||e.matchedVia)return e;if(e.ambiguous){let s=[e.match,...e.candidates||[]],o=s.map(r=>new Set(Wa(t,r.label))).reduce((r,i)=>r.filter(a=>i.has(a)),Wa(t,s[0].label));return o.length?{match:null,candidates:[],tier:null,ambiguous:!1,unplacedWords:o,nearestLabel:hn(s.slice(0,4).map(r=>r.label))}:e}let n=Wa(t,e.match.label);return n.length?{match:null,candidates:[],tier:null,ambiguous:!1,unplacedWords:n,nearestLabel:e.match.label}:e}function cn(e,t,n={}){let{expectedClass:s=null}=n;if(!s){let o=String(t||"").trim(),r=o.replace(p$,"").trim(),i=r.match(f$);if(i){let a=r.slice(0,i.index).trim(),l=Be[i[1].toLowerCase()];if(a&&l){let c=ti(Jo(e,a,{expectedClass:l}),a);if(c?.match?.id&&!c.ambiguous)return c}}if(r&&r!==o){let a=ti(Jo(e,r,n),r);if(a?.match?.id&&!a.ambiguous)return a}return ti(Jo(e,t,n),t)}return ti(Jo(e,t,n),t)}function Nn(e,t,n){if(bs.includes(String(t||"").trim().toLowerCase())){if(!n)return{match:null,candidates:[],tier:null,ambiguous:!1,unresolvedPronoun:!0};let s=e.byId.get(n);return s?{match:s,candidates:[],tier:1,ambiguous:!1}:{match:null,candidates:[],tier:null,ambiguous:!1,unresolvedPronoun:!0}}return cn(e,t)}function ic(e,t,n){let s=[];for(let o of We(e,"defines")){if(!t.has(o.subject))continue;let r=e.byId.get(o.object);r&&r.class===n&&s.push(r)}return s}function m$(e,t,n,s={}){let o=!n||n==="Change"||n==="Commit",r=o||n==="Module",i=o||ns.has(n),a=[...r?["touches"]:[],...i?["touchesSymbol"]:[]],l=a.flatMap(c=>We(e,c)).filter(c=>c.subject===t.id).map(c=>e.byId.get(c.object)).filter(Boolean);return n&&ns.has(n)&&(l=l.filter(c=>c.class===n)),{matches:l,objMatch:t,commitSubject:!0,ambiguous:!1,candidates:[],traversal:`${a.join("+")} edges where subject = commit ${t.label}`,...s}}function w$(e,t){let n=new Set(String(t||"").toLowerCase().split(/[\s-]+/).filter(Boolean));return(e.individuals||[]).filter(s=>s.class==="Module"&&ac.has($p(s.label))).map(s=>({ind:s,named:n.has($p(s.label))?1:0,depth:String(s.label).split("/").length,fixture:b$(s.label)?1:0})).sort((s,o)=>o.named-s.named||s.depth-o.depth||s.fixture-o.fixture||String(s.ind.label).localeCompare(String(o.ind.label))).map(s=>s.ind)}function y$(e,t,n){return e==="reverse"&&(t==="imports"||t==="calls")&&(!n||n==="Module")}function Ht(e,t,{contextId:n=null,prev:s=null,pinnedObjMatch:o=null}={}){if(!t)return{matches:[],objMatch:null,candidates:[],traversal:null,ambiguous:!1};if(t.node)return c$(e,t,{contextId:n,prev:s});if(t.ambiguousParse){let T=t.candidates.map(P=>{let G=Ht(e,P,{contextId:n,prev:s});return{parsed:P,result:G,rendered:gn(P,G,e)}});return{matches:[],objMatch:null,candidates:t.candidates,traversal:null,ambiguous:!0,branches:T}}let{shape:r,kind:i,entityType:a}=t;if(r==="meta"){let T=String(t.object||"").trim(),P=T.toLowerCase(),G=(e.individuals||[]).find(K=>{if(K.class!=="SchemaClass"&&K.class!=="SchemaPredicate")return!1;if(String(K.label).toLowerCase()===P)return!0;let te=(K.attributes||[]).find(F=>F.key==="token")?.value;return te&&String(te).toLowerCase()===P});if(!G){let K=Pp(e,T);return K?{matches:[K.hit],objMatch:K.hit,candidates:[],ambiguous:!1,metaCodeClass:!0,metaFallbackText:K.text,traversal:`schema lookup for "${T}" (miss), then unique code-entity individual by label`}:{matches:[],objMatch:null,candidates:[],traversal:`schema lookup for "${T}"`,ambiguous:!1}}return{matches:[G],objMatch:G,candidates:[],traversal:`schema lookup for "${T}"`,ambiguous:!1}}if(r==="mentions"){let T=String(t.object||"").trim();return{matches:(typeof $s=="function"?$s(e.proseIndex,T):[]).map(K=>e.byId.get(K.id)).filter(Boolean),objMatch:null,candidates:[],ambiguous:!1,mentionsShape:!0,traversal:`proseIndex word lookup for "${T}"`}}if(r==="where"&&h$.test(String(t.object||"").trim())){let T=w$(e,t.object);return{matches:T,objMatch:T[0]||null,candidates:T.slice(1,5),ambiguous:!1,entryPointShape:!0,traversal:`Module individuals with an entry-point basename (${[...ac].join("/")}), ranked query-named basename first, then shallower path, then non-test path`}}if(t.modifier&&t.modifier!=="direct"&&!y$(r,i,a))return{matches:[],objMatch:null,candidates:[],ambiguous:!1,unsupportedModifier:!0,traversal:`modifier "${t.modifier}" requested for a "${i}" query \u2014 no closure traversal exists for this combination yet`};if(r==="ask"){let T=Nn(e,t.subject,n),P=Nn(e,t.object,n);if(!T.match||!P.match||T.ambiguous||P.ambiguous)return{matches:[],objMatch:P.match,candidates:P.candidates,traversal:null,ambiguous:!1,answer:null,unresolvedPronoun:!!(T.unresolvedPronoun||P.unresolvedPronoun)};let[G,K]=[T.match,P.match];i==="touches"&&K.class==="Commit"&&G.class!=="Commit"&&([G,K]=[K,G]);let te=ao[i],F=[...new Set(te?[...Rt(i),te]:Rt(i))],D=F.flatMap(B=>We(e,B)).filter(B=>B.subject===G.id&&B.object===K.id);return{matches:D,answer:t.negated?D.length===0:D.length>0,objMatch:P.match,subjMatch:T.match,candidates:[],traversal:`${F.join("+")} edge from ${G.label} to ${K.label}`,ambiguous:!1}}let l;if(o)l={match:o,candidates:[],ambiguous:!1,matchedVia:null};else{if(l=Nn(e,t.object,n),t.altObject&&t.altObject!==t.object){let T=Nn(e,t.altObject,n),P=!!l.match&&!l.ambiguous,G=!!T.match&&!T.ambiguous;!P&&G?l=T:P&&G&&l.match.id!==T.match.id&&(l={...l,ambiguous:!0,candidates:[T.match,...l.candidates||[]]})}if(t.kind==="tests"&&l.match&&!l.ambiguous&&!String(t.object||"").includes("/")){let T=K=>K.replace(/\.(?:test|spec|tests)(?=\.[^.]+$)/,""),P=T(String(t.object||"").trim().toLowerCase()),G=(e.individuals||[]).find(K=>{if(K.class!=="Module"||K.id===l.match.id)return!1;let te=String(K.label||"").toLowerCase().split("/").pop();return te!==T(te)&&T(te)===P});G&&(l={...l,ambiguous:!0,candidates:[G,...l.candidates||[]]})}}let{match:c,candidates:u,ambiguous:d,unresolvedPronoun:m,matchedVia:p,unplacedWords:f,nearestLabel:g}=l;if(!c)return{matches:[],objMatch:null,candidates:u,traversal:null,ambiguous:!1,unresolvedPronoun:m,unplacedWords:f,nearestLabel:g};if(d){let P=Mn([c,...u||[]]).slice(0,Ue).map(G=>{let K=Ht(e,t,{contextId:n,prev:s,pinnedObjMatch:G});return{candidate:G,result:K,rendered:gn(t,K,e)}});return{matches:[],objMatch:c,candidates:u,traversal:null,ambiguous:!0,branches:P}}if(r==="where"){let T=(c.attributes||[]).find(P=>P.key==="site")?.value||null;return{matches:[c],objMatch:c,candidates:u,ambiguous:d,matchedVia:p,whereShape:!0,site:T,traversal:T?`site attribute of ${c.label}`:`class + defining module of ${c.label}`}}if(r==="when"){let T=K=>String((K.attributes||[]).find(te=>te.key==="date")?.value||""),P;if(c.class==="Commit")P=[c];else{let K=["touches","touchesSymbol"].flatMap(F=>We(e,F)).filter(F=>F.object===c.id),te=new Set;P=[];for(let F of K){if(te.has(F.subject))continue;te.add(F.subject);let D=e.byId.get(F.subject);D&&D.class==="Commit"&&P.push(D)}P.sort((F,D)=>T(D).localeCompare(T(F)))}let G=P.length&&T(P[0])?[{kind:"event",class:"Commit",label:P[0].label,ids:[P[0].id],attrs:{date:T(P[0]).slice(0,10)},lane:"when"}]:[];return{matches:P,objMatch:c,candidates:u,ambiguous:d,matchedVia:p,whenShape:!0,referents:G,traversal:`touches+touchesSymbol edges where object = ${c.label}, newest commit date first`}}if(r==="whoLast"){let T=F=>String((F.attributes||[]).find(D=>D.key==="date")?.value||""),P=["touches","touchesSymbol"].flatMap(F=>We(e,F)).filter(F=>F.object===c.id),G=new Set,K=[];for(let F of P){if(G.has(F.subject))continue;G.add(F.subject);let D=e.byId.get(F.subject);D&&D.class==="Commit"&&K.push(D)}K.sort((F,D)=>T(D).localeCompare(T(F)));let te=K.length&&T(K[0])?[{kind:"event",class:"Commit",label:K[0].label,ids:[K[0].id],attrs:{date:T(K[0]).slice(0,10)},lane:"whoLast"}]:[];return{matches:K,objMatch:c,candidates:u,ambiguous:d,matchedVia:p,whoLastShape:!0,referents:te,traversal:`touches+touchesSymbol edges where object = ${c.label}, newest commit's author`}}if(i==="touches"&&c.class==="Commit")return m$(e,c,a,{candidates:u,ambiguous:d,matchedVia:p});if(r==="forward"){let T=ao[i],G=!!(T&&c.class&&ns.has(c.class))?[...new Set([...Rt(i),T])]:Rt(i);if(a&&a!=="Change"){let W=Cp(e,G),C=Ba[a];if(W.size&&!W.has(a)&&!(C&&W.has(C)))return{matches:[],objMatch:c,candidates:u,ambiguous:d,matchedVia:p,forwardGrainMiss:!0,wantClasses:[...W],traversal:`${G.join("+")} edges where subject = ${c.label} (grain mismatch: this "${i}" relation never targets a ${es(a)})`}}let te=G.flatMap(W=>We(e,W)).filter(W=>W.subject===c.id).map(W=>e.byId.get(W.object)).filter(Boolean),F=Mn(te),D=F,B="";if(a&&a!=="Change"){D=F.filter(C=>C.class===a);let W=Ba[a];if(!D.length&&W){let C=F.filter(I=>I.class===W);C.length&&(D=C,B=`, widened to ${W} subjects (no ${a} recorded)`)}}return{matches:D,objMatch:c,candidates:u,traversal:`${G.join("+")} edges where subject = ${c.label}${B}`,ambiguous:d,matchedVia:p}}if(t.modifier==="transitive")return{matches:no(e,c,{maxDepth:xp}).flat().map(G=>e.byId.get(G.id)).filter(Boolean),objMatch:c,candidates:u,ambiguous:d,matchedVia:p,traversal:`reverse dependency closure over imports+calls edges from ${c.label} (impactClosure, maxDepth=${xp})`};let h=ao[i]||Rt(i).find(T=>Ep.has(T))||null,b=!!(c.class&&ns.has(c.class));if(h&&(ns.has(a)||b)){let T=We(e,h).filter(B=>B.object===c.id),P=Mn(T.map(B=>e.byId.get(B.subject)).filter(Boolean)),G=!a||a==="Change"?P:P.filter(B=>B.class===a),K="",te=Ba[a];if(!G.length&&te){let B=P.filter(W=>W.class===te);B.length&&(G=B,K=`, widened to ${te} subjects (no ${a} recorded)`)}let F=(i==="touches"||i==="calls"||i==="uses")&&c.class==="Class"&&!We(e,"contains").some(B=>B.subject===c.id),D=F?e.byId.get(co(e,c)||""):null;if(G.length||!(F&&D))return{matches:G,objMatch:c,candidates:u,traversal:`${h} edges where object = ${c.label}${K}`,ambiguous:d,matchedVia:p}}let w=c,v=u,$=d,k=p,y="",j=Ip(e,i);if(j&&w.class&&w.class!==j){let T=cn(e,t.object,{expectedClass:j});if(T.match&&!T.ambiguous)w=T.match,v=T.candidates,$=T.ambiguous,k=T.matchedVia;else if(j==="Module"){let P=co(e,w),G=P&&e.byId.get(P);if(G)y=`, refined from ${w.label} to its containing module`,w=G;else return{matches:[],objMatch:w,candidates:v,ambiguous:$,matchedVia:k,wrongGrainMiss:!0,wantClass:j,traversal:`"${t.object}" resolved to ${es(w.class)} ${w.label} (grain mismatch: this "${i}" question needs a ${es(j)}, and no containing module could be found to refine to)`}}else return{matches:[],objMatch:w,candidates:v,ambiguous:$,matchedVia:k,wrongGrainMiss:!0,wantClass:j,traversal:`"${t.object}" resolved to ${es(w.class)} ${w.label} (grain mismatch: this "${i}" question needs a ${es(j)})`}}let E=Rt(i).flatMap(T=>We(e,T)).filter(T=>T.object===w.id);i==="cochange"&&(E=E.concat(Rt(i).flatMap(T=>We(e,T)).filter(T=>T.subject===w.id).map(T=>({...T,subject:T.object,object:T.subject}))));let _="";if(!E.length&&w.class){let T=`ext:${String(w.label).toLowerCase()}`;E=Rt(i).flatMap(P=>We(e,P)).filter(P=>String(P.object).toLowerCase()===T),E.length&&(_=` (by name, via unresolved ${T} references)`)}let R=[],S=new Set;for(let T of E){let P=e.byId.get(T.subject);P&&!S.has(P.id)&&(S.add(P.id),R.push(P))}let A,M="";if(!a||a==="Change")A=R;else{let T=R.filter(P=>P.class===a);if(T.length)A=T;else if(a!=="Module"&&R.some(P=>P.class==="Module")){let P=new Set(R.filter(G=>G.class==="Module").map(G=>G.id));A=ic(e,P,a),M=`, then ${es(a)} defined in the matched module(s)`}else A=[]}return{matches:A,objMatch:w,candidates:v,traversal:`${Rt(i).join("+")} edges where object = ${w.label}${_}${M}${y}`,ambiguous:$,matchedVia:k}}function tr(e){if(e.class==="Module")return e.label;let t=(e.attributes||[]).find(s=>s.key==="site")?.value;if(t)return String(t).split(":")[0];let n=String(e.id||"").match(/^fn:(.+)#/);return n?n[1]:"(unknown module)"}function qa(e){let t=String(e.label||e.id||"");return["Function","Method"].includes(e.class)?`function ${t}()`:t}function v$(e){let t=String(e.label||e.id||""),n=(e.attributes||[]).find(s=>s.key==="author")?.value;return n?`${t} (${n})`:t}function hn(e){return e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]}function Qo(e){let t=e.object??e.subject??"?";return`${e.entityType?Pe(e.entityType,2)+" that ":""}${e.kind} "${t}"`}function Xa(e){return No[e]?.bare||e}function $$(e){let t=Xa(e);return t.endsWith("e")?`${t}d`:`${t}ed`}function x$(e){if(!Array.isArray(e.atoms)||e.atoms.length!==2)return null;let[t,n]=e.atoms;if(t.op!=="seed"||t.ast?.node!=="allOfClass"||n.op!=="difference")return null;let s=Pe(e.entityType,2);if(n.kind==="qual")return`${s} that are not ${n.filters.join(" and not ")}`;if(n.kind!=="set"||!n.ast)return null;if(n.ast.node==="existsEdge")return`${s} that do not ${Xa(n.ast.kind)} anything`;let o=n.ast.node==="clause"?n.ast.clause:n.ast;if(!o||o.node||!o.kind)return null;let r=o.object??o.subject;return r==null?null:`${s} that do not ${Xa(o.kind)} ${JSON.stringify(String(r))}`}function Kp(e){if(!e)return null;if(e.ambiguousParse)return{english:`ambiguous: ${e.candidates.map(Qo).join(" \u2014 or \u2014 ")}`,machine:`ambiguousParse(${e.candidates.map(r=>Kp(r)?.machine).join(", ")})`};if(e.node)return{english:(e.node==="boolean"?x$(e):null)||`a compositional query (${e.node})`,machine:`composite(${e.node})`};let t=r=>JSON.stringify(String(r??"")),n=[];e.kind&&n.push(e.kind),e.negated&&n.push("negated"),e.entityType&&n.push(`entityType=${e.entityType}`),e.modifier&&e.modifier!=="direct"&&n.push(`modifier=${e.modifier}`),e.subject!=null&&n.push(`subject=${t(e.subject)}`),e.object!=null&&n.push(t(e.object));let s=`${e.shape}(${n.join(", ")})`,o;if(e.shape==="ask")o=`does "${e.subject}" ${e.negated?"not ":""}${Rs(e.kind)} "${e.object}"?`;else if(e.shape==="meta")o=`what does "${e.object}" mean, in this graph's own vocabulary?`;else if(e.shape==="mentions")o=`where is "${e.object}" mentioned?`;else if(e.shape==="where")o=`where is "${e.object}" defined?`;else{let r=e.entityType?Pe(e.entityType,2)+" that ":"";o=e.shape==="forward"?`what "${e.object}" itself ${Rs(e.kind)}`:`${r}${Rs(e.kind)} "${e.object}"`}return{english:o,machine:s}}function gn(e,t,n=null){let s=Yp(e,t,n);return t&&t.matchedVia==="fuzzy"&&t.objMatch&&!s.ambiguous&&(s.content=`assuming you meant ${t.objMatch.label}: ${s.content}`),s}function Yp(e,t,n){if(!e)return{content:`couldn't parse this as a graph question. Try: ${rc()}`,miss:!0,ambiguous:!1};if(e.node)return u$(e,t,n);if(e.ambiguousParse)return t.branches&&t.branches.length?{content:`this could mean more than one thing:
54
+ \u2026+${o.length-Ea} more`:"")}var Uu,td,Gu,Ub,qb,xa,Gb,Ur,Vb,Hb,Kb,od,Yb,Xb,Jb,Qb,Zb,ew,tw,nw,sw,ow,rw,iw,aw,cw,lw,uw,dw,pw,fw,mw,hw,gw,bw,ww,yw,Vu,vw,$w,rd,id,ad,xw,kw,Sw,Ew,jw,Ku,Yu,Aw,Xu,zr,Ju,Qu,Zu,Go,Me,Cw,Iw,gd,Ow,Mt,vd,Lw,Td,Mw,Pw,Fw,Dw,zw,Bw,Uw,Ww,ka,ed,Gr,qw,Sa,Ea,Ce=L(()=>{Yn();ks();ba();qo();Es();Uu={"mgx:importsnamespace":"imports","mgx:callscoarse":"calls","seon:declaresmethod":"defines","mgx:testscoverage":"tests","mgx:touchedbycommit":"touches","seon:containscodeentity":"contains","seon:hassupertype":"inherits","mgx:changecoupledwith":"cochange","mgx:reexports":"reexports","mgx:touchessymbol":"touchesSymbol","mgx:callssymbol":"callsSymbol","seon:usescomplextype":"imports","seon:invokesmethod":"calls","seon:history":"touches","mgx:subclassof":"inherits","mg:imports":"imports","mg:calls":"calls","mg:defines":"defines","mg:tests":"tests","mg:touches":"touches","mgx:saidinsession":"saidInSession","mgx:inreplyto":"inReplyTo","mgx:statedby":"statedBy","mgx:canonicalisedfrom":"canonicalisedFrom"};td=e=>/^(git|turn):/.test(String(e||""));Gu=30,Ub=8;qb=2,xa=25,Gb=3;Ur=10,Vb=8,Hb=3,Kb=2,od=5,Yb=4,Xb=.2,Jb=.35,Qb=.15,Zb=e=>/(^|\/)(examples?|fixtures?|samples?|demos?|benchmarks?|test-[^/]+)(\/|$)/.test(e),ew=.2,tw=.35,nw=.2,sw=.35,ow=e=>/\.cs$/i.test(e),rw=e=>/^I[A-Z]/.test(String(e||"")),iw=.2,aw=.35,cw=50,lw=.2,uw=.35,dw=.5,pw=od,fw=3,mw=4,hw=1,gw=.9,bw=.5,ww=.2,yw=.35,Vu=4,vw=2,$w=[["imports"],["calls","callsSymbol"],["inherits"],["cochange"]],rd=3,id=12,ad=.9,xw=["imports","calls","callsSymbol","inherits"],kw=.5,Sw=.6,Ew=.2,jw=.35;Ku=128,Yu=4,Aw=64,Xu=250,zr=class extends Error{};Ju=new WeakMap;Qu=40,Zu=40,Go=30;Me=(e,t)=>(e?.attributes||[]).find(n=>n.key===t)?.value||"";Cw=25,Iw=15;gd=40,Ow="tests edges are recorded module to module, so this is module-grain coverage.";Mt=15;vd=new Set(["Function","Method"]);Lw=8;Td={function:"Function",class:"Class",method:"Method",attribute:"Attribute"};Mw=8,Pw=16,Fw=4,Dw=6,zw=12,Bw=2,Uw=8,Ww=3,ka=e=>String(e||"").split(",").map(t=>t.trim()).filter(Boolean),ed=e=>String(e||"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean),Gr=e=>{let t=String(e||"").trim();return t?t.split(",").map(n=>n.trim()).filter(Boolean).length:0},qw=e=>{let t=new Map,n=e[0]??0,s=0;for(let o of e){let r=(t.get(o)||0)+1;t.set(o,r),r>s&&(s=r,n=o)}return n};Sa=20;Ea=40});function He(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wd(e){let t=String(e||"");return Pd&&(t=t.replace(Pd," ")),t.replace(/\s+/g," ").trim()}function qd(e){let t=String(e||"");t=t.replace(dy," ").replace(/\s+/g," ").trim();for(let n=0;n<3;n++){let s=t,o=t.match(cy);if(o&&(t=o[1].trim()),o=t.match(ly),o&&(t=o[1].trim()),o=t.match(Fd),o&&(t=o[1].trim()),o=t.match(Dd),o&&(t=o[1].trim()),o=t.match(zd),o&&(t=o[1].trim()),o=t.match(uy),o&&(t=o[1].trim()),o=t.match(Bd),o&&(t=o[1].trim()),o=t.match(py),o&&(t=o[1].trim()),o=t.match(fy),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(my),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(hy),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(gy),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(by),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(wy),o&&Xn.test(o[1].trim())&&(t=o[1].trim()),o=t.match(yy),o&&(t=`what ${o[2].toLowerCase()} ${o[1].trim()}`),o=t.match(vy),o&&(t=`what does ${o[1].trim()} mean`),o=t.match($y),o){let r=o[1].trim();ay(r)||(t=oy.test(r)||Xn.test(r)?r:`describe ${r}`)}if(o=t.match(xy),o){let r=o[1].trim();(Xn.test(r)||ky.test(r)||Bd.test(r)||Fd.test(r)||zd.test(r)||Dd.test(r))&&(t=r)}if(t===s)break}return t}function jy(e){let t=String(e||"");for(let n=0;n<3;n++){let s=t,o=t.match(Sy);if(o&&(t=o[1].trim()),o=t.match(Ey),o&&(t=o[1].trim()),t===s)break}return t}function Ry(e){let t=String(e||"");for(let n=0;n<3;n++){let s=t.match(_y);if(!s)break;let o=s[1].trim();if(!o||o===t)break;t=o}return t}function Cy(e){let t=String(e||""),n=t.match(Ty);if(n){let o=Vd[n[1].toLowerCase()],r=Gd[n[2].toLowerCase()];return`${o} ${r} ${n[3].trim()} and ${n[4].toLowerCase()}`}let s=t.match(Hd);return s?`which modules transitively import ${s[1].trim()}`:t}function Hr(e){return String(e||"").replace(Xw,t=>ca[t.toLowerCase()])}function _s(e){let t=Hr(e);return t=t.replace(Jw,n=>la[n.toLowerCase()]),t=t.replace(Qw,n=>ua[n.toLowerCase()]),t=t.replace(Zw,"with"),t=t.replace(ey,(n,s)=>`${s} for`),t=t.replace(ty,(n,s)=>`for ${s}`),t=t.replace(ny,(n,s)=>s),t=t.replace(Iy,"$1$2"),t=t.replace(wu,"$1ing"),t=qd(t),t=Ry(t),t=jy(t),t=Cy(t),t=Wd(t),t=Xt(t),t=t.replace(/\?{2,}\s*$/,"?"),t.replace(/\s+/g," ").trim()}function Vo(e){for(let t of[...vu,...yu]){let n=e.match(t.re);if(n)return t.to(n).replace(/\s+/g," ").trim()}return e}function Ia(e){for(let t of Oy){let n=e.match(t.re);if(n)return t.to(n).replace(/\s+/g," ").trim()}return e}function Kd(e){let t=String(e||"").match(Ly);if(!t)return null;let n=t[1].toLowerCase(),s=t[2].trim();return s?{entWord:n,predicate:s}:null}var Yw,Xw,Ud,Jw,Qw,Zw,ey,ty,ny,sy,Pd,oy,Xn,ry,iy,ay,cy,ly,Fd,Dd,zd,uy,dy,py,fy,my,hy,gy,by,wy,yy,vy,$y,xy,ky,Bd,Sy,Ey,_y,Gd,Vd,Ay,Ty,Hd,Iy,Oy,Ly,st,Qt,me,Jn=L(()=>{An();Yw=e=>new RegExp("\\b("+Object.keys(e).sort((t,n)=>n.length-t.length).map(He).join("|")+")\\b","gi"),Xw=Yw(ca),Ud=e=>new RegExp("\\b("+Object.keys(e).sort((t,n)=>n.length-t.length).map(He).join("|")+")\\b(?!\\.[a-z0-9])","gi"),Jw=Ud(la),Qw=Ud(ua),Zw=/(?<=^|\s)w\/(?=\s|$)/gi,ey=/\b(thx|thanks|thank\s+you|many\s+thanks|ty|cheers)\s+4\b/gi,ty=/\b4\s+(example|instance)\b(?!\s*[a-z])/gi,ny=/\b(this|that)\s+(class|module|function|method|attribute|variable|file|commit)\b/gi,sy=Object.keys(de).sort((e,t)=>t.length-e.length).map(He).join("|"),Pd=Fo.length?new RegExp("\\b("+[...Fo].sort((e,t)=>t.length-e.length).map(He).join("|")+")\\b\\s*,?","gi"):null;oy=new RegExp("\\b(?:"+Object.keys(de).sort((e,t)=>t.length-e.length).map(He).join("|")+")\\b","i"),Xn=/^(?:which|what|who|whose|where|when|why|how)\b/i,ry=new Set(["modules","files","packages","functions","methods","classes","attributes","fields","properties","variables","globals","commits","changes","tests","members"]),iy=/^(?:all\s+|the\s+)?(?:module|file|package|function|method|class|attribute|field|property|variable|global|commit|change|test|member)\??$/i,ay=e=>{if(iy.test(e))return!0;let t=e.replace(/\?+\s*$/,"").trim().split(/\s+/);return ry.has((t[t.length-1]||"").toLowerCase())},cy=/^(?:hi|hiya|hello|hey|yo|howdy|g'?day|yeah\s+nah|good\s+(?:morning|afternoon|evening|day)|greetings|salutations)(?:\s+(?:there|pardner|folks|friend|mate))?\s*[,.—–-]\s*(?:(?:just\s+a\s+)?quick\s+question\s*[,:—–-]?\s*)?(.+)$/i,ly=/^(?:thanks|thank\s+you|many\s+thanks|thx|ty|cheers)(?:\s+(?:so\s+much|a\s+lot|very\s+much|a\s+bunch))?\s*[,—–-]\s*(?:(?:just\s+a\s+)?quick\s+question\s*[,:—–-]?\s*)?(.+)$/i,Fd=/^(?:(?:ok(?:ay)?|aight|cool|alright|sure|right|fine|great|nice|got it|gotcha|sounds good|no worries|no problem|(?:just\s+)?(?:one|another)\s+more|another\s+one)[\s,]+)+(.+)$/i,Dd=/^(?:just\s+(?:poking\s+around|looking\s+around|browsing|exploring|checking\s+(?:this|it)\s+out)|first\s+time\s+(?:trying\s+this\s+out|using\s+this|here)|i'?m\s+new\s+(?:here|around\s+here|to\s+(?:this|all\s+this)(?:\s+(?:repo|codebase|project|app|tool|thing))?))\s*[,.—–-]\s*(.+)$/i,zd=/^(?:(?:maybe|possibly|perhaps)\s+)+(.+)$/i,uy=/^(?:please[\s,]+)+(.+)$/i,dy=/,?\s*if\s+(?:it'?s|it\s+is|that'?s|that\s+is)\s+not\s+too\s+much\s+(?:trouble|bother|hassle)\s*,?\s*/i,py=/^(?:can|could|would|will)\s+you\s+(?:please\s+)?(.+?)(?:[,\s]+please)?\??$/i,fy=/^explain\s+(?:to\s+me\s+|please\s+)*(.+?)\??$/i,my=/^tell\s+me\s+(?:please\s+)?(.+?)\??$/i,hy=/^(?:(?:would|do)\s+you\s+)?mind\s+telling\s+(?:me|us)\s+(?:please\s+)?(.+?)\??$/i,gy=/^do\s+you\s+know\s+(.+?)\??$/i,by=/^i(?:'d|\s+would)?\s+(?:(?:like|want|need)\s+to|wanna)\s+know\s+(.+?)\??$/i,wy=/^i(?:\s+was|\s+am|'m)?\s+(?:just\s+)?(?:wonder(?:ing|ed)?|curious)(?:\s+(?:if|whether|about))?\s+(.+?)\??$/i,yy=/^what\s+((?:an?\s+|the\s+)?[\w'-]+(?:\s+[\w'-]+){0,2})\s+(is|are)\??$/i,vy=/^what\s+((?:an?\s+|the\s+)?[\w'-]+(?:\s+[\w'-]+){0,2})\s+means\??$/i,$y=/^(?:show|give)\s+me\s+(?:the\s+)?(.+?)\??$/i,xy=/^(?:and|also|so|then|now|but)\s+(.+)$/i,ky=/^(?:does|do|did|is|are|was|were|has|have|had|can|could|will|would|should)\b/i,Bd=/^(?:(?:actually|no\s+wait|wait|hold\s+on|never\s+mind|scratch\s+that|on\s+second\s+thought|i\s+mean(?:t)?)[\s,.]+)+(.+)$/i;Sy=/^(?:since|although|(?:even\s+)?though|while|because|whereas|given\s+that|now\s+that)\s+.+?,\s*(.+)$/i,Ey=/^(.+?),\s*(?:since|although|(?:even\s+)?though|while|because|whereas|given\s+that|now\s+that)\s+.+$/i;_y=/^.+?(?:\s*(?:--|—|-)\s*)?\b(?:sorry|i\s+mean)\b\s*(?:--|—|-|,|:)\s*(.+)$/i;Gd=Object.freeze({imports:"importing",calls:"calling",touches:"touching",tests:"testing",exports:"exporting",contains:"containing",defines:"defining",uses:"using","inherits from":"inheriting from"}),Vd=Object.freeze({module:"modules",class:"classes",function:"functions",method:"methods",attribute:"attributes",variable:"variables",commit:"commits",file:"files"}),Ay="public|private|protected|static|abstract|constant|re-?exported|exported|tested|covered|untested|uncovered",Ty=new RegExp("^if\\s+(?:a|an|the)?\\s*("+Object.keys(Vd).join("|")+")\\s+("+Object.keys(Gd).join("|")+")\\s+(.+?),\\s*(?:is|are)\\s+(?:it|that|they|this)\\s+("+Ay+")\\??$","i"),Hd=/^if\s+(.+?)\s+(?:were|was)\s+(?:deleted|removed),?\s*what\s+(?:would|might|could)\s+(?:break|fail|be\s+affected)\??$/i;Iy=new RegExp(`^(where\\s+(?:is|are|was|were)\\s+.+?)\\s+(?:${hu.map(He).join("|")})(\\s*[?.!]*)$`,"i");Oy=Object.freeze([{re:/^what\s+(?:functions?|methods?|members?|attributes?|fields?|properties)\s+(?:are|is)\s+(?:in|inside|within)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+(?:functions?|methods?|members?|attributes?|fields?|properties)\s+(?:does|do)\s+(.+?)\s+have\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+are\s+(?:the\s+)?(?:functions?|methods?|members?|attributes?|fields?|properties)\s+(?:of|in|inside|within)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^(?:the\s+)?(?:members?|methods?|attributes?|contents)\s+of\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+is\s+(?:in|inside)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+else\s+is\s+(?:in|inside)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`what does ${e[1]} contain`},{re:/^what\s+(?:defined|declared)\s+(?:the\s+)?(?:function\s+|method\s+|class\s+|module\s+|variable\s+|constant\s+)?(.+?)\??$/i,to:e=>`where is ${e[1]} defined`},{re:/^where'?s\s+(?:the\s+)?(.+?)\s+(defined|declared|located|implemented)\??$/i,to:e=>`where is ${e[1]} ${e[2]}`},{re:/^were\s+is\s+(?:the\s+)?(.+?)\s+(defined|declared|located|implemented)\??$/i,to:e=>`where is ${e[1]} ${e[2]}`},{re:/^what\s+is\s+the\s+purpose\s+of\s+(?:the\s+)?(?!(?:an?|it|this|that|these|those)\s)(.+?)\??$/i,to:e=>`what is a ${e[1]}`},{re:new RegExp(`^what\\s+does\\s+(?:the\\s+)?(?!(?:an?|it|this|that|these|those)\\s)(.+?)\\s+do\\s+(?:${aa.map(He).join("|")})\\??$`,"i"),to:e=>`what is a ${e[1]}`},{re:/^(?:which|what)\s+(?:the\s+|all\s+)?([a-z][a-z-]*?)\s+(?:are|is)\s+(public|private|protected|static|abstract|constant|exported|re-?exported|tested|covered|untested|uncovered)\??$/i,to:e=>`${e[2].toLowerCase()} ${e[1].toLowerCase()}`},{re:/^what\s+(?:is|are)\s+(not\s+)?(tested|untested|covered|uncovered)\??$/i,to:e=>{let t=e[2].toLowerCase();return`${e[1]?t==="tested"?"untested":t==="covered"?"uncovered":t:t} modules`}},{re:/^what\s+does\s+(.+?)\s+changes?\s+together\s+with\??$/i,to:e=>`what co-changes with ${e[1]}`},{re:/^what\s+changes?\s+together\s+with\s+(.+?)\??$/i,to:e=>`what co-changes with ${e[1]}`},{re:/^how\s+many\s+commits\s+(?:are|were)\s+(?:recorded|logged)\s+(?:for|against)\s+(?:the\s+)?(.+?)\??$/i,to:e=>`how many commits touched ${e[1]}`},{re:/^who\s+(?:wrote|authored)\s+(?:the\s+)?(?!(?:commit\s+)?[0-9a-f]{7,40}\??$)(.+?)\??$/i,to:e=>`who touched ${e[1]}`},{re:/^who\s+is\s+the\s+authors?\s+of\s+(?:the\s+)?(?!(?:commit\s+)?[0-9a-f]{7,40}\??$)(.+?)\??$/i,to:e=>`who touched ${e[1]}`},{re:/^(?:does|do)\s+(?!.*\bnot\b)(.+?)\s+have\s+(?:any\s+)?(?:tests?|test\s+coverage|coverage)\??$/i,to:e=>`what tests ${e[1]}`},{re:/^(?:is|are)\s+(?!.*\bnot\b)(.+?)\s+tested\??$/i,to:e=>`what tests ${e[1]}`},{re:/^what\s+needs\s+(?:to\s+be\s+)?(?:a\s+)?(?:tested|tests?|testing|coverage|covering)\??$/i,to:()=>"untested modules"},{re:/^(?:which|what|list|show(?:\s+me)?|find)?\s*(?:the\s+|all\s+)?([a-z][a-z-]*?)\s+(?:(?:that|which)\s+)?(?:have|has|having|with)\s+no\s+tests?\??$/i,to:e=>`untested ${e[1].toLowerCase()}`},{re:/^(?:which|what|list|show(?:\s+me)?|find)?\s*(?:the\s+|all\s+)?([a-z][a-z-]*?)\s+without\s+(?:any\s+)?tests?\??$/i,to:e=>`untested ${e[1].toLowerCase()}`},{re:new RegExp(`^(?:do|does)\\s+(.+?)\\s+(${sy})\\s+(?:anything|something)(?:\\s+else)?\\??$`,"i"),to:e=>`what does ${e[1]} ${e[2]}`}]);Ly=new RegExp("^(?:which|what|who|list|show(?:\\s+me)?|find|give\\s+me)?\\s*(?:the\\s+|all\\s+)?([a-z][a-z-]*)\\s+(?:(?:that|which|who)\\s+)?(?:(?:do|does|did|are|is|was|were|have|has|can|could|will|would|should)\\s+not|cannot|can't|won't|couldn't|shouldn't|wouldn't|not)\\s+(.+)$","i");st=new Set(["what","who","which","where","when","why","how","does","do","did","is","are","was","were","the","a","an","of","to","from","at","in","on","there","something","anything","nothing","one","any","anywhere","last","usually","typically","generally","normally","often","commonly","mostly","should","would","could","can","will","shall","might","must"]),Qt=e=>String(e).replace(/\?+\s*$/,"").replace(/,/g," ").split(/\s+/).filter(Boolean),me=e=>e.flatMap(t=>String(t).toLowerCase().split(" "))});var Xd,Yd=L(()=>{Xd={source:"corpus/wordnet/*.jsonl lemmas, expanded through the regular -s/-ed/-ing inflections",generator:"scripts/generate-real-word-collisions.mjs",targets:["alongside","build","builds","built","call","calling","calls","change","changed","changes","check","checks","class","co-change","co-changes","code","commits","contain","containing","contains","couple","couples","cover","covers","declare","declares","define","defined","defines","defining","depends","derive","derives","directly","edited","execute","executes","exercise","exercises","explicitly","export","exporting","exports","expose","exposes","extend","extending","extends","fire","fires","from","grab","grabs","have","hits","hold","holds","hooked","import","importing","imports","included","indirectly","inherit","inheriting","inherits","inside","into","invoke","invokes","kick","kicks","kind","land","landed","lean","leans","live","lives","make","makes","modified","modifies","move","moves","parent","part","pass","passes","pull","pulls","re-export","re-exports","reference","references","relies","rely","require","requires","runs","share","shares","sits","subclass","subclasses","subclassing","superclass","superclasses","sure","talk","talks","tend","tends","test","testing","tests","through","together","touch","touched","touches","touching","transitively","trigger","triggers","tweaked","updated","uses","using","usually","verifies","verify","went","were","wired","with"],words:["aalging","aasing","aave","ablies","abling","aboves","absing","abuses","abusing","acauling","achinged","acolds","acquire","acquires","acyling","adelies","adenine","adenined","adenines","adenining","aditted","aerides","aerified","aerifies","aerify","affine","affined","affines","affining","afire","afires","afling","agalling","ailing","aired","airied","airies","airport","airporting","airports","airsed","airses","airted","alaing","alases","albing","alecks","aleves","aliaes","alikes","alines","alive","alives","allaing","allies","alling","alls","allying","alongsided","alongsides","alping","alting","altogether","amasses","amazes","amends","amorting","amorts","amuses","amusing","analling","anded","anoded","ansing","anuses","apart","aparts","apises","apparent","appends","appose","apposes","apsing","apsises","arab","arabis","arabs","ardent","argent","arpent","arrive","arrives","arsing","asaing","asding","aseans","ases","ashing","ashore","ashores","asing","asking","asping","asring","asses","assess","assets","assing","assure","attending","attest","attesting","attests","audited","aufing","auging","auking","aurifies","aurify","avouch","avouched","avouches","avouching","awaked","awakes","awared","awares","awling","awried","axling","baases","badded","bailed","bailing","baited","bake","bakeds","bakers","bakes","balded","balding","baling","balk","balking","balks","ball","balling","balls","ballsing","ballying","balming","band","banded","bandeds","bandied","bandsed","banked","banned","barded","barelies","barely","barses","bart","baseses","bashes","basing","basises","bass","bassed","basses","basset","bassets","bassos","bastes","basting","batses","bauded","baulks","bawded","bawling","bbsing","beaked","bean","beanos","beans","beasting","beasts","beating","beeting","begild","begilds","behave","behold","beholds","belied","belief","beliefs","belies","belikes","belizes","belles","bellies","belling","belting","bend","bended","bends","bent","benting","besets","besots","besses","bessing","best","besting","bests","beting","betting","bevies","bhanged","biered","bigger","biggers","billing","bind","binded","birded","birled","birles","biroed","birred","bising","bjsing","bladed","blanced","bland","blanda","blandaed","blanded","blands","blanked","blares","blases","blasts","bleaked","bleaks","blears","bleats","blended","blends","blesting","blests","blinded","blinds","blited","blites","bloked","blonded","bmuses","bnsing","boched","boches","boching","bocked","bode","bodilied","bodilies","boiled","boileds","bokked","bold","bolds","bolling","bonded","boners","bonked","boobed","booked","bookeds","bookend","booker","bookied","booksed","boomed","booned","boored","booted","boozed","borers","borough","bosked","bosses","botched","botches","botching","boucheed","bouchees","boucle","boucled","boucling","boughed","boughing","boules","boulle","boulles","bouses","bousing","bowers","boxers","bpsing","bragger","braggers","brakes","branded","brasses","breaked","bricks","brigged","brills","broked","brooked","bruins","brunts","brunus","bses","bsing","bugled","bugles","buhled","builders","buildups","bull","bulled","bullet","bulling","bulls","buns","bunses","bunsing","buried","burieds","burled","burleds","buses","bushes","bushing","busied","busies","busking","bussing","busying","buyied","buying","bypass","bypasses","caballing","cabals","cabbing","cabers","cabged","cabging","cables","cablin","cabling","cablins","caching","cackling","cadded","cadding","cadent","cadged","cadges","cadging","cadring","cafers","caffing","cafing","cagers","caging","cagying","caining","cajoling","cake","cakes","cakiling","caking","calcine","calean","caleans","caleying","caleys","calf","calfing","calfs","califs","calkin","calking","calkins","callaing","callas","callers","callinged","callings","callous","callowing","callows","calluna","callus","calm","calming","calmings","calmlying","calms","calquing","calvaing","calvas","calves","calving","calvings","calx","calxes","calxing","calycling","calyxing","camass","camelling","camels","camming","camoing","camping","canaing","canalling","canals","candid","candied","candled","candling","cangue","cangued","cangues","caning","canning","canoes","canting","cantling","capers","caping","caplin","caplins","capoing","capping","captain","captaining","captains","carded","carding","caring","carking","carlina","carline","carling","carlings","carlos","carning","caroling","carolling","carols","carping","carring","cart","carting","carver","carvers","carving","casaing","cashes","cashing","casking","cassies","castes","castling","casually","casuses","caters","catling","catlings","catses","catsing","catting","cattling","caul","cauline","cauling","caulking","cauls","cavaing","cave","caverns","cavilling","cavils","caving","cavying","cawing","caying","ceases","cecalling","cede","cedied","ceiling","cell","celling","celloing","cellos","cells","cellsing","cent","centing","cercises","cere","cerise","cerises","certain","certaining","certains","certifies","certify","certing","cfling","cgsing","chadded","chafed","chaffed","chafinged","chagaed","chagas","chagga","chaggaed","chaggas","chained","chainsed","chainses","chaired","chaise","chaised","chaises","chaited","chaits","chajaed","chalked","chalking","challis","champed","chanal","chanals","chanar","chanars","chance","chanced","chancels","chances","chancied","chancies","chancre","chancred","chancres","chancy","changers","channels","chanted","chanters","chanteys","chantied","chanties","chanty","chaosed","chaoses","chapped","charded","chards","charge","charged","chargers","charges","charied","charmed","charms","charred","charrs","charted","charts","chased","chasmed","chasms","chassed","chaste","chasted","chastes","chatted","chaunaed","chaused","chauses","chawed","cheaps","cheats","checkeds","checkers","checksum","checkups","cheek","cheeks","cheeps","chelas","chenned","cheops","cherts","chesting","chewas","chianed","chick","chicks","chigger","chiggers","chiling","chilling","chills","chinaed","chined","chines","chinked","chinks","chinned","chinoed","chirks","chits","chives","choanaed","chock","chocked","chocks","choked","choker","chokers","choler","cholers","chonned","choosed","chords","chores","chough","chuaned","chuck","chucks","chugged","chunga","chungaed","chungas","chunked","chunks","chyling","cialis","cicers","ciders","circed","circes","cive","cives","civies","cladded","claded","clades","clading","clads","claims","clamps","clams","clamses","clanged","clangers","clanks","clans","claps","clarks","claros","clash","clashes","clasp","clasps","classed","classic","classy","clast","clasts","clausa","clausas","clause","clauses","claver","clavers","clavus","clawing","claws","claying","clays","clean","cleans","cleanse","clerks","clever","clevers","cliing","climes","clinged","cloaks","clocks","closer","closers","closes","cloved","cloven","clovens","clover","clovers","clucks","cluing","clving","clxing","cnsing","coached","coaches","coaching","coaling","coasts","coaxer","coaxers","cobber","cobbers","cobble","cobbles","cocain","cocaining","cocains","cocked","cocker","cockers","cockle","cockles","coda","codaed","codded","coddles","coded","coders","codes","codex","codgers","codified","codifies","codling","cods","coed","coeurs","coffer","coffers","coggle","coggles","coheres","coiling","coiner","coiners","coired","coke","colaing","cold","colded","colding","colds","cole","coleus","coliing","coling","colling","collins","collying","colors","coltan","coltanning","coltans","colter","colters","colting","comalling","combats","comber","combers","come","comer","comers","comfies","comfit","comfits","comics","comints","comity","commas","comments","commes","commie","commied","commies","comming","commit","commix","commixes","commons","commute","commutes","compel","compels","compile","compiles","complies","comply","comport","comporting","comports","conched","conches","conching","concluded","cone","coneys","confer","confers","confining","confits","conged","conger","congers","conges","conjoin","conjoining","conjoins","conked","conker","conkers","constrain","constraining","constrains","contact","contacting","contacts","contadinoing","contadinos","contagion","contagioning","contagions","containeds","containers","contemn","contemning","contemns","continuing","contrail","contrailing","contrails","contriting","contriving","converse","converso","converts","convex","convey","conveys","convoke","convokes","cooked","cookeds","cookers","cookied","cooled","cooler","coolers","cooling","cooned","cooped","cooper","coopers","cooted","cooter","cooters","copalling","cope","copeck","copecks","copier","copiers","copies","copper","coppers","copses","copula","copulas","coralling","corded","core","coreference","coreferences","corer","corers","corked","corker","corkers","corner","corners","corpse","corpses","corvee","corvees","cosecs","cosher","coshers","cosmics","cosmids","cosses","costing","cotanning","cotans","cote","cotter","cotters","couch","couched","couches","couching","coude","couded","coue","coughed","coughing","coupe","coupes","coupleds","couplers","couplets","coupon","coupons","course","courses","couthed","couthing","coved","coven","covens","covereds","coverts","covet","covets","covey","coveys","cower","cowers","cowling","cowpie","cowpies","cozens","cpsing","crab","crabs","cracks","cradling","cragged","crakes","craned","cranes","cranked","cranned","crass","crasses","crawling","crawls","creaked","creaks","credited","creeks","cresting","crests","criers","cringe","cringed","cringes","crocks","crooked","crouch","crouched","crouches","crouching","croupe","croupes","crumple","crumples","cruses","crusing","cses","csing","ctened","ctenes","cubing","cuking","culling","culming","culting","cupalling","cupels","cupsing","cupule","cupules","cure","curing","curling","curses","cursing","curtain","curtaining","curtains","cusking","cusping","cussing","cuting","cutlass","cutses","cutsing","cxling","cxlving","cyanned","cyanoed","cycling","cyders","cymling","cysting","dadded","dahling","dailing","daises","daling","dall","dalliing","dalling","dallis","dalls","dallying","daloing","danced","dander","dandied","dandled","danked","dansed","danses","darded","darling","dart","dashes","dassed","dassies","dative","datives","dayses","ddsing","deafened","deafening","deafing","deaing","dean","deaned","deaning","deans","dearie","dearies","debiled","debiling","debone","deboned","debones","deboning","debrises","debted","debting","decade","decades","decalling","decease","deceases","deceive","deceives","decents","decided","deciding","deciled","deciling","declaim","declaims","declareds","declarers","declaw","declined","declining","decode","decouple","decouples","decries","deepens","deface","defaced","defaces","defacing","defame","defamed","defames","defaming","defang","defanged","defanging","defangs","defence","defenced","defences","defencing","defended","defending","defends","defensed","defenses","defensing","deference","deferences","deferenses","defiance","defianced","defiances","defiancing","defiant","defianted","defianting","defiants","defied","defies","defile","defiled","defilers","defiles","defiling","defininged","definings","definited","definites","definiting","deflate","deflates","deftness","defuse","defused","defuses","defusing","deglaze","deglazes","deicing","deified","deifying","deigned","deigning","deisted","deisting","deists","deitied","delfing","deliing","delivers","delling","demands","demised","demising","denied","denned","denning","dent","dented","dentine","dentined","dentines","denting","dentining","depart","depend","depended","deplane","deplanes","deplore","deplores","depone","deponed","deponing","depose","deposes","deprave","depraves","deprive","depriveds","deprives","derate","derates","derbies","deride","derides","deriding","derisive","derisives","deriveds","deriving","dermises","derpies","derrises","descends","designed","designing","desired","desiring","desking","desponds","dessing","destined","destines","destining","destiny","detained","detaining","detents","detest","detesting","detests","detinue","detinued","detinues","detinuing","deuses","deusing","deveined","deveining","deviced","devicing","deviled","devised","devising","dewied","dewiness","dewing","dexone","dexoned","dexones","dexoning","dhalling","dholed","dholes","dick","dicks","dieted","digger","diggers","dilling","dining","dinted","dire","direct","directed","director","directory","directs","dired","dires","dirged","dirges","dirked","disport","disporting","disports","disses","ditaed","ditted","dive","dives","divest","divine","divined","divines","divining","dmuses","docked","doleds","dolling","domine","domined","domines","domining","doobed","doomed","doored","dopeds","dories","dorked","dosing","dosses","double","doubles","douched","douches","douching","doughed","doughing","douses","dousing","dove","doves","dowers","dozers","drab","drabas","drabs","dragger","draggers","drained","draining","drakes","dranged","drecks","drilies","drive","drivels","drivens","drivers","drives","drover","drovers","drunks","druses","drusing","drylies","dses","dsing","dsling","dtsing","ducing","duding","dudses","dudsing","duking","dulies","dull","dulling","dulls","dulses","dulsing","duning","duns","duoing","duping","duples","during","dusking","eagling","earling","earses","easies","easing","easted","easting","eating","eatses","ebitted","ebooked","ebsing","echted","eclats","ecting","eddaed","eddied","eddoed","edgied","edibled","edicted","editeds","editor","editted","edsing","edtaed","educed","eduled","eelses","eerilies","eerily","effort","efforting","efforts","efting","egesting","egests","eidoses","eiraed","elan","eland","elanded","elanned","elans","elanus","elated","elegans","elided","elinted","elited","elling","elocute","elocutes","elopses","elsing","eluted","elvers","emending","emiled","emitted","emoted","emotes","emsing","enated","encode","endived","ends","energise","energises","enquire","enquires","ensile","ensure","entendring","ententing","enting","epopses","eposes","equally","equine","equines","erectly","eroses","ersing","ersted","ersting","erting","erudited","escort","escorting","escorts","eses","esing","esports","esportsing","espouse","espouses","esquire","esquires","esting","ests","eternise","eternises","ethoses","evicted","evoked","evokes","exceed","exceeding","exceeds","exchange","exchanged","exchanges","excite","excited","excites","excluded","execrate","execrates","executeds","executive","executives","executors","exegete","exegetes","exercisers","exerciseses","exerting","exerts","exhort","exhorting","exhorts","exiled","existed","exitted","exodes","exorcise","exorcisers","exorcises","exorcism","exorcisms","exorcist","exorcists","exorcize","exorcizes","expand","expanding","expands","expanse","expanses","expats","expatting","expect","expecting","expects","expend","expending","expendings","expends","expense","expenses","expensing","expert","experting","expertise","expertises","experts","expiating","expiring","expiry","expirying","explicit","explicits","explode","explodes","exploit","exploiting","exploits","exploring","expoing","exporters","exportinged","exportings","expos","exposeds","exposing","exposure","exposures","express","exsert","exserting","exserts","extant","extanting","extants","extendeds","extent","extented","extenting","extents","extern","externa","externaing","externas","externed","externing","externus","extort","extorting","extorts","extruding","fabling","fadded","failing","failling","faire","faires","fairies","faited","fake","fakers","fakes","fall","falling","fallings","falls","fallsing","falses","falsing","fanned","farces","fare","fares","fart","fasces","fassed","fasting","fawkes","fcsing","feasting","feasts","feating","fecalling","feeting","feined","feining","feisting","feists","felids","feline","felined","felining","felises","fellies","felling","felting","fend","fended","fends","feres","ferined","ferining","fesses","fessing","feting","fetting","fevers","fibers","fibre","fibres","fice","fices","fide","fides","fiends","fierce","fierces","fieries","fieris","fife","fifes","figure","figures","file","filers","files","filets","filles","filling","filses","find","finded","fine","finers","fines","fining","fiords","fireds","firm","firmas","firmers","firms","firmus","firsts","firths","fishes","fisting","fitses","fixe","fixeds","fixers","fixes","fizzes","flakes","flange","flanges","flanked","flanned","flasks","flecks","flicks","fliers","flirts","focalling","fold","folds","folies","folked","fonded","fooded","fooled","footed","forces","fore","fores","forest","forges","forked","form","fortes","fosses","fountain","fountaining","fountains","foyers","fpsing","freaked","frieds","friers","fries","frigged","frog","froms","frores","fros","frsing","fsbing","fshing","full","fulling","fulls","fuming","funded","funs","furies","furzes","fuseds","fusees","fusels","fuses","fusing","fussing","fuzing","fwsing","gabling","gabs","gadded","gaeling","gaited","galaing","galing","gall","galliing","gallina","galling","gallings","gallis","galls","gallus","gand","ganded","gander","gandied","ganked","gaoling","garb","garbs","garded","garment","garnet","gaseses","gashes","gassed","gassies","gatling","gauched","gauches","gauching","gauded","gauling","gausses","gcsing","gean","geans","gelids","gellies","gelling","gelting","genies","gent","genting","gestaing","gestes","gesting","getting","gilling","girded","girled","giroed","gisting","give","givens","gives","gladded","gladed","glanced","gland","glanded","glands","glandsed","glansed","glares","glass","glasses","glassy","gleams","glean","gleans","glides","glises","gofers","gold","golds","gonded","goners","gooded","goofed","gooked","gooned","gooped","goosed","gorals","gouached","gouaches","gouaching","governs","gpsing","graces","grad","grades","grads","graf","grafs","grafts","grails","grains","gram","gramas","gramps","grams","gran","granded","grands","grange","granged","granges","grans","grants","grapes","graphs","grases","grasps","grass","grasses","grassy","gratas","grates","gratis","graves","gravis","gray","grays","grazes","greats","grebes","greylies","greyly","groaks","groans","groats","grouch","grouched","grouches","grouching","groves","grub","grubs","grunts","gruses","gsaing","gsring","guesting","guests","guiing","guild","guilds","guiled","guiles","guilt","guilty","guises","guising","gull","gulling","gulls","guns","guses","gushes","gushing","gussing","gutses","gutsing","guying","gyrans","habits","hacked","hadded","hagged","haicks","haiked","hailing","haired","haje","hakeas","hakes","halals","hale","halfing","haling","hall","halling","halls","halming","haloing","halting","halve","halved","halves","halving","hame","hand","handed","handeds","handel","hander","handied","handled","handsed","hanged","hangers","harded","harems","hares","harked","harold","harolds","hart","harvey","hashes","hassles","hastes","hasting","hate","hats","hauling","haved","haven","havens","haves","hawked","hawses","haze","heating","heave","heaved","heaven","heaver","heaves","hectare","hectares","hefting","heired","heisting","held","helds","helixes","helling","helves","here","hets","hetting","hexine","hexined","hexines","hexining","hexose","hexoses","hhsing","hiatus","hick","hicked","hicks","hies","hilling","hilts","hind","hinded","hinged","hinges","hins","hints","hips","hire","hired","hirers","hires","hirtas","hiss","hisses","hives","hivs","hoards","hoared","hoaxed","hobbed","hoboed","hocced","hocked","hockey","hodded","hods","hoed","hogged","hoists","hokaed","holcus","holders","holdups","hole","holed","holes","holeys","holism","hollas","hollos","holm","holms","holy","homers","homied","homoed","honied","honked","honker","honkey","honkied","honored","hooches","hooching","hood","hooded","hoodeds","hoods","hooeyed","hoofed","hoofeds","hoofer","hookah","hookeds","hooker","hookeri","hookers","hookied","hookies","hooksed","hookses","hookup","hooped","hoopoed","hoopsed","hooted","hooter","hooved","hooveds","hoovers","hopers","hopied","hopped","hopple","hopples","hopsed","horded","hordes","horned","horsed","hosing","hosted","hosting","hotbed","hots","hotsed","hotted","hounds","houred","housed","houses","housing","hover","hovers","hoyaed","hrts","hses","hsing","hucked","huging","hulked","hull","hulling","hullos","hulls","hunged","hunked","huns","huoned","hushes","hushing","husked","husking","husoing","huts","hyoids","ictalling","idioted","idlies","iising","ileals","illing","images","impact","impacting","impacts","impart","imparting","impartings","imparts","impasses","impends","implore","implores","imploring","impoliting","important","importeds","importeeing","importees","importers","importinged","importings","importune","importuning","imposing","impost","imposting","imposts","improving","impure","impures","impuring","imputing","inbuilt","incise","incite","inclined","inclosed","include","includeds","includes","income","incomes","indied","indirect","indirected","indirects","indite","indited","indole","indoles","inerting","inerts","inference","inferences","infidel","influxed","info","inhabit","inhabits","inhere","inhered","inherent","inherenting","inherents","inheriteds","inheritinged","inheritings","inheritors","inheritting","inhibit","inhibits","initio","inkied","inland","inlanded","inline","inosine","inquire","inquires","insane","insert","inserting","inserts","insided","insider","insiders","insides","insist","insoles","inspire","insted","insting","intake","intakes","intending","interim","interims","intermit","intermits","inti","intied","intoed","intones","intos","intro","intron","intros","intruded","invades","invert","inverting","inverts","invites","invoice","invoices","involve","involves","iodide","ipsing","ired","ires","ironside","irsing","iruses","ises","isiing","ising","island","islanded","isling","isming","isning","isring","itsing","iuding","jailing","jakes","janned","jawses","jean","jeans","jellies","jelling","jest","jesting","jestings","jests","jetting","jigger","jiggers","jirded","jive","jives","jocked","jokers","jooked","josing","josses","joules","jove","joves","juking","julies","juning","jure","juring","juses","jussing","justes","juting","kailing","kakkes","kalaing","kaliing","kaling","kalkas","karens","karling","kelpies","kelting","kepting","kerite","kerited","kerites","khanned","kianged","kickers","kied","killing","kilned","kina","kinaed","kinda","kindas","kindle","kindly","kinds","kine","kined","king","kinged","kinked","kinks","kinned","kino","kinoed","kins","kiosks","kirk","kirked","kirks","kisses","kith","kleins","klick","klicks","knacks","knocks","knucks","koined","kooked","kookied","kuiing","kvasses","kweeked","kylies","labbed","lacced","lacied","lacked","ladded","ladder","laddied","laded","ladied","ladled","ladling","laed","lagans","lagend","lagended","lagged","lahhed","lahued","laiced","laid","laided","lairded","lake","lakes","lakhed","lallying","lamaed","lambed","lament","lammed","lamnaed","lamped","lanaied","lanated","lanced","lancer","lances","lancet","landaued","landeds","lander","landers","landler","lands","lane","lang","langed","langued","lank","lankaed","lanked","lankied","lanned","lansaed","lanseh","lanset","lapped","lapsed","lapses","lard","larded","larder","larged","laried","larked","larred","lashed","lashes","lassas","lasses","lassies","lassos","lasted","lasting","latent","latest","latesting","latests","lathed","latked","latkes","latsed","latses","latted","lauans","laud","lauded","lauder","laudes","launced","launder","lavaed","laves","lavved","lawsed","lawses","laxaed","lazied","lead","leaded","leaden","leadens","leads","leaf","leafs","leak","leaked","leaks","leal","leals","leaners","leap","leaps","learn","learns","leases","leasting","leaven","leavens","ledded","lefting","legals","legends","lemnas","lemons","lended","lender","lends","lenifies","lenify","lens","lensed","lent","lented","lenting","leon","leones","leons","lesses","lessing","letting","levants","levees","levels","levited","lewded","lianaed","lianas","liared","libels","libred","lice","lices","lick","licks","lidded","lieded","lieges","lies","life","lifers","lifes","ligand","liganded","ligans","ligers","lignes","like","likeds","likens","likes","limans","lime","limens","limes","limeys","linden","lindied","line","lineds","linens","liners","lines","linged","linied","linked","linoed","linted","liraed","lirred","lises","lisles","listes","listing","lite","liters","lites","lithes","litred","livedos","livens","livers","livias","livids","llanoed","llanos","loached","loaches","loaching","loaded","loan","loans","localling","loched","loches","loching","locked","lode","lohans","loired","lolling","loners","longed","looked","looker","looksed","loomed","looned","looped","loosed","looted","lorded","losers","losing","losses","losting","louched","louches","louching","louded","loughed","loughing","loupes","louses","lousing","louver","louvers","lover","lovers","lowans","lowers","lsding","lubing","lueses","luesing","luging","lull","lulling","lulls","lunaed","lundaed","lunged","lunned","luoing","lure","luring","lushes","lushing","luting","luxing","lynxed","mace","macers","maces","maches","mackems","mackle","mackles","madake","madakes","madded","made","mades","maes","magens","mahoes","maided","mailing","maines","maired","maizes","makers","makeups","mako","makos","male","maleos","males","maliing","maliks","maling","mall","malling","malls","malsing","malting","mameys","mandaed","manded","mane","maneds","manes","manied","manies","mankies","manned","mansed","manxed","manxes","maples","mapling","mare","mares","marges","maries","markeds","markers","markets","marling","mart","martes","masers","mases","maskeds","maskers","mass","massed","masseds","masses","masting","mate","mateds","maters","mates","mateys","mattes","mauling","maunded","maxes","maybes","maze","mazeds","mazers","mazes","mazies","mealies","mean","means","meating","mediaed","mediated","medicied","meeting","meined","meining","melees","melias","melics","melting","mend","mended","mends","mere","merelies","merely","merited","mesaing","meshing","mesning","messes","messing","meting","metrifies","metrify","mick","micks","mike","mikes","milling","mind","minded","minified","minifies","minkes","mire","mired","mires","miried","miries","miroed","mising","misses","misting","mitred","mitres","mlsing","mocked","models","modems","modes","modest","modifieded","modifiered","modifiers","modished","modishes","modisted","modistes","modses","mogens","mohaves","mohses","moired","mojave","mojaves","mold","molds","mole","moles","molest","molles","mollified","mollifies","molling","molvas","mommies","monded","mondes","monels","moneys","monked","monses","montan","montanning","montans","montes","mooched","mooches","mooching","mooded","mooned","moored","moosed","mooses","mooted","mope","mopeds","mopes","more","morels","mores","morses","mortified","mortifies","moses","moseys","moshes","mosting","mote","motels","motes","motets","motiffed","motive","motives","moue","moues","moulds","mountain","mountaining","mountains","mousing","mouthed","mouthing","moveds","movie","movies","moxies","mpsing","mrsing","msbing","mscing","mses","msging","mshing","msing","muanged","muched","muches","muching","muling","mull","mullas","mulling","mulls","mullus","muming","musaing","musding","musers","muses","mushes","mushing","musing","musings","musking","mussing","muting","mutually","myalling","myalls","myopes","nadded","nailing","naives","nakeds","nalline","nanaed","nanced","nand","nanded","nandued","nanned","narded","nashes","nasuses","nauched","nauches","nauching","nave","neating","nemine","nemined","nemines","nemining","nerves","nervies","nesses","nessing","nest","nesting","nestings","nestling","nests","netting","nevers","newlies","newting","nexted","nexting","nick","nicks","nigger","niggers","nilling","nisied","nisting","nitred","nitres","niveas","nivose","nivoses","nocked","node","noired","noires","nolling","nonuple","nonuples","nooked","nookied","nooksed","nooned","noosed","nosing","notched","notches","notching","notified","notifies","nouses","nousing","nsaing","nscing","nsfing","nsuing","nswing","nuding","nuited","nuking","null","nulling","nulls","nuns","nurses","nursing","nutses","nutsing","nuxing","oakens","oasing","oasises","oasting","oatses","obtain","obtaining","obtains","occluded","oceans","ochers","octalling","octuple","octuples","odisted","ogives","oilies","oising","olds","olefine","olefined","olefines","olefining","oleins","olive","olives","onlies","onto","onuses","opalling","opiated","oppose","opposes","opulus","opuses","oralling","orange","oranged","oranges","oses","osing","otuses","ouring","ousels","outclass","outclasses","outclassing","outdated","outing","outrigger","outriggers","ovalling","over","overs","overts","pacoses","pacs","pact","padded","padres","pads","paduses","paeans","pageant","pageses","paided","pailing","painses","paired","paks","palases","paliing","paling","palling","pallying","palming","palmses","paloing","pals","palsies","pandaed","pander","pangses","panned","pans","pansies","pant","panted","pantses","paps","para","parang","pare","parental","parented","parents","parers","pareve","pari","paries","paring","parises","parity","park","parr","parsec","parsecs","parsed","parsee","parsees","parser","parsers","parses","parted","parti","partis","partly","parts","partses","party","paruses","parvenu","parves","pasches","paso","pasoed","pasos","pasques","passages","passed","passeds","passee","passeed","passees","passel","passels","passer","passers","passims","passives","passkey","passkeys","passu","passued","passus","pasted","pasteds","pastel","pastels","paster","pasters","pastes","pasties","pasting","pastises","pasts","patases","patens","patent","patents","patient","pats","patsies","pauling","paulis","paused","pauses","pausing","pave","pavises","pawling","paws","payees","payment","pays","pbsing","peaked","pean","peans","peated","peating","pecans","pecses","pekans","pelling","pelting","pent","penting","percent","pere","pert","perting","perves","pesoing","pessed","pessing","pest","pesting","pestis","pestling","pestoing","pestos","pests","petited","petrifies","petrify","petting","phaged","pharos","pholis","phsing","pick","picks","piered","pigses","pill","pilling","pills","pinses","pinto","pintos","pisces","piss","pissed","pisseds","pisser","pissers","pisses","pistes","pisting","pith","pitses","plaided","planaed","planked","planned","planted","plashes","plated","pleads","pleats","plover","plovers","pmsing","poached","poaches","poaching","pocked","poises","pokers","polers","polies","poll","polling","pollos","polls","pommies","ponded","ponses","pooched","pooches","pooching","pooded","poofed","pooled","pooned","pooped","poored","pooved","pooves","porched","porches","porching","porked","port","portent","posers","poshes","posies","posing","posits","possed","posses","possess","posset","possets","postes","posting","potent","pouch","pouched","pouches","pouching","powers","praises","pranged","prat","prated","preference","preferences","prelims","premies","preses","presses","prexies","pricks","prigged","prises","prom","proses","proves","prunes","prunos","prunus","psaing","psas","pses","psiing","psing","pucing","puking","pula","pulas","pule","pules","puling","pullers","pullets","pulleys","pulling","pulp","pulps","pulsing","puns","pupals","pupated","pupils","pure","purelies","purely","purifies","purify","puring","purl","purls","pursing","puses","pushing","puss","pussed","pusses","pussies","pussing","pyrene","qianged","quaing","quakes","quares","quells","questing","quests","quicks","quiing","quilt","quired","quited","quoing","quolls","rabies","racies","radded","raided","railing","raises","rake","rakes","raling","rallies","rallying","ramies","ranaed","rand","randed","randied","raneed","ranges","ranied","ranked","ranted","rarelies","rarely","rarifies","rarify","rashes","rasing","rassed","rave","ravers","readies","realines","realise","realises","realizes","reallies","really","realties","realty","reaves","rebuild","rebuilds","reburies","recall","recalling","recalls","recces","reccies","recipes","recited","recites","reclines","recode","recommits","recover","recovers","redefine","redefined","redefines","redefining","redlines","reedies","reefies","reeves","referee","referees","referenceds","referent","refine","refined","refiners","refines","refining","refinings","refits","regias","regimes","regius","reined","reining","reited","reiting","rejigs","relaces","relates","relaxes","relay","relics","relict","relicts","relied","relief","reliefs","relieve","relieves","relievo","relievos","relines","relining","relish","relishes","relived","relives","remake","remakes","remise","remises","remiss","remits","remove","removes","rend","rended","rends","renins","renises","rent","rentes","renting","repands","repens","repents","repine","repined","repining","replay","replied","replies","reply","repose","reposes","requiems","requireds","requite","requites","requote","requotes","reruns","resets","reshes","reshing","reside","resides","resids","resiles","resins","resizes","respire","respires","ressing","rest","resting","restings","rests","retied","reties","reting","retire","retouch","retouched","retouches","retouching","retries","retting","reusing","reverence","reverences","revers","review","reviews","reviles","revise","revises","revive","revoke","revokes","revues","rewire","rewired","rhuses","rick","ricks","rigged","riggeds","rigger","riggers","rilling","rimies","rind","rinded","ringer","ringers","ringside","rising","risses","rive","rives","rivets","roached","roaches","roaching","rocked","rogers","roilies","rolling","rons","rooded","roofed","rooked","rookied","roomed","rooted","ropers","ropies","rosies","rosing","rouble","roubles","roughed","roughing","rounds","rouses","rousing","rove","rover","rovers","roves","rowers","rubens","rubies","rubing","rubins","rubs","rudelies","rudely","ruding","rues","rugger","ruggers","rugs","ruins","rulied","rulies","ruling","ruly","rumens","rums","rune","runes","rung","rungs","runics","runing","runt","runts","runups","ruses","rushes","rushing","rusing","rusking","russing","ruts","saales","saaling","saames","sabling","sabres","sadded","saided","sailing","saints","saises","sake","sakes","salals","saling","salk","salking","salks","salling","sallying","salols","salping","salting","salving","sand","sanded","sander","sandied","sandsed","sanned","sansed","sanses","sapling","sarded","sarees","sashes","sass","sassed","sasses","sassies","sats","saurel","save","savers","scalding","scalds","scaling","scalping","scalps","scalying","scapes","scarce","scarces","scare","scareds","scarers","scares","scarfs","scaries","scarps","scends","schick","schicks","scired","scoked","scolds","scorer","scorers","scores","scoter","scoters","scruple","scruples","sculling","seaport","seaporting","seaports","seareds","seases","seating","seaxes","secluded","secting","secure","sedans","seined","seines","seining","selling","semited","send","sended","sends","sent","senting","septing","sequine","sequines","serifs","serined","serining","serves","sesses","sessing","sets","setting","severs","sexies","sexpot","sexpots","sexpotting","sexted","sexting","shabus","shade","shadeds","shades","shadies","shafts","shagged","shake","shakens","shakers","shakes","shakies","shakos","shale","shales","shame","shameds","shames","shamus","shanged","shanked","shanks","shanned","shape","shapeds","shapers","shapes","shard","shards","shareds","sharers","shareses","sharias","shark","sharks","sharons","sharp","sharpens","sharpers","sharpie","sharpies","sharps","shart","sharts","shaveds","shavens","shavers","shaves","shawls","shawms","sheareds","shearers","shearses","sheers","sheiks","sherds","shines","shinto","shire","shires","shirks","shirrs","shited","shnooked","shocked","shocks","shoeds","shooed","shooked","shooted","shore","shoreas","shores","shorns","shorts","shotes","shover","shovers","shreds","shrews","shrive","shrives","shucks","sibs","sick","sicks","sics","sids","sieves","sifts","sights","silling","silts","sind","sinded","sing","sins","sips","sirced","sired","sirens","sires","sirred","sirs","sising","siss","sisses","sitars","site","sites","sitkas","sittas","situ","situs","sitz","sitzes","sixths","skates","skinks","skints","skirts","skits","skives","skulls","slander","slanted","slates","slices","slicks","slides","slimes","slits","slivers","slouch","slouched","slouches","slouching","slsing","smalling","smalls","smarms","smarts","smited","smites","smiths","smoked","snare","snarers","snares","snarfs","snarls","sneaked","snicks","snigger","sniggers","snits","snooked","snores","soaked","sobers","socked","solare","solares","sold","solds","solids","solling","solver","solvers","solves","sooned","sooted","sore","sorelies","sorely","sots","souchong","soughed","soughing","souked","soupies","source","soured","souses","sousing","southed","southing","sowers","spaces","spades","spalling","spanged","spare","sparers","spares","sparge","sparges","sparks","spasms","spated","spates","spazes","speaked","specks","spells","sphere","spheres","spicks","spills","spinto","spired","spirts","spited","spites","spits","splits","spoked","spooked","spores","sprigger","spriggers","sprits","spurge","squally","squares","squires","ssaing","sses","ssing","ssping","sssing","sswing","stacks","stages","stalk","stalks","stalling","standed","stands","stanks","stapes","stare","starers","stares","starets","starses","starts","starve","starves","states","staves","steads","steaked","steeds","stenting","stetting","sticks","stilts","stints","stoked","stores","stover","stovers","stoves","streaked","stringer","stringers","strive","strives","suaves","subclassed","suched","suches","suching","sucre","sucred","sudated","sudses","sudsing","suer","suered","sues","suiing","suing","suited","suites","suits","sullas","summits","sundated","sunglass","sunglasses","sunglassing","suns","superclassed","supergrass","supergrasses","sura","suraed","surd","surded","sured","surelies","sures","surety","surf","surfed","surfer","surge","surged","surges","suring","surrey","survey","suses","sussing","suture","swages","swales","swards","swarms","swarts","sweared","sweated","swerve","swifts","swined","swiped","swirled","switch","taaling","tables","tabling","tabses","tached","taches","taching","tack","tacks","tacting","tadded","taeling","tagger","taggers","tailing","tajiks","take","takens","takers","takes","tala","talaing","talas","talc","talcing","talcs","tale","talent","tales","taling","talkers","talkies","talking","talksed","talkses","talling","tallying","talons","talus","tandem","tank","tankas","tanked","tanks","tanned","taoses","tapses","tart","tarting","task","tasking","tasks","tassed","tassel","tassels","tasses","tasset","tassets","tassing","tasting","tastings","tastying","tatting","tauting","tawses","tdting","teached","teaches","teaching","teaing","teaked","teaking","tealed","tealing","teamed","teaming","teared","tearing","teased","teases","teasing","teasling","teat","teated","teating","teats","tebets","teccing","teched","teches","tectaing","tectas","tedding","teds","teed","teeing","teeming","teened","teening","teething","teeths","teffing","tegging","teiids","tejuing","tellies","temming","temping","tempting","tempts","tenched","tenches","tenching","tendeds","tenders","tendons","tenens","tenged","tenges","tenging","tenias","tenned","tenning","tennis","tennos","tenons","tenors","tensed","tenseds","tensing","tented","tenthing","tenting","tentings","tenuis","tepids","teraing","tercing","tereting","terming","terned","terning","terrifies","terrify","terses","tersing","teslaing","teslas","testaing","testas","testating","testeds","testeeing","testees","testers","testes","testied","testify","testily","testinged","testings","testis","testying","tether","tething","tetting","tevets","texans","text","texted","textes","texting","textings","texts","thaned","thanked","thanks","thanned","thecas","thefting","thefts","theist","theisting","theists","theres","thesis","thinged","tholed","tholes","thonged","thorough","thoroughs","thought","thrive","thrives","throng","throngs","throughed","throughs","thrush","thuses","ticalling","tick","ticks","tiered","tigers","tilling","tilting","tineds","tinting","tire","tired","tires","tiroed","titred","titres","titting","tnting","toasting","toasts","toeaed","toeses","toesing","togethers","told","tolds","tolling","tommies","tomtits","toneds","toners","tontining","tooled","tooned","tooted","toothed","toothing","tooting","topers","toposes","topple","topples","torch","torched","torches","torching","torting","toshed","toshes","tosked","tosking","tosses","tossing","toters","toting","totting","toucan","toucans","touchers","touchied","touchies","touchinged","touchingly","touchings","touchline","touchy","touchying","tough","toughed","toughens","toughied","toughies","toughing","toughying","touped","toupee","toupeed","touping","toured","touring","tousle","tousled","tousling","touted","towers","tracks","transitive","transitived","transitives","transitivity","treaded","treads","treated","treating","treats","treeds","trekked","trend","trends","trenting","tressing","trestling","triage","triaged","tricker","trickers","tricks","triers","trifler","triflers","trigged","trimer","trimers","trimmer","trimmers","tripper","trippers","trited","triting","troched","troches","troching","trough","troughed","troughing","troughs","troves","truced","truces","trucing","trucked","trucking","trudger","trudgers","trulies","trunks","trusting","trusts","truthed","truthing","trysting","trysts","tsetse","tsetsing","tubing","tucked","tucking","tufting","tugger","tuggers","tuling","tulles","tulling","tumses","tumsing","tuning","tuns","turing","tushed","tutting","tuxing","twanged","tweaks","tweeded","tweeds","tweeped","tweeted","tweeting","tweets","tweezed","twelved","twenty","twerked","twerped","twiced","twigged","twined","twirled","twirped","twisting","twists","twitch","ufoing","uglies","uhfing","uing","ukases","ukasing","ukes","uking","ulls","ulting","umaing","umping","unchanged","unclouded","uncouple","uncouples","uncover","uncovers","undated","undateds","undefined","unding","unedited","unhooked","uniated","uning","united","unkind","unlive","unlives","unmake","unmakes","unmated","unmodified","unqing","unsated","unsees","unsung","unsure","untouched","unusually","unwired","unyoke","unyokes","upbeated","upcasted","update","updates","updrafted","uphold","upholds","uping","upland","uplanded","upsets","upside","uptaked","upvoted","urated","urging","urling","urning","urns","ursine","uruses","usages","usaging","usaing","usas","usbegs","usbeks","uscbing","usdaed","usdaing","used","useds","user","users","ushers","usinged","usings","usmcing","usneas","usning","usns","usps","uspses","uspsing","usss","usssing","usualed","usuals","usurer","utaing","utcing","utes","uting","utning","uubing","uuhing","uuping","uuqing","uuting","uving","uziing","valiing","valing","valling","valses","valsing","valuing","valving","vandaed","vanned","varment","vasing","vassed","vasting","vedisted","vegans","veined","veines","veining","vend","vended","vends","vent","venting","verbified","verbifies","verbify","veridis","veridises","veried","verified","verifieds","verifier","verifiers","verited","veritied","verities","verity","versified","versifier","versifiers","versifies","versify","versting","versts","verting","verves","vest","vesting","vests","vetting","vianded","vilifies","vilify","vinifies","vinify","virens","vireos","vising","visits","visually","vitrifies","vitrify","vive","vives","vivifies","vivify","vivred","vocalling","vomers","vomits","voters","vouch","vouched","voucheed","vouchees","vouchers","vouches","vouching","vowers","wadded","wadses","waifed","wailed","wailing","wained","waived","waives","wake","wakens","wakers","wakes","waling","walk","walking","walks","wall","walling","wallings","walls","wallying","wand","wanded","wander","wanked","wanned","want","wanted","ware","wared","waried","warmed","warned","warped","warred","warsed","warses","wart","warted","washes","wassed","wastes","wasting","watses","wauling","wave","wavers","wawling","wayses","wbsing","weaked","weaken","wealed","wean","weaned","weans","wearer","weaved","weeked","weft","wefting","weirded","weired","wekaed","welling","welt","welting","wended","wends","wens","weres","westing","wests","wetting","whacks","whales","whanged","wharfs","whelks","whiled","whined","whirled","whirred","whists","whites","whits","wholed","wholes","whooped","whored","whores","wick","wicked","wicks","wided","width","widths","wifed","wified","wigged","wilded","wiled","wilied","wilies","willed","willing","wilted","wimped","winced","wind","wined","winged","winied","winked","winned","winoed","wiped","wipeds","wireds","wirer","wiried","wised","wisent","wish","wished","wising","wisped","witch","withal","withe","wither","withes","within","withs","withy","witsed","witted","wive","wived","wives","wizzed","wlanned","wokked","wold","wolds","wonked","wont","wooded","wooers","woofed","wooled","worded","worlds","wormed","worned","worsed","worted","woulds","wove","woves","wraith","wrasses","wreaked","wrecks","wresting","wrests","wricks","wried","wriggler","wrigglers","wringer","wringers","writhe","wswing","wussing","wyrded","xmases","yanaed","yanked","yarded","yawling","yawses","yearns","yeasting","yeasts","yelling","yessing","yetting","yolked","yorked","youthed","youthing","yuling","yuses","yussing","zaired","zaires","zanied","zend","zended","zends","zest","zesting","zests","zestying","zeuses","zeusing","zhuanged","zilling","zonked","zoomed","zooted"]}});function Ln(e,t,n){if(e===t)return 0;if(Math.abs(e.length-t.length)>n)return n+1;let s=null,o=Array.from({length:t.length+1},(r,i)=>i);for(let r=1;r<=e.length;r+=1){let i=[r],a=r;for(let l=1;l<=t.length;l+=1){let c=e[r-1]===t[l-1]?0:1,u=Math.min(o[l]+1,i[l-1]+1,o[l-1]+c);r>1&&l>1&&e[r-1]===t[l-2]&&e[r-2]===t[l-1]&&(u=Math.min(u,s[l-2]+c)),i[l]=u,u<a&&(a=u)}if(a>n)return n+1;s=o,o=i}return o[t.length]}function La(e){return/^[a-z]+$/.test(e)&&!st.has(e)&&!Oa.has(e)}function Jd(e){return zy(e)?null:Na(e,Fy,Qn(e))}function Na(e,t,n=Qn(e)){let s=n+1,o=null,r=!1;for(let i of t){let a=Ln(e,i,Math.min(s,n));a<s?(s=a,o=i,r=!1):a===s&&a<=n&&i!==o&&(r=!0)}return s<=n&&!r?o:null}var My,Qn,Oa,Py,Fy,Dy,zy,Ho=L(()=>{An();Yd();Jn();My=["used"];Qn=e=>e.length<=5?1:2,Oa=new Set([...Object.keys(de),...Object.keys(Be),...Object.keys(Gt),...My].flatMap(e=>e.split(" "))),Py=4,Fy=[...new Set([...Object.keys(de),...Object.keys(Gt)].flatMap(e=>e.split(" ")).filter(e=>e.length>=Py))],Dy=new Set(Xd.words),zy=e=>Dy.has(e)});function oo(e){for(let t of qy){let n=e.match(t.re);if(n){let s=t.build(n);if(s)return s}}return null}var Kr,By,Uy,Wy,Ma,qy,Qd,Yr=L(()=>{An();Jn();Kr=Object.keys(de).sort((e,t)=>t.length-e.length).map(He).join("|"),By=Object.keys(Be).sort((e,t)=>t.length-e.length).map(He).join("|"),Uy=Object.keys(Gt).sort((e,t)=>t.length-e.length).map(He).join("|"),Wy=ws.slice().sort((e,t)=>t.length-e.length).map(He).join("|"),Ma=(e,t)=>e==="defines"&&Po.has(t),qy=[{name:"ask",re:new RegExp(`^(?:does|do|did)\\s+(.+?)\\s+(${Kr})\\s+(.+?)\\??$`,"i"),build:e=>{let t=e[2].toLowerCase(),n=de[t];if(Ma(n,t))return null;let s=e[1].trim(),o=e[3].trim();return Mo.includes(t)&&([s,o]=[o,s]),{shape:"ask",entityType:null,modifier:"direct",kind:n,subject:s,object:o}}},{name:"reverse",re:new RegExp(`^which\\s+(${By})\\s+(?:(${Uy})\\s+)?(${Kr})\\s+(.+?)\\??$`,"i"),build:e=>{let t=e[3].toLowerCase(),n=de[t];return Ma(n,t)?null:{shape:"reverse",entityType:Be[e[1].toLowerCase()],modifier:e[2]?Gt[e[2].toLowerCase()]:"direct",kind:n,object:e[4].trim()}}},{name:"forward",re:new RegExp(`^what\\s+(?:does|do|did)\\s+(.+?)\\s+(${Kr})\\??$`,"i"),build:e=>{let t=e[2].toLowerCase(),n=de[t];return Ma(n,t)?null:{shape:"forward",entityType:null,modifier:"direct",kind:n,object:e[1].trim()}}},{name:"meta-mean",re:new RegExp(`^what\\s+(?:does|do|is|are)\\s+(.+?)\\s+(?:${Wy})\\??$`,"i"),build:e=>({shape:"meta",entityType:null,modifier:"direct",kind:"meta",object:e[1].trim()})},{name:"meta-whatis",re:new RegExp("^what\\s+(?:is|are)\\s+(?:(an?|the)\\s+)?(.+?)\\??$","i"),build:e=>{let t=e[1]?e[1].toLowerCase():null,n=Xt(e[2].trim()),s=!/\s/.test(n);if(t==="the"&&!s||!t&&!Be[n.toLowerCase()])return null;let o=n.toLowerCase();return t&&t!=="the"&&gu.some(r=>o===r||o.startsWith(`${r} `))?null:{shape:"meta",entityType:null,modifier:"direct",kind:"meta",object:gs(n)}}},{name:"mention",re:new RegExp(`^where\\s+(?:is|are|was|were)\\s+(.+?)\\s+(?:${an.map(He).join("|")})\\??$`,"i"),build:e=>({shape:"mentions",entityType:null,modifier:"direct",kind:"mentions",object:e[1].trim()})},{name:"where",re:new RegExp(`^where\\s+(?:is|are|was|were)\\s+(.+?)(?:\\s+(?:${Yt.map(He).join("|")}))?\\??$`,"i"),build:e=>({shape:"where",entityType:null,modifier:"direct",kind:"where",object:e[1].trim()})},{name:"when",re:new RegExp(`^when\\s+(?:did|does|do|was|were|is)\\s+(.+?)\\s+(?:last\\s+)?(${Kr})\\??$`,"i"),build:e=>de[e[2].toLowerCase()]==="touches"?{shape:"when",entityType:null,modifier:"direct",kind:"touches",object:e[1].trim()}:null},{name:"commit-history",re:/^(?:the\s+)?commit\s+history\s+(?:of|for)\s+(.+?)\??$/i,build:e=>({shape:"when",entityType:null,modifier:"direct",kind:"touches",object:e[1].trim()})},{name:"cochange-partners",re:/^co-?change\s+partners\s+(?:of|for|with)\s+(.+?)\??$/i,build:e=>({shape:"reverse",entityType:"Module",modifier:"direct",kind:"cochange",object:e[1].trim()})}];Qd={id:"grammar",class:"graph-query",run(e){let t=oo(e);return t?{strategyId:"grammar",class:"graph-query",candidates:[{parsed:t,confidence:.9}]}:null}}});function xt(e,t,n=null){let s=Object.keys(t).sort((o,r)=>r.split(" ").length-o.split(" ").length);for(let o of s){let r=o.split(" ");for(let i=0;i<=e.length-r.length;i+=1)if(!(n&&r.some((a,l)=>n.has(i+l)))&&r.every((a,l)=>e[i+l]===a))return{kind:t[o],start:i,end:i+r.length}}return null}function Yo(e,t=null){let n=e.replace(/\?+\s*$/,"").replace(/,/g," ").split(/\s+/).filter(Boolean),s=n.map(E=>E.toLowerCase());if(s.includes("where")&&!xt(s,de)){let E=s.some(S=>an.includes(S)),_=new Set([...Yt,...an]),R=n.filter((S,A)=>!st.has(s[A])&&!_.has(s[A])).join(" ").trim();if(R){let S=E?"mentions":"where";return{shape:S,entityType:null,modifier:"direct",kind:S,object:R}}}if(new Set(["has","have","had"]).has(s[0])){let E=s.length;for(;E>1&&(s[E-1]==="ever"||s[E-1]==="been");)E-=1;if((E>1?de[s[E-1]]:null)==="touches"){let R=n.slice(1,E-1).filter((S,A)=>!st.has(s[1+A])).join(" ").trim();if(R)return{shape:"when",entityType:null,modifier:"direct",kind:"touches",object:R}}}let r=s,i=xt(s,de);if(!i&&t){let E=s.map(_=>{if(!La(_))return _;let R=t.lemma(_);return Oa.has(R)?R:_});i=xt(E,de),i&&(r=E)}let a=null;if(!i){let E=s.map(_=>_.length>=4&&La(_)&&Jd(_)||_);if(i=xt(E,de),i){r=E;let _=s.slice(i.start,i.end).findIndex((S,A)=>S!==E[i.start+A]),R=i.start+Math.max(_,0);a={from:s[R],to:E[R]}}}let l=!1;if(!i)for(let E=0;E<s.length;E+=1){let _=Hn[s[E]];if(!(_&&s[E]==="used"&&s[E+1]==="for")&&_&&s.slice(0,E).some(R=>Ko.has(R))){i={kind:_,start:E,end:E+1},l=!0;break}}if(!i)return null;!l&&i.end-i.start===1&&Hn[s[i.start]]&&s.slice(0,i.start).some(E=>Ko.has(E))&&(l=!0);let c=E=>a?{...E,fuzzyVerb:a}:E;if(t&&i.end-i.start===1){let E=i.start,_=s[E-1];if((_==="the"||_==="these"||_==="those")&&s[E+1]==="of"&&t.posTags(n)[E]==="NOUN"){let S=n.slice(E+2).filter((A,M)=>!st.has(s[E+2+M])).join(" ").trim();if(S)return c({shape:"forward",entityType:null,modifier:"direct",kind:i.kind,object:S})}}let u=new Set,d=E=>{if(E)for(let _=E.start;_<E.end;_+=1)u.add(_)};d(i);for(let[E,_]of Object.entries(de)){if(_!==i.kind)continue;let R=E.split(" "),S=i.end;if(R.every((A,M)=>r[S+M]===A)){d({start:S,end:S+R.length});break}}let m=xt(r,Be,u);d(m);let p=xt(r,Gt,u);d(p);let f=(E,_)=>n.slice(E,_).filter((R,S)=>!u.has(E+S)&&!st.has(s[E+S])).join(" ").trim(),g=f(0,i.start),h=f(i.end,n.length);l&&!s.includes("by")&&Hy.has(h.toLowerCase())&&(h="");let b=i.kind,w=m?Be[r.slice(m.start,m.end).join(" ")]:null,v=p?Gt[r.slice(p.start,p.end).join(" ")]:"direct";if(b==="touches"&&s.includes("when")){let E=g||h;if(E)return c({shape:"when",entityType:null,modifier:"direct",kind:"touches",object:E})}if(b==="touches"&&s.includes("who")&&s.includes("last")){let E=g||h;if(E)return c({shape:"whoLast",entityType:null,modifier:"direct",kind:"touches",object:E})}let $=s.indexOf("by"),k=s.slice(0,i.start).findIndex(E=>Ko.has(E)),y=k>=0,j=y&&k>$;if($>=0&&!u.has($)&&y){let E=(S,A)=>n.slice(S,A).filter((M,T)=>{let P=S+T,G=s[P];return!u.has(P)&&!st.has(G)&&G!=="by"&&!Ko.has(G)&&!Gy.has(G)&&!Vy.has(G)}).join(" ").trim(),[_,R]=j?[E(k+1,n.length),E($+1,k)]:[E(0,$),E($+1,n.length)];if(_&&R)return b==="defines"&&Po.has(r.slice(i.start,i.end).join(" "))?null:c({shape:"ask",entityType:null,modifier:"direct",kind:b,subject:R,object:_});if(R)return c({shape:"forward",entityType:w,modifier:v,kind:b,object:R});if(_)return c({shape:"reverse",entityType:w,modifier:v,kind:b,object:_})}if(l&&$<0&&h&&s[i.start]==="called")return null;if(g&&h){let E=r.slice(i.start,i.end).join(" ");if(b==="defines"&&Po.has(E))return null;let _=g,R=h;return Mo.includes(E)&&([_,R]=[R,_]),c({shape:"ask",entityType:null,modifier:"direct",kind:b,subject:_,object:R})}if(h){let E=m&&m.start>=i.end?null:w;return c({shape:"reverse",entityType:E,modifier:v,kind:b,object:h})}if(b==="inherits"&&!g&&m&&m.start===i.end){let E=r.slice(m.start,m.end).join(" ");if(E)return c({shape:"reverse",entityType:null,modifier:v,kind:b,object:E})}if(g&&!h&&y&&i.end-i.start===1&&Hn[s[i.start]]){if(g.split(/\s+/).length>1)return null;if(b==="touches")return c({shape:"when",entityType:null,modifier:"direct",kind:b,object:g});let E=Ko.has(s[0]);return c({shape:"reverse",entityType:w,modifier:v,kind:b,object:g,...E?{polar:!0}:{}})}return g?c({shape:"forward",entityType:w,modifier:"direct",kind:b,object:g}):null}var Ko,Gy,Vy,Hy,Zd,Xr=L(()=>{An();Jn();Ho();Ko=new Set(["is","are","was","were","be","been","being","get","gets","got"]),Gy=new Set(["which","what","who","whom","whose"]),Vy=new Set(Rn.map(e=>e.toLowerCase())),Hy=new Set(["recently","lately","yet","already","ever","again"]);Zd={id:"keyword-spot",class:"graph-query",run(e,t={}){let n=Yo(e,t.nlp||null);return n?{strategyId:"keyword-spot",class:"graph-query",candidates:[{parsed:n,confidence:.7}]}:null}}});function Yy(e,t,n){if(!n||typeof n.posTags!="function"||!t.length)return[];let s=new Set(t.map(i=>i.toLowerCase())),o;try{o=n.posTags(e)}catch{return[]}let r=[];for(let i=0;i<e.length;i+=1){let a=e[i],l=a.toLowerCase();!/^[a-z]+$/.test(a)||ep.has(l)||!s.has(l)||o[i]==="VERB"&&r.push(l)}return r}function Xy(e,t=null){let n=Qt(e),s=[],o=[];for(let i of n){let a=i.toLowerCase();/^[a-z]+$/.test(i)&&!ep.has(a)&&(Ky.has(a)||t&&typeof t.isStopWord=="function"&&t.isStopWord(a))?o.push(i):s.push(i)}let r=Yy(n,s,t);return{text:s.join(" "),dropped:o,maybeNoise:r}}var ep,Ky,tp,np=L(()=>{An();Jn();Yr();Xr();ep=new Set([...st,...me(bs),...me(Object.keys(de)),...me(Object.keys(Be)),...me(Object.keys(Gt)),...me(Object.keys(Ve)),...me(ys),...me(vs),...me(Object.keys(Kn)),...me(Object.keys(fn)),...me(Object.keys(Xs)),...me(Rn),...me(Do),...me(ws),...me(Yt),...me(an),...me(_n),...me(Object.keys(Qs))]),Ky=new Set([...me(Fo),...me(Lr)]);tp={id:"noise-strip",class:"noise-stripped",run(e,t={}){if(oo(e))return null;let{text:n,dropped:s,maybeNoise:o}=Xy(e,t.nlp||null);if(!s.length||!n)return null;let r=oo(n)||Yo(n,t.nlp||null);if(!r)return null;if(o.length&&(r.shape==="where"||r.shape==="mentions")&&r.object){let i=r.object.split(/\s+/).filter(a=>!o.includes(a.toLowerCase())).join(" ").trim();i&&i!==r.object&&(r.altObject=i)}return{strategyId:"noise-strip",class:"noise-stripped",candidates:[{parsed:r,confidence:.75,note:`noise-stripped to "${n}"`}]}}}});var sp=L(()=>{});var Jr,Qr=L(()=>{Jr=()=>{}});function rp(e,t){return e.shape!==t.shape||e.kind!==t.kind?!1:e.shape==="ask"?ro(e.subject)===ro(t.subject)&&ro(e.object)===ro(t.object):ro(e.object)===ro(t.object)}function Pa(e){let t=(e||[]).filter(c=>c&&Array.isArray(c.candidates)&&c.candidates.length);if(!t.length)return null;let n=[];for(let c of t)for(let u of c.candidates)!u||!u.parsed||n.push({parsed:u.parsed,confidence:typeof u.confidence=="number"?u.confidence:.5,note:u.note||null,via:u.via||null,strategyId:c.strategyId,class:c.class});if(n.some(c=>!ip(c))&&(n=n.filter(c=>!ip(c))),!n.length)return null;let s=new Map;for(let c of n)s.has(c.class)||s.set(c.class,[]),s.get(c.class).push(c);let o=[];for(let[c,u]of s){let d=[];for(let m of u){let p=d.find(f=>rp(f.parsed,m.parsed)&&f.via===m.via);if(p){p.agreed+=1,p.confidence=Math.max(p.confidence,m.confidence),op(m.parsed)<op(p.parsed)&&(p.parsed=m.parsed);continue}d.push({...m,agreed:1})}d.length&&o.push({class:c,candidates:d})}if(!o.length)return null;let r=c=>Math.max(...c.candidates.map(u=>u.confidence)),i=o[0];for(let c of o)r(c)>r(i)&&(i=c);let a=i.candidates.length===1?i.candidates[0].parsed:{ambiguousParse:!0,candidates:i.candidates.map(c=>c.parsed)},l=o.filter(c=>c!==i).map(c=>c.candidates[0]).filter(c=>!i.candidates.some(u=>rp(u.parsed,c.parsed)));return{class:i.class,parsed:a,winner:i.candidates[0],alternates:l}}function Zy(e){if(!e)return"something else";if(e.ambiguousParse)return"one of several readings";let t=e.object??e.subject??"?";return`${e.kind} "${t}"`}function ap(e,{describe:t=Zy,answerFor:n=null}={}){return(e||[]).map(s=>{let o=s.note||t(s.parsed),r=n&&n(s)||"ask it that way";return`if you mean ${o} then ${r}`})}var ro,Jy,op,Qy,ip,Fa=L(()=>{ro=e=>String(e||"").trim().toLowerCase().replace(/\s+/g," ").replace(/^(?:the|a|an)\s+/,"").replace(/^commit\s+(?=[0-9a-f]{7,40}$)/,""),Jy=/^\s*(?:the|a|an)\s+/i,op=e=>[e?.subject,e?.object].filter(t=>Jy.test(String(t||""))).length;Qy=new Set(["fuzzy","lemma","spell"]),ip=e=>Qy.has(e.via)});function Zr(e){Da=e}function ei(){return typeof Da=="function"?Da():null}var Da,io=L(()=>{Da=null});function up(e,t={},n=tv){let s=[];for(let o of n)try{let r=o.run(e,t);r&&typeof r.then!="function"&&s.push(r)}catch{}return s}var ev,tv,dp=L(()=>{Jn();Yr();Xr();np();sp();Qr();Fa();io();ev=[...typeof void 0<"u"?[void 0]:[],...typeof void 0<"u"?[void 0]:[]],tv=[Qd,Zd,tp,...ev]});var Xo,za=L(()=>{Xo=(e,t,n)=>n});var Zp={};En(Zp,{DYNAMIC_TAIL_OK_RE:()=>lc,applyNegationFrames:()=>Vo,ask:()=>ss,classDisplayName:()=>es,degreeMetric:()=>qp,metaFallbackEntityAnswer:()=>Pp,normalizeQuery:()=>_s,parseQuery:()=>er,parseQueryFull:()=>Qa,render:()=>bn,rephraseHint:()=>rc,resolveObject:()=>cn,traverse:()=>Ht});function We(e,t){let n=pp.get(e);n||(n=new Map,pp.set(e,n));let s=n.get(t);if(s)return s;let o=[];for(let r of e.relations)if(On(r)===t)for(let i of r.edges)o.push(i);return n.set(t,o),o}function Pe(e,t){let[n,s]=jp[e]||["result","results"];return t===1?n:s}function nr(e,t,n,s={}){return!e||!t.length?[]:[{kind:"set",class:e,label:`${t.length} ${Pe(e,t.length)}`,ids:t.map(o=>o.id),attrs:{count:t.length},lane:n,...s}]}function es(e){let t=String(e||"");if(typeof mn=="function"){let n=mn(t).join(" ");if(n)return n}return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase()}function Rs(e){return sv[e]||e}function cv(e){if(!e?.ambiguousParse||!Array.isArray(e.candidates)||e.candidates.length!==2)return e;let t=e.candidates.find(r=>r?.shape==="meta"),n=e.candidates.find(r=>r!==t);if(!t||!n)return e;let s=String(t.object||"").trim().toLowerCase();if(!s||av.has(s))return e;let o=String(n.object||"").trim().toLowerCase();return me(ws).includes(o)?t:e}function er(e,{nlp:t=void 0}={}){return Qa(e,{nlp:t}).parsed}function Qa(e,{nlp:t=void 0}={}){let n=t===void 0?ei():t,s=String(e||"").trim().replace(/\s+/g," ");if(!s)return{parsed:null,alternates:[],class:null};let o=Ia(Vo(_s(s)));if(!o)return{parsed:null,alternates:[],class:null};let r=uv(o,n);if(r)return{parsed:r,alternates:[],class:null};let i=Pa(up(o,{nlp:n,raw:s}));return i?{parsed:cv(i.parsed),alternates:i.alternates||[],class:i.class||null}:{parsed:null,alternates:[],class:null}}function Va(e,t){return t.length&&Rp.has(t[0])?{bw:e.slice(1),blc:t.slice(1)}:{bw:e,blc:t}}function lo(e,t){return oo(e)||Yo(e,t)}function uv(e,t){let n=Qt(e),s=n.map(o=>o.toLowerCase());return Tv(n,s)||Iv(n,s)||mv(n,s,t)||Tp(e,t,0)||Ov(n,s,t)||gv(n,s,t)||kv(n,s,t,0)||Ev(n,s)||Rv(n,s,t)||Lv(n,s,t)||Fv(n,s,t)||zv(n,s,t,0)||Pv(n,s,t,0)||ec(n,s,t,0)||wv(n,s,t)||pv(n,s)||Np(n,s,t,0)}function pv(e,t){let n=0;dv.has(t[n])&&(n+=1);let s=kt(t[n]);if(!s||s.placeholder||!s.entityType)return null;let o=s.entityType;n+=1;let r=f=>f+1<t.length?bu[`${t[f]} ${t[f+1]}`]:void 0,i=r(n);if(!i)return null;let a=n+2,l=-1,c;for(let f=a;f+1<t.length;f+=1){let g=r(f);if(g){l=f,c=g;break}}if(l<0)return null;let u=e.slice(a,l).join(" ").trim(),d=e.slice(l+2).join(" ").trim();if(!u||!d)return null;let m=(f,g)=>f.role==="object"?{shape:"reverse",kind:f.kind,entityType:o,modifier:"direct",object:g}:{shape:"forward",kind:f.kind,modifier:"direct",object:g},p=m(i,u);return p.entityType=o,{node:"boolean",entityType:o,atoms:[{op:"seed",kind:"set",ast:{node:"clause",clause:p}},{op:"intersection",kind:"set",ast:{node:"clause",clause:m(c,d)}}]}}function ni(e,t){return{node:"boolean",entityType:e,atoms:[{op:"seed",kind:"set",ast:{node:"allOfClass",entityType:e}},t]}}function mv(e,t,n){if(!["do","does","did"].includes(t[0])||!fv.has(t[1]))return null;let s=kt(t[2]);if(!s||s.placeholder||!s.entityType)return null;let o=s.entityType;if(o==="Change")return{node:"miss",reason:`"${t[2]}" isn't an enumerable kind \u2014 a universal check needs a concrete kind (functions, classes, modules, \u2026)`};let r=t[2],i=e.slice(3),a=t.slice(3);if(!i.length)return null;let l=xt(a,de);if(!l)return{node:"miss",reason:"a universal check needs a known relation verb (import, call, inherit from, test, \u2026)"};let u=i.filter((m,p)=>(p<l.start||p>=l.end)&&!st.has(a[p])&&a[p]!=="from").join(" ").trim();if(!u)return null;let d=uo(`which ${r} ${i.join(" ")}`,n,1);return!d||d.node==="miss"?{node:"miss",reason:d&&d.reason||"the universal clause didn't parse"}:{node:"universal",entityType:o,kind:l.kind,object:u,complement:ni(o,{op:"difference",kind:"set",ast:d})}}function Tp(e,t,n=0){let s=Kd(e);if(!s)return null;let o=kt(s.entWord);if(!o||o.placeholder||!o.entityType)return null;let r=o.entityType;if(r==="Change")return{node:"miss",reason:`"${s.entWord}" isn't an enumerable kind \u2014 a set complement needs a concrete kind (functions, classes, modules, \u2026)`};let i=Qt(s.predicate),a=i.map(d=>d.toLowerCase());if(a.length&&a.every(d=>Ve[d]))return ni(r,{op:"difference",kind:"qual",filters:a});let l=xt(a,de);if(!l)return{node:"miss",reason:"a negated set query needs a known relation verb (import, call, inherit from, test, \u2026)"};if(!i.filter((d,m)=>(m<l.start||m>=l.end)&&!st.has(a[m])&&a[m]!=="from").length)return ni(r,{op:"difference",kind:"set",ast:{node:"existsEdge",entityType:r,kind:l.kind}});let u=uo(`which ${s.entWord} ${s.predicate}`,t,n+1);return!u||u.node==="miss"?{node:"miss",reason:u&&u.reason||"the negated clause didn't parse"}:ni(r,{op:"difference",kind:"set",ast:u})}function gv(e,t,n){let s=0;for(;s<t.length&&hv.has(t[s]);)s+=1;if(!["do","does","did"].includes(t[s]))return null;s+=1;let o=e.slice(s),r=t.slice(s),i=r.indexOf("not");if(i<0)return null;let a=xt(r,de);if(!a)return null;let c=o.filter((u,d)=>d!==i&&(d<a.start||d>=a.end)&&r[d]!=="from"&&!st.has(r[d])).join(" ").trim();return c?{node:"forwardComplement",kind:a.kind,subjectTerm:c}:null}function Cp(e,t){let n=new Set;for(let s of t)for(let o of We(e,s)){let r=e.byId.get(o.object);r&&r.class&&n.add(r.class)}return n}function Ip(e,t){let n=Rt(t),s=n.filter(r=>!Ep.has(r)),o=Cp(e,s.length?s:n);return o.size===1?[...o][0]:null}function uo(e,t,n){if(n>_p)return{node:"miss",reason:"too deep to resolve"};let s=Tp(e,t,n);if(s)return s;let o=Qt(e),r=o.map(c=>c.toLowerCase()),i=ec(o,r,t,n);if(i)return i;let a=Np(o,r,t,n);if(a)return a;let l=lo(e,t);return l?{node:"clause",clause:l}:null}function ec(e,t,n,s){for(let o=1;o<t.length;o+=1){let r=_n.includes(t[o]),i=!r&&Ap(t[o]);if(!r&&!i||r&&o+1>=t.length||!kt(t[o-1]))continue;let l=e.slice(0,o-1);if(!l.length||l.every(m=>Ve[m.toLowerCase()]))continue;let c=lo([...l,Ga].join(" "),n);if(!c||c.shape!=="reverse"&&c.shape!=="forward"||c.modifier&&c.modifier!=="direct")continue;let u=`which ${t[o-1]} ${e.slice(r?o+1:o).join(" ")}`,d=uo(u,n,s+1);return!d||d.node==="miss"?d?{node:"miss",reason:d.reason||"inner clause didn't parse"}:{node:"miss",reason:"inner clause didn't parse"}:{node:c.shape==="reverse"?"reverseSet":"forwardSet",kind:c.kind,entityType:c.entityType,inner:d}}return null}function wv(e,t,n){for(let s=0;s<t.length;s+=1){if(!bv.has(t[s])||t[s-1]==="of")continue;let o=s===t.length-1,r=s+1<t.length&&!!de[t[s+1]];if(!o&&!r)continue;let i=[...e.slice(0,s),Ga,...e.slice(s+1)],a=lo(i.join(" "),n);if(!(!a||a.shape!=="reverse"&&a.shape!=="forward")&&a.object===Ga&&!(a.modifier&&a.modifier!=="direct"))return{node:a.shape==="reverse"?"reverseSet":"forwardSet",kind:a.kind,entityType:a.entityType,inner:{node:"prevSet"}}}return null}function kv(e,t,n,s=0){if(t[0]!=="when")return null;let o=1;if(!yv.has(t[o]))return null;o+=1;let r=-1;for(let d=t.length-1;d>=o;d-=1)if(vv.has(t[d])){r=d;break}if(r<0)return null;let i=e.slice(o,r),a=t.slice(o,r);for(;a.length&&$v.has(a[a.length-1]);)i=i.slice(0,-1),a=a.slice(0,-1);for(;a.length&&xv.has(a[0]);)i=i.slice(1),a=a.slice(1);if(!i.length||!a.some(d=>_n.includes(d)))return null;let l=Za.has(a[0])?i.join(" "):`which ${i.join(" ")}`,c=uo(l,n,s+1);if(!c||c.node==="miss")return c?{node:"miss",reason:c.reason||"the inner set of the temporal query didn't parse"}:{node:"miss",reason:"the inner set of the temporal query didn't parse"};let u=kt(a[0]);return{node:"temporal",inner:c,entityType:u&&u.entityType||null}}function Ev(e,t){if(t[0]!=="what"||t[1]!=="changed")return null;let n=2;if(t[n]==="ever"&&(n+=1),!Sv.has(t[n]))return null;let s=t[n],o=e.slice(n+1).join(" ").trim();return o?{node:"commitFilter",op:s,pivotRaw:o}:{node:"miss",reason:`"what changed ${s}" needs a date or commit afterward`}}function _v(e){let t=new Set,n=[];for(let s of e){if(!s||!jv.test(s))continue;let o=s.toLowerCase();t.has(o)||(t.add(o),n.push(s))}return n}function Rv(e,t,n){if(t.length===2&&t[0]==="which"&&(t[1]==="ones"||t[1]==="one"))return{node:"anaphora",mode:"list",filter:{type:"all"}};let s=-1,o=!1;for(let d=1;d<t.length;d+=1){if(!Do.includes(t[d]))continue;if(t[d-1]==="of"){s=d,o=!0;break}let m=t.slice(0,d).join(" ");if(d===t.length-1&&(ys.includes(m)||vs.includes(m))){s=d;break}}if(s<0)return null;let r=(o?t.slice(0,s-1):t.slice(0,s)).join(" "),i=ys.includes(r)||/^(how many|how much|count|number|quantity|total)\b/.test(r)?"count":"list",a=Av(e.slice(s+1),n);if(a===void 0)return{node:"miss",reason:"the follow-up filter didn't parse"};let l=o?s-1:s,c=_v(e.slice(0,l)),u={node:"anaphora",mode:i,filter:a};return c.length>=2&&(u.candidateTerms=c),u}function Av(e,t){let n=0,s=e.map(a=>a.toLowerCase());for(;n<s.length&&lv.has(s[n]);)n+=1;let o=e.slice(n),r=s.slice(n);if(!o.length)return{type:"all"};if(r.every(a=>Ve[a]))return{type:"qual",filters:r};if(o.length===1){let a=kt(r[0]);if(a&&!a.placeholder&&a.entityType)return{type:"entity",entityType:a.entityType}}let i=lo(`what ${o.join(" ")}`,t);if(i&&(i.shape==="reverse"||i.shape==="forward")&&i.object)return{type:"clause",clause:i}}function Tv(e,t){let n;if(t[0]==="is"&&t[1]==="there")n=2;else if(t[0]==="are"&&t[1]==="there")n=2;else return null;let s=t[n];if(s==="a"||s==="an"||s==="any")n+=1;else return null;let o=n<t.length?kt(t[n]):null;if(!o||o.placeholder||!o.entityType)return null;let r=o.entityType;n+=1;let i=t.slice(n),a=e.slice(n);if(i.length&&i[i.length-1]==="anywhere"?(i=i.slice(0,-1),a=a.slice(0,-1)):i.length>=2&&i[i.length-2]==="at"&&i[i.length-1]==="all"&&(i=i.slice(0,-2),a=a.slice(0,-2)),!i.length)return{node:"exists",entityType:r,term:null,scopeModule:null};if(i[0]==="called"||i[0]==="named"){if(i.length<2)return{node:"miss",reason:`"${i[0]}" needs a name afterward`};let l=i.indexOf("in",1);if(l>0){let u=a.slice(1,l).join(" ").trim(),d=a.slice(l+1).join(" ").trim();return!u||!d?{node:"miss",reason:'a named existence check needs both a name and a module after "in"'}:{node:"exists",entityType:r,term:u,scopeModule:d}}let c=a.slice(1).join(" ").trim();return c?{node:"exists",entityType:r,term:c,scopeModule:null}:{node:"miss",reason:`"${i[0]}" needs a name afterward`}}if(i[0]==="in"){let l=a.slice(1).join(" ").trim();return l?{node:"exists",entityType:r,term:null,scopeModule:l}:{node:"miss",reason:'"in" needs a module afterward'}}return null}function Cv(e,t){if(!t.length)return null;let n=`${e} ${t.join(" ")}`,s=gs(n).slice(e.length).trim(),o=Qt(s),r=o.findIndex(a=>a.toLowerCase()==="in");if(r<0)return null;let i=o.slice(r+1).join(" ").trim();return i?{scope:i}:{node:"miss",reason:'"in" needs a scope afterward'}}function Iv(e,t){if(t[0]!=="is"&&t[0]!=="are"||t[1]==="there")return null;let n=-1,s=!1;for(let c=1;c<t.length;c+=1)if(Ve[t[c]]){n=c,s=t[c-1]==="not";break}if(n<0)return null;let o=t.indexOf("by",n+1);if(o>0&&Hn[t[n]]){let c=o+1;for(;c<t.length&&(t[c]==="the"||t[c]==="a"||t[c]==="an");)c+=1;let u=t[c];if(u&&!$u.has(u))return null}let r=Cv(t[n],e.slice(n+1));if(r?.node==="miss")return r;let i=1;t[i]==="the"&&(i+=1);let a=s?n-1:n;a>i&&(t[a-1]==="a"||t[a-1]==="an")&&(a-=1);let l=a>i?e.slice(i,a).join(" ").trim():"";return l?{node:"qualCheck",term:l,qualifier:t[n],negated:s,scope:r?.scope||null}:{node:"miss",reason:'"is/are <qualifier>" needs a named thing to check first'}}function Ov(e,t,n){if(!["do","does","did","is","are","was","were"].includes(t[0]))return null;let s=t.indexOf("not",1);if(s<0)return null;let o=lo(e.filter((r,i)=>i!==s).join(" "),n);return!o||o.shape!=="ask"?null:{...o,negated:!0}}function Lv(e,t,n){let s=ys.find(d=>t.slice(0,d.split(" ").length).join(" ")===d);if(!s)return null;let o=s.split(" ").length;for(;o<t.length&&(t[o]==="the"||t[o]==="a"||t[o]==="all");)o+=1;let r=[];for(;o<t.length&&Ve[t[o]];)r.push(t[o]),o+=1;let i=o<t.length?kt(t[o]):null;if(!i)return{node:"miss",reason:"count needs a known entity kind (functions, classes, modules, \u2026)"};let a=t[o];o+=1;let l=e.slice(o),c=t.slice(o).some(d=>!st.has(d)&&!Op.has(d)),u;if(c){let d=uo(`which ${a} ${l.join(" ")}`,n,1);if(!d||d.node==="miss")return{node:"miss",reason:"the count restrictor didn't parse"};u=d}else u={node:"allOfClass",entityType:i.entityType};return r.length&&(u={node:"qualifier",filters:r,inner:u}),{node:"count",entityType:i.entityType,base:u}}function Pv(e,t,n,s){let o=0,r=!1,i=null;for(let w of Nv){let v=w.split(" ");if(t.slice(0,v.length).join(" ")===w){i=w,o=v.length;break}}if(!i)if(t[0]==="what"||t[0]==="which")r=!0,o=1;else return null;for(;o<t.length&&tc.has(t[o]);)o+=1;let a=[];for(;o<t.length&&Ve[t[o]];)a.push(t[o]),o+=1;let l=o<t.length?kt(t[o]):null;if(!l||l.placeholder||l.entityType==="Change")return!r&&o<t.length&&o===t.length-1&&/^[a-z]+$/.test(t[o])&&!de[t[o]]&&!Rn.includes(t[o])?{node:"miss",reason:`"${t[o]}" isn't a listable kind \u2014 try ${Lp}`}:null;let c=l.entityType,u=t[o];o+=1;let d=e.slice(o),m=t.slice(o).some(w=>!st.has(w)&&!Op.has(w)),p=t.slice(o),f=d;(p[0]==="is"||p[0]==="are")&&(p=p.slice(1),f=f.slice(1));let g=r&&Mv.has(p[0]);if(r&&(m&&!g||d.length===0))return null;let h,b=!1;if(m){let w=g?f:d,v=uo(`which ${[...a,u,...w].join(" ")}`,n,(s||0)+1);if(!v||v.node==="miss")return{node:"miss",reason:v&&v.reason||"the list filter didn't parse"};h=v,b=!0}else h={node:"allOfClass",entityType:c},a.length&&(h={node:"qualifier",filters:a,inner:h});return{node:"list",entityType:c,base:h,scoped:b}}function Fv(e,t,n){let s=null,o=-1;for(let f=0;f<t.length;f+=1){let g=t.slice(f,f+2).join(" ");if(Kn[g]){s=Kn[g],o=f;break}if(Kn[t[f]]){s=Kn[t[f]],o=f;break}}if(!s)return null;let r=null,i=null;for(let f=o;f<t.length;f+=1)if(fn[t[f]]){r=fn[t[f]],i=t[f];break}if(!r){for(let f=o-1;f>=0;f-=1)if(fn[t[f]]){r=fn[t[f]],i=t[f];break}}let a=t.includes("connected")||t.slice(o,o+2).join(" ")==="most connected"||["largest","biggest","smallest"].includes(t[o]),l=["important","significant","central","key","core","essential","critical","principal"],c=t.some(f=>l.includes(f));!r&&(a||c)&&(r=fn.connections,i="connections");let u,d=null;for(let f of t){let g=kt(f);if(g&&!g.placeholder){u=g.entityType,d=f;break}}if(!d&&(u=i?xu[i]:void 0,!u))return{node:"miss",reason:"a superlative needs an entity kind (module, class, function, \u2026)"};if(!r)return{node:"miss",reason:"name what to rank by (imports, callers, methods, tests, or connections)"};let m=["needs","need","needing","lacks","lack","lacking","misses","missing"],p=t.some(f=>m.includes(f))?s==="most"?"fewest":"most":s;return{node:"superlative",entityType:u,metric:r,metricNoun:i,extreme:p}}function zv(e,t,n,s){if(t[0]!=="find")return null;let o=1;for(;o<t.length&&tc.has(t[o]);)o+=1;if(o>=t.length)return null;let r=kt(t[o]);if(r&&!r.placeholder&&r.entityType!=="Change"&&o+1<t.length&&Dv.has(t[o+1])){let a=e.slice(o+2).join(" ").trim();if(a)return{node:"find",entityType:r.entityType,term:a}}let i=kt(t[t.length-1]);if(i&&!i.placeholder&&i.entityType!=="Change"){let a=e.slice(o,t.length-1).join(" ").trim();if(a)return{node:"find",entityType:i.entityType,term:a}}return t.some(a=>_n.includes(a))?null:o===t.length-1&&/^[a-z]+$/.test(t[o])&&!de[t[o]]&&!Rn.includes(t[o])?{node:"miss",reason:`"${t[o]}" isn't a listable kind \u2014 try ${Lp}`}:null}function Bv(e,t){if(t[0]!=="find")return null;let n=1;for(;n<t.length&&tc.has(t[n]);)n+=1;let s=-1;for(let i=n+1;i<t.length;i+=1)if(_n.includes(t[i])){s=i;break}if(s<0)return null;let o=kt(t[s-1]);if(!o||o.placeholder||o.entityType==="Change")return null;let r=e.slice(n,s-1).join(" ").trim();return r?{entityType:o.entityType,term:r,relIdx:s}:null}function Uv(e,t,n,s,o,r){let{branches:i,ops:a}=si(n,s),l=null,c=[];for(let u=0;u<i.length;u+=1){let d=i[u],m=d.map(w=>w.toLowerCase()),p=u===0?"intersection":a[u-1],f=Va(d,m);if(f.blc.length&&f.blc.every(w=>Ve[w])){c.push({op:p,kind:"qual",filters:f.blc});continue}if(m[0]==="of"||m[0]==="in"){c.push({op:p,kind:"set",ast:{node:"membership",entityType:e,term:d.slice(1).join(" ")}});continue}let g=d,h=xt(m,de);h?l=d.slice(h.start,h.end):l&&(g=[...l,...d]);let b=Mp(`${t} ${g.join(" ")}`,o,r);if(!b||b.node==="miss")return{miss:b&&b.reason||"a clause in the combination didn't parse"};c.push({op:p,kind:"set",ast:b})}return{atoms:c}}function Np(e,t,n,s){let o=Bv(e,t);if(o){let{entityType:R,term:S,relIdx:A}=o,M=t.slice(A+1),T=e.slice(A+1);if(!M.length)return{node:"miss",reason:`a relative clause needs a predicate after "${t[A]}"`};let P=Uv(R,`which ${t[A-1]}`,M,T,n,s+1);if(P.miss)return{node:"miss",reason:P.miss};let G=[{op:"seed",kind:"set",ast:{node:"find",entityType:R,term:S}},...P.atoms];return G.length===1?G[0].ast:{node:"boolean",entityType:R,atoms:G}}let r=0;for(;r<t.length&&Za.has(t[r]);)r+=1;let i=r>0,a=[];for(;r<t.length&&Ve[t[r]];)a.push(t[r]),r+=1;let l=r<t.length?kt(t[r]):null;if(!l){let R=r+1<t.length?kt(t[r+1]):null;if(fp.has(t[r])&&R&&R.entityType==="Commit"&&r+2===t.length)return{node:"recentCommits"};if(Rp.has(t[r])){let S=r+1;S<t.length&&(t[S]==="the"||t[S]==="a"||t[S]==="an")&&(S+=1);let A=S+1<t.length?kt(t[S+1]):null;if(fp.has(t[S])&&A&&A.entityType==="Commit"&&S+2===t.length)return{node:"recentCommits"}}return(i||a.length)&&R&&/^[a-z]+$/.test(t[r])&&!de[t[r]]&&!st.has(t[r])&&!cc.has(t[r])?{node:"find",entityType:R.entityType,term:e[r]}:null}let c=l.entityType,u=t[r];r+=1;let d=t.slice(r),m=e.slice(r),p=!1;d.length&&_n.includes(d[0])&&(p=!0,d=d.slice(1),m=m.slice(1));let f=d[0]==="of"||d[0]==="in",g=d.length>0&&Ap(d[0]),h=m.length>0&&si(d,m).branches.some(R=>{let{blc:S}=Va(R,R.map(A=>A.toLowerCase()));return S.length&&S.every(A=>Ve[A])}),b=m.length>0?si(d,m).branches:[],w=!1;if(b.length>1){let R=b[0].map(A=>A.toLowerCase()),S=xt(R,de);S&&S.start===0&&(w=b.slice(1).every(A=>{let M=A.map(P=>P.toLowerCase()),T=xt(M,de);return T&&T.start===0?T.kind===S.kind:!T}))}let v=!1;if(b.length>1){let R=b[0].map(A=>A.toLowerCase()),S=xt(R,de);S&&S.start===0&&(v=b.slice(1).every(A=>{let M=A.map(P=>P.toLowerCase()),T=xt(M,de);return!!T&&T.start===0&&T.end-T.start===1}))}if(!(a.length||p||f||g||h||w||v))return null;if(!m.length){let R={node:"allOfClass",entityType:c};return a.length?{node:"qualifier",filters:a,inner:R,entityType:c}:{node:"miss",reason:"nothing to filter or traverse"}}let $=l.placeholder?"what":`which ${u}`,{branches:k,ops:y}=si(d,m),j=null,E=[];for(let R=0;R<k.length;R+=1){let S=k[R],A=S.map(te=>te.toLowerCase()),M=R===0?"seed":y[R-1],T=Va(S,A);if(T.blc.length&&T.blc.every(te=>Ve[te])){E.push({op:M,kind:"qual",filters:T.blc});continue}if(A[0]==="of"||A[0]==="in"){E.push({op:M,kind:"set",ast:{node:"membership",entityType:c,term:S.slice(1).join(" ")}});continue}let P=S,G=xt(A,de);G?j=S.slice(G.start,G.end):j&&(P=[...j,...S]);let K=Mp(`${$} ${P.join(" ")}`,n,s+1);if(!K||K.node==="miss")return{node:"miss",reason:K&&K.reason||"a clause in the combination didn't parse"};E.push({op:M,kind:"set",ast:K})}if(E[0].kind!=="set")return{node:"miss",reason:"start with a clause, then combine with and/or/but-not"};let _;return E.length===1?_=E[0].ast:_={node:"boolean",entityType:c,atoms:E},a.length&&(_={node:"qualifier",filters:a,inner:_,entityType:c}),_}function Mp(e,t,n){if(n>_p)return{node:"miss",reason:"too deep to resolve"};let s=Qt(e),o=s.map(a=>a.toLowerCase()),r=ec(s,o,t,n);if(r)return r;let i=lo(e,t);return i?{node:"clause",clause:i}:null}function si(e,t){let n=Object.keys(Xs).sort((a,l)=>l.split(" ").length-a.split(" ").length),s=[],o=[],r=0,i=0;for(;i<e.length;){let a=null;for(let l of n){let c=l.split(" ");if(e.slice(i,i+c.length).join(" ")===l){a={c:l,len:c.length};break}}a&&i>r?(s.push(t.slice(r,i)),o.push(Xs[a.c]),i+=a.len,r=i):a?(i+=a.len,r=i):i+=1}return s.push(t.slice(r)),{branches:s,ops:o}}function nc(e,t,n,s){let o=ao[t];if(o&&ns.has(n)){let u=We(e,o).filter(d=>s.has(d.object));return Mn(u.map(d=>e.byId.get(d.subject)).filter(d=>d&&d.class===n))}let a=(!!o&&[...s].some(u=>ns.has(e.byId.get(u)?.class))?[...Rt(t),o]:Rt(t)).flatMap(u=>We(e,u)).filter(u=>s.has(u.object)),l=Mn(a.map(u=>e.byId.get(u.subject)).filter(Boolean));if(!n||n==="Change")return l;let c=l.filter(u=>u.class===n);return c.length?c:n!=="Module"&&l.some(u=>u.class==="Module")?ic(e,new Set(l.filter(u=>u.class==="Module").map(u=>u.id)),n):[]}function qv(e,t){let n=new Set(nc(e,"touches","Commit",t).map(s=>String(s.label||"").toLowerCase()));for(let s of t)for(let o of e.byId.get(s)?.derived_from||[]){let r=Wv.exec(String(o||""));r&&n.add(r[1].toLowerCase())}return n.size}function Zo(e,t,n){let s=Rt(t).flatMap(o=>We(e,o)).filter(o=>n.has(o.subject));return Mn(s.map(o=>e.byId.get(o.object)).filter(Boolean))}function Mn(e){let t=new Set,n=[];for(let s of e)s&&!t.has(s.id)&&(t.add(s.id),n.push(s));return n}function Gv(e,t){let n=Cn(t);if(!n)return[];let s=`${n}/`;return e.individuals.filter(o=>o.class==="Module"&&Cn(o.label).startsWith(s))}function Ha(e){let t=mp.get(e);if(t)return t;let n=new Set;for(let i of We(e,"reexports")){n.add(String(i.object).toLowerCase());let a=e.byId.get(i.object);a&&n.add(String(a.label).toLowerCase())}let s=new Set,o=new Set;for(let i of We(e,"tests"))s.add(i.object),o.add(i.subject);let r=new Map;for(let i of We(e,"defines"))r.set(i.object,i.subject);return t={exported:n,testedModules:s,testModules:o,moduleOfSymbol:r},mp.set(e,t),t}function co(e,t){return t?t.class==="Module"?t.id:Ha(e).moduleOfSymbol.get(t.id)||null:null}function Pp(e,t){let n=String(t||"").trim().toLowerCase();if(!n)return null;let s=(e?.individuals||[]).filter(d=>Vv.has(d.class)&&String(d.label).toLowerCase()===n);if(s.length!==1)return null;let o=s[0],r=co(e,o),i=r&&e.byId.get(r)?.label||String((o.attributes||[]).find(d=>d.key==="site")?.value||"").split(":")[0]||null,a=Pe(o.class,1),l=a==="attribute"?"an":"a",c=i?`, ${Xo("defined-in",o.id,"defined in")} ${i}`:"",u=o.class==="Class"?` or "which classes inherit from ${o.label}"`:"";return{text:`${o.label} is ${l} ${a} in this codebase${c} \u2014 try "describe ${o.label}"${u}.`,hit:o,modLabel:i}}function Ka(e,t,n){let s=Mn(Js.flatMap(o=>Zo(e,o,new Set([t]))));return n?s.filter(o=>o.class===n):s}function sc(e,t,n=null){let s=Nn(e,t,n);if(!(s.match&&s.tier===1)){let o=Gv(e,t);if(o.length)return{kind:"dir",mods:o}}return s.match?{kind:"single",id:s.match.id,entityClass:s.match.class,label:s.match.label}:{kind:"miss"}}function Fp(e,t,n,s,o){let r=o||(()=>!0),i=Ka(e,t,s).filter(r);if(i.length||!zp(e,n))return{own:i,inherited:[],viaId:null,viaLabel:null};for(let a of Dp(e,t)){let l=e.byId.get(a);if(!l)continue;let c=Ka(e,a,s).filter(r);if(c.length)return{own:i,inherited:c,viaId:a,viaLabel:l.label}}return{own:i,inherited:[],viaId:null,viaLabel:null}}function As(e,t,n){if(!n)return!1;switch(n.via){case"visibility":return String((t.attributes||[]).find(o=>o.key==="visibility")?.value||"public").toLowerCase()===n.value;case"attr":return!!(t.attributes||[]).find(s=>s.key===n.attr)?.value;case"exported":{let s=Ha(e).exported;return s.has(String(t.label).toLowerCase())||s.has(String(t.id).toLowerCase())}case"tested":{let s=co(e,t),o=Ha(e),r=s?e.byId?.get?.(s):null;return s&&(o.testModules.has(s)||r&&Ss(String(r.label).toLowerCase()))?!1:(!!s&&o.testedModules.has(s))===n.value}default:return!1}}function oc(e){return We(e,"inherits")}function Ya(e,t){return oc(e).filter(n=>n.object===t).map(n=>n.subject)}function hp(e,t){return oc(e).filter(n=>n.subject===t).map(n=>n.object)}function Hv(e,t){let n=new Set,s=[...Ya(e,t)];for(;s.length;){let o=s.shift();if(!n.has(o)){n.add(o);for(let r of Ya(e,o))n.has(r)||s.push(r)}}return n}function Dp(e,t){let n=new Set,s=[...hp(e,t)];for(;s.length;){let o=s.shift();if(!n.has(o)){n.add(o);for(let r of hp(e,o))n.has(r)||s.push(r)}}return n}function zp(e,t){let n=gp.get(e);if(n||(n=new Map,gp.set(e,n)),n.has(t))return n.get(t);let s=oc(e).some(o=>{let r=e.byId.get(o.subject),i=e.byId.get(o.object);return!!r&&!!i&&r.class===t&&i.class===t});return n.set(t,s),s}function bp(e,t){let n=String(e.label||"").toLowerCase();if(t.every(o=>n.includes(o)))return"label";let s=(e.attributes||[]).map(o=>String(o.value??"").toLowerCase());return t.every(o=>s.some(r=>r.includes(o)))?"attr":null}function yp(e){return e.slice().sort((t,n)=>wp[n.via]-wp[t.via]||String(t.ind.label).length-String(n.ind.label).length).map(t=>t.ind)}function vp(e,t){let n=String(t||"").trim().toLowerCase();if(n.length<4)return!1;let s=Qn(n);if(Ln(String(e.label||"").toLowerCase(),n,s)<=s)return!0;for(let o of Ts(e.label))if(Ln(o,n,s)<=s)return!0;return!1}function Bp(e,t,n){let s=e.individuals.filter(l=>l.class===t),o=[...Ts(n)];if(!o.length||!s.length)return{narrow:[],broad:[]};let r=zp(e,t),i=[];for(let l of s){let c=bp(l,o);if(c){i.push({ind:l,via:c});continue}if(!r)continue;[...Hv(e,l.id)].some(d=>{let m=e.byId.get(d);return!!m&&!!bp(m,o)})&&i.push({ind:l,via:"chain"})}if(i.length||!r)return{narrow:yp(i),broad:[]};let a=new Map;for(let l of s)for(let c of Dp(e,l.id)){if(!a.has(c)){let u=e.byId.get(c);u&&u.class===t&&vp(u,n)&&a.set(c,{ind:u,via:"chain"})}for(let u of Ya(e,c)){if(u===l.id||a.has(u))continue;let d=e.byId.get(u);d&&d.class===t&&vp(d,n)&&a.set(u,{ind:d,via:"chain"})}}return{narrow:[],broad:yp([...a.values()])}}function Kv(e){return[...Wr(qr(e)).entries()].sort((t,n)=>n[1]-t[1]||t[0].localeCompare(n[0])).map(([t])=>({id:`pkg:${t}`,label:t,class:"Package"}))}function Zt(e,t,n){switch(t.node){case"clause":return Ht(e,t.clause,n).matches||[];case"allOfClass":return t.entityType==="Package"?Kv(e):e.individuals.filter(s=>s.class===t.entityType);case"find":{let{narrow:s,broad:o}=Bp(e,t.entityType,t.term);return s.length?s:o}case"existsEdge":{let s=new Set(Rt(t.kind).flatMap(o=>We(e,o)).map(o=>o.subject));return e.individuals.filter(o=>s.has(o.id)&&(!t.entityType||o.class===t.entityType))}case"forwardComplement":{let s=Nn(e,t.subjectTerm,n&&n.contextId);if(!s.match)return[];let o=Ip(e,t.kind);if(!o)return[];let r=new Set(Zo(e,t.kind,new Set([s.match.id])).map(i=>i.id));return e.individuals.filter(i=>i.class===o&&!r.has(i.id))}case"reverseSet":{let s=new Set(Zt(e,t.inner,n).map(o=>o.id));return nc(e,t.kind,t.entityType,s)}case"forwardSet":{let s=new Set(Zt(e,t.inner,n).map(o=>o.id));return Zo(e,t.kind,s)}case"prevSet":{let s=n&&n.prev;return Array.isArray(s)?s.map(o=>e.byId.get(o)).filter(Boolean):[]}case"membership":{let s=sc(e,t.term,n&&n.contextId);if(s.kind==="dir"){if(!t.entityType||t.entityType==="Module")return s.mods;let i=new Set(s.mods.map(l=>l.id));return Mn(Js.flatMap(l=>Zo(e,l,i))).filter(l=>l.class===t.entityType)}if(s.kind==="miss")return[];let{own:o,inherited:r}=Fp(e,s.id,s.entityClass,t.entityType);return o.length?o:r}case"qualifier":return t.inner.node==="membership"?Gp(e,t,n).matches:Zt(e,t.inner,n).filter(o=>t.filters.every(r=>As(e,o,Ve[r])));case"boolean":return Up(e,t,n);case"anaphora":return Wp(e,t,n).matches;default:return[]}}function Up(e,t,n){let s=[];for(let o of t.atoms){if(o.op==="seed"){s=Zt(e,o.ast,n);continue}if(o.kind==="qual"){let i=l=>o.filters.every(c=>As(e,l,Ve[c])),a=l=>o.filters.every(c=>{let u=Yv(Ve[c]);return u?As(e,l,u):!As(e,l,Ve[c])});s=o.op==="difference"?s.filter(a):s.filter(i);continue}let r=new Set(Zt(e,o.ast,n).map(i=>i.id));if(o.op==="intersection")s=s.filter(i=>r.has(i.id));else if(o.op==="difference")s=s.filter(i=>!r.has(i.id));else if(o.op==="union"){let i=new Set(s.map(a=>a.id));for(let a of Zt(e,o.ast,n))i.has(a.id)||(i.add(a.id),s.push(a))}}return s}function Xv(e,t){if(!Array.isArray(t)||t.length<2)return null;let n=new Set,s=[];for(let o of t){let r=cn(e,o);r&&r.match&&!n.has(r.match.id)&&(n.add(r.match.id),s.push(r.match))}return s.length>=2?s:null}function Wp(e,t,n){let o=Xv(e,t.candidateTerms);if(!o){let d=n&&n.prev;if(!Array.isArray(d)||!d.length)return{compositeMiss:!0,reason:"no-prev",matches:[]};o=d.map(m=>e.byId.get(m)).filter(Boolean)}let r=o,i=t.filter;if(i&&i.type==="qual")r=r.filter(d=>i.filters.every(m=>As(e,d,Ve[m])));else if(i&&i.type==="entity")r=r.filter(d=>d.class===i.entityType);else if(i&&i.type==="clause"){let d=cn(e,i.clause.object);if(!d.match)r=[];else{let m=ao[i.clause.kind],p=[...Rt(i.clause.kind),...m?[m]:[]],f=new Set(p.flatMap(g=>We(e,g)).filter(g=>g.object===d.match.id).map(g=>g.subject));r=r.filter(g=>f.has(g.id))}}let a=d=>d.length&&d.every(m=>m.class===d[0].class)?d[0].class:null,l=i&&i.type==="entity"?i.entityType:a(o),c=r.length?a(r):l;if(t.mode==="count")return{compositeKind:"count",count:r.length,entityType:c,matches:[]};let u=nr(c,r,"anaphora",{bound:!0});return{compositeKind:"set",matches:r,entityType:c,referents:u}}function qp(e,t,n){let s=n.kind==="*"?Jv:[n.kind,...n.sibling?[n.sibling]:[]],o=0;for(let r of s)for(let i of We(e,r)){let a=i.subject===t.id,l=i.object===t.id;if(n.dir==="out"&&a){if(n.filter){let c=e.byId.get(i.object);if(!c||c.class!==n.filter)continue}o+=1}else(n.dir==="in"&&l||n.dir==="both"&&(a||l))&&(o+=1)}return o}function Qv(e){let t=e.individuals.filter(s=>s.class==="Commit"),n=s=>String((s.attributes||[]).find(o=>o.key==="date")?.value||"");return t.sort((s,o)=>n(o).localeCompare(n(s))),{compositeKind:"recentCommits",matches:t}}function e$(e,t){let{op:n,pivotRaw:s}=t,o=u=>String((u.attributes||[]).find(d=>d.key==="date")?.value||"").slice(0,10),r=null,i=null,a=null;if(Zv.test(s))r=s;else{let{match:u,ambiguous:d}=cn(e,s,{expectedClass:"Commit"});u&&!d&&u.class==="Commit"&&o(u)&&(i=u.id,a=u.label,r=o(u))}if(!r)return{compositeKind:"commitFilter",op:n,pivotRaw:s,pivotResolved:!1,matches:[]};let l=e.individuals.filter(u=>u.class==="Commit"&&u.id!==i&&o(u)).filter(u=>{let d=o(u);return n==="since"?d>=r:n==="before"?d<r:n==="after"?d>r:d===r}).sort((u,d)=>o(d).localeCompare(o(u))),c=[];return l.length&&c.push({kind:"set",class:"Commit",label:`${l.length} commit${l.length===1?"":"s"} ${n} ${s}`,ids:l.map(u=>u.id),attrs:{count:l.length,op:n,...i?{pivot:i}:{}},lane:"commitFilter"}),i&&c.push({kind:"event",class:"Commit",label:a,ids:[i],attrs:{date:r},lane:"commitFilter"}),{compositeKind:"commitFilter",op:n,pivotRaw:s,pivotDate:r,pivotResolved:!0,matches:l,referents:c}}function t$(e,t,n){let s=Zt(e,t.inner,n),o=new Set(s.map(a=>a.id));if(!o.size)return{compositeKind:"temporal",matches:[],entityType:t.entityType,innerCount:0};let r=nc(e,"touches","Commit",o),i=a=>String((a.attributes||[]).find(l=>l.key==="date")?.value||"");return r.sort((a,l)=>i(l).localeCompare(i(a))),{compositeKind:"temporal",matches:r,entityType:t.entityType,innerCount:s.length}}function n$(e,t){let n=e.individuals.filter(a=>a.class===t.entityType);if(t.metric?.kind==="tests"&&t.entityType==="Module"){let a=new Set(We(e,"tests").map(l=>l.subject));n=n.filter(l=>!a.has(l.id)&&!Ss(String(l.label).toLowerCase()))}let s=n.map(a=>({ind:a,score:qp(e,a,t.metric)})).sort((a,l)=>t.extreme==="most"?l.score-a.score:a.score-l.score);if(!s.length)return{compositeKind:"superlative",entityType:t.entityType,matches:[]};let o=s[0].score,r=s.filter(a=>a.score===o).map(a=>a.ind),i=r.length>=2?nr(t.entityType,r,"superlative"):[{kind:"entity",class:t.entityType,label:r[0].label,ids:[r[0].id],attrs:{},lane:"superlative"}];return i.push({kind:"measure",label:`${o} ${t.metricNoun}`,ids:[],attrs:{metric:o},lane:"superlative"}),{compositeKind:"superlative",entityType:t.entityType,metricNoun:t.metricNoun,extreme:t.extreme,score:o,matches:r,referents:i}}function Gp(e,t,n){let s=t.node==="qualifier"&&t.inner.node==="membership"?t:null,o=s?s.inner:t,r=o.entityType,i=s?f=>s.filters.every(g=>As(e,f,Ve[g])):null,a=f=>nr(r,f,"membership"),l=sc(e,o.term,n&&n.contextId);if(l.kind==="dir"){let f;if(!r||r==="Module")f=l.mods;else{let g=new Set(l.mods.map(h=>h.id));f=Mn(Js.flatMap(h=>Zo(e,h,g))).filter(h=>h.class===r)}return i&&(f=f.filter(i)),{compositeKind:"set",matches:f,entityType:r,referents:a(f)}}if(l.kind==="miss")return{compositeKind:"set",matches:[],entityType:r};let{own:c,inherited:u,viaLabel:d}=Fp(e,l.id,l.entityClass,r,i),m=!c.length&&u.length>0,p=m?u:c;return{compositeKind:"membership",entityType:r,matches:p,inheritedNotOwn:m,viaLabel:d,ownerLabel:l.label,referents:a(p)}}function s$(e,t){let{entityType:n,term:s,scopeModule:o}=t,r=null;if(o){let a=cn(e,o,{expectedClass:"Module"});if(!a.match)return{compositeKind:"exists",entityType:n,term:s,scopeModule:o,scopeMiss:!0,matches:[]};r=a.match}if(s){let a=cn(e,s,{expectedClass:n}),l=!r||a.match&&co(e,a.match)===r.id,c=a.match&&l;return{compositeKind:"exists",entityType:n,term:s,scopeModule:o,scopeMatch:r,matches:c?[a.match]:[]}}let i=r?ic(e,new Set([r.id]),n):e.individuals.filter(a=>a.class===n);return{compositeKind:"exists",entityType:n,term:null,scopeModule:o,scopeMatch:r,matches:i}}function o$(e,t,n){let s=co(e,t);return n.kind==="dir"?n.mods.some(o=>o.id===t.id||o.id===s):s===n.id||Ka(e,n.id).some(o=>o.id===t.id)}function r$(e,t,n){let{term:s,qualifier:o,negated:r,scope:i}=t,a=Nn(e,s,n.contextId);if(a.unresolvedPronoun)return{compositeKind:"qualCheck",qualCheckMiss:"pronoun",term:s,matches:[]};if(!a.match)return{compositeKind:"qualCheck",qualCheckMiss:"unresolved",term:s,matches:[]};if(i){let d=sc(e,i,n.contextId);if(d.kind==="miss")return{compositeKind:"qualCheck",qualCheckMiss:"scope",term:s,scope:i,matches:[]};if(!o$(e,a.match,d))return{compositeKind:"qualCheck",qualCheckMiss:"outsideScope",term:s,scope:i,subjectLabel:a.match.label,scopeLabel:d.kind==="dir"?i:d.label,matches:[]}}let l=As(e,a.match,Ve[o]),c=r?!l:l,u=[{kind:"entity",class:a.match.class,label:a.match.label,ids:[a.match.id],attrs:{},lane:"qualCheck"}];return{compositeKind:"qualCheck",subject:a.match,qualifier:o,negated:r,holds:c,matches:[a.match],referents:u}}function i$(e,t,n){let s=cn(e,t.object);if(!s||!s.match)return{compositeKind:"universal",universalMiss:"unresolved",object:t.object,matches:[]};let o=Zt(e,{node:"allOfClass",entityType:t.entityType},n),r=Up(e,t.complement,n),i=r.length===0;return{compositeKind:"universal",entityType:t.entityType,kind:t.kind,object:s.match.label,holds:i,total:o.length,counter:r,matches:i?o:r}}function a$(e,t,n){if(t.node==="reverseSet"&&t.kind==="touches"&&t.entityType==="Commit")return new Set(Zt(e,t.inner,n).map(s=>s.id));if(t.node==="clause"&&t.clause?.shape==="reverse"&&t.clause.kind==="touches"&&t.clause.entityType==="Commit"){let{objMatch:s,ambiguous:o}=Ht(e,t.clause,n);return s&&!o?new Set([s.id]):null}return null}function c$(e,t,n={}){if(t.node==="miss")return{compositeMiss:!0,reason:t.reason||null,matches:[]};if(t.node==="exists")return s$(e,t);if(t.node==="qualCheck")return r$(e,t,n);if(t.node==="universal")return i$(e,t,n);if(t.node==="count"){let i=a$(e,t.base,n);return i?{compositeKind:"count",count:qv(e,i),entityType:t.entityType,matches:[]}:{compositeKind:"count",count:Zt(e,t.base,n).length,entityType:t.entityType,matches:[]}}if(t.node==="list")return{compositeKind:"list",matches:Zt(e,t.base,n),entityType:t.entityType,scoped:t.scoped};if(t.node==="superlative")return n$(e,t);if(t.node==="temporal")return t$(e,t,n);if(t.node==="recentCommits")return Qv(e);if(t.node==="commitFilter")return e$(e,t);if(t.node==="anaphora")return Wp(e,t,n);if(t.node==="membership"||t.node==="qualifier"&&t.inner.node==="membership")return Gp(e,t,n);if(t.node==="find"){let{narrow:i,broad:a}=Bp(e,t.entityType,t.term);return{compositeKind:"find",entityType:t.entityType,term:t.term,matches:i.length?i:a,broad:!i.length&&a.length>0}}if((t.node==="reverseSet"||t.node==="forwardSet")&&t.inner.node==="prevSet"&&!(Array.isArray(n.prev)&&n.prev.length))return{compositeMiss:!0,reason:"no-prev",matches:[]};let s=Zt(e,t,n),o=t.entityType||null,r=nr(o,s,t.node==="qualifier"?"qualifierListing":"compositeSet");return{compositeKind:"set",matches:s,entityType:o,referents:r}}function Vp(){return'compositional queries also work: "which functions call X and call Y", "what calls something that imports X", "public methods of X", "list functions" / "show me the classes", "how many classes", "which module has the most imports", "find me the payment class", or (after a listing) "which of those are tested"'}function l$(e){let t=["Function","Method"].includes(e.class)?`${e.label}()`:e.label;if(e.class==="Module")return t;let n=tr(e);return n&&n!=="(unknown module)"?`${t} in ${n}`:t}function u$(e,t,n){if(t.compositeMiss)return t.reason==="no-prev"?{content:'"those"/"them" needs a previous answer to refer to \u2014 ask a listing question first, then follow up.',miss:!0,ambiguous:!1}:{content:`couldn't compile this compositional question${t.reason?` (${t.reason})`:""}. ${Vp()}.`,miss:!0,ambiguous:!1};if(t.compositeKind==="exists"){if(t.scopeMiss)return{content:`no module matching "${t.scopeModule}" found in the index.`,miss:!0,ambiguous:!1};let s=Pe(t.entityType,1),o=Pe(t.entityType,2),r=t.scopeMatch?` in ${t.scopeMatch.label}`:"";if(t.term){if(!t.matches.length)return{content:`No \u2014 no ${s} named "${t.term}" found${r}.`,miss:!0,ambiguous:!1};let i=t.matches[0],a=tr(i),l=i.class==="Module"?"":a&&a!=="(unknown module)"?`, ${Xo("defined-in",i.id,"defined in")} ${a}`:"";return{content:`Yes \u2014 ${i.label} is a ${s}${l}.`,miss:!1,ambiguous:!1,matches:t.matches}}return t.matches.length?{content:`Yes \u2014 ${Zn(t.matches)}${r}.`,miss:!1,ambiguous:!1,matches:t.matches}:{content:`No \u2014 no ${o} found${r}.`,miss:!0,ambiguous:!1}}if(t.compositeKind==="qualCheck"){if(t.qualCheckMiss==="pronoun")return{content:`"${t.term}" needs a selected node to refer to \u2014 click a node first, or name it directly.`,miss:!0,ambiguous:!1};if(t.qualCheckMiss==="unresolved")return{content:`couldn't find "${t.term}" in the index to check.`,miss:!0,ambiguous:!1};if(t.qualCheckMiss==="scope")return{content:`couldn't find "${t.scope}" in the index to check inside.`,miss:!0,ambiguous:!1};if(t.qualCheckMiss==="outsideScope")return{content:`No \u2014 ${t.subjectLabel} isn't in ${t.scopeLabel}.`,miss:!0,ambiguous:!1};let s=t.subject.label,o=t.negated?`not ${t.qualifier}`:t.qualifier,r=t.negated?t.qualifier:`not ${t.qualifier}`;return{content:`${t.holds?"Yes":"No"} \u2014 ${s} is ${t.holds?o:r}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="universal"){if(t.universalMiss==="unresolved")return{content:`couldn't find "${t.object}" in the index to check.`,miss:!0,ambiguous:!1,matches:[]};let s=Pe(t.entityType,t.total),o=rv(t.kind);return t.holds?{content:`Yes \u2014 all ${t.total} ${s} ${o} ${t.object}.`,miss:!1,ambiguous:!1,matches:t.matches}:{content:`No \u2014 ${t.counter.length} of ${t.total} ${s} do not ${o} ${t.object}: ${Zn(t.counter)}.`,miss:!1,ambiguous:!1,matches:t.counter}}if(t.compositeKind==="count"){let s=t.entityType?Pe(t.entityType,t.count):t.count===1?"result":"results";return{content:`${t.count} ${s}.`,miss:!1,ambiguous:!1,matches:[]}}if(t.compositeKind==="list"){if(!t.matches.length)return{content:`no ${Pe(t.entityType,2)} in this index.`,miss:!0,ambiguous:!1,matches:[]};let s=!["Module","Package","Commit","Fact","Utterance","Session","Source","Rule"].includes(t.entityType),o=!t.scoped&&s&&t.matches.length>Ue?` \u2014 narrow with "${Pe(t.entityType,2)} in <module>"`:"";return{content:`${Zn(t.matches)}${o}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="membership"){if(!t.matches.length)return{content:`nothing in the index matches that${t.entityType?` (${Pe(t.entityType,2)})`:""}. ${ts(n)}`,miss:!0,ambiguous:!1,matches:[]};if(t.inheritedNotOwn){let s=Pe(t.entityType,2);return{content:`${t.ownerLabel?`${t.ownerLabel} has no own ${s}`:`no own ${s}`} \u2014 inherited from ${t.viaLabel}: ${Zn(t.matches)}.`,miss:!1,ambiguous:!1,matches:t.matches,inheritedNotOwn:!0}}return{content:`${Zn(t.matches)}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="find"){let s=Pe(t.entityType,1);if(!t.matches.length)return{content:`no ${Pe(t.entityType,2)} found matching "${t.term}".`,miss:!0,ambiguous:!1,matches:[]};let o=t.matches.length===1?l$(t.matches[0]):Zn(t.matches);return t.broad?{content:`no exact ${s} named "${t.term}", but found a related ${t.matches.length===1?s:Pe(t.entityType,2)}: ${o}.`,miss:!1,ambiguous:!1,matches:t.matches,relatedNotExact:!0}:{content:`${o}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="recentCommits"){if(!t.matches.length)return{content:"no commits recorded in this index.",miss:!0,ambiguous:!1,matches:[]};let s=i=>String((i.attributes||[]).find(a=>a.key==="date")?.value||""),o=t.matches.slice(0,Mt).map(i=>{let a=s(i).slice(0,10),l=(i.attributes||[]).find(c=>c.key==="message")?.value||"";return`${i.label}${a?` (${a})`:""}${l?` \u2014 ${l}`:""}`}),r=t.matches.length>Mt?` \u2026+${t.matches.length-Mt} more`:"";return{content:`${t.matches.length} recent commit(s): ${o.join(", ")}${r}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="commitFilter"){if(!t.pivotResolved)return{content:`"${t.pivotRaw}" isn't a recognized date (yyyy-mm-dd) or a known commit \u2014 try "what changed since 2026-06-01" or "what changed before <commit>".`,miss:!0,ambiguous:!1,matches:[]};if(!t.matches.length)return{content:`no commits recorded ${t.op} ${t.pivotRaw}.`,miss:!0,ambiguous:!1,matches:[]};let s=i=>String((i.attributes||[]).find(a=>a.key==="date")?.value||""),o=t.matches.slice(0,Mt).map(i=>{let a=s(i).slice(0,10),l=(i.attributes||[]).find(c=>c.key==="message")?.value||"";return`${i.label}${a?` (${a})`:""}${l?` \u2014 ${l}`:""}`}),r=t.matches.length>Mt?` \u2026+${t.matches.length-Mt} more`:"";return{content:`${t.matches.length} commit(s) changed ${t.op} ${t.pivotRaw}: ${o.join(", ")}${r}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="superlative"){if(!t.matches.length)return{content:`no ${Pe(t.entityType,2)} to rank in this index.`,miss:!0,ambiguous:!1};let s=t.extreme==="most"?"the most":"the fewest",o=t.matches.length>1?` (${t.matches.length}-way tie)`:"";return{content:`${Zn(t.matches)} \u2014 ${s} ${t.metricNoun} (${t.score})${o}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.compositeKind==="temporal"){let s=t.innerCount||0,o=t.entityType?Pe(t.entityType,s||2):s===1?"entity":"entities",r=s===1?"was":"were";if(!s)return{content:`nothing in the index matches the inner set, so there is no change history to date. ${ts(n)}`,miss:!0,ambiguous:!1,matches:[]};if(!t.matches.length)return{content:`no recorded commit touched the ${s} ${o} in that set in this index. ${ts(n)}`,miss:!0,ambiguous:!1,matches:[]};let i=t.matches[0],a=(i.attributes||[]).find(d=>d.key==="date")?.value||"";if(!a)return{content:`the ${o} in that set ${r} last touched by commit ${i.label}, but this index records no commit dates \u2014 regenerate the graph to attach mgx:commitDate.`,miss:!0,ambiguous:!1,matches:t.matches};let l=(i.attributes||[]).find(d=>d.key==="message")?.value||"",c=String(a).slice(0,10),u=t.matches.length-1;return{content:`the ${o} in that set ${r} last touched by commit ${i.label} on ${c}${l?` ("${l}")`:""}${u?`; ${u} earlier commit${u===1?"":"s"} recorded`:""}.`,miss:!1,ambiguous:!1,matches:t.matches}}return t.matches.length?{content:`${Zn(t.matches)}.`,miss:!1,ambiguous:!1,matches:t.matches}:{content:`nothing in the index matches that${t.entityType?` (${Pe(t.entityType,2)})`:""}. ${ts(n)}`,miss:!0,ambiguous:!1,matches:[]}}function rc(){return`"which <functions|classes|modules> <imports|calls|uses|inherits from|tests> <name>" or "what does <name> <import|call|export>" or "what uses <name>" or "where is <name> defined" / "where is <name> mentioned" or "when did <name> change" or "which commits touched <name>" or "which changes touch commit <sha>"/"what did commit <sha> touch" (a commit's own changes) or plainly "what calls this" (about a selected node) or "what does <term> mean"/"what is a <ClassName>" (about the graph's own vocabulary). `+Vp()}function ts(e=null){return e&&ja(e)===0?"This store holds no code index, so it records no modules or commits to look through.":`Try "who touched <a module that actually has commits>" or "/describe <module>" to see what's in the index.`}function Ts(e){return new Set(String(e).toLowerCase().split(/[^a-z0-9]+/).filter(Boolean))}function ri(e){if(e.length<5)return e;let t=e.replace(/(ing|ers|ors|er|or)$/,"");return t===e?e:t.length>=3&&t[t.length-1]===t[t.length-2]?t.slice(0,-1):t}function Hp(e){return String(e||"").replace(/\.[a-z0-9]+$/i,"").toLowerCase().replace(/[/\-_.]+/g,"")}function d$(e){return String(e||"").trim().replace(/^(?:the|a|an)\s+/i,"").toLowerCase().replace(/[\s\-_]+/g,"")}function Jo(e,t,{expectedClass:n=null}={}){let s=String(t||"").trim();if(!s)return{match:null,candidates:[],tier:null,ambiguous:!1};let o=s.toLowerCase(),r=n?e.individuals.filter(h=>h.class===n):e.individuals,i=o.match(/^(commit[:\s])?([0-9a-f]{7,40})$/);if(i){let h=i[2],b=r.filter(w=>w.class==="Commit"&&(String(w.id).toLowerCase().startsWith(`commit:${h}`)||String(w.label).toLowerCase().startsWith(h)));if(b.length===1)return{match:b[0],candidates:[],tier:1,ambiguous:!1};if(b.length>1)return{match:b[0],candidates:b.slice(1,5),tier:1,ambiguous:!0};if(i[1])return{match:null,candidates:[],tier:null,ambiguous:!1}}let a=r.find(h=>String(h.label).toLowerCase()===o||String(h.id).toLowerCase()===o);if(a)return{match:a,candidates:[],tier:1,ambiguous:!1};let l=`ext:${o}`,c=null;e:for(let h of e.relations)for(let b of h.edges)if(String(b.object).toLowerCase()===l){c=b.object;break e}if(c&&!n)return{match:{id:c,label:s,class:null},candidates:[],tier:2,ambiguous:!1};let u=s.split(/\s+and\s+/i).map(h=>h.trim()).filter(Boolean);if(u.length>1){let h=new Set;for(let b of u){let w=Jo(e,b,{expectedClass:n});w.match&&!w.ambiguous&&h.add(w.match.id)}if(h.size>1)return{match:null,candidates:[],tier:null,ambiguous:!1}}let d=[],m=!o.includes("/")&&/^[\w$]+(\.[\w$]+)+$/.test(o);if(m){let h=o.split(".").pop();for(let b of r){let w=String(b.label||"").toLowerCase();b.class==="Module"?w.split("/").pop()===o&&d.push({ind:b,score:1e3-Math.abs(w.length-o.length)}):w.includes(o)?d.push({ind:b,score:2e3-Math.abs(w.length-o.length)}):w.endsWith(`.${h}`)&&d.push({ind:b,score:1500-Math.abs(w.length-o.length)})}}else{let h=[...Ts(s)],b=o.split(/\s+/).find(y=>y.includes("/")),w=b?b.split("/").pop().replace(/\.[a-z0-9]+$/,""):null,$=s.trim().replace(/^(?:the|a|an)\s+/i,"").trim().split(/\s+/).filter(Boolean).length>=2,k=$?d$(s):null;for(let y of r){let j=String(y.label||"").toLowerCase(),E=j.split("/").pop().replace(/\.[a-z0-9]+$/,"");if(E===o){d.push({ind:y,score:5e3});continue}if(o.length>=4&&(E.startsWith(o)||E.endsWith(o))){d.push({ind:y,score:4e3-Math.abs(E.length-o.length)});continue}if($){let S=Hp(y.label);if(S&&S===k){d.push({ind:y,score:5e3});continue}let A=/[/_-]/.test(y.label)||/\.[a-z0-9]+$/i.test(String(y.label||""));if(S&&A&&k.length>=4&&S.includes(k)){d.push({ind:y,score:2e3-Math.abs(S.length-k.length)});continue}}if(y.class==="Module"){let S=ri(o);if(S!==o&&S===ri(E)){let A=Qn(o);if(Ln(E,o,A)>A){d.push({ind:y,score:3e3-Math.abs(E.length-o.length)});continue}}}if(o.length>=4&&j.includes(o)){d.push({ind:y,score:1e3-Math.abs(j.length-o.length)});continue}let _=Ts(y.label),R=h.filter(S=>_.has(S)).length;R>0&&(!w||_.has(w))&&d.push({ind:y,score:R/h.length*Ua})}}if(d.sort((h,b)=>b.score-h.score),d.length){let[h,...b]=d,w=b.filter($=>$.score===h.score),v=h.score>=Ua?b.filter($=>$.score>=Ua):b;return{match:h.ind,candidates:v.slice(0,4).map($=>$.ind),tier:3,ambiguous:w.length>0}}let p=m||o.includes("/"),f=null,g=!p&&typeof $s=="function"?$s(e.proseIndex,s).filter(h=>!n||e.byId.get(h.id)?.class===n):[];if(g.length){let[h,...b]=g,w=e.byId.get(h.id);if(w){let v=b.filter($=>$.score===h.score);if(f={match:w,candidates:b.slice(0,4).map($=>e.byId.get($.id)).filter(Boolean),tier:4,ambiguous:v.length>0,matchedVia:"prose"},!f.ambiguous&&h.via!=="spell")return f}}if(!i&&o.length>=4){let h=Qn(o),b=h+1,w=[];for(let v of r){let $=Ln(String(v.label||"").toLowerCase(),o,h);if($>0)for(let k of Ts(v.label)){if($<=0)break;$=Math.min($,Ln(k,o,h))}$<b?(b=$,w=[v]):$===b&&$<=h&&w.push(v)}if(b<=h&&w.length===1)return{match:w[0],candidates:[],tier:5,ambiguous:!1,matchedVia:"fuzzy"};if(b<=h&&w.length>1&&!f){let[v,...$]=w;return{match:v,candidates:$.slice(0,4),tier:5,ambiguous:!0,matchedVia:"fuzzy"}}}return f||{match:null,candidates:[],tier:null,ambiguous:!1}}function Wa(e,t){let n=Hp(t),s=[...Ts(t)],o=[];for(let r of Ts(e))n.includes(r)||s.some(i=>ri(i)===ri(r))||oi.has(r)||Xp.has(r)||o.push(r);return o}function ti(e,t){if(!e?.match||e.tier!==3||e.matchedVia)return e;if(e.ambiguous){let s=[e.match,...e.candidates||[]],o=s.map(r=>new Set(Wa(t,r.label))).reduce((r,i)=>r.filter(a=>i.has(a)),Wa(t,s[0].label));return o.length?{match:null,candidates:[],tier:null,ambiguous:!1,unplacedWords:o,nearestLabel:gn(s.slice(0,4).map(r=>r.label))}:e}let n=Wa(t,e.match.label);return n.length?{match:null,candidates:[],tier:null,ambiguous:!1,unplacedWords:n,nearestLabel:e.match.label}:e}function cn(e,t,n={}){let{expectedClass:s=null}=n;if(!s){let o=String(t||"").trim(),r=o.replace(p$,"").trim(),i=r.match(f$);if(i){let a=r.slice(0,i.index).trim(),l=Be[i[1].toLowerCase()];if(a&&l){let c=ti(Jo(e,a,{expectedClass:l}),a);if(c?.match?.id&&!c.ambiguous)return c}}if(r&&r!==o){let a=ti(Jo(e,r,n),r);if(a?.match?.id&&!a.ambiguous)return a}return ti(Jo(e,t,n),t)}return ti(Jo(e,t,n),t)}function Nn(e,t,n){if(bs.includes(String(t||"").trim().toLowerCase())){if(!n)return{match:null,candidates:[],tier:null,ambiguous:!1,unresolvedPronoun:!0};let s=e.byId.get(n);return s?{match:s,candidates:[],tier:1,ambiguous:!1}:{match:null,candidates:[],tier:null,ambiguous:!1,unresolvedPronoun:!0}}return cn(e,t)}function ic(e,t,n){let s=[];for(let o of We(e,"defines")){if(!t.has(o.subject))continue;let r=e.byId.get(o.object);r&&r.class===n&&s.push(r)}return s}function m$(e,t,n,s={}){let o=!n||n==="Change"||n==="Commit",r=o||n==="Module",i=o||ns.has(n),a=[...r?["touches"]:[],...i?["touchesSymbol"]:[]],l=a.flatMap(c=>We(e,c)).filter(c=>c.subject===t.id).map(c=>e.byId.get(c.object)).filter(Boolean);return n&&ns.has(n)&&(l=l.filter(c=>c.class===n)),{matches:l,objMatch:t,commitSubject:!0,ambiguous:!1,candidates:[],traversal:`${a.join("+")} edges where subject = commit ${t.label}`,...s}}function w$(e,t){let n=new Set(String(t||"").toLowerCase().split(/[\s-]+/).filter(Boolean));return(e.individuals||[]).filter(s=>s.class==="Module"&&ac.has($p(s.label))).map(s=>({ind:s,named:n.has($p(s.label))?1:0,depth:String(s.label).split("/").length,fixture:b$(s.label)?1:0})).sort((s,o)=>o.named-s.named||s.depth-o.depth||s.fixture-o.fixture||String(s.ind.label).localeCompare(String(o.ind.label))).map(s=>s.ind)}function y$(e,t,n){return e==="reverse"&&(t==="imports"||t==="calls")&&(!n||n==="Module")}function Ht(e,t,{contextId:n=null,prev:s=null,pinnedObjMatch:o=null}={}){if(!t)return{matches:[],objMatch:null,candidates:[],traversal:null,ambiguous:!1};if(t.node)return c$(e,t,{contextId:n,prev:s});if(t.ambiguousParse){let T=t.candidates.map(P=>{let G=Ht(e,P,{contextId:n,prev:s});return{parsed:P,result:G,rendered:bn(P,G,e)}});return{matches:[],objMatch:null,candidates:t.candidates,traversal:null,ambiguous:!0,branches:T}}let{shape:r,kind:i,entityType:a}=t;if(r==="meta"){let T=String(t.object||"").trim(),P=T.toLowerCase(),G=(e.individuals||[]).find(K=>{if(K.class!=="SchemaClass"&&K.class!=="SchemaPredicate")return!1;if(String(K.label).toLowerCase()===P)return!0;let te=(K.attributes||[]).find(F=>F.key==="token")?.value;return te&&String(te).toLowerCase()===P});if(!G){let K=Pp(e,T);return K?{matches:[K.hit],objMatch:K.hit,candidates:[],ambiguous:!1,metaCodeClass:!0,metaFallbackText:K.text,traversal:`schema lookup for "${T}" (miss), then unique code-entity individual by label`}:{matches:[],objMatch:null,candidates:[],traversal:`schema lookup for "${T}"`,ambiguous:!1}}return{matches:[G],objMatch:G,candidates:[],traversal:`schema lookup for "${T}"`,ambiguous:!1}}if(r==="mentions"){let T=String(t.object||"").trim();return{matches:(typeof $s=="function"?$s(e.proseIndex,T):[]).map(K=>e.byId.get(K.id)).filter(Boolean),objMatch:null,candidates:[],ambiguous:!1,mentionsShape:!0,traversal:`proseIndex word lookup for "${T}"`}}if(r==="where"&&h$.test(String(t.object||"").trim())){let T=w$(e,t.object);return{matches:T,objMatch:T[0]||null,candidates:T.slice(1,5),ambiguous:!1,entryPointShape:!0,traversal:`Module individuals with an entry-point basename (${[...ac].join("/")}), ranked query-named basename first, then shallower path, then non-test path`}}if(t.modifier&&t.modifier!=="direct"&&!y$(r,i,a))return{matches:[],objMatch:null,candidates:[],ambiguous:!1,unsupportedModifier:!0,traversal:`modifier "${t.modifier}" requested for a "${i}" query \u2014 no closure traversal exists for this combination yet`};if(r==="ask"){let T=Nn(e,t.subject,n),P=Nn(e,t.object,n);if(!T.match||!P.match||T.ambiguous||P.ambiguous)return{matches:[],objMatch:P.match,candidates:P.candidates,traversal:null,ambiguous:!1,answer:null,unresolvedPronoun:!!(T.unresolvedPronoun||P.unresolvedPronoun)};let[G,K]=[T.match,P.match];i==="touches"&&K.class==="Commit"&&G.class!=="Commit"&&([G,K]=[K,G]);let te=ao[i],F=[...new Set(te?[...Rt(i),te]:Rt(i))],D=F.flatMap(B=>We(e,B)).filter(B=>B.subject===G.id&&B.object===K.id);return{matches:D,answer:t.negated?D.length===0:D.length>0,objMatch:P.match,subjMatch:T.match,candidates:[],traversal:`${F.join("+")} edge from ${G.label} to ${K.label}`,ambiguous:!1}}let l;if(o)l={match:o,candidates:[],ambiguous:!1,matchedVia:null};else{if(l=Nn(e,t.object,n),t.altObject&&t.altObject!==t.object){let T=Nn(e,t.altObject,n),P=!!l.match&&!l.ambiguous,G=!!T.match&&!T.ambiguous;!P&&G?l=T:P&&G&&l.match.id!==T.match.id&&(l={...l,ambiguous:!0,candidates:[T.match,...l.candidates||[]]})}if(t.kind==="tests"&&l.match&&!l.ambiguous&&!String(t.object||"").includes("/")){let T=K=>K.replace(/\.(?:test|spec|tests)(?=\.[^.]+$)/,""),P=T(String(t.object||"").trim().toLowerCase()),G=(e.individuals||[]).find(K=>{if(K.class!=="Module"||K.id===l.match.id)return!1;let te=String(K.label||"").toLowerCase().split("/").pop();return te!==T(te)&&T(te)===P});G&&(l={...l,ambiguous:!0,candidates:[G,...l.candidates||[]]})}}let{match:c,candidates:u,ambiguous:d,unresolvedPronoun:m,matchedVia:p,unplacedWords:f,nearestLabel:g}=l;if(!c)return{matches:[],objMatch:null,candidates:u,traversal:null,ambiguous:!1,unresolvedPronoun:m,unplacedWords:f,nearestLabel:g};if(d){let P=Mn([c,...u||[]]).slice(0,Ue).map(G=>{let K=Ht(e,t,{contextId:n,prev:s,pinnedObjMatch:G});return{candidate:G,result:K,rendered:bn(t,K,e)}});return{matches:[],objMatch:c,candidates:u,traversal:null,ambiguous:!0,branches:P}}if(r==="where"){let T=(c.attributes||[]).find(P=>P.key==="site")?.value||null;return{matches:[c],objMatch:c,candidates:u,ambiguous:d,matchedVia:p,whereShape:!0,site:T,traversal:T?`site attribute of ${c.label}`:`class + defining module of ${c.label}`}}if(r==="when"){let T=K=>String((K.attributes||[]).find(te=>te.key==="date")?.value||""),P;if(c.class==="Commit")P=[c];else{let K=["touches","touchesSymbol"].flatMap(F=>We(e,F)).filter(F=>F.object===c.id),te=new Set;P=[];for(let F of K){if(te.has(F.subject))continue;te.add(F.subject);let D=e.byId.get(F.subject);D&&D.class==="Commit"&&P.push(D)}P.sort((F,D)=>T(D).localeCompare(T(F)))}let G=P.length&&T(P[0])?[{kind:"event",class:"Commit",label:P[0].label,ids:[P[0].id],attrs:{date:T(P[0]).slice(0,10)},lane:"when"}]:[];return{matches:P,objMatch:c,candidates:u,ambiguous:d,matchedVia:p,whenShape:!0,referents:G,traversal:`touches+touchesSymbol edges where object = ${c.label}, newest commit date first`}}if(r==="whoLast"){let T=F=>String((F.attributes||[]).find(D=>D.key==="date")?.value||""),P=["touches","touchesSymbol"].flatMap(F=>We(e,F)).filter(F=>F.object===c.id),G=new Set,K=[];for(let F of P){if(G.has(F.subject))continue;G.add(F.subject);let D=e.byId.get(F.subject);D&&D.class==="Commit"&&K.push(D)}K.sort((F,D)=>T(D).localeCompare(T(F)));let te=K.length&&T(K[0])?[{kind:"event",class:"Commit",label:K[0].label,ids:[K[0].id],attrs:{date:T(K[0]).slice(0,10)},lane:"whoLast"}]:[];return{matches:K,objMatch:c,candidates:u,ambiguous:d,matchedVia:p,whoLastShape:!0,referents:te,traversal:`touches+touchesSymbol edges where object = ${c.label}, newest commit's author`}}if(i==="touches"&&c.class==="Commit")return m$(e,c,a,{candidates:u,ambiguous:d,matchedVia:p});if(r==="forward"){let T=ao[i],G=!!(T&&c.class&&ns.has(c.class))?[...new Set([...Rt(i),T])]:Rt(i);if(a&&a!=="Change"){let W=Cp(e,G),C=Ba[a];if(W.size&&!W.has(a)&&!(C&&W.has(C)))return{matches:[],objMatch:c,candidates:u,ambiguous:d,matchedVia:p,forwardGrainMiss:!0,wantClasses:[...W],traversal:`${G.join("+")} edges where subject = ${c.label} (grain mismatch: this "${i}" relation never targets a ${es(a)})`}}let te=G.flatMap(W=>We(e,W)).filter(W=>W.subject===c.id).map(W=>e.byId.get(W.object)).filter(Boolean),F=Mn(te),D=F,B="";if(a&&a!=="Change"){D=F.filter(C=>C.class===a);let W=Ba[a];if(!D.length&&W){let C=F.filter(I=>I.class===W);C.length&&(D=C,B=`, widened to ${W} subjects (no ${a} recorded)`)}}return{matches:D,objMatch:c,candidates:u,traversal:`${G.join("+")} edges where subject = ${c.label}${B}`,ambiguous:d,matchedVia:p}}if(t.modifier==="transitive")return{matches:no(e,c,{maxDepth:xp}).flat().map(G=>e.byId.get(G.id)).filter(Boolean),objMatch:c,candidates:u,ambiguous:d,matchedVia:p,traversal:`reverse dependency closure over imports+calls edges from ${c.label} (impactClosure, maxDepth=${xp})`};let h=ao[i]||Rt(i).find(T=>Ep.has(T))||null,b=!!(c.class&&ns.has(c.class));if(h&&(ns.has(a)||b)){let T=We(e,h).filter(B=>B.object===c.id),P=Mn(T.map(B=>e.byId.get(B.subject)).filter(Boolean)),G=!a||a==="Change"?P:P.filter(B=>B.class===a),K="",te=Ba[a];if(!G.length&&te){let B=P.filter(W=>W.class===te);B.length&&(G=B,K=`, widened to ${te} subjects (no ${a} recorded)`)}let F=(i==="touches"||i==="calls"||i==="uses")&&c.class==="Class"&&!We(e,"contains").some(B=>B.subject===c.id),D=F?e.byId.get(co(e,c)||""):null;if(G.length||!(F&&D))return{matches:G,objMatch:c,candidates:u,traversal:`${h} edges where object = ${c.label}${K}`,ambiguous:d,matchedVia:p}}let w=c,v=u,$=d,k=p,y="",j=Ip(e,i);if(j&&w.class&&w.class!==j){let T=cn(e,t.object,{expectedClass:j});if(T.match&&!T.ambiguous)w=T.match,v=T.candidates,$=T.ambiguous,k=T.matchedVia;else if(j==="Module"){let P=co(e,w),G=P&&e.byId.get(P);if(G)y=`, refined from ${w.label} to its containing module`,w=G;else return{matches:[],objMatch:w,candidates:v,ambiguous:$,matchedVia:k,wrongGrainMiss:!0,wantClass:j,traversal:`"${t.object}" resolved to ${es(w.class)} ${w.label} (grain mismatch: this "${i}" question needs a ${es(j)}, and no containing module could be found to refine to)`}}else return{matches:[],objMatch:w,candidates:v,ambiguous:$,matchedVia:k,wrongGrainMiss:!0,wantClass:j,traversal:`"${t.object}" resolved to ${es(w.class)} ${w.label} (grain mismatch: this "${i}" question needs a ${es(j)})`}}let E=Rt(i).flatMap(T=>We(e,T)).filter(T=>T.object===w.id);i==="cochange"&&(E=E.concat(Rt(i).flatMap(T=>We(e,T)).filter(T=>T.subject===w.id).map(T=>({...T,subject:T.object,object:T.subject}))));let _="";if(!E.length&&w.class){let T=`ext:${String(w.label).toLowerCase()}`;E=Rt(i).flatMap(P=>We(e,P)).filter(P=>String(P.object).toLowerCase()===T),E.length&&(_=` (by name, via unresolved ${T} references)`)}let R=[],S=new Set;for(let T of E){let P=e.byId.get(T.subject);P&&!S.has(P.id)&&(S.add(P.id),R.push(P))}let A,M="";if(!a||a==="Change")A=R;else{let T=R.filter(P=>P.class===a);if(T.length)A=T;else if(a!=="Module"&&R.some(P=>P.class==="Module")){let P=new Set(R.filter(G=>G.class==="Module").map(G=>G.id));A=ic(e,P,a),M=`, then ${es(a)} defined in the matched module(s)`}else A=[]}return{matches:A,objMatch:w,candidates:v,traversal:`${Rt(i).join("+")} edges where object = ${w.label}${_}${M}${y}`,ambiguous:$,matchedVia:k}}function tr(e){if(e.class==="Module")return e.label;let t=(e.attributes||[]).find(s=>s.key==="site")?.value;if(t)return String(t).split(":")[0];let n=String(e.id||"").match(/^fn:(.+)#/);return n?n[1]:"(unknown module)"}function qa(e){let t=String(e.label||e.id||"");return["Function","Method"].includes(e.class)?`function ${t}()`:t}function v$(e){let t=String(e.label||e.id||""),n=(e.attributes||[]).find(s=>s.key==="author")?.value;return n?`${t} (${n})`:t}function gn(e){return e.length>1?`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`:e[0]}function Qo(e){let t=e.object??e.subject??"?";return`${e.entityType?Pe(e.entityType,2)+" that ":""}${e.kind} "${t}"`}function Xa(e){return No[e]?.bare||e}function $$(e){let t=Xa(e);return t.endsWith("e")?`${t}d`:`${t}ed`}function x$(e){if(!Array.isArray(e.atoms)||e.atoms.length!==2)return null;let[t,n]=e.atoms;if(t.op!=="seed"||t.ast?.node!=="allOfClass"||n.op!=="difference")return null;let s=Pe(e.entityType,2);if(n.kind==="qual")return`${s} that are not ${n.filters.join(" and not ")}`;if(n.kind!=="set"||!n.ast)return null;if(n.ast.node==="existsEdge")return`${s} that do not ${Xa(n.ast.kind)} anything`;let o=n.ast.node==="clause"?n.ast.clause:n.ast;if(!o||o.node||!o.kind)return null;let r=o.object??o.subject;return r==null?null:`${s} that do not ${Xa(o.kind)} ${JSON.stringify(String(r))}`}function Kp(e){if(!e)return null;if(e.ambiguousParse)return{english:`ambiguous: ${e.candidates.map(Qo).join(" \u2014 or \u2014 ")}`,machine:`ambiguousParse(${e.candidates.map(r=>Kp(r)?.machine).join(", ")})`};if(e.node)return{english:(e.node==="boolean"?x$(e):null)||`a compositional query (${e.node})`,machine:`composite(${e.node})`};let t=r=>JSON.stringify(String(r??"")),n=[];e.kind&&n.push(e.kind),e.negated&&n.push("negated"),e.entityType&&n.push(`entityType=${e.entityType}`),e.modifier&&e.modifier!=="direct"&&n.push(`modifier=${e.modifier}`),e.subject!=null&&n.push(`subject=${t(e.subject)}`),e.object!=null&&n.push(t(e.object));let s=`${e.shape}(${n.join(", ")})`,o;if(e.shape==="ask")o=`does "${e.subject}" ${e.negated?"not ":""}${Rs(e.kind)} "${e.object}"?`;else if(e.shape==="meta")o=`what does "${e.object}" mean, in this graph's own vocabulary?`;else if(e.shape==="mentions")o=`where is "${e.object}" mentioned?`;else if(e.shape==="where")o=`where is "${e.object}" defined?`;else{let r=e.entityType?Pe(e.entityType,2)+" that ":"";o=e.shape==="forward"?`what "${e.object}" itself ${Rs(e.kind)}`:`${r}${Rs(e.kind)} "${e.object}"`}return{english:o,machine:s}}function bn(e,t,n=null){let s=Yp(e,t,n);return t&&t.matchedVia==="fuzzy"&&t.objMatch&&!s.ambiguous&&(s.content=`assuming you meant ${t.objMatch.label}: ${s.content}`),s}function Yp(e,t,n){if(!e)return{content:`couldn't parse this as a graph question. Try: ${rc()}`,miss:!0,ambiguous:!1};if(e.node)return u$(e,t,n);if(e.ambiguousParse)return t.branches&&t.branches.length?{content:`this could mean more than one thing:
55
55
  ${t.branches.map((l,c)=>`${c+1}) as ${Qo(l.parsed)}: ${l.rendered.content}`).join(`
56
56
  `)}
57
- (ask one of these directly, or try rephrasing more specifically, to get just that reading)`,miss:!1,ambiguous:!0,candidates:e.candidates.map(Qo),candidateParses:e.candidates}:{content:`this could mean more than one thing: ${e.candidates.map((a,l)=>`${l+1}) ${Qo(a)}`).join(" or ")} \u2014 try rephrasing more specifically.`,miss:!1,ambiguous:!0,candidates:e.candidates.map(Qo),candidateParses:e.candidates};if(t.unresolvedPronoun)return{content:`"${e.object??e.subject}" needs a selected node to refer to \u2014 click a node first, or name it directly.`,miss:!0,ambiguous:!1};if(t.unsupportedModifier)return{content:`the "${e.modifier}" modifier isn't supported for "${e.kind}" queries yet \u2014 only imports/calls (module-level) have a transitive closure today.`,miss:!0,ambiguous:!1};if(t.wrongGrainMiss){let i=t.objMatch.class?Pe(t.objMatch.class,1):"term",a=Pe(t.wantClass,1);return{content:`"${e.object}" resolved to the ${i} ${t.objMatch.label}, but this question needs a ${a} \u2014 no ${a} named "${e.object}" was found in the index.`,miss:!0,ambiguous:!1}}if(t.forwardGrainMiss){let i=t.wantClasses.map(a=>Pe(a,2));return{content:`${t.objMatch.label}'s "${Rs(e.kind)}" relation in this index never produces ${Pe(e.entityType,2)} \u2014 only ${hn(i)}.`,miss:!0,ambiguous:!1}}if(e.shape==="meta"){if(!t.objMatch)return{content:`"${e.object}" isn't a term in this graph's own vocabulary (no matching class or predicate).`,miss:!0,ambiguous:!1};if(t.metaCodeClass)return{content:t.metaFallbackText,miss:!1,ambiguous:!1,matches:t.matches};let i=(t.objMatch.attributes||[]).find(l=>l.key==="doc")?.value||"",a=t.objMatch.class==="SchemaClass"?"a class in the graph's schema":"a predicate (relation) in the graph's schema";return{content:`${t.objMatch.label} is ${a}: ${i}`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.mentionsShape){if(!t.matches.length)return{content:`"${e.object}" is not mentioned in any indexed identifier or doc-comment prose.`,miss:!0,ambiguous:!1};let i=t.matches.slice(0,Ue).map(l=>`${l.label} (${Pe(l.class,1)})`),a=t.matches.length>Ue?`, \u2026and ${t.matches.length-Ue} more`:"";return{content:`"${e.object}" is mentioned in the prose tokens of ${hn(i)}${a}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.entryPointShape){if(!t.matches.length)return{content:`no entry-point module found in the index \u2014 no module basename matches ${hn([...ac])}.`,miss:!0,ambiguous:!1,candidates:[]};let[i,...a]=t.matches,l=a.slice(0,Ue).map(d=>d.label),c=a.length>Ue?`, \u2026and ${a.length-Ue} more`:"",u=a.length?` \u2014 also matched: ${hn(l)}${c}`:"";return{content:`ranked ${t.matches.length} entry-point match${t.matches.length===1?"":"es"}; top: ${i.label}${u}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(!t.objMatch&&(!t.candidates||t.candidates.length===0)&&e.shape!=="ask"){let i=String(e.object||"").trim(),a=e.entityType&&jp[e.entityType]?Pe(e.entityType,1):"module",l=/^(?:commit[:\s])?[0-9a-f]{7,40}$/i.test(i)?"commit":!i.includes("/")&&/^[\w$]+(\.[\w$]+)+$/.test(i)?"symbol":a;if(t.unplacedWords?.length){let c=hn(t.unplacedWords.map(m=>`"${m}"`)),u=t.unplacedWords.length===1?"names":"name",d=t.nearestLabel?` Did you mean ${t.nearestLabel}?`:"";return{content:`no ${l} matching "${e.object}" found in the index. ${c} ${u} nothing here, and reading past ${t.unplacedWords.length===1?"it":"them"} would answer a different question.${d}`,miss:!0,ambiguous:!1,candidates:[]}}return{content:`no ${l} matching "${e.object}" found in the index. ${ts(n)}`,miss:!0,ambiguous:!1,candidates:[]}}if(t.ambiguous){let i=[t.objMatch,...t.candidates||[]].filter(Boolean),a=t.branches;if(e.kind&&e.kind!=="touches"&&!i.every(h=>h.class==="Commit")){let h=w=>!["Commit","Session","Source","Utterance"].includes(w?.class),b=i.filter(h);b.length&&(i=b,a?.length&&(a=a.filter(w=>h(w.candidate))))}if(n&&!/[/.]/.test(String(e.object||""))){let h=String(e.object||"").toLowerCase(),b=new Set(fn(String(e.object||"")).filter(y=>y.length>=3)),w=new Set(i.map(y=>y.id)),v=null,$=0,k=1/0;if(b.size)for(let y of n.individuals){if(!["Function","Method","Class","GlobalVariable","Attribute"].includes(y.class)||w.has(y.id))continue;let j=fn(String(y.label)).filter(_=>b.has(_)).length;if(!j||j<$)continue;let E=Ln(String(y.label).toLowerCase(),h,8);(j>$||E<k)&&(v=y,$=j,k=E)}if(v&&(i=[...i,v],a)){let y=Ht(n,e,{pinnedObjMatch:v});a=[...a,{candidate:v,result:y,rendered:gn(e,y,n)}]}}let l=i.length&&i.every(h=>h.class==="Commit")?"commit":"module",c=i.slice(0,Ue).map(h=>h.label),u=i.length>Ue?`, \u2026and ${i.length-Ue} more`:"",d=`"${e.object}" matches more than one ${l} ambiguously \u2014 did you mean ${hn(c)}${u}? Try one of those. If you're not sure, narrow it to one name.`,m=String(e.object||""),p=m?new RegExp(`\\b${He(m)}\\b`,"gi"):null,f=h=>p?h.rendered.content.replace(p,h.candidate.label):h.rendered.content;return{content:a&&a.length?`${d}
57
+ (ask one of these directly, or try rephrasing more specifically, to get just that reading)`,miss:!1,ambiguous:!0,candidates:e.candidates.map(Qo),candidateParses:e.candidates}:{content:`this could mean more than one thing: ${e.candidates.map((a,l)=>`${l+1}) ${Qo(a)}`).join(" or ")} \u2014 try rephrasing more specifically.`,miss:!1,ambiguous:!0,candidates:e.candidates.map(Qo),candidateParses:e.candidates};if(t.unresolvedPronoun)return{content:`"${e.object??e.subject}" needs a selected node to refer to \u2014 click a node first, or name it directly.`,miss:!0,ambiguous:!1};if(t.unsupportedModifier)return{content:`the "${e.modifier}" modifier isn't supported for "${e.kind}" queries yet \u2014 only imports/calls (module-level) have a transitive closure today.`,miss:!0,ambiguous:!1};if(t.wrongGrainMiss){let i=t.objMatch.class?Pe(t.objMatch.class,1):"term",a=Pe(t.wantClass,1);return{content:`"${e.object}" resolved to the ${i} ${t.objMatch.label}, but this question needs a ${a} \u2014 no ${a} named "${e.object}" was found in the index.`,miss:!0,ambiguous:!1}}if(t.forwardGrainMiss){let i=t.wantClasses.map(a=>Pe(a,2));return{content:`${t.objMatch.label}'s "${Rs(e.kind)}" relation in this index never produces ${Pe(e.entityType,2)} \u2014 only ${gn(i)}.`,miss:!0,ambiguous:!1}}if(e.shape==="meta"){if(!t.objMatch)return{content:`"${e.object}" isn't a term in this graph's own vocabulary (no matching class or predicate).`,miss:!0,ambiguous:!1};if(t.metaCodeClass)return{content:t.metaFallbackText,miss:!1,ambiguous:!1,matches:t.matches};let i=(t.objMatch.attributes||[]).find(l=>l.key==="doc")?.value||"",a=t.objMatch.class==="SchemaClass"?"a class in the graph's schema":"a predicate (relation) in the graph's schema";return{content:`${t.objMatch.label} is ${a}: ${i}`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.mentionsShape){if(!t.matches.length)return{content:`"${e.object}" is not mentioned in any indexed identifier or doc-comment prose.`,miss:!0,ambiguous:!1};let i=t.matches.slice(0,Ue).map(l=>`${l.label} (${Pe(l.class,1)})`),a=t.matches.length>Ue?`, \u2026and ${t.matches.length-Ue} more`:"";return{content:`"${e.object}" is mentioned in the prose tokens of ${gn(i)}${a}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.entryPointShape){if(!t.matches.length)return{content:`no entry-point module found in the index \u2014 no module basename matches ${gn([...ac])}.`,miss:!0,ambiguous:!1,candidates:[]};let[i,...a]=t.matches,l=a.slice(0,Ue).map(d=>d.label),c=a.length>Ue?`, \u2026and ${a.length-Ue} more`:"",u=a.length?` \u2014 also matched: ${gn(l)}${c}`:"";return{content:`ranked ${t.matches.length} entry-point match${t.matches.length===1?"":"es"}; top: ${i.label}${u}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(!t.objMatch&&(!t.candidates||t.candidates.length===0)&&e.shape!=="ask"){let i=String(e.object||"").trim(),a=e.entityType&&jp[e.entityType]?Pe(e.entityType,1):"module",l=/^(?:commit[:\s])?[0-9a-f]{7,40}$/i.test(i)?"commit":!i.includes("/")&&/^[\w$]+(\.[\w$]+)+$/.test(i)?"symbol":a;if(t.unplacedWords?.length){let c=gn(t.unplacedWords.map(m=>`"${m}"`)),u=t.unplacedWords.length===1?"names":"name",d=t.nearestLabel?` Did you mean ${t.nearestLabel}?`:"";return{content:`no ${l} matching "${e.object}" found in the index. ${c} ${u} nothing here, and reading past ${t.unplacedWords.length===1?"it":"them"} would answer a different question.${d}`,miss:!0,ambiguous:!1,candidates:[]}}return{content:`no ${l} matching "${e.object}" found in the index. ${ts(n)}`,miss:!0,ambiguous:!1,candidates:[]}}if(t.ambiguous){let i=[t.objMatch,...t.candidates||[]].filter(Boolean),a=t.branches;if(e.kind&&e.kind!=="touches"&&!i.every(h=>h.class==="Commit")){let h=w=>!["Commit","Session","Source","Utterance"].includes(w?.class),b=i.filter(h);b.length&&(i=b,a?.length&&(a=a.filter(w=>h(w.candidate))))}if(n&&!/[/.]/.test(String(e.object||""))){let h=String(e.object||"").toLowerCase(),b=new Set(mn(String(e.object||"")).filter(y=>y.length>=3)),w=new Set(i.map(y=>y.id)),v=null,$=0,k=1/0;if(b.size)for(let y of n.individuals){if(!["Function","Method","Class","GlobalVariable","Attribute"].includes(y.class)||w.has(y.id))continue;let j=mn(String(y.label)).filter(_=>b.has(_)).length;if(!j||j<$)continue;let E=Ln(String(y.label).toLowerCase(),h,8);(j>$||E<k)&&(v=y,$=j,k=E)}if(v&&(i=[...i,v],a)){let y=Ht(n,e,{pinnedObjMatch:v});a=[...a,{candidate:v,result:y,rendered:bn(e,y,n)}]}}let l=i.length&&i.every(h=>h.class==="Commit")?"commit":"module",c=i.slice(0,Ue).map(h=>h.label),u=i.length>Ue?`, \u2026and ${i.length-Ue} more`:"",d=`"${e.object}" matches more than one ${l} ambiguously \u2014 did you mean ${gn(c)}${u}? Try one of those. If you're not sure, narrow it to one name.`,m=String(e.object||""),p=m?new RegExp(`\\b${He(m)}\\b`,"gi"):null,f=h=>p?h.rendered.content.replace(p,h.candidate.label):h.rendered.content;return{content:a&&a.length?`${d}
58
58
  ${a.map((h,b)=>`${b+1}) ${h.candidate.label}: ${f(h)}`).join(`
59
- `)}`:d,miss:!1,ambiguous:!0,candidates:i.map(h=>h.label)}}if(t.whereShape){let i=t.objMatch;if(i.class==="Module")return{content:`${i.label} is a module \u2014 the label is its repo path.`,miss:!1,ambiguous:!1,matches:t.matches};if(i.class==="Commit")return{content:`${i.label} is a commit, not a code location \u2014 try "what did commit ${i.label} touch".`,miss:!0,ambiguous:!1};let a=String(t.site||"").match(/^(.*):(\d+)(?:-(\d+))?$/);if(a){let l=a[3]&&a[3]!==a[2]?`lines ${a[2]}-${a[3]}`:`line ${a[2]}`;return{content:`${qa(i)} is defined in ${a[1]} at ${l}.`,miss:!1,ambiguous:!1,matches:t.matches}}return{content:`${qa(i)} is defined in ${tr(i)} (no line span recorded in this index).`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.whenShape){let i=t.objMatch.label;if(!t.matches.length)return{content:`no recorded commit touches ${i} in this index. ${ts(n)}`,miss:!0,ambiguous:!1};let a=t.matches[0],l=(a.attributes||[]).find(m=>m.key==="date")?.value||"";if(!l)return{content:`commit ${a.label} touched ${i}, but this index records no commit dates \u2014 regenerate the graph to attach mgx:commitDate.`,miss:!0,ambiguous:!1};let c=(a.attributes||[]).find(m=>m.key==="message")?.value||"",u=String(l).slice(0,10);if(a.id===t.objMatch.id)return{content:`commit ${a.label} ${Xo("is-dated",a.id,"is dated")} ${u}${c?` ("${c}")`:""}.`,miss:!1,ambiguous:!1,matches:t.matches};let d=t.matches.length-1;return{content:`${i} was last touched by commit ${a.label} on ${u}${c?` ("${c}")`:""}${d?`; ${d} earlier commit${d===1?"":"s"} recorded`:""}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.whoLastShape){let i=t.objMatch.label;if(!t.matches.length)return{content:`no recorded commit touches ${i} in this index. ${ts(n)}`,miss:!0,ambiguous:!1};let a=t.matches[0],l=(a.attributes||[]).find(u=>u.key==="author")?.value;if(!l)return{content:`commit ${a.label} last touched ${i}, but this index records no commit author \u2014 regenerate the graph to attach mgx:commitAuthor.`,miss:!0,ambiguous:!1};let c=t.matches.length-1;return{content:`${i} was last touched by ${l} (commit ${a.label})${c?`; ${c} earlier commit${c===1?"":"s"} recorded`:""}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.commitSubject){let i=`commit ${t.objMatch.label}`;if(!t.matches.length)return{content:`${i} touched nothing recorded in the index.`,miss:!0,ambiguous:!1};let a=new Map;for(let u of t.matches.slice(0,Ue)){let d=u.class||"Module";a.has(d)||a.set(d,[]),a.get(d).push(["Function","Method"].includes(d)?`${u.label}()`:u.label)}let l=[...a.entries()].map(([u,d])=>`${Pe(u,d.length)} ${hn(d)}`),c=t.matches.length>Ue?`; \u2026and ${t.matches.length-Ue} more`:"";return{content:`${i} touched ${l.join("; ")}${c}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(e.shape==="ask"){if(!t.objMatch||!t.subjMatch)return{content:"couldn't resolve one of the terms in this question.",miss:!0,ambiguous:!1};let i=`${t.traversal}.`,a=`no ${e.kind} edge found from ${t.subjMatch.label} to ${t.objMatch.label}.`,l=e.negated?a:i,c=e.negated?i:a;return{content:`${t.answer?"Yes":"No"} \u2014 ${t.answer?l:c}`,miss:!t.matches.length,ambiguous:!1}}if(!t.matches.length){if(e.shape==="forward"){if(Js.includes(e.kind)&&n&&t.objMatch)for(let l of Js){if(l===e.kind)continue;let c={...e,kind:l},u=Ht(n,c,{pinnedObjMatch:t.objMatch});if(u?.matches?.length&&!u.ambiguous)return Yp(c,u,n)}return{content:`${t.objMatch.label} has no ${Rs(e.kind)} edges in the index.`,miss:!0,ambiguous:!1}}if(e.kind==="tests"&&!e.entityType)return{content:`No tests cover ${String(e.object||"").replace(iv,"").trim()||String(e.object||"").trim()}.`,miss:!0,ambiguous:!1};let i=Pe(e.entityType||"Module",2),a=t.objMatch&&bs.includes(String(e.object||"").toLowerCase())?t.objMatch.label:e.object;return{content:`No ${i} found whose module directly ${Rs(e.kind)} ${a}. ${ts(n)}`,miss:!0,ambiguous:!1}}if(e.polar&&t.matches.length===1)return{content:`Yes \u2014 ${t.objMatch?.label||e.object} is ${$$(e.kind)} by ${t.matches[0].label}.`,miss:!1,ambiguous:!1,matches:t.matches};if(e.shape==="forward"||e.entityType==="Module"||t.matches.every(i=>!ns.has(i.class))){let i=t.matches.slice(0,Ue).map(l=>l.class==="Commit"?v$(l):l.label),a=t.matches.length>Ue?`, \u2026and ${t.matches.length-Ue} more`:"";return{content:i.join(" and ")+a+".",miss:!1,ambiguous:!1,matches:t.matches}}let s=new Map;for(let i of t.matches.slice(0,Ue)){let a=tr(i);s.has(a)||s.set(a,[]),s.get(a).push(qa(i))}let o=[...s.entries()].map(([i,a],l)=>{let c=hn(a);return l===0?`in ${i} there is ${c}`:`there is ${c} in ${i}`}),r=t.matches.length>Ue?` \u2026and ${t.matches.length-Ue} more`:"";return{content:o.join(" and ")+r+".",miss:!1,ambiguous:!1,matches:t.matches}}function Jp(e){if(e.length<4||E$.has(e))return null;let t=Qn(e),n=t+1,s=null,o=!1;for(let r of S$){let i=Ln(e,r,Math.min(n,t));i<n?(n=i,s=r,o=!1):i===n&&i<=t&&r!==s&&(o=!0)}return n<=t&&!o?s:null}function kp(e,t){if(!e?.match||e.matchedVia!=="fuzzy"||e.ambiguous)return!1;let n=e.match.class;if(n!=="SchemaClass"&&n!=="SchemaPredicate")return!1;let s=String(t||"").trim().toLowerCase(),o=Jp(s);return!!o&&o!==s&&!!Be[o]}function Qp(e,t,n){if(!t)return!1;if(t.ambiguousParse)return"ambiguous";if(t.node)return t.node!=="miss";if(t.shape==="meta"||t.shape==="mentions")return!0;let s=Nn(e,t.object,n);if(s.unresolvedPronoun)return"pronoun";if(!s.match||kp(s,t.object))return!1;if(t.shape==="ask"){let o=Nn(e,t.subject,n);return o.unresolvedPronoun?"pronoun":!!(o.match&&!kp(o,t.subject))}return!0}function j$(e){let t=String(e||"").trim().toLowerCase().replace(/[?.!\s]+$/,"");return ku.includes(t)}function _$(e,t,{nlp:n=void 0,contextId:s=null,prev:o=null}={}){let r=Vo(_s(String(t||""))),i=Qt(r);if(!i.length)return null;let a=[],l=[],c=S=>{let A=cn(e,S);return!!A.match&&A.tier!=null&&A.tier<=2},u=S=>{let A=cn(e,S);return!!A.match&&A.tier!=null&&A.tier<=3},d=S=>{let A=String(S||"").trim().toLowerCase();return bs.includes(A)?!0:Qt(A).some(M=>{let T=M.toLowerCase();return!oi.has(T)&&!Ja.has(T)})},m=new Set(["reverse","forward","where","when","ask"]),p=S=>{let A=S.join(" "),M=er(A,{nlp:n});return Qp(e,M,s)!==!0||M&&!M.node&&m.has(M.shape)&&(M.object!=null&&!d(M.object)||M.shape==="ask"&&M.subject!=null&&!d(M.subject))||gn(M,Ht(e,M,{contextId:s,prev:o}),e).miss?null:{parsed:M,text:A}},f=S=>({parsed:S.parsed,from:r,to:S.text,dropped:[...a],steps:l}),g=0,h=Math.max(i.length,1)+12;for(;g<h;g+=1){let S=-1;for(let T=0;T<i.length;T+=1){let P=i[T].toLowerCase();if(cc.has(P)&&!oi.has(P)&&!c(i[T])){S=T;break}}if(S<0)break;let A=i[S];i=i.filter((T,P)=>P!==S),a.push(A),l.push(`strip noise "${A}" \u2192 "${i.join(" ")}"`);let M=p(i);if(M)return f(M)}let b=er(i.join(" "),{nlp:n}),w=new Set;if(b&&!b.node&&m.has(b.shape))for(let S of[b.object,b.subject])for(let A of Qt(String(S||"").toLowerCase()))w.add(A);let v=[],$=[],k=[];for(let S of i){let A=S.toLowerCase();if(!/^[a-z]+$/.test(A)||oi.has(A)||Ja.has(A)||u(S)){v.push(S);continue}let T=Jp(A);if(T&&T!==A){v.push(T),k.push(`${S}\u2192${T}`);continue}if(w.has(A)){v.push(S);continue}$.push(S)}if((k.length||$.length)&&v.length){i=v,a.push(...$),k.length&&l.push(`fuzzy-correct ${JSON.stringify(k)} \u2192 "${i.join(" ")}"`),$.length&&l.push(`drop unmatched ${JSON.stringify($)} \u2192 "${i.join(" ")}"`);let S=p(i);if(S)return f(S)}let y=!1,j=i.map(S=>{let A=S.toLowerCase();return Qs[A]&&!u(S)?(y=!0,Qs[A]):S});if(y){l.push(`normalise synonyms \u2192 "${j.join(" ")}"`);let S=p(j);if(S)return f(S)}let E=Qt(r).map(S=>S.toLowerCase()),_=[],R=[];for(let S of E){if(Xp.has(S))continue;let A=Be[S];A&&A!=="Change"?_.push(S):R.push(S)}if(_.length===1&&R.length===0){let S=p(["count",_[0]]);if(S)return l.push(`bare kind "${_[0]}" \u2192 count`),f(S)}return null}function A$(e,t){let n=String(t||"");if(!e||!Sp.test(n))return n;let s=e.individuals.filter(l=>l.class==="Commit");if(!s.length)return n;let o=l=>String((l.attributes||[]).find(c=>c.key==="date")?.value||""),r=[...s].sort((l,c)=>o(c).localeCompare(o(l)))[0];if(!r)return n;let i=n.replace(Sp,`commit ${r.label}`),a=i.trim().replace(/[?.!]+$/,"");return R$.test(a)?`${a} touched`:i}function T$(e){let t=String(e||"").toLowerCase(),n=new Set([t]);return t.endsWith("ies")&&n.add(`${t.slice(0,-3)}y`),(t.endsWith("ses")||t.endsWith("es"))&&n.add(t.slice(0,-2)),t.endsWith("s")&&t.length>1&&n.add(t.slice(0,-1)),[...n]}function C$(e,t){let n=T$(t);for(let s of e?.individuals||[])if(s?.class&&n.includes(String(s.class).toLowerCase()))return s.class;return null}function L$(e,t){let n=String(t||"").trim(),s=n.match(I$),o=s?null:n.match(O$),r=s||o;if(!r||!lc.test(r[2]||"")||Be[r[1].toLowerCase()])return null;let i=C$(e,r[1]);if(!i)return null;let a={node:"allOfClass",entityType:i};return s?{node:"list",entityType:i,base:a,scoped:!1}:{node:"count",entityType:i,base:a}}function ss(e,t,{contextId:n=null,nlp:s=void 0,prev:o=null}={}){if(j$(t))return{content:rc(),tmct_ask:{mechanical:!0,parsed:null,canonical:null,matches:[],traversal:null,miss:!0,ambiguous:!1,matchedVia:null,help:!0,relaxed:null}};t=A$(e,t);let r=Qa(t,{nlp:s}),i=r.parsed,a=i,l=null;if(Qp(e,i,n)===!1){let m=_$(e,t,{nlp:s,contextId:n,prev:o});m&&(a=m.parsed,l={from:m.from,to:m.to,dropped:m.dropped,steps:m.steps})}let c=Ht(e,a,{contextId:n,prev:o}),u=gn(a,c,e);if(u.miss&&!u.ambiguous){let m=L$(e,t);if(m){let p=Ht(e,m,{contextId:n,prev:o}),f=gn(m,p,e);f.miss||(a=m,c=p,u=f,l=null)}}if(a===null&&u.miss&&!u.ambiguous){let p=Hr(String(t||"")).trim().match(N$)?.[1]?.trim();if(p&&!/\s+(?:for|about)$/i.test(p)){let f=er(`what is a ${p}`,{nlp:s});f?.shape==="meta"&&(c=Ht(e,f,{contextId:n,prev:o}),u=gn(f,c,e))}}if(a===null&&u.miss&&!u.ambiguous){let p=_s(String(t||"")).match(M$)?.[1]?.trim();if(p){let f=er(`what is a ${p}`,{nlp:s});if(f?.shape==="meta"){let g=Ht(e,f,{contextId:n,prev:o}),h=gn(f,g,e);!h.miss&&!h.ambiguous&&(c=g,u=h)}}}let d=l&&!u.miss&&l.to!==l.from?`read as "${l.to}" \u2014 ${u.content}`:u.content;if(!l&&!u.miss&&!u.ambiguous&&r.alternates.length){let m=r.alternates.map(p=>{let f=Ht(e,p.parsed,{contextId:n,prev:o}),g=gn(p.parsed,f,e);return g.miss?null:{a:p,text:g.content}}).filter(Boolean);if(m.length){let p=ap(m.map(f=>f.a),{answerFor:f=>m.find(g=>g.a===f)?.text||null});d=`${d}
59
+ `)}`:d,miss:!1,ambiguous:!0,candidates:i.map(h=>h.label)}}if(t.whereShape){let i=t.objMatch;if(i.class==="Module")return{content:`${i.label} is a module \u2014 the label is its repo path.`,miss:!1,ambiguous:!1,matches:t.matches};if(i.class==="Commit")return{content:`${i.label} is a commit, not a code location \u2014 try "what did commit ${i.label} touch".`,miss:!0,ambiguous:!1};let a=String(t.site||"").match(/^(.*):(\d+)(?:-(\d+))?$/);if(a){let l=a[3]&&a[3]!==a[2]?`lines ${a[2]}-${a[3]}`:`line ${a[2]}`;return{content:`${qa(i)} is defined in ${a[1]} at ${l}.`,miss:!1,ambiguous:!1,matches:t.matches}}return{content:`${qa(i)} is defined in ${tr(i)} (no line span recorded in this index).`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.whenShape){let i=t.objMatch.label;if(!t.matches.length)return{content:`no recorded commit touches ${i} in this index. ${ts(n)}`,miss:!0,ambiguous:!1};let a=t.matches[0],l=(a.attributes||[]).find(m=>m.key==="date")?.value||"";if(!l)return{content:`commit ${a.label} touched ${i}, but this index records no commit dates \u2014 regenerate the graph to attach mgx:commitDate.`,miss:!0,ambiguous:!1};let c=(a.attributes||[]).find(m=>m.key==="message")?.value||"",u=String(l).slice(0,10);if(a.id===t.objMatch.id)return{content:`commit ${a.label} ${Xo("is-dated",a.id,"is dated")} ${u}${c?` ("${c}")`:""}.`,miss:!1,ambiguous:!1,matches:t.matches};let d=t.matches.length-1;return{content:`${i} was last touched by commit ${a.label} on ${u}${c?` ("${c}")`:""}${d?`; ${d} earlier commit${d===1?"":"s"} recorded`:""}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.whoLastShape){let i=t.objMatch.label;if(!t.matches.length)return{content:`no recorded commit touches ${i} in this index. ${ts(n)}`,miss:!0,ambiguous:!1};let a=t.matches[0],l=(a.attributes||[]).find(u=>u.key==="author")?.value;if(!l)return{content:`commit ${a.label} last touched ${i}, but this index records no commit author \u2014 regenerate the graph to attach mgx:commitAuthor.`,miss:!0,ambiguous:!1};let c=t.matches.length-1;return{content:`${i} was last touched by ${l} (commit ${a.label})${c?`; ${c} earlier commit${c===1?"":"s"} recorded`:""}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(t.commitSubject){let i=`commit ${t.objMatch.label}`;if(!t.matches.length)return{content:`${i} touched nothing recorded in the index.`,miss:!0,ambiguous:!1};let a=new Map;for(let u of t.matches.slice(0,Ue)){let d=u.class||"Module";a.has(d)||a.set(d,[]),a.get(d).push(["Function","Method"].includes(d)?`${u.label}()`:u.label)}let l=[...a.entries()].map(([u,d])=>`${Pe(u,d.length)} ${gn(d)}`),c=t.matches.length>Ue?`; \u2026and ${t.matches.length-Ue} more`:"";return{content:`${i} touched ${l.join("; ")}${c}.`,miss:!1,ambiguous:!1,matches:t.matches}}if(e.shape==="ask"){if(!t.objMatch||!t.subjMatch)return{content:"couldn't resolve one of the terms in this question.",miss:!0,ambiguous:!1};let i=`${t.traversal}.`,a=`no ${e.kind} edge found from ${t.subjMatch.label} to ${t.objMatch.label}.`,l=e.negated?a:i,c=e.negated?i:a;return{content:`${t.answer?"Yes":"No"} \u2014 ${t.answer?l:c}`,miss:!t.matches.length,ambiguous:!1}}if(!t.matches.length){if(e.shape==="forward"){if(Js.includes(e.kind)&&n&&t.objMatch)for(let l of Js){if(l===e.kind)continue;let c={...e,kind:l},u=Ht(n,c,{pinnedObjMatch:t.objMatch});if(u?.matches?.length&&!u.ambiguous)return Yp(c,u,n)}return{content:`${t.objMatch.label} has no ${Rs(e.kind)} edges in the index.`,miss:!0,ambiguous:!1}}if(e.kind==="tests"&&!e.entityType)return{content:`No tests cover ${String(e.object||"").replace(iv,"").trim()||String(e.object||"").trim()}.`,miss:!0,ambiguous:!1};let i=Pe(e.entityType||"Module",2),a=t.objMatch&&bs.includes(String(e.object||"").toLowerCase())?t.objMatch.label:e.object;return{content:`No ${i} found whose module directly ${Rs(e.kind)} ${a}. ${ts(n)}`,miss:!0,ambiguous:!1}}if(e.polar&&t.matches.length===1)return{content:`Yes \u2014 ${t.objMatch?.label||e.object} is ${$$(e.kind)} by ${t.matches[0].label}.`,miss:!1,ambiguous:!1,matches:t.matches};if(e.shape==="forward"||e.entityType==="Module"||t.matches.every(i=>!ns.has(i.class))){let i=t.matches.slice(0,Ue).map(l=>l.class==="Commit"?v$(l):l.label),a=t.matches.length>Ue?`, \u2026and ${t.matches.length-Ue} more`:"";return{content:i.join(" and ")+a+".",miss:!1,ambiguous:!1,matches:t.matches}}let s=new Map;for(let i of t.matches.slice(0,Ue)){let a=tr(i);s.has(a)||s.set(a,[]),s.get(a).push(qa(i))}let o=[...s.entries()].map(([i,a],l)=>{let c=gn(a);return l===0?`in ${i} there is ${c}`:`there is ${c} in ${i}`}),r=t.matches.length>Ue?` \u2026and ${t.matches.length-Ue} more`:"";return{content:o.join(" and ")+r+".",miss:!1,ambiguous:!1,matches:t.matches}}function Jp(e){if(e.length<4||E$.has(e))return null;let t=Qn(e),n=t+1,s=null,o=!1;for(let r of S$){let i=Ln(e,r,Math.min(n,t));i<n?(n=i,s=r,o=!1):i===n&&i<=t&&r!==s&&(o=!0)}return n<=t&&!o?s:null}function kp(e,t){if(!e?.match||e.matchedVia!=="fuzzy"||e.ambiguous)return!1;let n=e.match.class;if(n!=="SchemaClass"&&n!=="SchemaPredicate")return!1;let s=String(t||"").trim().toLowerCase(),o=Jp(s);return!!o&&o!==s&&!!Be[o]}function Qp(e,t,n){if(!t)return!1;if(t.ambiguousParse)return"ambiguous";if(t.node)return t.node!=="miss";if(t.shape==="meta"||t.shape==="mentions")return!0;let s=Nn(e,t.object,n);if(s.unresolvedPronoun)return"pronoun";if(!s.match||kp(s,t.object))return!1;if(t.shape==="ask"){let o=Nn(e,t.subject,n);return o.unresolvedPronoun?"pronoun":!!(o.match&&!kp(o,t.subject))}return!0}function j$(e){let t=String(e||"").trim().toLowerCase().replace(/[?.!\s]+$/,"");return ku.includes(t)}function _$(e,t,{nlp:n=void 0,contextId:s=null,prev:o=null}={}){let r=Vo(_s(String(t||""))),i=Qt(r);if(!i.length)return null;let a=[],l=[],c=S=>{let A=cn(e,S);return!!A.match&&A.tier!=null&&A.tier<=2},u=S=>{let A=cn(e,S);return!!A.match&&A.tier!=null&&A.tier<=3},d=S=>{let A=String(S||"").trim().toLowerCase();return bs.includes(A)?!0:Qt(A).some(M=>{let T=M.toLowerCase();return!oi.has(T)&&!Ja.has(T)})},m=new Set(["reverse","forward","where","when","ask"]),p=S=>{let A=S.join(" "),M=er(A,{nlp:n});return Qp(e,M,s)!==!0||M&&!M.node&&m.has(M.shape)&&(M.object!=null&&!d(M.object)||M.shape==="ask"&&M.subject!=null&&!d(M.subject))||bn(M,Ht(e,M,{contextId:s,prev:o}),e).miss?null:{parsed:M,text:A}},f=S=>({parsed:S.parsed,from:r,to:S.text,dropped:[...a],steps:l}),g=0,h=Math.max(i.length,1)+12;for(;g<h;g+=1){let S=-1;for(let T=0;T<i.length;T+=1){let P=i[T].toLowerCase();if(cc.has(P)&&!oi.has(P)&&!c(i[T])){S=T;break}}if(S<0)break;let A=i[S];i=i.filter((T,P)=>P!==S),a.push(A),l.push(`strip noise "${A}" \u2192 "${i.join(" ")}"`);let M=p(i);if(M)return f(M)}let b=er(i.join(" "),{nlp:n}),w=new Set;if(b&&!b.node&&m.has(b.shape))for(let S of[b.object,b.subject])for(let A of Qt(String(S||"").toLowerCase()))w.add(A);let v=[],$=[],k=[];for(let S of i){let A=S.toLowerCase();if(!/^[a-z]+$/.test(A)||oi.has(A)||Ja.has(A)||u(S)){v.push(S);continue}let T=Jp(A);if(T&&T!==A){v.push(T),k.push(`${S}\u2192${T}`);continue}if(w.has(A)){v.push(S);continue}$.push(S)}if((k.length||$.length)&&v.length){i=v,a.push(...$),k.length&&l.push(`fuzzy-correct ${JSON.stringify(k)} \u2192 "${i.join(" ")}"`),$.length&&l.push(`drop unmatched ${JSON.stringify($)} \u2192 "${i.join(" ")}"`);let S=p(i);if(S)return f(S)}let y=!1,j=i.map(S=>{let A=S.toLowerCase();return Qs[A]&&!u(S)?(y=!0,Qs[A]):S});if(y){l.push(`normalise synonyms \u2192 "${j.join(" ")}"`);let S=p(j);if(S)return f(S)}let E=Qt(r).map(S=>S.toLowerCase()),_=[],R=[];for(let S of E){if(Xp.has(S))continue;let A=Be[S];A&&A!=="Change"?_.push(S):R.push(S)}if(_.length===1&&R.length===0){let S=p(["count",_[0]]);if(S)return l.push(`bare kind "${_[0]}" \u2192 count`),f(S)}return null}function A$(e,t){let n=String(t||"");if(!e||!Sp.test(n))return n;let s=e.individuals.filter(l=>l.class==="Commit");if(!s.length)return n;let o=l=>String((l.attributes||[]).find(c=>c.key==="date")?.value||""),r=[...s].sort((l,c)=>o(c).localeCompare(o(l)))[0];if(!r)return n;let i=n.replace(Sp,`commit ${r.label}`),a=i.trim().replace(/[?.!]+$/,"");return R$.test(a)?`${a} touched`:i}function T$(e){let t=String(e||"").toLowerCase(),n=new Set([t]);return t.endsWith("ies")&&n.add(`${t.slice(0,-3)}y`),(t.endsWith("ses")||t.endsWith("es"))&&n.add(t.slice(0,-2)),t.endsWith("s")&&t.length>1&&n.add(t.slice(0,-1)),[...n]}function C$(e,t){let n=T$(t);for(let s of e?.individuals||[])if(s?.class&&n.includes(String(s.class).toLowerCase()))return s.class;return null}function L$(e,t){let n=String(t||"").trim(),s=n.match(I$),o=s?null:n.match(O$),r=s||o;if(!r||!lc.test(r[2]||"")||Be[r[1].toLowerCase()])return null;let i=C$(e,r[1]);if(!i)return null;let a={node:"allOfClass",entityType:i};return s?{node:"list",entityType:i,base:a,scoped:!1}:{node:"count",entityType:i,base:a}}function ss(e,t,{contextId:n=null,nlp:s=void 0,prev:o=null}={}){if(j$(t))return{content:rc(),tmct_ask:{mechanical:!0,parsed:null,canonical:null,matches:[],traversal:null,miss:!0,ambiguous:!1,matchedVia:null,help:!0,relaxed:null}};t=A$(e,t);let r=Qa(t,{nlp:s}),i=r.parsed,a=i,l=null;if(Qp(e,i,n)===!1){let m=_$(e,t,{nlp:s,contextId:n,prev:o});m&&(a=m.parsed,l={from:m.from,to:m.to,dropped:m.dropped,steps:m.steps})}let c=Ht(e,a,{contextId:n,prev:o}),u=bn(a,c,e);if(u.miss&&!u.ambiguous){let m=L$(e,t);if(m){let p=Ht(e,m,{contextId:n,prev:o}),f=bn(m,p,e);f.miss||(a=m,c=p,u=f,l=null)}}if(a===null&&u.miss&&!u.ambiguous){let p=Hr(String(t||"")).trim().match(N$)?.[1]?.trim();if(p&&!/\s+(?:for|about)$/i.test(p)){let f=er(`what is a ${p}`,{nlp:s});f?.shape==="meta"&&(c=Ht(e,f,{contextId:n,prev:o}),u=bn(f,c,e))}}if(a===null&&u.miss&&!u.ambiguous){let p=_s(String(t||"")).match(M$)?.[1]?.trim();if(p){let f=er(`what is a ${p}`,{nlp:s});if(f?.shape==="meta"){let g=Ht(e,f,{contextId:n,prev:o}),h=bn(f,g,e);!h.miss&&!h.ambiguous&&(c=g,u=h)}}}let d=l&&!u.miss&&l.to!==l.from?`read as "${l.to}" \u2014 ${u.content}`:u.content;if(!l&&!u.miss&&!u.ambiguous&&r.alternates.length){let m=r.alternates.map(p=>{let f=Ht(e,p.parsed,{contextId:n,prev:o}),g=bn(p.parsed,f,e);return g.miss?null:{a:p,text:g.content}}).filter(Boolean);if(m.length){let p=ap(m.map(f=>f.a),{answerFor:f=>m.find(g=>g.a===f)?.text||null});d=`${d}
60
60
  ${p.join(`
61
61
  `)}`}}if(!u.ambiguous&&c.objMatch&&Array.isArray(c.candidates)&&c.candidates.length){let m=new Set((c.matches||[]).map(f=>f&&f.id)),p=c.candidates.filter(f=>f&&f.id&&f.id!==c.objMatch.id&&!m.has(f.id));if(p.length){let f=p.slice(0,3).map(b=>b.label).filter(Boolean),g=p.length-f.length,h=f.join(", ")+(g>0?`, +${g} more`:"");d=`${d}
62
- (answering for ${c.objMatch.label} \u2014 ${p.length} other match${p.length===1?"":"es"}: ${h})`}}return!Array.isArray(c.referents)&&!u.miss&&!u.ambiguous&&(a?.shape==="reverse"||a?.shape==="forward")&&a.entityType&&Array.isArray(c.matches)&&c.matches.length&&c.matches.every(m=>m&&m.class===a.entityType)&&(c={...c,referents:nr(a.entityType,c.matches,"relationListing")}),{content:d,tmct_ask:{mechanical:!0,parsed:a&&!a.ambiguousParse?a:null,canonical:Kp(a),matches:(c.matches||[]).map(m=>({id:m.id,label:m.label,type:m.class,module:m.class?tr(m):void 0})),traversal:c.traversal||null,miss:!!u.miss,ambiguous:!!u.ambiguous,relaxed:l,matchedVia:c.matchedVia||null,...Array.isArray(c.referents)&&c.referents.length?{discourse:c.referents}:{},...u.ambiguous?{candidates:u.candidates,candidateParses:u.candidateParses}:{}}}}var pp,ao,ns,Ba,nv,Rt,Ep,Ue,jp,sv,ov,rv,iv,av,_p,Ga,lv,Za,Rp,kt,Ap,dv,fv,hv,bv,yv,vv,$v,xv,Sv,jv,Op,tc,Nv,Lp,Mv,Dv,fp,Wv,mp,Vv,gp,wp,Yv,Jv,Zv,Zn,Ua,p$,f$,h$,ac,g$,$p,b$,xp,oi,Ja,cc,Xp,k$,S$,E$,Sp,R$,I$,O$,lc,N$,M$,os=L(()=>{Ce();ba();An();Jn();Ho();Yr();Xr();dp();Fa();Yn();za();io();pp=new WeakMap;ao={calls:"callsSymbol",touches:"touchesSymbol"},ns=new Set(["Function","Method","Class","Attribute","GlobalVariable"]),Ba={Function:"Method",Method:"Function"},nv={uses:["imports","calls","callsSymbol"]},Rt=e=>nv[e]||[e],Ep=new Set(Object.values(ao)),Ue=12,jp={Function:["function","functions"],Method:["method","methods"],Class:["class","classes"],Module:["module","modules"],Attribute:["attribute","attributes"],GlobalVariable:["variable","variables"],Commit:["commit","commits"],Change:["change","changes"],Package:["package","packages"],Fact:["fact","facts"],Utterance:["utterance","utterances"],Session:["session","sessions"],Source:["source","sources"],Rule:["rule","rules"]};sv={cochange:"cochanges",reexports:"export"};ov={imports:"import",calls:"call",callsSymbol:"call",inherits:"inherit from",contains:"contain",tests:"test",touches:"touch",cochange:"cochange",reexports:"export",uses:"use"},rv=e=>ov[e]||Rs(e),iv=new RegExp(`^(?:${Object.keys(de).sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})(?:s|ing|ed)?\\s+`,"i"),av=new Set(["imports"]);_p=4,Ga="zzinnerset",lv=new Set(["that","which","who","are","is","was","were","do","does","also","still","both","and","then","though"]),Za=new Set(["which","what","who","list","show","find","give","me","us","all"]),Rp=new Set(["are","is","was","were"]);kt=e=>Be[e]?{entityType:Be[e],placeholder:!1}:Rn.includes(e)?{entityType:null,placeholder:!0}:null,Ap=e=>!!de[e]&&e.endsWith("ing");dv=new Set(["which","the","all"]);fv=new Set(["all","every","each"]);hv=new Set(["what","which","thing","things","one","ones","stuff"]);bv=new Set(["those","them"]);yv=new Set(["did","was","were","do","does","has","have","had"]),vv=new Set(["change","changed","changes","update","updated","updates","modify","modified","modifies","touch","touched","touches","edit","edited","revise","revised"]),$v=new Set(["last","recently","ever","get","got","been","then","now","already"]),xv=new Set(["the","a","an","all","those","these","any"]);Sv=new Set(["since","before","after","on"]);jv=/\b[\w-]+(?:[/.][\w-]+)+\b|\b[A-Z][A-Za-z0-9_]*\b|\b[a-z][a-z0-9]*[A-Z][A-Za-z0-9]*\b/;Op=new Set(["total","altogether","overall","exist","exists","existing","present","here","now","currently","graph","index","codebase","repo","repository","this","that"]);tc=new Set(["the","a","an","all","me","us"]),Nv=[...vs].sort((e,t)=>t.split(" ").length-e.split(" ").length),Lp="functions, classes, methods, modules, packages, attributes, variables, or commits",Mv=new Set(["in","inside","under"]);Dv=new Set(["called","named","about","like","containing","matching","with"]);fp=new Set(["recent","latest","newest"]);Wv=/^git:(.+)$/i;mp=new WeakMap;Vv=new Set(["Class","Function","Method","GlobalVariable","Attribute"]);gp=new WeakMap;wp={label:3,chain:2,attr:1};Yv=e=>e&&typeof e.value=="boolean"?{...e,value:!e.value}:null;Jv=["imports","calls","callsSymbol","inherits","contains","tests"];Zv=/^\d{4}-\d{2}-\d{2}$/;Zn=e=>hn(e.slice(0,Ue).map(t=>["Function","Method"].includes(t.class)?`${t.label}()`:t.label))+(e.length>Ue?`, \u2026and ${e.length-Ue} more`:"");Ua=10;p$=/^(?:the|a|an)\s+/i,f$=new RegExp(`\\s+(${Object.keys(Be).join("|")})$`,"i");h$=/^(?:the\s+)?(?:main\s+|primary\s+)?entry[\s-]?points?(?:\s+(?:of|to|for)\s+(?:this|the)\s+(?:codebase|code|repo|repository|project|app))?$/i,ac=new Set(["index","main","app","server","cli","__main__"]),g$=new Set(["test","tests","__tests__","fixture","fixtures","spec","specs","testdata"]),$p=e=>String(e).toLowerCase().split("/").pop().replace(/\.[a-z0-9]+$/,""),b$=e=>String(e).toLowerCase().split("/").slice(0,-1).some(t=>g$.has(t));xp=8;oi=new Set([...me(Object.keys(de)),...me(Object.keys(Be)),...me(Object.keys(Gt)),...me(Object.keys(Ve)),...me(ys),...me(Object.keys(Kn)),...me(Object.keys(pn)),...me(Object.keys(Xs)),...me(Rn),...me(Do),...me(ws),...me(Yt),...me(an),...me(_n),...me(Object.keys(Qs))]),Ja=new Set([...st,...Za,...bs]),cc=new Set(me(Lr)),Xp=new Set([...cc,...Ja]),k$=["many","count","number","quantity","total","tally","list","show","display","print","dump","enumerate","name"],S$=[...new Set([...me(Object.keys(de)),...Object.keys(Be),...k$])].filter(e=>/^[a-z]+$/.test(e)&&e.length>=4&&!st.has(e)),E$=new Set(["impact","impacts","impacted"]);Sp=/\b(?:the\s+)?(?:last|latest|most\s+recent)\s+commit\b/i,R$=/^when\s+(?:was|were|is|did|does|do)\s+commit\s+[0-9a-fA-F:]+$/i;I$=/^(?:list|show(?:\s+me)?)\s+(?:all\s+|the\s+)?([a-z][a-z'-]*)\s*(.*)$/i,O$=/^(?:how\s+many|number\s+of|count(?:\s+the)?)\s+([a-z][a-z'-]*)\s*(.*)$/i,lc=/^(?:are there(?:\s+in\s+total)?|is there|do you know(?:\s+about)?|do you have|exist(?:s)?|are known|in (?:the |a )?(?:graph|memory)|you know(?:\s+about)?)?[?.!\s]*$/i;N$=/^what\s+(?:is|are)\s+(?:an?\s+)?(.+?)[?.!\s]*$/i,M$=/^what\s+is\s+(?:the\s+)?(?!(?:an?|it|this|that|these|those)\s)(.+?)\s+(?:used\s+)?for[?.!\s]*$/i});function rs(e,t,n,s){let o=Math.max(1,t),r=Math.min(e.length,n),i=!1;s!=null&&r-o+1>s&&(r=o+s-1,i=!0);let a=e.slice(o-1,r).map((l,c)=>`${o+c} ${l}`).join(`
62
+ (answering for ${c.objMatch.label} \u2014 ${p.length} other match${p.length===1?"":"es"}: ${h})`}}return!Array.isArray(c.referents)&&!u.miss&&!u.ambiguous&&(a?.shape==="reverse"||a?.shape==="forward")&&a.entityType&&Array.isArray(c.matches)&&c.matches.length&&c.matches.every(m=>m&&m.class===a.entityType)&&(c={...c,referents:nr(a.entityType,c.matches,"relationListing")}),{content:d,tmct_ask:{mechanical:!0,parsed:a&&!a.ambiguousParse?a:null,canonical:Kp(a),matches:(c.matches||[]).map(m=>({id:m.id,label:m.label,type:m.class,module:m.class?tr(m):void 0})),traversal:c.traversal||null,miss:!!u.miss,ambiguous:!!u.ambiguous,relaxed:l,matchedVia:c.matchedVia||null,...Array.isArray(c.referents)&&c.referents.length?{discourse:c.referents}:{},...u.ambiguous?{candidates:u.candidates,candidateParses:u.candidateParses}:{}}}}var pp,ao,ns,Ba,nv,Rt,Ep,Ue,jp,sv,ov,rv,iv,av,_p,Ga,lv,Za,Rp,kt,Ap,dv,fv,hv,bv,yv,vv,$v,xv,Sv,jv,Op,tc,Nv,Lp,Mv,Dv,fp,Wv,mp,Vv,gp,wp,Yv,Jv,Zv,Zn,Ua,p$,f$,h$,ac,g$,$p,b$,xp,oi,Ja,cc,Xp,k$,S$,E$,Sp,R$,I$,O$,lc,N$,M$,os=L(()=>{Ce();ba();An();Jn();Ho();Yr();Xr();dp();Fa();Yn();za();io();pp=new WeakMap;ao={calls:"callsSymbol",touches:"touchesSymbol"},ns=new Set(["Function","Method","Class","Attribute","GlobalVariable"]),Ba={Function:"Method",Method:"Function"},nv={uses:["imports","calls","callsSymbol"]},Rt=e=>nv[e]||[e],Ep=new Set(Object.values(ao)),Ue=12,jp={Function:["function","functions"],Method:["method","methods"],Class:["class","classes"],Module:["module","modules"],Attribute:["attribute","attributes"],GlobalVariable:["variable","variables"],Commit:["commit","commits"],Change:["change","changes"],Package:["package","packages"],Fact:["fact","facts"],Utterance:["utterance","utterances"],Session:["session","sessions"],Source:["source","sources"],Rule:["rule","rules"]};sv={cochange:"cochanges",reexports:"export"};ov={imports:"import",calls:"call",callsSymbol:"call",inherits:"inherit from",contains:"contain",tests:"test",touches:"touch",cochange:"cochange",reexports:"export",uses:"use"},rv=e=>ov[e]||Rs(e),iv=new RegExp(`^(?:${Object.keys(de).sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})(?:s|ing|ed)?\\s+`,"i"),av=new Set(["imports"]);_p=4,Ga="zzinnerset",lv=new Set(["that","which","who","are","is","was","were","do","does","also","still","both","and","then","though"]),Za=new Set(["which","what","who","list","show","find","give","me","us","all"]),Rp=new Set(["are","is","was","were"]);kt=e=>Be[e]?{entityType:Be[e],placeholder:!1}:Rn.includes(e)?{entityType:null,placeholder:!0}:null,Ap=e=>!!de[e]&&e.endsWith("ing");dv=new Set(["which","the","all"]);fv=new Set(["all","every","each"]);hv=new Set(["what","which","thing","things","one","ones","stuff"]);bv=new Set(["those","them"]);yv=new Set(["did","was","were","do","does","has","have","had"]),vv=new Set(["change","changed","changes","update","updated","updates","modify","modified","modifies","touch","touched","touches","edit","edited","revise","revised"]),$v=new Set(["last","recently","ever","get","got","been","then","now","already"]),xv=new Set(["the","a","an","all","those","these","any"]);Sv=new Set(["since","before","after","on"]);jv=/\b[\w-]+(?:[/.][\w-]+)+\b|\b[A-Z][A-Za-z0-9_]*\b|\b[a-z][a-z0-9]*[A-Z][A-Za-z0-9]*\b/;Op=new Set(["total","altogether","overall","exist","exists","existing","present","here","now","currently","graph","index","codebase","repo","repository","this","that"]);tc=new Set(["the","a","an","all","me","us"]),Nv=[...vs].sort((e,t)=>t.split(" ").length-e.split(" ").length),Lp="functions, classes, methods, modules, packages, attributes, variables, or commits",Mv=new Set(["in","inside","under"]);Dv=new Set(["called","named","about","like","containing","matching","with"]);fp=new Set(["recent","latest","newest"]);Wv=/^git:(.+)$/i;mp=new WeakMap;Vv=new Set(["Class","Function","Method","GlobalVariable","Attribute"]);gp=new WeakMap;wp={label:3,chain:2,attr:1};Yv=e=>e&&typeof e.value=="boolean"?{...e,value:!e.value}:null;Jv=["imports","calls","callsSymbol","inherits","contains","tests"];Zv=/^\d{4}-\d{2}-\d{2}$/;Zn=e=>gn(e.slice(0,Ue).map(t=>["Function","Method"].includes(t.class)?`${t.label}()`:t.label))+(e.length>Ue?`, \u2026and ${e.length-Ue} more`:"");Ua=10;p$=/^(?:the|a|an)\s+/i,f$=new RegExp(`\\s+(${Object.keys(Be).join("|")})$`,"i");h$=/^(?:the\s+)?(?:main\s+|primary\s+)?entry[\s-]?points?(?:\s+(?:of|to|for)\s+(?:this|the)\s+(?:codebase|code|repo|repository|project|app))?$/i,ac=new Set(["index","main","app","server","cli","__main__"]),g$=new Set(["test","tests","__tests__","fixture","fixtures","spec","specs","testdata"]),$p=e=>String(e).toLowerCase().split("/").pop().replace(/\.[a-z0-9]+$/,""),b$=e=>String(e).toLowerCase().split("/").slice(0,-1).some(t=>g$.has(t));xp=8;oi=new Set([...me(Object.keys(de)),...me(Object.keys(Be)),...me(Object.keys(Gt)),...me(Object.keys(Ve)),...me(ys),...me(Object.keys(Kn)),...me(Object.keys(fn)),...me(Object.keys(Xs)),...me(Rn),...me(Do),...me(ws),...me(Yt),...me(an),...me(_n),...me(Object.keys(Qs))]),Ja=new Set([...st,...Za,...bs]),cc=new Set(me(Lr)),Xp=new Set([...cc,...Ja]),k$=["many","count","number","quantity","total","tally","list","show","display","print","dump","enumerate","name"],S$=[...new Set([...me(Object.keys(de)),...Object.keys(Be),...k$])].filter(e=>/^[a-z]+$/.test(e)&&e.length>=4&&!st.has(e)),E$=new Set(["impact","impacts","impacted"]);Sp=/\b(?:the\s+)?(?:last|latest|most\s+recent)\s+commit\b/i,R$=/^when\s+(?:was|were|is|did|does|do)\s+commit\s+[0-9a-fA-F:]+$/i;I$=/^(?:list|show(?:\s+me)?)\s+(?:all\s+|the\s+)?([a-z][a-z'-]*)\s*(.*)$/i,O$=/^(?:how\s+many|number\s+of|count(?:\s+the)?)\s+([a-z][a-z'-]*)\s*(.*)$/i,lc=/^(?:are there(?:\s+in\s+total)?|is there|do you know(?:\s+about)?|do you have|exist(?:s)?|are known|in (?:the |a )?(?:graph|memory)|you know(?:\s+about)?)?[?.!\s]*$/i;N$=/^what\s+(?:is|are)\s+(?:an?\s+)?(.+?)[?.!\s]*$/i,M$=/^what\s+is\s+(?:the\s+)?(?!(?:an?|it|this|that|these|those)\s)(.+?)\s+(?:used\s+)?for[?.!\s]*$/i});function rs(e,t,n,s){let o=Math.max(1,t),r=Math.min(e.length,n),i=!1;s!=null&&r-o+1>s&&(r=o+s-1,i=!0);let a=e.slice(o-1,r).map((l,c)=>`${o+c} ${l}`).join(`
63
63
  `);return{start:o,end:r,text:a,truncated:i}}async function Pn({readFile:e,repoRoot:t,path:n,start:s,end:o,maxLines:r}){let i=qt(t),a=qt(i,n);if(a!==i&&!a.startsWith(i+pu))throw new Oe(`refusing to read outside the repository root: ${n}`);let c=(await e(a,"utf8")).split(`
64
- `);return s==null||o==null?{lines:c}:{lines:c,...rs(c,s,o,r)}}var ii=L(()=>{De();Lt()});function ht(e){return{ok:!0,value:e}}function gt(e,{detail:t="",term:n=null}={}){if(!Xe[e])throw new TypeError(`miss(): unknown reason "${e}" (not in MISS_REASONS)`);return{ok:!1,miss:{reason:e,detail:t,term:n}}}function wn(e){return!e||!e.id?null:{id:String(e.id),label:e.label!=null?String(e.label):String(e.id),class:e.class||"Entity",attributes:(Array.isArray(e.attributes)?e.attributes:[]).map(t=>({key:t.key,value:t.value,prop:t.prop||null}))}}function ai(e,{predicate:t="",prop:n=null}={}){let s={subject:e.subject,object:e.object,predicate:t,prop:n||null};return e.subjectLabel!=null&&(s.subjectLabel=e.subjectLabel),e.objectLabel!=null&&(s.objectLabel=e.objectLabel),e.weight!=null&&(s.weight=e.weight),s}var dc,P$,Xe,pc,nA,ef,fc,F$,bn,uc,St,sA,tf=L(()=>{dc="1.1.0",P$="urn:tmct:core",Xe=Object.freeze({UNRESOLVED_TERM:"UNRESOLVED_TERM",CAPABILITY_ABSENT:"CAPABILITY_ABSENT",TRUNCATED_GRAPH:"TRUNCATED_GRAPH",NO_SOURCE:"NO_SOURCE"}),pc=Object.freeze(["imports","calls","callsSymbol","defines","tests","touches","touchesSymbol","contains","inherits","cochange","reexports"]),nA=Object.freeze({imports:"tmct:imports",calls:"tmct:calls",callsSymbol:"tmct:calls",defines:"tmct:defines",tests:"tmct:covers",touches:"tmct:touches",touchesSymbol:"tmct:touches",contains:"tmct:contains",inherits:"tmct:extends",cochange:"tmct:dependsOn",reexports:"tmct:exports"}),ef=Object.freeze({resolution:["resolve","describe","members","subclasses","exports","signature"],traversal:["edges","impact"],source:["snippet","context"],aggregate:["architecture","untested","stats"],temporal:["history"],search:["search","ask"]}),fc=Object.freeze(Object.values(ef).flat()),F$=Object.freeze(new Set(ef.source));bn="Individual",uc="Edge",St="concurrent-safe: reads immutable graph truth; no shared mutable state",sA=Object.freeze({version:dc,ontology:P$,missReasons:Object.values(Xe),edgeKinds:[...pc],types:{Individual:{fields:{id:"string (opaque provider id)",label:"string (human/display name)",class:"string \u2014 a tmct: class token (module|class|function|method|attribute|variable|commit|test|\u2026)",attributes:"Array<{ key: string, value: string, prop: string|null }> \u2014 prop is the SEON/mgx token grounding the value"}},Edge:{fields:{subject:"string (individual id)",object:"string (individual id)",predicate:"string \u2014 the relation predicate",prop:"string|null \u2014 the SEON/mgx property token; see edgeKinds \u2192 tmct: mapping",subjectLabel:"string? (additive)",objectLabel:"string? (additive)",weight:"number? (additive; e.g. cochange coupling)"}},Result:{shape:"{ ok: true, value: T } | { ok: false, miss: Miss }"},Miss:{shape:"{ reason: MISS_REASONS, detail: string, term: string|null }"}},capabilitiesModel:"A provider advertises `capabilities: string[]` (service names it implements). A service outside the set is negotiated away to miss(CAPABILITY_ABSENT) \u2014 never an error. snippet may be advertised yet answer miss(NO_SOURCE) when no working tree exists (it has nothing useful without fs); context is graph-only-capable since INTERFACE_VERSION 1.1.0 \u2014 it returns a real hit (graph-only bundle) for any resolvable symbol even with no working tree, only escalating NO_SOURCE-style behavior to richer body text when source-capable.",services:{resolve:{group:"resolution",args:{term:"string"},result:`{ match: ${bn}, candidates: ${bn}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The resolveSymbol seam: map a free term to an individual + runner-up candidates. Every id-taking service consumes a resolved id."},describe:{group:"resolution",args:{id:"string"},result:`{ individual: ${bn}, out: ${uc}[], incoming: ${uc}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"Full typed portrait of one individual: its attributes and its outgoing/incoming edges."},members:{group:"resolution",args:{classId:"string"},result:`{ methods: ${bn}[], attributes: ${bn}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"A class's methods + attributes (via the contains relation) \u2014 replaces reading the class body."},subclasses:{group:"resolution",args:{classId:"string"},result:`{ bases: ${bn}[], subclasses: ${bn}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"Forward bases + the transitive reverse inheritance closure (who extends this)."},exports:{group:"resolution",args:{moduleId:"string"},result:`{ exports: ${bn}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"A module's curated public API (resolved __all__ / re-exports)."},signature:{group:"resolution",args:{id:"string"},result:"{ id, label, class, params, returns, raises, decorators, doc, selfFields, flags }",misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The compact API surface of a symbol without its body."},edges:{group:"traversal",args:{id:"string",kind:"EDGE_KINDS member"},result:`{ kind: string, edges: ${uc}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"Outgoing edges of one closed kind from an individual (an honest empty array is not a miss).",note:"An unknown kind (outside EDGE_KINDS) is a programming error and throws TypeError, not a miss."},impact:{group:"traversal",args:{moduleId:"string"},result:"{ total: number, levels: Array<Array<{ id, label, via, tests }>> }",misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The transitive dependent closure the interpreter cannot compute without provider truth."},snippet:{group:"source",args:{id:"string"},result:"{ path: string, span: { start, end }, body: string|null } \u2014 Promise<Result>",misses:["UNRESOLVED_TERM","NO_SOURCE"],concurrency:St,purpose:"The exact source span of a symbol. A provider with no working tree returns miss(NO_SOURCE) honestly \u2014 snippet has nothing useful without fs.",note:"ASYNC (returns Promise<Result>) \u2014 a real body read is inherently fs I/O; callers should always await it. A graph-only provider still resolves synchronously-in-spirit (the promise settles on the same tick) but the return type is uniformly a Promise regardless of sourceAccess."},context:{group:"source",args:{symbol:"string",depth:"min|auto|full?"},result:"{ text: string, tier: string } (a sized edit bundle) \u2014 Promise<Result>",misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The composed edit bundle (exemplar, siblings, registration, insertion region). A graph-only provider returns the graph-only sections as a real hit; a source-capable provider (sourceAccess:true, repoRoot, readFile) additionally includes the anchor/exemplar/inlined-callee body text.",note:"ASYNC (returns Promise<Result>) \u2014 see snippet's note; source-capable rendering is fs I/O."},architecture:{group:"aggregate",args:{package:"string?"},result:"{ modules: number, packages: Array<[dir, count]>, hubs: Array<{ id, label, importers }> }",misses:[],concurrency:St,purpose:"Package/module shape + the most-imported hub modules. Optional package prefix scopes it."},untested:{group:"aggregate",args:{},result:`{ modules: ${bn}[] }`,misses:[],concurrency:St,purpose:"Modules with no covering test module (via the tests relation)."},stats:{group:"aggregate",args:{},result:"{ total: number, classes: Array<{ class: string, count: number }>, truncated: boolean }",misses:[],concurrency:St,purpose:"Per-tmct:class individual counts, read straight from the payload."},history:{group:"temporal",args:{id:"string"},result:"{ commits: Array<{ id, label, author, date, message }> }",misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The commits that touched an individual (tmct:commit individuals via tmct:touches)."},search:{group:"search",args:{query:"string",kind:"string?",name:"string?",decorator:"string?"},result:`{ results: ${bn}[] }`,misses:[],concurrency:St,purpose:"Lexical, provider-local locate. An empty result set is honest, not a miss."},ask:{group:"search",args:{query:"string"},result:"{ content: string, tmct_ask: object } (the composed NL round-trip envelope)",misses:[],concurrency:St,purpose:"The mechanical, zero-model NL query over the graph \u2014 tmct's whole reason to exist."}}})});function D$(e,t){let n=[],s=[];for(let o of e.relations)for(let r of o.edges)r.subject===t&&n.push(ai(r,{predicate:o.predicate,prop:o.prop})),r.object===t&&s.push(ai(r,{predicate:o.predicate,prop:o.prop}));return{out:n,incoming:s}}function z$(e,t){for(let n of e.relations)if(On(n)===t)return{predicate:n.predicate,prop:n.prop};return{predicate:t,prop:null}}async function U$(e,t,{readFile:n,repoRoot:s}){if(!e.moduleLabel)return"";let o=null;try{({lines:o}=await Pn({readFile:n,repoRoot:s,path:e.moduleLabel}))}catch{o=null}if(!o)return"";let r=[];if(t.anchor&&e.anchor?.site){let{start:i,end:a}=e.anchor.site;r.push(`
64
+ `);return s==null||o==null?{lines:c}:{lines:c,...rs(c,s,o,r)}}var ii=L(()=>{De();Lt()});function ht(e){return{ok:!0,value:e}}function gt(e,{detail:t="",term:n=null}={}){if(!Xe[e])throw new TypeError(`miss(): unknown reason "${e}" (not in MISS_REASONS)`);return{ok:!1,miss:{reason:e,detail:t,term:n}}}function wn(e){return!e||!e.id?null:{id:String(e.id),label:e.label!=null?String(e.label):String(e.id),class:e.class||"Entity",attributes:(Array.isArray(e.attributes)?e.attributes:[]).map(t=>({key:t.key,value:t.value,prop:t.prop||null}))}}function ai(e,{predicate:t="",prop:n=null}={}){let s={subject:e.subject,object:e.object,predicate:t,prop:n||null};return e.subjectLabel!=null&&(s.subjectLabel=e.subjectLabel),e.objectLabel!=null&&(s.objectLabel=e.objectLabel),e.weight!=null&&(s.weight=e.weight),s}var dc,P$,Xe,pc,nA,ef,fc,F$,ln,uc,St,sA,tf=L(()=>{dc="1.1.0",P$="urn:tmct:core",Xe=Object.freeze({UNRESOLVED_TERM:"UNRESOLVED_TERM",CAPABILITY_ABSENT:"CAPABILITY_ABSENT",TRUNCATED_GRAPH:"TRUNCATED_GRAPH",NO_SOURCE:"NO_SOURCE"}),pc=Object.freeze(["imports","calls","callsSymbol","defines","tests","touches","touchesSymbol","contains","inherits","cochange","reexports"]),nA=Object.freeze({imports:"tmct:imports",calls:"tmct:calls",callsSymbol:"tmct:calls",defines:"tmct:defines",tests:"tmct:covers",touches:"tmct:touches",touchesSymbol:"tmct:touches",contains:"tmct:contains",inherits:"tmct:extends",cochange:"tmct:dependsOn",reexports:"tmct:exports"}),ef=Object.freeze({resolution:["resolve","describe","members","subclasses","exports","signature"],traversal:["edges","impact"],source:["snippet","context"],aggregate:["architecture","untested","stats"],temporal:["history"],search:["search","ask"]}),fc=Object.freeze(Object.values(ef).flat()),F$=Object.freeze(new Set(ef.source));ln="Individual",uc="Edge",St="concurrent-safe: reads immutable graph truth; no shared mutable state",sA=Object.freeze({version:dc,ontology:P$,missReasons:Object.values(Xe),edgeKinds:[...pc],types:{Individual:{fields:{id:"string (opaque provider id)",label:"string (human/display name)",class:"string \u2014 a tmct: class token (module|class|function|method|attribute|variable|commit|test|\u2026)",attributes:"Array<{ key: string, value: string, prop: string|null }> \u2014 prop is the SEON/mgx token grounding the value"}},Edge:{fields:{subject:"string (individual id)",object:"string (individual id)",predicate:"string \u2014 the relation predicate",prop:"string|null \u2014 the SEON/mgx property token; see edgeKinds \u2192 tmct: mapping",subjectLabel:"string? (additive)",objectLabel:"string? (additive)",weight:"number? (additive; e.g. cochange coupling)"}},Result:{shape:"{ ok: true, value: T } | { ok: false, miss: Miss }"},Miss:{shape:"{ reason: MISS_REASONS, detail: string, term: string|null }"}},capabilitiesModel:"A provider advertises `capabilities: string[]` (service names it implements). A service outside the set is negotiated away to miss(CAPABILITY_ABSENT) \u2014 never an error. snippet may be advertised yet answer miss(NO_SOURCE) when no working tree exists (it has nothing useful without fs); context is graph-only-capable since INTERFACE_VERSION 1.1.0 \u2014 it returns a real hit (graph-only bundle) for any resolvable symbol even with no working tree, only escalating NO_SOURCE-style behavior to richer body text when source-capable.",services:{resolve:{group:"resolution",args:{term:"string"},result:`{ match: ${ln}, candidates: ${ln}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The resolveSymbol seam: map a free term to an individual + runner-up candidates. Every id-taking service consumes a resolved id."},describe:{group:"resolution",args:{id:"string"},result:`{ individual: ${ln}, out: ${uc}[], incoming: ${uc}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"Full typed portrait of one individual: its attributes and its outgoing/incoming edges."},members:{group:"resolution",args:{classId:"string"},result:`{ methods: ${ln}[], attributes: ${ln}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"A class's methods + attributes (via the contains relation) \u2014 replaces reading the class body."},subclasses:{group:"resolution",args:{classId:"string"},result:`{ bases: ${ln}[], subclasses: ${ln}[], levels: Array<${ln}[]> }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"Forward bases + the transitive reverse inheritance closure (who extends this). `subclasses` is the flat closure; `levels` groups the same individuals by inheritance depth (direct children first), mirroring `impact`'s leveled shape."},exports:{group:"resolution",args:{moduleId:"string"},result:`{ exports: ${ln}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"A module's curated public API (resolved __all__ / re-exports)."},signature:{group:"resolution",args:{id:"string"},result:"{ id, label, class, params, returns, raises, decorators, doc, selfFields, flags }",misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The compact API surface of a symbol without its body."},edges:{group:"traversal",args:{id:"string",kind:"EDGE_KINDS member"},result:`{ kind: string, edges: ${uc}[] }`,misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"Outgoing edges of one closed kind from an individual (an honest empty array is not a miss).",note:"An unknown kind (outside EDGE_KINDS) is a programming error and throws TypeError, not a miss."},impact:{group:"traversal",args:{moduleId:"string"},result:"{ total: number, levels: Array<Array<{ id, label, via, tests }>> }",misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The transitive dependent closure the interpreter cannot compute without provider truth."},snippet:{group:"source",args:{id:"string"},result:"{ path: string, span: { start, end }, body: string|null } \u2014 Promise<Result>",misses:["UNRESOLVED_TERM","NO_SOURCE"],concurrency:St,purpose:"The exact source span of a symbol. A provider with no working tree returns miss(NO_SOURCE) honestly \u2014 snippet has nothing useful without fs.",note:"ASYNC (returns Promise<Result>) \u2014 a real body read is inherently fs I/O; callers should always await it. A graph-only provider still resolves synchronously-in-spirit (the promise settles on the same tick) but the return type is uniformly a Promise regardless of sourceAccess."},context:{group:"source",args:{symbol:"string",depth:"min|auto|full?"},result:"{ text: string, tier: string } (a sized edit bundle) \u2014 Promise<Result>",misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The composed edit bundle (exemplar, siblings, registration, insertion region). A graph-only provider returns the graph-only sections as a real hit; a source-capable provider (sourceAccess:true, repoRoot, readFile) additionally includes the anchor/exemplar/inlined-callee body text.",note:"ASYNC (returns Promise<Result>) \u2014 see snippet's note; source-capable rendering is fs I/O."},architecture:{group:"aggregate",args:{package:"string?"},result:"{ modules: number, packages: Array<[dir, count]>, hubs: Array<{ id, label, importers }> }",misses:[],concurrency:St,purpose:"Package/module shape + the most-imported hub modules. Optional package prefix scopes it."},untested:{group:"aggregate",args:{},result:`{ modules: ${ln}[] }`,misses:[],concurrency:St,purpose:"Modules with no covering test module (via the tests relation)."},stats:{group:"aggregate",args:{},result:"{ total: number, classes: Array<{ class: string, count: number }>, truncated: boolean }",misses:[],concurrency:St,purpose:"Per-tmct:class individual counts, read straight from the payload."},history:{group:"temporal",args:{id:"string"},result:"{ commits: Array<{ id, label, author, date, message }> }",misses:["UNRESOLVED_TERM"],concurrency:St,purpose:"The commits that touched an individual (tmct:commit individuals via tmct:touches)."},search:{group:"search",args:{query:"string",kind:"string?",name:"string?",decorator:"string?"},result:`{ results: ${ln}[] }`,misses:[],concurrency:St,purpose:"Lexical, provider-local locate. An empty result set is honest, not a miss."},ask:{group:"search",args:{query:"string"},result:"{ content: string, tmct_ask: object } (the composed NL round-trip envelope)",misses:[],concurrency:St,purpose:"The mechanical, zero-model NL query over the graph \u2014 tmct's whole reason to exist."}}})});function D$(e,t){let n=[],s=[];for(let o of e.relations)for(let r of o.edges)r.subject===t&&n.push(ai(r,{predicate:o.predicate,prop:o.prop})),r.object===t&&s.push(ai(r,{predicate:o.predicate,prop:o.prop}));return{out:n,incoming:s}}function z$(e,t){for(let n of e.relations)if(On(n)===t)return{predicate:n.predicate,prop:n.prop};return{predicate:t,prop:null}}async function U$(e,t,{readFile:n,repoRoot:s}){if(!e.moduleLabel)return"";let o=null;try{({lines:o}=await Pn({readFile:n,repoRoot:s,path:e.moduleLabel}))}catch{o=null}if(!o)return"";let r=[];if(t.anchor&&e.anchor?.site){let{start:i,end:a}=e.anchor.site;r.push(`
65
65
  ## anchor: ${e.anchor.label} (${e.anchor.class}) @ ${e.moduleLabel}:${i}-${a}`),r.push(rs(o,i,a,mc).text),e.callHint&&r.push(e.callHint)}if(t.exemplar&&e.exemplar?.site){let{start:i,end:a}=e.exemplar.site,l=e.exemplar.decorators?` @${e.exemplar.decorators}`:"";r.push(`
66
66
  ## closest example (full body) \u2014 copy this style: ${e.exemplar.label} (${e.exemplar.class})${l} @ ${e.moduleLabel}:${i}-${a}`),r.push(rs(o,i,a,mc).text),e.callHint&&r.push(e.callHint)}if(t.inlinedCallees&&e.calleeBodies.length){let i=B$;for(let a of e.calleeBodies){if(i<=0)break;let l=a.site.start,u=a.site.path===e.moduleLabel?o:null;if(!u)try{({lines:u}=await Pn({readFile:n,repoRoot:s,path:a.site.path}))}catch{u=null}if(!u)continue;let d=rs(u,l,a.site.end,i);r.push(`
67
67
  ## inlined callee body (depth-1 in-repo call): ${a.label} @ ${a.site.path}:${l}-${a.site.end}`),r.push(d.text),i-=d.end-l+1}}return r.join(`
68
- `)}function ci(e,{sourceAccess:t=!1,repoRoot:n=null,readFile:s=null,tel:o=null,ask:r=null}={}){let i=e.byId;if(t&&(!n||typeof s!="function"))throw new TypeError("createGraphService({ sourceAccess: true }) requires both repoRoot and readFile \u2014 fs access is an injected capability, not an ambient import.");let a=c=>i.get(c)||null,l={version:dc,capabilities:[...fc],sourceAccess:!!t,graph:e,resolve(c){let{match:u,candidates:d}=Vt(e,String(c??""));return u?ht({match:wn(u),candidates:d.map(wn)}):gt(Xe.UNRESOLVED_TERM,{term:String(c??"")})},describe(c){let u=a(c);if(!u)return gt(Xe.UNRESOLVED_TERM,{term:c});let{out:d,incoming:m}=D$(e,c);return ht({individual:wn(u),out:d,incoming:m})},members(c){if(!a(c))return gt(Xe.UNRESOLVED_TERM,{term:c});let d=Se(e,"contains").filter(f=>f.subject===c),m=[],p=[];for(let f of d){let g=i.get(f.object),h=g?wn(g):{id:f.object,label:f.objectLabel||f.object,class:"Entity",attributes:[]};(g?.class||"")==="Attribute"?p.push(h):m.push(h)}return ht({methods:m,attributes:p})},subclasses(c){if(!a(c))return gt(Xe.UNRESOLVED_TERM,{term:c});let d=Se(e,"inherits"),m=d.filter(b=>b.subject===c).map(b=>i.get(b.object)?wn(i.get(b.object)):{id:b.object,label:b.objectLabel||b.object,class:"Class",attributes:[]}),p=new Map;for(let b of d)p.has(b.object)||p.set(b.object,[]),p.get(b.object).push(b.subject);let f=new Set([c]),g=[],h=[c];for(let b=0;b<8&&h.length;b+=1){let w=[];for(let v of h)for(let $ of p.get(v)||[]){if(f.has($))continue;f.add($);let k=i.get($);g.push(k?wn(k):{id:$,label:$,class:"Class",attributes:[]}),w.push($)}h=w}return ht({bases:m,subclasses:g})},exports(c){if(!a(c))return gt(Xe.UNRESOLVED_TERM,{term:c});let m=Se(e,"reexports").filter(p=>p.subject===c).map(p=>i.get(p.object)?wn(i.get(p.object)):{id:p.object,label:p.objectLabel||p.object,class:"Entity",attributes:[]});return ht({exports:m})},signature(c){let u=a(c);if(!u)return gt(Xe.UNRESOLVED_TERM,{term:c});let d=[];for(let[p,f]of[["isStatic","static"],["isAbstract","abstract"],["isConstant","constant"]])Pt(u,p)&&d.push(f);let m=Pt(u,"visibility");return m&&d.push(m),ht({id:u.id,label:u.label,class:u.class||"Entity",params:Pt(u,"params"),returns:Pt(u,"returns"),raises:Pt(u,"raises"),decorators:Pt(u,"decorators"),doc:Pt(u,"doc"),selfFields:Pt(u,"self_fields"),flags:d})},edges(c,u,{limit:d,offset:m=0}={}){if(!pc.includes(u))throw new TypeError(`edges(): unknown kind "${u}" (not in EDGE_KINDS)`);if(!a(c))return gt(Xe.UNRESOLVED_TERM,{term:c});let f=z$(e,u),g=Se(e,u).filter(h=>h.subject===c).map(h=>ai(h,f));return g=d==null?g.slice(m):g.slice(m,m+d),ht({kind:u,edges:g})},impact(c,{maxDepth:u}={}){let d=a(c);if(!d)return gt(Xe.UNRESOLVED_TERM,{term:c});let m=u==null?no(e,d):no(e,d,{maxDepth:u}),p=m.reduce((f,g)=>f+g.length,0);return ht({total:p,levels:m})},async snippet(c){let u=a(c);if(!u)return gt(Xe.UNRESOLVED_TERM,{term:c});let d=$t(u);if(!l.sourceAccess)return gt(Xe.NO_SOURCE,{term:c,detail:d?`span is ${d.path}:${d.start}-${d.end}; this provider exposes no working tree`:"no source span in the graph"});if(!d)return gt(Xe.NO_SOURCE,{term:c,detail:"no source span in the graph (likely a module)"});try{let m=await Pn({readFile:s,repoRoot:n,path:d.path,start:d.start,end:d.end,maxLines:mc});return ht({path:d.path,span:{start:d.start,end:d.end},body:m.text})}catch(m){return gt(Xe.NO_SOURCE,{term:c,detail:`could not read ${d.path}: ${m?.message||m}`})}},async context(c,{depth:u="auto"}={}){let{match:d}=Vt(e,String(c??""));if(!d)return gt(Xe.UNRESOLVED_TERM,{term:String(c??"")});let m=so(e,d),p=String(u||"auto").trim().toLowerCase(),f,g;p==="min"?(f="TINY",g=js("TINY")):p==="full"?(f="FULL",g=js("FULL")):{tier:f,mask:g}=Vr(m,e,{});let h=Od(m,g);if(!l.sourceAccess)return ht({text:h,tier:f});let b=await U$(m,g,{readFile:s,repoRoot:n});return ht({text:b?`${h}
68
+ `)}function ci(e,{sourceAccess:t=!1,repoRoot:n=null,readFile:s=null,tel:o=null,ask:r=null}={}){let i=e.byId;if(t&&(!n||typeof s!="function"))throw new TypeError("createGraphService({ sourceAccess: true }) requires both repoRoot and readFile \u2014 fs access is an injected capability, not an ambient import.");let a=c=>i.get(c)||null,l={version:dc,capabilities:[...fc],sourceAccess:!!t,graph:e,resolve(c){let{match:u,candidates:d}=Vt(e,String(c??""));return u?ht({match:wn(u),candidates:d.map(wn)}):gt(Xe.UNRESOLVED_TERM,{term:String(c??"")})},describe(c){let u=a(c);if(!u)return gt(Xe.UNRESOLVED_TERM,{term:c});let{out:d,incoming:m}=D$(e,c);return ht({individual:wn(u),out:d,incoming:m})},members(c){if(!a(c))return gt(Xe.UNRESOLVED_TERM,{term:c});let d=Se(e,"contains").filter(f=>f.subject===c),m=[],p=[];for(let f of d){let g=i.get(f.object),h=g?wn(g):{id:f.object,label:f.objectLabel||f.object,class:"Entity",attributes:[]};(g?.class||"")==="Attribute"?p.push(h):m.push(h)}return ht({methods:m,attributes:p})},subclasses(c){if(!a(c))return gt(Xe.UNRESOLVED_TERM,{term:c});let d=Se(e,"inherits"),m=d.filter(w=>w.subject===c).map(w=>i.get(w.object)?wn(i.get(w.object)):{id:w.object,label:w.objectLabel||w.object,class:"Class",attributes:[]}),p=new Map;for(let w of d)p.has(w.object)||p.set(w.object,[]),p.get(w.object).push(w.subject);let f=new Set([c]),g=[],h=[],b=[c];for(let w=0;w<8&&b.length;w+=1){let v=[],$=[];for(let k of b)for(let y of p.get(k)||[]){if(f.has(y))continue;f.add(y);let j=i.get(y),E=j?wn(j):{id:y,label:y,class:"Class",attributes:[]};g.push(E),$.push(E),v.push(y)}$.length&&h.push($),b=v}return ht({bases:m,subclasses:g,levels:h})},exports(c){if(!a(c))return gt(Xe.UNRESOLVED_TERM,{term:c});let m=Se(e,"reexports").filter(p=>p.subject===c).map(p=>i.get(p.object)?wn(i.get(p.object)):{id:p.object,label:p.objectLabel||p.object,class:"Entity",attributes:[]});return ht({exports:m})},signature(c){let u=a(c);if(!u)return gt(Xe.UNRESOLVED_TERM,{term:c});let d=[];for(let[p,f]of[["isStatic","static"],["isAbstract","abstract"],["isConstant","constant"]])Pt(u,p)&&d.push(f);let m=Pt(u,"visibility");return m&&d.push(m),ht({id:u.id,label:u.label,class:u.class||"Entity",params:Pt(u,"params"),returns:Pt(u,"returns"),raises:Pt(u,"raises"),decorators:Pt(u,"decorators"),doc:Pt(u,"doc"),selfFields:Pt(u,"self_fields"),flags:d})},edges(c,u,{limit:d,offset:m=0}={}){if(!pc.includes(u))throw new TypeError(`edges(): unknown kind "${u}" (not in EDGE_KINDS)`);if(!a(c))return gt(Xe.UNRESOLVED_TERM,{term:c});let f=z$(e,u),g=Se(e,u).filter(h=>h.subject===c).map(h=>ai(h,f));return g=d==null?g.slice(m):g.slice(m,m+d),ht({kind:u,edges:g})},impact(c,{maxDepth:u}={}){let d=a(c);if(!d)return gt(Xe.UNRESOLVED_TERM,{term:c});let m=u==null?no(e,d):no(e,d,{maxDepth:u}),p=m.reduce((f,g)=>f+g.length,0);return ht({total:p,levels:m})},async snippet(c){let u=a(c);if(!u)return gt(Xe.UNRESOLVED_TERM,{term:c});let d=$t(u);if(!l.sourceAccess)return gt(Xe.NO_SOURCE,{term:c,detail:d?`span is ${d.path}:${d.start}-${d.end}; this provider exposes no working tree`:"no source span in the graph"});if(!d)return gt(Xe.NO_SOURCE,{term:c,detail:"no source span in the graph (likely a module)"});try{let m=await Pn({readFile:s,repoRoot:n,path:d.path,start:d.start,end:d.end,maxLines:mc});return ht({path:d.path,span:{start:d.start,end:d.end},body:m.text})}catch(m){return gt(Xe.NO_SOURCE,{term:c,detail:`could not read ${d.path}: ${m?.message||m}`})}},async context(c,{depth:u="auto"}={}){let{match:d}=Vt(e,String(c??""));if(!d)return gt(Xe.UNRESOLVED_TERM,{term:String(c??"")});let m=so(e,d),p=String(u||"auto").trim().toLowerCase(),f,g;p==="min"?(f="TINY",g=js("TINY")):p==="full"?(f="FULL",g=js("FULL")):{tier:f,mask:g}=Vr(m,e,{});let h=Od(m,g);if(!l.sourceAccess)return ht({text:h,tier:f});let b=await U$(m,g,{readFile:s,repoRoot:n});return ht({text:b?`${h}
69
69
  ${b}`:h,tier:f})},architecture({package:c=""}={}){let u=String(c||"").trim().toLowerCase().replace(/^\.?\//,""),d=e.individuals.filter(b=>(b.class||"")==="Module"&&(!u||String(b.label||"").toLowerCase().startsWith(u))),m=new Map;for(let b of d){let w=b.label.includes("/")?b.label.slice(0,b.label.lastIndexOf("/")):"(root)";m.set(w,(m.get(w)||0)+1)}let p=new Set(d.map(b=>b.id)),f=new Map;for(let b of Se(e,"imports"))p.has(b.object)&&f.set(b.object,(f.get(b.object)||0)+1);let g=[...f.entries()].sort((b,w)=>w[1]-b[1]).map(([b,w])=>({id:b,label:i.get(b)?.label||b,importers:w})),h=[...m.entries()].sort((b,w)=>w[1]-b[1]);return ht({modules:d.length,packages:h,hubs:g})},untested(){let c=new Set(Se(e,"tests").map(d=>d.object)),u=e.individuals.filter(d=>(d.class||"")==="Module"&&!c.has(d.id)&&!/\.test\./.test(d.label||"")).map(wn);return ht({modules:u})},stats(){let c=new Map;for(let d of e.individuals){let m=d.class||"Entity";c.set(m,(c.get(m)||0)+1)}let u=[...c.entries()].map(([d,m])=>({class:d,count:m})).sort((d,m)=>m.count-d.count||d.class.localeCompare(m.class));return ht({total:e.individuals.length,classes:u,truncated:(e.truncated||[]).length>0})},history(c){if(!a(c))return gt(Xe.UNRESOLVED_TERM,{term:c});let d=[...Se(e,"touches"),...Se(e,"touchesSymbol")].filter(f=>f.object===c),m=new Set,p=[];for(let f of d){if(m.has(f.subject))continue;m.add(f.subject);let g=i.get(f.subject);p.push({id:f.subject,label:f.subjectLabel||g?.label||f.subject,author:g?Pt(g,"author")??Pt(g,"commitAuthor"):null,date:g?Pt(g,"date")??Pt(g,"commitDate"):null,message:g?Pt(g,"message")??Pt(g,"commitMessage"):null})}return ht({commits:p})},search(c,{kind:u="",name:d="",decorator:m="",limit:p=Ur,offset:f=0}={}){let g=String(c||""),h=String(u||"").trim().toLowerCase(),b=String(d||"").trim(),w=String(m||"").trim().toLowerCase(),v;if(h&&h!=="module"){let k=null;if(b){let j=Ra(b);if(j.error)return gt(Xe.UNRESOLVED_TERM,{term:b,detail:j.error});k=j}let y=g.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean);try{v=Ca(e,y,{kind:h,decFilter:w,nameRe:k}).map(j=>j.ind)}catch(j){return gt(Xe.UNRESOLVED_TERM,{term:b,detail:String(j?.message||j)})}}else{let k=new Map;for(let y of e.individuals)(y.class||"")==="Module"&&k.set(y.label,y);v=ud(e,g).map(({path:y})=>k.get(y)).filter(Boolean)}let $=v.slice(f,f+p).map(wn);return ht({results:$})},ask(c){if(typeof r!="function")return gt(Xe.CAPABILITY_ABSENT,"this provider was constructed without an ask answerer");let{content:u,tmct_ask:d}=r(e,String(c||""));return ht({content:u,tmct_ask:d})}};if(o)for(let c of fc){let u=l[c];typeof u=="function"&&(l[c]=(...d)=>{let m=performance.now(),p=u.apply(l,d);return p&&typeof p.then=="function"?p.then(f=>(nf(o,c,performance.now()-m,f),f)):(nf(o,c,performance.now()-m,p),p)})}return l}function nf(e,t,n,s){try{e.record({tool:`ri.${t}`,perf:{ms_total:n},response:W$(s)})}catch{}}function W$(e){if(!e||typeof e!="object"||e.ok!==!0)return{ok:!1,reason:e?.miss?.reason||null};let t=0,n=e.value;if(Array.isArray(n))t=n.length;else if(n&&typeof n=="object")for(let s of Object.values(n))Array.isArray(s)&&(t+=s.length);return{ok:!0,count:t}}var Pt,mc,B$,li=L(()=>{Ce();ii();tf();Pt=(e,t)=>(e?.attributes||[]).find(n=>n.key===t)?.value??null;mc=200,B$=120});async function sr(e,t){let n=await t.fetchEntities(e),s=Br(n);if(!s.individuals.length){let o=new Oe(`the graph at ${e.graphFile} is empty \u2014 no entities to answer from yet (this repo starts with no graph; the chat session folds the conversation into one).`);throw o.emptyGraph=!0,o}return s}var ui=L(()=>{Lt();Ce()});function ot(e,t){let n=String(e?.[t]||"").trim();if(!n)throw new Oe(`${t} is required`);return n}function yt(e,t,n){let{match:s,candidates:o}=Vt(e.graph,t);if(!s)throw new Oe(`no entity matching ${n} "${t}" in the code-map graph. Try a repo-relative path (e.g. path/to/module), a basename, or tmct_search for a fuzzy lookup.`);return{match:s,candidates:o}}var or,Je,Ke=L(()=>{Lt();Ce();or=200;Je=e=>(t,{graph:n,svc:s})=>{let{match:o}=yt(s,ot(t,"symbol"),"symbol");return e(n,o)}});async function sf(e,{config:t,source:n=eo,trim:s=!1,tel:o=null}={}){let r=String(e?.symbol||"").trim();if(!r)throw new Oe("symbol is required");let i=String(e?.depth||"auto").trim().toLowerCase(),a=!!e?.min,l=!!e?.untuned,c=!!e?.max,u=await sr(t,n),d=$e($e(t.graphFile)),m=ci(u,{sourceAccess:!0,repoRoot:d,readFile:ze,tel:o,ask:ss}),{match:p}=yt(m,r,"symbol"),f=so(u,p),g,h,b=!1;a||i==="min"?(g="TINY",h=js("TINY")):c||i==="full"?(g="FULL",h=js("FULL"),b=!0):{tier:g,mask:h,topup:b}=Vr(f,u,{untuned:l}),s&&!c&&(h=Cd(h));let w=null;if(f.moduleLabel)try{({lines:w}=await Pn({readFile:ze,repoRoot:d,path:f.moduleLabel}))}catch{w=null}let v=y=>w&&w[y-1]!=null?w[y-1].trim():"",$=(y,j)=>rs(w,y,j,or).text,k=[`Edit context for ${f.moduleLabel} [${g}${s?" secondary":""}] \u2014 assembled from the typed graph + that file. You do NOT need to Read it; write the new code directly after reviewing this.`];if(h.anchor&&f.anchor?.site&&w){let{start:y,end:j}=f.anchor.site;k.push(`
70
70
  ## anchor: ${f.anchor.label} (${f.anchor.class}) @ ${f.moduleLabel}:${y}-${j}`),k.push($(y,j)),f.callHint&&k.push(f.callHint)}if(h.registration&&f.globals.length){k.push(`
71
71
  ## registration / module globals (replicate this pattern):`);for(let y of f.globals)k.push(` ${y.label} = ${y.value}${y.site?` [:${y.site.start}]`:""}`)}if(h.exemplar&&f.exemplar?.site&&w){let{start:y,end:j}=f.exemplar.site,E=f.exemplar.decorators?` @${f.exemplar.decorators}`:"";k.push(`
@@ -82,7 +82,7 @@ ${b}`:h,tier:f})},architecture({package:c=""}={}){let u=String(c||"").trim().toL
82
82
  ## covering tests: ${f.tests.join(", ")}`),h.cochange&&f.cochange&&f.cochange.length&&k.push(`
83
83
  ## usually changed together (consider editing these too): ${f.cochange.map(y=>`${y.label} (\xD7${y.weight})`).join(", ")}`),k.push(`
84
84
  You now have the snippet, the sibling style, the registration anchor and the tests. Write the new code with Edit/Write \u2014 do NOT Read ${f.moduleLabel}.`),g!=="FULL"&&k.push(`(bundle tier ${g}; for any omitted sections run tmct_context_more {"symbol":"${r}"}, or tmct_context with depth="full".)`),{text:k.join(`
85
- `),tier:g,topup:b}}async function hc(e,{config:t,source:n,tel:s}){return(await sf(e,{config:t,source:n,tel:s})).text}var gc=L(()=>{vt();De();Lt();ii();Bo();Ce();os();li();ui();Ke();hc.ownsGraphLoad=!0});function of(e,{graph:t,svc:n}){let{match:s}=yt(n,ot(e,"symbol"),"symbol");return Id(so(t,s))}var rf=L(()=>{Ce();Ke()});function di(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function rr(e){return di(e).toString(16).padStart(8,"0")}function G$(e){let t=new TextEncoder().encode(String(e)),n=t.length*8,s=new Uint8Array((t.length+8>>6)+1<<6);s.set(t),s[t.length]=128;let o=new DataView(s.buffer);o.setUint32(s.length-8,Math.floor(n/4294967296)),o.setUint32(s.length-4,n>>>0);let r=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),i=new Uint32Array(64),a=(u,d)=>u>>>d|u<<32-d;for(let u=0;u<s.length;u+=64){for(let v=0;v<16;v+=1)i[v]=o.getUint32(u+v*4);for(let v=16;v<64;v+=1){let $=a(i[v-15],7)^a(i[v-15],18)^i[v-15]>>>3,k=a(i[v-2],17)^a(i[v-2],19)^i[v-2]>>>10;i[v]=i[v-16]+$+i[v-7]+k>>>0}let[d,m,p,f,g,h,b,w]=r;for(let v=0;v<64;v+=1){let $=a(g,6)^a(g,11)^a(g,25),k=g&h^~g&b,y=w+$+k+q$[v]+i[v]>>>0,j=a(d,2)^a(d,13)^a(d,22),E=d&m^d&p^m&p,_=j+E>>>0;w=b,b=h,h=g,g=f+y>>>0,f=p,p=m,m=d,d=y+_>>>0}r[0]=r[0]+d>>>0,r[1]=r[1]+m>>>0,r[2]=r[2]+p>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+g>>>0,r[5]=r[5]+h>>>0,r[6]=r[6]+b>>>0,r[7]=r[7]+w>>>0}let l=new Uint8Array(32),c=new DataView(l.buffer);for(let u=0;u<8;u+=1)c.setUint32(u*4,r[u]);return l}function V$(e,t){let n=G$(e),s="";for(let o=0;o<t;o+=1)s+=n[o].toString(16).padStart(2,"0");return s}function ee(e){let t=Fn(e);return t=t.replace(/^\/c\/[a-z]{2,3}\//i,""),t=t.replace(/^[a-z][\w.-]*:/i,""),t=t.replace(/_/g," ").replace(/\s+/g," ").trim(),t=t.replace(/^(?:the|an?)\s+/i,""),t.toLowerCase()}function Dn(e){let t=Fn(e);return K$.get(t)??t}function he(e,t,n){return ir(ee(e),Dn(t),ee(n))}var q$,H$,Fn,K$,ir,en=L(()=>{q$=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);H$=2e3,Fn=e=>String(e??"").replace(/\s+/g," ").trim().slice(0,H$);K$=new Map([["mgx:cause","mgx:causes"],["mgx:desire","mgx:desires"],["mgx:want","mgx:desires"],["mgx:require","mgx:hasPrerequisite"],["mgx:involve","mgx:hasSubevent"],["mgx:used-for","mgx:usedFor"],["mgx:made-of","mgx:madeOf"]]);ir=(e,t,n)=>`fact:${V$(`${e}\0${t}\0${n}`,8)}`});var tn={};En(tn,{CARDINALITY_RULE_CONFIDENCE:()=>tx,CAX_DW_RULE:()=>wc,CAX_DW_RULE_CONFIDENCE:()=>vc,CAX_MAXC0_RULE_CONFIDENCE:()=>sx,CLS_SVF1_RULE:()=>$c,CLS_SVF1_RULE_CONFIDENCE:()=>kc,DEFAULT_MAX_ENVIRONMENTS:()=>pi,DISJOINT_PREDICATE:()=>po,ENTAILED_DISJOINT_PROVENANCE:()=>yc,ENTAILED_PROVENANCE:()=>lf,ENTAILED_SCM_SVF_PROVENANCE:()=>jc,ENTAILED_SVF1_PROVENANCE:()=>xc,ENTAILED_TYPE_PROVENANCE:()=>df,ON_PROPERTY_PREDICATE:()=>yn,SCM_SVF_RULE:()=>Ec,SCM_SVF_RULE_CONFIDENCE:()=>_c,SOME_VALUES_FROM_PREDICATE:()=>vn,SUBCLASS_PREDICATE:()=>Fe,TYPE_PREDICATE:()=>At,buildCardinalityRestrictions:()=>ex,buildRelevanceFrontier:()=>bc,deriveDisjointViolations:()=>hf,deriveSomeValuesFromApplication:()=>gf,deriveSomeValuesFromSubsumption:()=>bf,deriveSubClassClosure:()=>pf,deriveSubClassClosureDelta:()=>ff,deriveTypePropagation:()=>mf,entailedTrustFrom:()=>X$,findConsistencyViolations:()=>rx,findIsaChain:()=>Rc,proveCardinalityAtLeast:()=>nx,proveMaxCardinalityZeroDenial:()=>ox,retractSubClassOf:()=>ux,syllogise:()=>ix});function af(e,t,n){for(let s of t)if(typeof e?.[s]!="function")throw new TypeError(`${n} needs a store option carrying { ${t.join(", ")} } (memory/core.mjs's read/write functions) \u2014 missing ${s}`);return e}function X$(e,t=1){let n=(Array.isArray(e)?e:[]).filter(o=>typeof o=="number");if(!n.length)return null;let s=Math.max(0,Math.min(1,Math.min(...n)*t));return Number(s.toFixed(6))}function zn(e){if(!e)return null;let t=e instanceof Set?[...e]:Array.isArray(e)?e:[],n=new Set;for(let s of t){let o=ee(s);o&&n.add(o)}return n.size?n:null}function pf(e,{depth:t=32,budget:n=50,focus:s=null}={}){let o=new Set,r=new Map;for(let[u,d]of e||[])!u||!d||u===d||(o.add(`${u}${Ie}${d}`),r.has(u)||r.set(u,new Set),r.get(u).add(d));let i=s instanceof Set?s.size?s:null:zn(s),a=(u,d,m)=>!i||i.has(u)||i.has(d)||i.has(m),l=[],c=new Set;for(let u=0;u<t;u+=1){let d=[];for(let[p,f]of r)for(let g of f){let h=r.get(g);if(h)for(let b of h){if(p===b)continue;let w=`${p}${Ie}${b}`;o.has(w)||c.has(w)||a(p,g,b)&&d.push([p,g,b,w])}}if(!d.length)break;d.sort((p,f)=>p[0].localeCompare(f[0])||p[2].localeCompare(f[2])||p[1].localeCompare(f[1]));let m=!1;for(let[p,f,g,h]of d)if(!c.has(h)){if(l.length>=n)break;c.add(h),l.push({subject:p,object:g,via:f}),r.has(p)||r.set(p,new Set),r.get(p).add(g),m=!0}if(l.length>=n||!m)break}return l}function ff(e,t,{depth:n=32,budget:s=50,focus:o=null}={}){let r=new Set,i=new Map,a=new Map;for(let[f,g]of e||[])!f||!g||f===g||(r.add(`${f}${Ie}${g}`),i.has(f)||i.set(f,new Set),i.get(f).add(g),a.has(g)||a.set(g,new Set),a.get(g).add(f));let l=[],c=new Set;for(let[f,g]of t||[]){if(!f||!g||f===g)continue;let h=`${f}${Ie}${g}`;c.has(h)||(c.add(h),l.push([f,g]))}let u=o instanceof Set?o.size?o:null:zn(o),d=(f,g,h)=>!u||u.has(f)||u.has(g)||u.has(h),m=[],p=new Set;for(let f=0;f<n&&l.length;f+=1){let g=[],h=(v,$,k)=>{if(v===k)return;let y=`${v}${Ie}${k}`;r.has(y)||p.has(y)||d(v,$,k)&&g.push([v,$,k,y])};for(let[v,$]of l){for(let k of i.get($)||[])h(v,$,k);for(let k of a.get(v)||[])h(k,v,$)}if(!g.length)break;g.sort((v,$)=>v[0].localeCompare($[0])||v[2].localeCompare($[2])||v[1].localeCompare($[1]));let b=!1,w=[];for(let[v,$,k,y]of g)if(!p.has(y)){if(m.length>=s)break;p.add(y),m.push({subject:v,object:k,via:$}),i.has(v)||i.set(v,new Set),i.get(v).add(k),a.has(k)||a.set(k,new Set),a.get(k).add(v),w.push([v,k]),b=!0}if(m.length>=s||!b)break;l=w}return m}function $n(e){let t=new Map;for(let[s,o]of e||[])!s||!o||s===o||(t.has(s)||t.set(s,new Set),t.get(s).add(o));let n=new Map;return s=>{if(n.has(s))return n.get(s);let o=new Set,r=[...t.get(s)||[]];for(;r.length;){let i=r.pop();if(!o.has(i)){o.add(i);for(let a of t.get(i)||[])o.has(a)||r.push(a)}}return n.set(s,o),o}}function J$(e){return $n((e||[]).map(([t,n])=>[n,t]))}function bc(e,t){let n=[],s=[],o=new Map,r=new Map;for(let c of e||[])!c||!c.subject||!c.predicate||!c.object||(is(c.predicate)?n.push([c.subject,c.object]):Is(c.predicate)?s.push([c.subject,c.object]):fo(c.predicate)?o.set(c.subject,c.object):cr(c.predicate)&&r.set(c.subject,c.object));let i=J$(n),a=new Set;for(let c of t||[]){let u=ee(c);if(u){a.add(u);for(let d of i(u))a.add(d)}}let l=new Set(a);for(let[c,u]of s)a.has(u)&&l.add(c);for(let[c,u]of r)o.has(c)&&a.has(u)&&l.add(c);return l}function mf(e,t,{budget:n=50,focus:s=null,presentTypeEdges:o=e}={}){let r=$n(t),i=new Set,a=new Set;for(let[p,f]of o||[])p&&f&&i.add(`${p}${Ie}${f}`);let l=s instanceof Set?s.size?s:null:zn(s),c=(p,f,g)=>!l||l.has(p)||l.has(f)||l.has(g),u=[];for(let[p,f]of e||[]){if(!p||!f)continue;let g=`${p}${Ie}${f}`;if(!a.has(g)){a.add(g);for(let h of r(f)){if(h===f||h===p)continue;let b=`${p}${Ie}${h}`;i.has(b)||c(p,f,h)&&u.push([p,f,h,b])}}}u.sort((p,f)=>p[0].localeCompare(f[0])||p[2].localeCompare(f[2])||p[1].localeCompare(f[1]));let d=[],m=new Set;for(let[p,f,g,h]of u)if(!m.has(h)){if(d.length>=n)break;m.add(h),d.push({subject:p,object:g,via:f})}return d}function hf(e,t,n,{budget:s=50,focus:o=null}={}){let r=$n(t),i=new Map,a=new Set;for(let[f,g]of n||[])!f||!g||f===g||(a.add(`${f}${Ie}${g}`),a.add(`${g}${Ie}${f}`),i.has(f)||i.set(f,new Set),i.get(f).add(g),i.has(g)||i.set(g,new Set),i.get(g).add(f));if(!i.size)return[];let l=new Set,c=o instanceof Set?o.size?o:null:zn(o),u=(f,g,h)=>!c||c.has(f)||c.has(g)||c.has(h),d=[];for(let[f,g]of e||[]){if(!f||!g)continue;let h=`${f}${Ie}${g}`;if(!l.has(h)){l.add(h);for(let b of[g,...r(g)]){let w=i.get(b);if(w)for(let v of w){if(v===f)continue;let $=`${f}${Ie}${v}`;a.has($)||u(f,g,v)&&d.push([f,g,b,v,$])}}}}d.sort((f,g)=>f[0].localeCompare(g[0])||f[3].localeCompare(g[3])||f[2].localeCompare(g[2])||f[1].localeCompare(g[1]));let m=[],p=new Set;for(let[f,g,h,b,w]of d)if(!p.has(w)){if(m.length>=s)break;p.add(w),m.push({subject:f,object:b,viaType:g,viaClass:h})}return m}function gf(e,t,n,s,{budget:o=50,focus:r=null}={}){let i=$n(n),a=new Map;for(let h of s||[]){if(!h||!h.restriction||!h.property||!h.target)continue;let b=`${h.property}${Ie}${h.target}`;a.has(b)||a.set(b,new Set),a.get(b).add(h.restriction)}if(!a.size)return[];let l=new Set,c=new Map;for(let[h,b]of t||[])!h||!b||(l.add(`${h}${Ie}${b}`),c.has(h)||c.set(h,new Set),c.get(h).add(b));let u=r instanceof Set?r.size?r:null:zn(r),d=(h,b,w)=>!u||u.has(h)||u.has(b)||u.has(w),m=new Set,p=[];for(let[h,b,w]of e||[]){if(!h||!b||!w)continue;let v=ee(b),$=`${h}${Ie}${v}${Ie}${w}`;if(m.has($))continue;m.add($);let k=c.get(w);if(k)for(let y of k)for(let j of[y,...i(y)]){let E=a.get(`${v}${Ie}${j}`);if(E)for(let _ of E){if(h===_)continue;let R=`${h}${Ie}${_}`;l.has(R)||d(h,w,_)&&p.push([h,b,v,w,y,j,_,R])}}}p.sort((h,b)=>h[0].localeCompare(b[0])||h[6].localeCompare(b[6])||h[1].localeCompare(b[1])||h[3].localeCompare(b[3]));let f=[],g=new Set;for(let[h,b,w,v,$,k,y,j]of p)if(!g.has(j)){if(f.length>=o)break;g.add(j),f.push({subject:h,object:y,viaProperty:b,viaPropertyKey:w,viaValue:v,viaType:$,viaTarget:k})}return f}function ex(e){let t=new Map,n=new Map,s=new Map;for(let r of e||[])if(!(!r||!r.subject||!r.predicate))if(fo(r.predicate))t.set(r.subject,r.object);else if(Y$(r.predicate))s.set(r.subject,r.object);else{let i=Z$[String(r.predicate).trim().toLowerCase()];if(!i)continue;let a=Number(r.object);Number.isFinite(a)&&n.set(r.subject,{kind:i,n:a})}let o=[];for(let[r,{kind:i,n:a}]of n){if(t.get(r)!==Q$)continue;let l=s.get(r);l&&o.push({restriction:r,kind:i,n:a,onClass:l})}return o.sort((r,i)=>r.restriction.localeCompare(i.restriction)),o}function bf(e,t,{budget:n=50,focus:s=null}={}){let o=$n(t),r=new Map;for(let m of e||[]){if(!m||!m.restriction||!m.property||!m.target)continue;let p=ee(m.property);r.has(p)||r.set(p,[]),r.get(p).push({restriction:m.restriction,target:m.target})}let i=new Set;for(let[m,p]of t||[])m&&p&&i.add(`${m}${Ie}${p}`);let a=s instanceof Set?s.size?s:null:zn(s),l=(m,p)=>!a||a.has(m)||a.has(p),c=[];for(let[,m]of r)if(!(m.length<2))for(let p of m)for(let f of m){if(p.restriction===f.restriction||p.target===f.target||!o(p.target).has(f.target))continue;let g=`${p.restriction}${Ie}${f.restriction}`;i.has(g)||l(p.restriction,f.restriction)&&c.push([p.restriction,f.restriction,p.target,f.target,g])}c.sort((m,p)=>m[0].localeCompare(p[0])||m[1].localeCompare(p[1]));let u=[],d=new Set;for(let[m,p,f,g,h]of c)if(!d.has(h)){if(u.length>=n)break;d.add(h),u.push({subject:m,object:p,viaY1:f,viaY2:g})}return u}function wf(e,t,n,s,{budget:o=20,focus:r=null}={}){if(!n)return null;let i=$n(e),a=r instanceof Set?r.size?r:null:zn(r),l=m=>!a||a.has(n)||a.has(m),c=new Map;for(let[m,p]of e||[])!m||!p||(c.has(m)||c.set(m,new Set),c.get(m).add(p));let u=new Map((t||[]).map(m=>[m.restriction,m])),d=0;for(let m of[n,...i(n)]){if(d>=o)break;if(d+=1,!!l(m))for(let p of c.get(m)||[]){let f=u.get(p);if(f&&s(f))return{viaClass:m,viaRestriction:p,record:f}}}return null}function nx(e,t,n,s,o,r={}){if(!s||!Number.isFinite(o))return null;let i=wf(e,t,n,a=>a.onClass===s&&(a.kind==="exactly"||a.kind==="min")&&a.n>=o,r);return i?{subject:n,object:s,m:o,n:i.record.n,kind:i.record.kind,viaClass:i.viaClass,viaRestriction:i.viaRestriction}:null}function ox(e,t,n,s,o={}){if(!s)return null;let r=wf(e,t,n,i=>i.onClass===s&&i.kind==="max"&&i.n===0,o);return r?{subject:n,object:s,viaClass:r.viaClass,viaRestriction:r.viaRestriction}:null}function rx(e,t,n,{budget:s=50,focus:o=null}={}){let r=$n(t),i=new Map;for(let[p,f]of n||[])!p||!f||p===f||(i.has(p)||i.set(p,new Set),i.get(p).add(f),i.has(f)||i.set(f,new Set),i.get(f).add(p));if(!i.size)return[];let a=new Map;for(let[p,f]of e||[])!p||!f||(a.has(p)||a.set(p,new Set),a.get(p).add(f));let l=o instanceof Set?o.size?o:null:zn(o),c=p=>!l||l.has(p),u=[],d=new Set;for(let[p,f]of a){if(!c(p))continue;let g=[...f].sort();for(let h=0;h<g.length;h+=1)for(let b=h+1;b<g.length;b+=1){let[w,v]=[g[h],g[b]],$=[w,...r(w)],k=[v,...r(v)],y=null;for(let E of $){let _=i.get(E);if(_){for(let R of k)if(_.has(R)){y=[E,R];break}if(y)break}}if(!y)continue;let j=`${p}${Ie}${w}${Ie}${v}`;d.has(j)||(d.add(j),u.push([p,w,v,y[0],y[1]]))}}u.sort((p,f)=>p[0].localeCompare(f[0])||p[1].localeCompare(f[1])||p[2].localeCompare(f[2]));let m=[];for(let[p,f,g,h,b]of u){if(m.length>=s)break;m.push({subject:p,classA:f,classB:g,viaA:h,viaB:b})}return m}async function ix(e,{depth:t=32,budget:n=50,focus:s=null,expandFocus:o=!1,maxEnvironments:r=pi,full:i=!1,store:a}={}){let{loadMemory:l,readFactRows:c,appendFacts:u}=af(a,["loadMemory","readFactRows","appendFacts"],"syllogise"),d=typeof a?.loadSyllogiseState=="function"&&typeof a?.saveSyllogiseState=="function",m=await l(e),p=c(m),f=p.filter(x=>is(x.predicate)).map(x=>[x.subject,x.object]),g=p.filter(x=>Is(x.predicate)).map(x=>[x.subject,x.object]),h=p.filter(x=>Cs(x.predicate)).map(x=>[x.subject,x.object]),b=new Map,w=new Map,v=[];for(let x of p){let ue=String(x.predicate||"").trim().toLowerCase();fo(x.predicate)?b.set(x.subject,x.object):cr(x.predicate)?w.set(x.subject,x.object):Sc.has(ue)||v.push([x.subject,x.predicate,x.object])}let $=[];for(let[x,ue]of b){let Re=w.get(x);Re&&$.push({restriction:x,property:ue,target:Re})}let k=zn(s),y=o&&k?bc(p,[...k]):k,j=y===null&&d?await a.loadSyllogiseState(e):null,E=new Set(p.map(x=>x.id)),_=Array.isArray(j?.factIds)?j.factIds.filter(x=>!E.has(x)):[],R=j&&Array.isArray(j.factIds)&&!_.length&&!i?"delta":"full",S=R==="delta"?new Set(j.factIds):null,A=R==="delta"?p.filter(x=>!S.has(x.id)):p,M=A.length,T=new Map;for(let x of p)T.set(`${x.subject}${Ie}${x.predicate}${Ie}${x.object}`,x.trust);let P=(x,ue,Re)=>T.get(`${x}${Ie}${ue}${Ie}${Re}`),G=(x,ue,Re)=>T.has(`${x}${Ie}${ue}${Ie}${Re}`),K=x=>x.filter(ue=>typeof ue=="number"),te=R==="delta"&&!A.length,F=R==="delta"?A.filter(x=>is(x.predicate)).map(x=>[x.subject,x.object]):[],D=R==="delta"?F.length?ff(f,F,{depth:t,budget:n,focus:y}):[]:pf(f,{depth:t,budget:n,focus:y}),B=f.concat(D.map(x=>[x.subject,x.object])),W=y,C=null;if(R==="delta"&&!te){let x=p.concat(D.map(Re=>({subject:Re.subject,predicate:Fe,object:Re.object}))),ue=[];for(let Re of A)ue.push(Re.subject,Re.object);C=bc(x,ue),W=C}let I=x=>!C||C.has(x),O=C?g.filter(([x,ue])=>I(x)||I(ue)):g,N=new Set;if(C)for(let x of A)Cs(x.predicate)&&(N.add(x.subject),N.add(x.object));let q=C&&N.size?$n(B):null,U=C?g.filter(([x,ue])=>I(x)||I(ue)||q&&[...q(ue)].some(Re=>N.has(Re))):g,ie=new Set;if(C){for(let x of A)if(fo(x.predicate)||cr(x.predicate)){let ue=b.get(x.subject);ue&&ie.add(ee(ue))}}let se=C?v.filter(([x,ue,Re])=>I(x)||I(Re)||ie.has(ee(ue))):v,X=Math.max(0,n-D.length),J=X>0&&!te?mf(O,B,{budget:X,focus:W,presentTypeEdges:g}):[],oe=Math.max(0,n-D.length-J.length),H=oe>0&&!te?hf(U,B,h,{budget:oe,focus:W}):[],le=Math.max(0,n-D.length-J.length-H.length),ne=le>0&&$.length&&!te?gf(se,g,B,$,{budget:le,focus:W}):[],_e=Math.max(0,n-D.length-J.length-H.length-ne.length),Le=_e>0&&$.length>1&&!te?bf($,B,{budget:_e,focus:W}):[],Q=new Map($.map(x=>[x.restriction,x])),xe=[...D.map(x=>({subject:x.subject,predicate:Fe,object:x.object,provenance:lf,justification:[[he(x.subject,Fe,x.via),he(x.via,Fe,x.object)]]})),...J.map(x=>({subject:x.subject,predicate:At,object:x.object,provenance:df,justification:[[he(x.subject,At,x.via),he(x.via,Fe,x.object)]]})),...H.map(x=>{let ue=G(x.viaClass,po,x.object),[Re,Sn]=ue?[x.viaClass,x.object]:[x.object,x.viaClass],Ys=K([P(x.subject,At,x.viaType),P(Re,po,Sn),...x.viaClass!==x.viaType?[P(x.viaType,Fe,x.viaClass)]:[]]);return{subject:x.subject,predicate:po,object:x.object,provenance:yc,justification:[[he(x.subject,At,x.viaType),he(Re,po,Sn),...x.viaClass!==x.viaType?[he(x.viaType,Fe,x.viaClass)]:[]]],...Ys.length?{premiseTrusts:Ys,ruleConfidence:vc}:{}}}),...ne.map(x=>{let ue=K([P(x.subject,x.viaProperty,x.viaValue),P(x.viaValue,At,x.viaType),P(x.object,yn,x.viaPropertyKey),P(x.object,vn,x.viaTarget),...x.viaType!==x.viaTarget?[P(x.viaType,Fe,x.viaTarget)]:[]]);return{subject:x.subject,predicate:At,object:x.object,provenance:xc,justification:[[he(x.subject,x.viaProperty,x.viaValue),he(x.viaValue,At,x.viaType),he(x.object,yn,x.viaPropertyKey),he(x.object,vn,x.viaTarget),...x.viaType!==x.viaTarget?[he(x.viaType,Fe,x.viaTarget)]:[]]],...ue.length?{premiseTrusts:ue,ruleConfidence:kc}:{}}}),...Le.map(x=>{let ue=Q.get(x.subject),Re=Q.get(x.object),Sn=K([ue&&P(x.subject,yn,ue.property),P(x.subject,vn,x.viaY1),Re&&P(x.object,yn,Re.property),P(x.object,vn,x.viaY2),P(x.viaY1,Fe,x.viaY2)]);return{subject:x.subject,predicate:Fe,object:x.object,provenance:jc,justification:[[...ue?[he(x.subject,yn,ue.property)]:[],he(x.subject,vn,x.viaY1),...Re?[he(x.object,yn,Re.property)]:[],he(x.object,vn,x.viaY2),he(x.viaY1,Fe,x.viaY2)]],...Sn.length?{premiseTrusts:Sn,ruleConfidence:_c}:{}}})],ge=xe.map(x=>({id:he(x.subject,x.predicate,x.object),subject:x.subject,predicate:x.predicate,object:x.object,environments:x.justification,write:x})),ve=vf(p.concat(ge.map(x=>({id:x.id,subject:x.subject,predicate:x.predicate,object:x.object})))),V=new Map(p.map(x=>[x.id,x])),re=x=>is(x)||Is(x)||Cs(x),fe=x=>R!=="delta"||C!==null&&(C.has(x.subject)||C.has(x.object)),ce=p.filter(x=>re(x.predicate)&&yf(x.provenance)&&ar(x).length<r&&fe(x)).map(x=>({id:x.id,subject:x.subject,predicate:x.predicate,object:x.object,environments:ar(x),provenance:x.provenance})),wt=[...ge,...ce].sort((x,ue)=>x.subject.localeCompare(ue.subject)||x.predicate.localeCompare(ue.predicate)||x.object.localeCompare(ue.object)),Bt=0,Qe=!1,un=0;for(let x of wt){if(un>=n){Qe=!0;break}un+=1;let ue=ve(x,{maxEnvironments:r+1}),{kept:Re,truncated:Sn}=cx(x.environments,ue,r);if(Sn&&(Qe=!0),!(Re.length<=x.environments.length)){if(Bt+=Re.length-x.environments.length,x.write){x.write.justification=Re;continue}xe.push({subject:x.subject,predicate:x.predicate,object:x.object,justification:Re,...$f(x.provenance,Re,Ys=>V.get(Ys)?.trust)||{}})}}let{ids:Kt}=await u(e,xe),Ut=[],It=0;for(let x of D)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.via,rule:cf}),It+=1;for(let x of J)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.via,rule:uf}),It+=1;for(let x of H)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.viaClass,rule:wc}),It+=1;for(let x of ne)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.viaValue,rule:$c}),It+=1;for(let x of Le)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.viaY1,rule:Ec}),It+=1;let Tr=Ut.length>=n;if(y===null&&d&&!Tr){let x=new Set(E);for(let ue of Kt)x.add(ue);await a.saveSyllogiseState(e,{version:1,factIds:[...x].sort(),completedAt:new Date().toISOString()})}return{derived:Ut,count:Ut.length,budget:n,depth:t,truncated:Tr,mode:R,deltaSize:M,environmentsAdded:Bt,alternatesTruncated:Qe}}function yf(e){let t=String(e||"").split(" | ").filter(Boolean);return t.length>0&&t.every(n=>n.startsWith("entailed:"))}function ax(e){let t=[],n=new Map,s=new Map,o=new Map,r=new Map,i=new Map;for(let u of e){let d=String(u.predicate||"").trim().toLowerCase();is(u.predicate)?t.push([u.subject,u.object]):Is(u.predicate)?(n.has(u.subject)||n.set(u.subject,new Set),n.get(u.subject).add(u.object)):Cs(u.predicate)?(s.has(u.subject)||s.set(u.subject,new Set),s.get(u.subject).add(u.object),s.has(u.object)||s.set(u.object,new Set),s.get(u.object).add(u.subject)):fo(u.predicate)?o.set(u.subject,u.object):cr(u.predicate)?r.set(u.subject,u.object):Sc.has(d)||(i.has(u.subject)||i.set(u.subject,[]),i.get(u.subject).push([ee(u.predicate),u.object]))}let a=$n(t),l=(u,d)=>u!==d&&a(u).has(d),c=u=>{let d=o.get(u),m=r.get(u);return d&&m?{property:ee(d),target:m}:null};return u=>{if(is(u.predicate)){if(l(u.subject,u.object))return!0;let d=c(u.subject),m=c(u.object);return!!(d&&m&&d.property===m.property&&l(d.target,m.target))}if(Is(u.predicate)){for(let m of n.get(u.subject)||[])if(l(m,u.object))return!0;let d=c(u.object);if(d){for(let[m,p]of i.get(u.subject)||[])if(m===d.property){for(let f of n.get(p)||[])if(f===d.target||l(f,d.target))return!0}}return!1}if(Cs(u.predicate)){for(let d of n.get(u.subject)||[])for(let m of[d,...a(d)])if(s.get(m)?.has(u.object))return!0;return!1}return!0}}function vf(e){let t=new Set,n=[],s=new Map,o=new Map,r=new Set,i=new Map,a=new Map,l=new Map,c=new Map;for(let p of e){if(!p||!p.subject||!p.predicate||!p.object)continue;p.id&&t.add(p.id);let f=String(p.predicate||"").trim().toLowerCase();is(p.predicate)?(n.push([p.subject,p.object]),s.has(p.subject)||s.set(p.subject,new Set),s.get(p.subject).add(p.object)):Is(p.predicate)?(o.has(p.subject)||o.set(p.subject,new Set),o.get(p.subject).add(p.object)):Cs(p.predicate)?(r.add(`${p.subject}${Ie}${p.object}`),i.has(p.subject)||i.set(p.subject,new Set),i.get(p.subject).add(p.object),i.has(p.object)||i.set(p.object,new Set),i.get(p.object).add(p.subject)):fo(p.predicate)?a.set(p.subject,p.object):cr(p.predicate)?l.set(p.subject,p.object):Sc.has(f)||(c.has(p.subject)||c.set(p.subject,[]),c.get(p.subject).push([p.predicate,p.object]))}let u=$n(n),d=p=>s.get(p)||new Set,m=p=>{let f=a.get(p),g=l.get(p);return f&&g?{property:f,propertyKey:ee(f),target:g}:null};return(p,{maxEnvironments:f=pi}={})=>{let g=[],h=new Set,b=w=>{if(g.length>=f||p.id&&w.includes(p.id)||!w.every($=>t.has($)))return;let v=[...w].sort().join(" ");h.has(v)||(h.add(v),g.push(w))};if(is(p.predicate)){for(let w of[...d(p.subject)].sort()){if(g.length>=f)break;w===p.subject||w===p.object||d(w).has(p.object)&&b([he(p.subject,Fe,w),he(w,Fe,p.object)])}if(g.length<f){let w=m(p.subject),v=m(p.object);w&&v&&w.propertyKey===v.propertyKey&&w.target!==v.target&&d(w.target).has(v.target)&&b([he(p.subject,yn,w.property),he(p.subject,vn,w.target),he(p.object,yn,v.property),he(p.object,vn,v.target),he(w.target,Fe,v.target)])}return g}if(Is(p.predicate)){for(let v of[...o.get(p.subject)||[]].sort()){if(g.length>=f)break;v!==p.object&&d(v).has(p.object)&&b([he(p.subject,At,v),he(v,Fe,p.object)])}let w=m(p.object);if(w){let v=[...c.get(p.subject)||[]].filter(([$])=>ee($)===w.propertyKey).sort(($,k)=>$[0].localeCompare(k[0])||$[1].localeCompare(k[1]));for(let[$,k]of v){if(g.length>=f)break;for(let y of[...o.get(k)||[]].sort()){if(g.length>=f)break;y!==w.target&&!d(y).has(w.target)||b([he(p.subject,$,k),he(k,At,y),he(p.object,yn,w.propertyKey),he(p.object,vn,w.target),...y!==w.target?[he(y,Fe,w.target)]:[]])}}}return g}if(Cs(p.predicate)){let w=[];for(let v of o.get(p.subject)||[])for(let $ of[v,...u(v)])(i.get($)||new Set).has(p.object)&&w.push([v,$]);w.sort((v,$)=>v[0].localeCompare($[0])||v[1].localeCompare($[1]));for(let[v,$]of w){if(g.length>=f)break;let k=r.has(`${$}${Ie}${p.object}`),[y,j]=k?[$,p.object]:[p.object,$];b([he(p.subject,At,v),he(y,po,j),...$!==v?[he(v,Fe,$)]:[]])}return g}return g}}function cx(e,t,n){let s=[],o=new Set,r=!1;for(let i of[...e||[],...t||[]]){if(!Array.isArray(i)||!i.length)continue;let a=[...i].sort().join(" ");if(!o.has(a)){if(s.length>=n){r=!0;continue}o.add(a),s.push(i)}}return{kept:s,truncated:r}}function $f(e,t,n){let s;for(let i of String(e||"").split(" | ")){let a=lx.get(i);if(a!==void 0){s=a;break}}if(s===void 0)return null;let o=null,r=-1;for(let i of t||[]){let a=i.map(c=>n(c)).filter(c=>typeof c=="number");if(a.length!==i.length)continue;let l=Math.min(...a);l>r&&(r=l,o=a)}return o?{premiseTrusts:o,ruleConfidence:s}:null}async function ux(e,t,n,{budget:s=50,depth:o=32,maxEnvironments:r=pi,store:i}={}){let{loadMemory:a,readFactRows:l,removeFacts:c}=af(i,["loadMemory","readFactRows","removeFacts"],"retractSubClassOf"),u=typeof i?.appendFacts=="function"?i.appendFacts:null,d=ee(t),m=ee(n),p=he(d,Fe,m),f=await a(e),g=l(f),h=new Map(g.map(R=>[R.id,R]));if(!h.has(p))return{retracted:[],count:0,budget:s,depth:o,truncated:!1,found:!1};let b=g.filter(R=>ar(R).length&&yf(R.provenance)),w=new Map;for(let R of b)for(let S of ar(R))for(let A of S)w.has(A)||w.set(A,new Set),w.get(A).add(R.id);let v=new Set([p]),$=[p],k=new Map,y=!1,j=0,E=[p];for(;j<o;j+=1){let R=new Set;for(let te of E)for(let F of w.get(te)||[])v.has(F)||R.add(F);let S=[...R].map(te=>h.get(te)).sort((te,F)=>te.subject.localeCompare(F.subject)||te.predicate.localeCompare(F.predicate)||te.object.localeCompare(F.object));if(!S.length)break;let A=g.filter(te=>!v.has(te.id)&&!R.has(te.id)),M=new Set(A.map(te=>te.id)),T=vf(A),P=ax(A),G=!1,K=!1;E=[];for(let te of S){if(v.size>=s){K=!0;break}let F=ar(te),D=F.filter(W=>W.every(C=>M.has(C)));if(D.length){D.length!==F.length&&k.set(te.id,D);continue}let B=T(te,{maxEnvironments:r});if(B.length){k.set(te.id,B);continue}P(te)||(v.add(te.id),$.push(te.id),E.push(te.id),G=!0)}if(K){y=!0;break}if(!G)break}!y&&j>=o&&(y=b.some(R=>!v.has(R.id)&&R.justification.some(S=>v.has(S))));let{removed:_}=await c(e,$);if(u){let R=[...k.entries()].filter(([S])=>!v.has(S)).sort((S,A)=>S[0].localeCompare(A[0])).map(([S,A])=>{let M=h.get(S);return{subject:M.subject,predicate:M.predicate,object:M.object,justification:A,...$f(M.provenance,A,T=>h.get(T)?.trust)||{}}});R.length&&await u(e,R)}return{retracted:_,count:_.length,budget:s,depth:o,truncated:y,found:!0}}function Rc(e,t,n,s,{maxHops:o=6}={}){let r=t instanceof Set?t:new Set(t||[]),i=new Map;for(let[c,u]of s||[])!c||!u||c===u||(i.has(c)||i.set(c,new Set),i.get(c).add(u));let a=[];for(let[c,u]of n||[])c===e&&u&&a.push({node:u,path:[{subject:c,predicate:At,object:u}]});for(let c of i.get(e)||[])a.push({node:c,path:[{subject:e,predicate:Fe,object:c}]});let l=new Set([e]);for(let c=1;c<=o&&a.length;c+=1){for(let{node:d,path:m}of a)if(r.has(d))return m;if(c===o)break;let u=[];for(let{node:d,path:m}of a)if(!l.has(d)){l.add(d);for(let p of i.get(d)||[])l.has(p)||u.push({node:p,path:[...m,{subject:d,predicate:Fe,object:p}]})}a=u}return null}var Fe,cf,lf,At,uf,df,po,wc,yc,vc,yn,vn,$c,xc,kc,pi,Ie,is,Is,Cs,fo,cr,Y$,Sc,Q$,Z$,Ec,jc,_c,tx,sx,ar,lx,Ft=L(()=>{en();Fe="rdfs:subClassOf",cf="subClassOf",lf=`entailed:${cf}`,At="rdf:type",uf="type",df=`entailed:${uf}`,po="owl:disjointWith",wc="disjointWith",yc=`entailed:${wc}`,vc=.95,yn="owl:onProperty",vn="owl:someValuesFrom",$c="someValuesFrom",xc=`entailed:${$c}`,kc=.95,pi=4,Ie="\u241F",is=e=>String(e||"").trim().toLowerCase()==="rdfs:subclassof",Is=e=>String(e||"").trim().toLowerCase()==="rdf:type",Cs=e=>String(e||"").trim().toLowerCase()==="owl:disjointwith",fo=e=>String(e||"").trim().toLowerCase()==="owl:onproperty",cr=e=>String(e||"").trim().toLowerCase()==="owl:somevaluesfrom",Y$=e=>String(e||"").trim().toLowerCase()==="owl:onclass",Sc=new Set(["rdfs:subclassof","rdf:type","owl:disjointwith","owl:onproperty","owl:somevaluesfrom","owl:intersectionof"]);Q$="has",Z$={"owl:cardinality":"exactly","owl:mincardinality":"min","owl:maxcardinality":"max"};Ec="someValuesFromSubsumption",jc=`entailed:${Ec}`,_c=.95;tx=.95;sx=.95;ar=e=>e.environments||(Array.isArray(e.justification)&&e.justification.length?[e.justification]:[]);lx=new Map([[yc,vc],[xc,kc],[jc,_c]])});function bo(e){let t=String(e||""),n=xf.get(t);return n||(t.startsWith(Ac)?mo+t.slice(Ac.length):t)}function kf(e){let t=String(e||""),n=dx.get(t);return n||(t.startsWith(mo)?Ac+t.slice(mo.length):null)}function jf(e,t,n,s,o){let r=null;for(let i of e){if(i===t)return[];let a=Rc(i,new Set([t]),n,s,{maxHops:o});a&&(!r||a.length<r.length)&&(r=a)}return r}function hi(e,t,n,{maxHops:s=3}={}){let o=go(e),r=go(t),i=Array.isArray(n)?n:[],{typeEdges:a,subClassEdges:l}=Ef(i),c=i.filter(b=>(b.predicate===mi||b.predicate===ho)&&r.has(b.object)),u=[];for(let b of c){let w=b.predicate===ho?"negative":"positive";if(o.has(b.subject)){u.push({fact:b,polarity:w,hops:0,chain:null});continue}let v=jf(o,b.subject,a,l,s);v&&v.length&&u.push({fact:b,polarity:w,hops:v.length,chain:v})}if(!u.length)return{verdict:"none",hops:0,positive:[],negative:[],chain:null,overrides:null,baseRate:Cc(o,r,i,{maxHops:s})};u.sort((b,w)=>b.hops-w.hops||(w.fact.trust||0)-(b.fact.trust||0));let d=u[0].hops,m=u.filter(b=>b.hops===d),p=m.filter(b=>b.polarity==="positive").map(b=>b.fact),f=m.filter(b=>b.polarity==="negative").map(b=>b.fact),g=f.length&&!p.length?"negative":"positive",h=u.find(b=>b.hops>d&&b.polarity!==g)||null;return{verdict:p.length&&f.length?"both":f.length?"no":"yes",hops:d,positive:p,negative:f,chain:u[0].chain,overrides:h?{fact:h.fact,chain:h.chain}:null,baseRate:null}}function Cc(e,t,n,{maxHops:s=3}={}){let o=go(e),r=go(t),i=Array.isArray(n)?n:[],a=i.filter(g=>g.predicate===Fe||g.predicate===At),l=a.filter(g=>o.has(g.subject)).map(g=>g.object);if(!l.length)return null;let c=l[0],u=[...new Set(a.filter(g=>g.object===c&&!o.has(g.subject)).map(g=>g.subject))],d=g=>{let h=i.find(b=>b.subject===g&&r.has(b.object)&&(b.predicate===mi||b.predicate===ho));return h?{name:g,polarity:h.predicate===ho?"negative":"positive",fact:h}:{name:g,polarity:"unknown",fact:null}},m=u.map(d),{typeEdges:p,subClassEdges:f}=Ef(i);return{klass:c,kinds:u.length,positive:m.filter(g=>g.polarity==="positive"),negative:m.filter(g=>g.polarity==="negative"),unknown:m.filter(g=>g.polarity==="unknown"),chain:jf(o,c,p,f,s)}}function Ic(e,t,{exclude:n=[],maxHops:s=3}={}){let o=go(e),r=go(n),i=Array.isArray(t)?t:[],a=new Set,l=[];for(let c of i)c.predicate!==mi||!o.has(c.object)||r.has(c.subject)||a.has(c.subject)||(a.add(c.subject),hi(new Set([c.subject]),o,i,{maxHops:s}).verdict==="yes"&&l.push(c));return l.sort(px)}var mo,Ac,fi,xf,dx,Sf,mi,ho,Tc,px,go,Ef,Oc=L(()=>{Ft();mo="mgxneg:",Ac="mgx:",fi="mgxneg:subClassOf",xf=new Map([[Fe,fi]]),dx=new Map([...xf].map(([e,t])=>[t,e]));Sf=e=>String(e||"").startsWith(mo),mi="mgx:capableOf",ho=bo(mi),Tc=6,px=(e,t)=>(t.trust||0)-(e.trust||0)||String(e.subject).localeCompare(String(t.subject)),go=e=>e instanceof Set?e:new Set(Array.isArray(e)?e:[e]),Ef=e=>({typeEdges:e.filter(t=>t.predicate===At).map(t=>[t.subject,t.object]),subClassEdges:e.filter(t=>t.predicate===Fe).map(t=>[t.subject,t.object])})});function wo(e,t){let n=(e?.attributes||[]).find(s=>s?.prop===t);return n?String(n.value??""):void 0}function gx(e,t){(!e?.class||!fx.has(e.class))&&t.push(`must have a class from the closed vocabulary Utterance | Fact | Session | Source | Rule (got ${JSON.stringify(e?.class)})`)}function bx(e,t){for(let s of["rdf:subject","rdf:predicate","rdf:object"])gi(wo(e,s))||t.push(`a Fact needs a non-empty ${s}`);for(let s of["rdf:subject","rdf:object"]){let o=wo(e,s);o!==void 0&&hx.test(o)&&t.push(`a Fact's ${s} must be a single term, not text spanning a sentence boundary (got ${JSON.stringify(o)})`)}let n=wo(e,"mgx:factProvenance");n!==void 0&&!gi(n)&&t.push("mgx:factProvenance, when present, must be non-empty")}function wx(e,t){gi(wo(e,"mgx:ruleName"))||t.push("a Rule needs a non-empty mgx:ruleName");let n=wo(e,"mgx:ruleKind");if(!n||!_f.has(n)){t.push(`a Rule's mgx:ruleKind must be one of ${[..._f].join(" | ")} (got ${JSON.stringify(n)})`);return}for(let s of mx[n])gi(wo(e,s))||t.push(`a ${n} Rule needs a non-empty ${s}`)}function yx(e){let t=[];return gx(e,t),e?.class==="Fact"&&bx(e,t),e?.class==="Rule"&&wx(e,t),{ok:t.length===0,violations:t}}function Lc(e){let t=yx(e);if(!t.ok){let n=new Error(`SHACL validation failed for ${e?.class} "${e?.id}": ${t.violations.join(" | ")}`);throw n.violations=t.violations,n}}var fx,_f,mx,hx,gi,Rf=L(()=>{fx=new Set(["Utterance","Fact","Session","Source","Rule"]),_f=new Set(["compose2","filter","recursive","action-signature","action-precond","action-effect","action-constraint"]),mx={compose2:["mgx:ruleBase1","mgx:ruleBase2"],filter:["mgx:ruleBase1","mgx:ruleFilterProperty"],recursive:["mgx:ruleBaseCase","mgx:ruleRecStep"],"action-signature":["mgx:ruleActionSubjectClass","mgx:ruleActionTargetClass"],"action-precond":["mgx:ruleActionPrecondShape","mgx:ruleActionPrecondPredicate","mgx:ruleActionPrecondRole","mgx:ruleActionPrecondScope"],"action-effect":["mgx:ruleActionEffectPredicate","mgx:ruleActionEffectSubject"],"action-constraint":["mgx:ruleActionConstraintLeft","mgx:ruleActionConstraintRight","mgx:ruleActionConstraintGuard"]},hx=/[.!?]\s+\w/;gi=e=>typeof e=="string"&&e.trim().length>0});var Af={};En(Af,{access:()=>xx,appendFile:()=>Ex,basename:()=>Bx,copyFile:()=>Ix,createInterface:()=>Vx,createReadStream:()=>Lx,createRequire:()=>vx,createWriteStream:()=>Nx,default:()=>Kx,dirname:()=>Fx,existsSync:()=>Mx,fileURLToPath:()=>Wx,isAbsolute:()=>zx,join:()=>Px,mkdir:()=>jx,mkdtemp:()=>_x,randomBytes:()=>qx,readFile:()=>kx,readFileSync:()=>$x,readdir:()=>Ox,rename:()=>Rx,resolve:()=>Dx,rm:()=>Tx,sep:()=>Ux,spawnSync:()=>Gx,stat:()=>Cx,tmpdir:()=>Hx,unlink:()=>Ax,writeFile:()=>Sx});var rt,vx,$x,xx,kx,Sx,Ex,jx,_x,Rx,Ax,Tx,Cx,Ix,Ox,Lx,Nx,Mx,Px,Fx,Dx,zx,Bx,Ux,Wx,qx,Gx,Vx,Hx,Kx,Tf=L(()=>{rt=e=>()=>{throw new Error(e+" unavailable in the browser ask bundle")},vx=rt("createRequire"),$x=rt("readFileSync"),xx=rt("access"),kx=rt("readFile"),Sx=rt("writeFile"),Ex=rt("appendFile"),jx=rt("mkdir"),_x=rt("mkdtemp"),Rx=rt("rename"),Ax=rt("unlink"),Tx=rt("rm"),Cx=rt("stat"),Ix=rt("copyFile"),Ox=rt("readdir"),Lx=rt("createReadStream"),Nx=rt("createWriteStream"),Mx=()=>!1,Px=(...e)=>e.join("/"),Fx=e=>String(e).replace(/\/[^/]*$/,""),Dx=(...e)=>e.join("/"),zx=e=>String(e).startsWith("/"),Bx=e=>String(e).split("/").pop(),Ux="/",Wx=e=>String(e),qx=rt("randomBytes"),Gx=rt("spawnSync"),Vx=rt("createInterface"),Hx=()=>"/tmp",Kx={}});var Yx,lr,Nc=L(()=>{Yx=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i,lr=class e extends Date{#t=!1;#n=!1;#e=null;constructor(t){let n=!0,s=!0,o="Z";if(typeof t=="string"){let r=t.match(Yx);r?(r[1]||(n=!1,t=`0000-01-01T${t}`),s=!!r[2],s&&t[10]===" "&&(t=t.replace(" ","T")),r[2]&&+r[2]>23?t="":(o=r[3]||null,t=t.toUpperCase(),!o&&s&&(t+="Z"))):t=""}super(t),isNaN(this.getTime())||(this.#t=n,this.#n=s,this.#e=o)}isDateTime(){return this.#t&&this.#n}isLocal(){return!this.#t||!this.#n||!this.#e}isDate(){return this.#t&&!this.#n}isTime(){return this.#n&&!this.#t}isValid(){return this.#t||this.#n}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#e===null)return t.slice(0,-1);if(this.#e==="Z")return t;let n=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return n=this.#e[0]==="-"?n:-n,new Date(this.getTime()-n*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(t,n="Z"){let s=new e(t);return s.#e=n,s}static wrapAsLocalDateTime(t){let n=new e(t);return n.#e=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#n=!1,n.#e=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#t=!1,n.#e=null,n}}});function Xx(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function Jx(e,t,n){let s=e.split(/\r\n|\n|\r/g),o="",r=(Math.log10(t+1)|0)+1;for(let i=t-1;i<=t+1;i++){let a=s[i-1];a&&(o+=i.toString().padEnd(r," "),o+=": ",o+=a,o+=`
85
+ `),tier:g,topup:b}}async function hc(e,{config:t,source:n,tel:s}){return(await sf(e,{config:t,source:n,tel:s})).text}var gc=L(()=>{vt();De();Lt();ii();Bo();Ce();os();li();ui();Ke();hc.ownsGraphLoad=!0});function of(e,{graph:t,svc:n}){let{match:s}=yt(n,ot(e,"symbol"),"symbol");return Id(so(t,s))}var rf=L(()=>{Ce();Ke()});function di(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function rr(e){return di(e).toString(16).padStart(8,"0")}function G$(e){let t=new TextEncoder().encode(String(e)),n=t.length*8,s=new Uint8Array((t.length+8>>6)+1<<6);s.set(t),s[t.length]=128;let o=new DataView(s.buffer);o.setUint32(s.length-8,Math.floor(n/4294967296)),o.setUint32(s.length-4,n>>>0);let r=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),i=new Uint32Array(64),a=(u,d)=>u>>>d|u<<32-d;for(let u=0;u<s.length;u+=64){for(let v=0;v<16;v+=1)i[v]=o.getUint32(u+v*4);for(let v=16;v<64;v+=1){let $=a(i[v-15],7)^a(i[v-15],18)^i[v-15]>>>3,k=a(i[v-2],17)^a(i[v-2],19)^i[v-2]>>>10;i[v]=i[v-16]+$+i[v-7]+k>>>0}let[d,m,p,f,g,h,b,w]=r;for(let v=0;v<64;v+=1){let $=a(g,6)^a(g,11)^a(g,25),k=g&h^~g&b,y=w+$+k+q$[v]+i[v]>>>0,j=a(d,2)^a(d,13)^a(d,22),E=d&m^d&p^m&p,_=j+E>>>0;w=b,b=h,h=g,g=f+y>>>0,f=p,p=m,m=d,d=y+_>>>0}r[0]=r[0]+d>>>0,r[1]=r[1]+m>>>0,r[2]=r[2]+p>>>0,r[3]=r[3]+f>>>0,r[4]=r[4]+g>>>0,r[5]=r[5]+h>>>0,r[6]=r[6]+b>>>0,r[7]=r[7]+w>>>0}let l=new Uint8Array(32),c=new DataView(l.buffer);for(let u=0;u<8;u+=1)c.setUint32(u*4,r[u]);return l}function V$(e,t){let n=G$(e),s="";for(let o=0;o<t;o+=1)s+=n[o].toString(16).padStart(2,"0");return s}function ee(e){let t=Fn(e);return t=t.replace(/^\/c\/[a-z]{2,3}\//i,""),t=t.replace(/^[a-z][\w.-]*:/i,""),t=t.replace(/_/g," ").replace(/\s+/g," ").trim(),t=t.replace(/^(?:the|an?)\s+/i,""),t.toLowerCase()}function Dn(e){let t=Fn(e);return K$.get(t)??t}function he(e,t,n){return ir(ee(e),Dn(t),ee(n))}var q$,H$,Fn,K$,ir,en=L(()=>{q$=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);H$=2e3,Fn=e=>String(e??"").replace(/\s+/g," ").trim().slice(0,H$);K$=new Map([["mgx:cause","mgx:causes"],["mgx:desire","mgx:desires"],["mgx:want","mgx:desires"],["mgx:require","mgx:hasPrerequisite"],["mgx:involve","mgx:hasSubevent"],["mgx:used-for","mgx:usedFor"],["mgx:made-of","mgx:madeOf"]]);ir=(e,t,n)=>`fact:${V$(`${e}\0${t}\0${n}`,8)}`});var tn={};En(tn,{CARDINALITY_RULE_CONFIDENCE:()=>tx,CAX_DW_RULE:()=>wc,CAX_DW_RULE_CONFIDENCE:()=>vc,CAX_MAXC0_RULE_CONFIDENCE:()=>sx,CLS_SVF1_RULE:()=>$c,CLS_SVF1_RULE_CONFIDENCE:()=>kc,DEFAULT_MAX_ENVIRONMENTS:()=>pi,DISJOINT_PREDICATE:()=>po,ENTAILED_DISJOINT_PROVENANCE:()=>yc,ENTAILED_PROVENANCE:()=>lf,ENTAILED_SCM_SVF_PROVENANCE:()=>jc,ENTAILED_SVF1_PROVENANCE:()=>xc,ENTAILED_TYPE_PROVENANCE:()=>df,ON_PROPERTY_PREDICATE:()=>yn,SCM_SVF_RULE:()=>Ec,SCM_SVF_RULE_CONFIDENCE:()=>_c,SOME_VALUES_FROM_PREDICATE:()=>vn,SUBCLASS_PREDICATE:()=>Fe,TYPE_PREDICATE:()=>At,buildCardinalityRestrictions:()=>ex,buildRelevanceFrontier:()=>bc,deriveDisjointViolations:()=>hf,deriveSomeValuesFromApplication:()=>gf,deriveSomeValuesFromSubsumption:()=>bf,deriveSubClassClosure:()=>pf,deriveSubClassClosureDelta:()=>ff,deriveTypePropagation:()=>mf,entailedTrustFrom:()=>X$,findConsistencyViolations:()=>rx,findIsaChain:()=>Rc,proveCardinalityAtLeast:()=>nx,proveMaxCardinalityZeroDenial:()=>ox,retractSubClassOf:()=>ux,syllogise:()=>ix});function af(e,t,n){for(let s of t)if(typeof e?.[s]!="function")throw new TypeError(`${n} needs a store option carrying { ${t.join(", ")} } (memory/core.mjs's read/write functions) \u2014 missing ${s}`);return e}function X$(e,t=1){let n=(Array.isArray(e)?e:[]).filter(o=>typeof o=="number");if(!n.length)return null;let s=Math.max(0,Math.min(1,Math.min(...n)*t));return Number(s.toFixed(6))}function zn(e){if(!e)return null;let t=e instanceof Set?[...e]:Array.isArray(e)?e:[],n=new Set;for(let s of t){let o=ee(s);o&&n.add(o)}return n.size?n:null}function pf(e,{depth:t=32,budget:n=50,focus:s=null}={}){let o=new Set,r=new Map;for(let[u,d]of e||[])!u||!d||u===d||(o.add(`${u}${Ie}${d}`),r.has(u)||r.set(u,new Set),r.get(u).add(d));let i=s instanceof Set?s.size?s:null:zn(s),a=(u,d,m)=>!i||i.has(u)||i.has(d)||i.has(m),l=[],c=new Set;for(let u=0;u<t;u+=1){let d=[];for(let[p,f]of r)for(let g of f){let h=r.get(g);if(h)for(let b of h){if(p===b)continue;let w=`${p}${Ie}${b}`;o.has(w)||c.has(w)||a(p,g,b)&&d.push([p,g,b,w])}}if(!d.length)break;d.sort((p,f)=>p[0].localeCompare(f[0])||p[2].localeCompare(f[2])||p[1].localeCompare(f[1]));let m=!1;for(let[p,f,g,h]of d)if(!c.has(h)){if(l.length>=n)break;c.add(h),l.push({subject:p,object:g,via:f}),r.has(p)||r.set(p,new Set),r.get(p).add(g),m=!0}if(l.length>=n||!m)break}return l}function ff(e,t,{depth:n=32,budget:s=50,focus:o=null}={}){let r=new Set,i=new Map,a=new Map;for(let[f,g]of e||[])!f||!g||f===g||(r.add(`${f}${Ie}${g}`),i.has(f)||i.set(f,new Set),i.get(f).add(g),a.has(g)||a.set(g,new Set),a.get(g).add(f));let l=[],c=new Set;for(let[f,g]of t||[]){if(!f||!g||f===g)continue;let h=`${f}${Ie}${g}`;c.has(h)||(c.add(h),l.push([f,g]))}let u=o instanceof Set?o.size?o:null:zn(o),d=(f,g,h)=>!u||u.has(f)||u.has(g)||u.has(h),m=[],p=new Set;for(let f=0;f<n&&l.length;f+=1){let g=[],h=(v,$,k)=>{if(v===k)return;let y=`${v}${Ie}${k}`;r.has(y)||p.has(y)||d(v,$,k)&&g.push([v,$,k,y])};for(let[v,$]of l){for(let k of i.get($)||[])h(v,$,k);for(let k of a.get(v)||[])h(k,v,$)}if(!g.length)break;g.sort((v,$)=>v[0].localeCompare($[0])||v[2].localeCompare($[2])||v[1].localeCompare($[1]));let b=!1,w=[];for(let[v,$,k,y]of g)if(!p.has(y)){if(m.length>=s)break;p.add(y),m.push({subject:v,object:k,via:$}),i.has(v)||i.set(v,new Set),i.get(v).add(k),a.has(k)||a.set(k,new Set),a.get(k).add(v),w.push([v,k]),b=!0}if(m.length>=s||!b)break;l=w}return m}function $n(e){let t=new Map;for(let[s,o]of e||[])!s||!o||s===o||(t.has(s)||t.set(s,new Set),t.get(s).add(o));let n=new Map;return s=>{if(n.has(s))return n.get(s);let o=new Set,r=[...t.get(s)||[]];for(;r.length;){let i=r.pop();if(!o.has(i)){o.add(i);for(let a of t.get(i)||[])o.has(a)||r.push(a)}}return n.set(s,o),o}}function J$(e){return $n((e||[]).map(([t,n])=>[n,t]))}function bc(e,t){let n=[],s=[],o=new Map,r=new Map;for(let c of e||[])!c||!c.subject||!c.predicate||!c.object||(is(c.predicate)?n.push([c.subject,c.object]):Is(c.predicate)?s.push([c.subject,c.object]):fo(c.predicate)?o.set(c.subject,c.object):cr(c.predicate)&&r.set(c.subject,c.object));let i=J$(n),a=new Set;for(let c of t||[]){let u=ee(c);if(u){a.add(u);for(let d of i(u))a.add(d)}}let l=new Set(a);for(let[c,u]of s)a.has(u)&&l.add(c);for(let[c,u]of r)o.has(c)&&a.has(u)&&l.add(c);return l}function mf(e,t,{budget:n=50,focus:s=null,presentTypeEdges:o=e}={}){let r=$n(t),i=new Set,a=new Set;for(let[p,f]of o||[])p&&f&&i.add(`${p}${Ie}${f}`);let l=s instanceof Set?s.size?s:null:zn(s),c=(p,f,g)=>!l||l.has(p)||l.has(f)||l.has(g),u=[];for(let[p,f]of e||[]){if(!p||!f)continue;let g=`${p}${Ie}${f}`;if(!a.has(g)){a.add(g);for(let h of r(f)){if(h===f||h===p)continue;let b=`${p}${Ie}${h}`;i.has(b)||c(p,f,h)&&u.push([p,f,h,b])}}}u.sort((p,f)=>p[0].localeCompare(f[0])||p[2].localeCompare(f[2])||p[1].localeCompare(f[1]));let d=[],m=new Set;for(let[p,f,g,h]of u)if(!m.has(h)){if(d.length>=n)break;m.add(h),d.push({subject:p,object:g,via:f})}return d}function hf(e,t,n,{budget:s=50,focus:o=null}={}){let r=$n(t),i=new Map,a=new Set;for(let[f,g]of n||[])!f||!g||f===g||(a.add(`${f}${Ie}${g}`),a.add(`${g}${Ie}${f}`),i.has(f)||i.set(f,new Set),i.get(f).add(g),i.has(g)||i.set(g,new Set),i.get(g).add(f));if(!i.size)return[];let l=new Set,c=o instanceof Set?o.size?o:null:zn(o),u=(f,g,h)=>!c||c.has(f)||c.has(g)||c.has(h),d=[];for(let[f,g]of e||[]){if(!f||!g)continue;let h=`${f}${Ie}${g}`;if(!l.has(h)){l.add(h);for(let b of[g,...r(g)]){let w=i.get(b);if(w)for(let v of w){if(v===f)continue;let $=`${f}${Ie}${v}`;a.has($)||u(f,g,v)&&d.push([f,g,b,v,$])}}}}d.sort((f,g)=>f[0].localeCompare(g[0])||f[3].localeCompare(g[3])||f[2].localeCompare(g[2])||f[1].localeCompare(g[1]));let m=[],p=new Set;for(let[f,g,h,b,w]of d)if(!p.has(w)){if(m.length>=s)break;p.add(w),m.push({subject:f,object:b,viaType:g,viaClass:h})}return m}function gf(e,t,n,s,{budget:o=50,focus:r=null}={}){let i=$n(n),a=new Map;for(let h of s||[]){if(!h||!h.restriction||!h.property||!h.target)continue;let b=`${h.property}${Ie}${h.target}`;a.has(b)||a.set(b,new Set),a.get(b).add(h.restriction)}if(!a.size)return[];let l=new Set,c=new Map;for(let[h,b]of t||[])!h||!b||(l.add(`${h}${Ie}${b}`),c.has(h)||c.set(h,new Set),c.get(h).add(b));let u=r instanceof Set?r.size?r:null:zn(r),d=(h,b,w)=>!u||u.has(h)||u.has(b)||u.has(w),m=new Set,p=[];for(let[h,b,w]of e||[]){if(!h||!b||!w)continue;let v=ee(b),$=`${h}${Ie}${v}${Ie}${w}`;if(m.has($))continue;m.add($);let k=c.get(w);if(k)for(let y of k)for(let j of[y,...i(y)]){let E=a.get(`${v}${Ie}${j}`);if(E)for(let _ of E){if(h===_)continue;let R=`${h}${Ie}${_}`;l.has(R)||d(h,w,_)&&p.push([h,b,v,w,y,j,_,R])}}}p.sort((h,b)=>h[0].localeCompare(b[0])||h[6].localeCompare(b[6])||h[1].localeCompare(b[1])||h[3].localeCompare(b[3]));let f=[],g=new Set;for(let[h,b,w,v,$,k,y,j]of p)if(!g.has(j)){if(f.length>=o)break;g.add(j),f.push({subject:h,object:y,viaProperty:b,viaPropertyKey:w,viaValue:v,viaType:$,viaTarget:k})}return f}function ex(e){let t=new Map,n=new Map,s=new Map;for(let r of e||[])if(!(!r||!r.subject||!r.predicate))if(fo(r.predicate))t.set(r.subject,r.object);else if(Y$(r.predicate))s.set(r.subject,r.object);else{let i=Z$[String(r.predicate).trim().toLowerCase()];if(!i)continue;let a=Number(r.object);Number.isFinite(a)&&n.set(r.subject,{kind:i,n:a})}let o=[];for(let[r,{kind:i,n:a}]of n){if(t.get(r)!==Q$)continue;let l=s.get(r);l&&o.push({restriction:r,kind:i,n:a,onClass:l})}return o.sort((r,i)=>r.restriction.localeCompare(i.restriction)),o}function bf(e,t,{budget:n=50,focus:s=null}={}){let o=$n(t),r=new Map;for(let m of e||[]){if(!m||!m.restriction||!m.property||!m.target)continue;let p=ee(m.property);r.has(p)||r.set(p,[]),r.get(p).push({restriction:m.restriction,target:m.target})}let i=new Set;for(let[m,p]of t||[])m&&p&&i.add(`${m}${Ie}${p}`);let a=s instanceof Set?s.size?s:null:zn(s),l=(m,p)=>!a||a.has(m)||a.has(p),c=[];for(let[,m]of r)if(!(m.length<2))for(let p of m)for(let f of m){if(p.restriction===f.restriction||p.target===f.target||!o(p.target).has(f.target))continue;let g=`${p.restriction}${Ie}${f.restriction}`;i.has(g)||l(p.restriction,f.restriction)&&c.push([p.restriction,f.restriction,p.target,f.target,g])}c.sort((m,p)=>m[0].localeCompare(p[0])||m[1].localeCompare(p[1]));let u=[],d=new Set;for(let[m,p,f,g,h]of c)if(!d.has(h)){if(u.length>=n)break;d.add(h),u.push({subject:m,object:p,viaY1:f,viaY2:g})}return u}function wf(e,t,n,s,{budget:o=20,focus:r=null}={}){if(!n)return null;let i=$n(e),a=r instanceof Set?r.size?r:null:zn(r),l=m=>!a||a.has(n)||a.has(m),c=new Map;for(let[m,p]of e||[])!m||!p||(c.has(m)||c.set(m,new Set),c.get(m).add(p));let u=new Map((t||[]).map(m=>[m.restriction,m])),d=0;for(let m of[n,...i(n)]){if(d>=o)break;if(d+=1,!!l(m))for(let p of c.get(m)||[]){let f=u.get(p);if(f&&s(f))return{viaClass:m,viaRestriction:p,record:f}}}return null}function nx(e,t,n,s,o,r={}){if(!s||!Number.isFinite(o))return null;let i=wf(e,t,n,a=>a.onClass===s&&(a.kind==="exactly"||a.kind==="min")&&a.n>=o,r);return i?{subject:n,object:s,m:o,n:i.record.n,kind:i.record.kind,viaClass:i.viaClass,viaRestriction:i.viaRestriction}:null}function ox(e,t,n,s,o={}){if(!s)return null;let r=wf(e,t,n,i=>i.onClass===s&&i.kind==="max"&&i.n===0,o);return r?{subject:n,object:s,viaClass:r.viaClass,viaRestriction:r.viaRestriction}:null}function rx(e,t,n,{budget:s=50,focus:o=null}={}){let r=$n(t),i=new Map;for(let[p,f]of n||[])!p||!f||p===f||(i.has(p)||i.set(p,new Set),i.get(p).add(f),i.has(f)||i.set(f,new Set),i.get(f).add(p));if(!i.size)return[];let a=new Map;for(let[p,f]of e||[])!p||!f||(a.has(p)||a.set(p,new Set),a.get(p).add(f));let l=o instanceof Set?o.size?o:null:zn(o),c=p=>!l||l.has(p),u=[],d=new Set;for(let[p,f]of a){if(!c(p))continue;let g=[...f].sort();for(let h=0;h<g.length;h+=1)for(let b=h+1;b<g.length;b+=1){let[w,v]=[g[h],g[b]],$=[w,...r(w)],k=[v,...r(v)],y=null;for(let E of $){let _=i.get(E);if(_){for(let R of k)if(_.has(R)){y=[E,R];break}if(y)break}}if(!y)continue;let j=`${p}${Ie}${w}${Ie}${v}`;d.has(j)||(d.add(j),u.push([p,w,v,y[0],y[1]]))}}u.sort((p,f)=>p[0].localeCompare(f[0])||p[1].localeCompare(f[1])||p[2].localeCompare(f[2]));let m=[];for(let[p,f,g,h,b]of u){if(m.length>=s)break;m.push({subject:p,classA:f,classB:g,viaA:h,viaB:b})}return m}async function ix(e,{depth:t=32,budget:n=50,focus:s=null,expandFocus:o=!1,maxEnvironments:r=pi,full:i=!1,store:a}={}){let{loadMemory:l,readFactRows:c,appendFacts:u}=af(a,["loadMemory","readFactRows","appendFacts"],"syllogise"),d=typeof a?.loadSyllogiseState=="function"&&typeof a?.saveSyllogiseState=="function",m=await l(e),p=c(m),f=p.filter(x=>is(x.predicate)).map(x=>[x.subject,x.object]),g=p.filter(x=>Is(x.predicate)).map(x=>[x.subject,x.object]),h=p.filter(x=>Cs(x.predicate)).map(x=>[x.subject,x.object]),b=new Map,w=new Map,v=[];for(let x of p){let ue=String(x.predicate||"").trim().toLowerCase();fo(x.predicate)?b.set(x.subject,x.object):cr(x.predicate)?w.set(x.subject,x.object):Sc.has(ue)||v.push([x.subject,x.predicate,x.object])}let $=[];for(let[x,ue]of b){let Re=w.get(x);Re&&$.push({restriction:x,property:ue,target:Re})}let k=zn(s),y=o&&k?bc(p,[...k]):k,j=y===null&&d?await a.loadSyllogiseState(e):null,E=new Set(p.map(x=>x.id)),_=Array.isArray(j?.factIds)?j.factIds.filter(x=>!E.has(x)):[],R=j&&Array.isArray(j.factIds)&&!_.length&&!i?"delta":"full",S=R==="delta"?new Set(j.factIds):null,A=R==="delta"?p.filter(x=>!S.has(x.id)):p,M=A.length,T=new Map;for(let x of p)T.set(`${x.subject}${Ie}${x.predicate}${Ie}${x.object}`,x.trust);let P=(x,ue,Re)=>T.get(`${x}${Ie}${ue}${Ie}${Re}`),G=(x,ue,Re)=>T.has(`${x}${Ie}${ue}${Ie}${Re}`),K=x=>x.filter(ue=>typeof ue=="number"),te=R==="delta"&&!A.length,F=R==="delta"?A.filter(x=>is(x.predicate)).map(x=>[x.subject,x.object]):[],D=R==="delta"?F.length?ff(f,F,{depth:t,budget:n,focus:y}):[]:pf(f,{depth:t,budget:n,focus:y}),B=f.concat(D.map(x=>[x.subject,x.object])),W=y,C=null;if(R==="delta"&&!te){let x=p.concat(D.map(Re=>({subject:Re.subject,predicate:Fe,object:Re.object}))),ue=[];for(let Re of A)ue.push(Re.subject,Re.object);C=bc(x,ue),W=C}let I=x=>!C||C.has(x),O=C?g.filter(([x,ue])=>I(x)||I(ue)):g,N=new Set;if(C)for(let x of A)Cs(x.predicate)&&(N.add(x.subject),N.add(x.object));let q=C&&N.size?$n(B):null,U=C?g.filter(([x,ue])=>I(x)||I(ue)||q&&[...q(ue)].some(Re=>N.has(Re))):g,ie=new Set;if(C){for(let x of A)if(fo(x.predicate)||cr(x.predicate)){let ue=b.get(x.subject);ue&&ie.add(ee(ue))}}let se=C?v.filter(([x,ue,Re])=>I(x)||I(Re)||ie.has(ee(ue))):v,X=Math.max(0,n-D.length),J=X>0&&!te?mf(O,B,{budget:X,focus:W,presentTypeEdges:g}):[],oe=Math.max(0,n-D.length-J.length),H=oe>0&&!te?hf(U,B,h,{budget:oe,focus:W}):[],le=Math.max(0,n-D.length-J.length-H.length),ne=le>0&&$.length&&!te?gf(se,g,B,$,{budget:le,focus:W}):[],_e=Math.max(0,n-D.length-J.length-H.length-ne.length),Le=_e>0&&$.length>1&&!te?bf($,B,{budget:_e,focus:W}):[],Q=new Map($.map(x=>[x.restriction,x])),xe=[...D.map(x=>({subject:x.subject,predicate:Fe,object:x.object,provenance:lf,justification:[[he(x.subject,Fe,x.via),he(x.via,Fe,x.object)]]})),...J.map(x=>({subject:x.subject,predicate:At,object:x.object,provenance:df,justification:[[he(x.subject,At,x.via),he(x.via,Fe,x.object)]]})),...H.map(x=>{let ue=G(x.viaClass,po,x.object),[Re,Sn]=ue?[x.viaClass,x.object]:[x.object,x.viaClass],Ys=K([P(x.subject,At,x.viaType),P(Re,po,Sn),...x.viaClass!==x.viaType?[P(x.viaType,Fe,x.viaClass)]:[]]);return{subject:x.subject,predicate:po,object:x.object,provenance:yc,justification:[[he(x.subject,At,x.viaType),he(Re,po,Sn),...x.viaClass!==x.viaType?[he(x.viaType,Fe,x.viaClass)]:[]]],...Ys.length?{premiseTrusts:Ys,ruleConfidence:vc}:{}}}),...ne.map(x=>{let ue=K([P(x.subject,x.viaProperty,x.viaValue),P(x.viaValue,At,x.viaType),P(x.object,yn,x.viaPropertyKey),P(x.object,vn,x.viaTarget),...x.viaType!==x.viaTarget?[P(x.viaType,Fe,x.viaTarget)]:[]]);return{subject:x.subject,predicate:At,object:x.object,provenance:xc,justification:[[he(x.subject,x.viaProperty,x.viaValue),he(x.viaValue,At,x.viaType),he(x.object,yn,x.viaPropertyKey),he(x.object,vn,x.viaTarget),...x.viaType!==x.viaTarget?[he(x.viaType,Fe,x.viaTarget)]:[]]],...ue.length?{premiseTrusts:ue,ruleConfidence:kc}:{}}}),...Le.map(x=>{let ue=Q.get(x.subject),Re=Q.get(x.object),Sn=K([ue&&P(x.subject,yn,ue.property),P(x.subject,vn,x.viaY1),Re&&P(x.object,yn,Re.property),P(x.object,vn,x.viaY2),P(x.viaY1,Fe,x.viaY2)]);return{subject:x.subject,predicate:Fe,object:x.object,provenance:jc,justification:[[...ue?[he(x.subject,yn,ue.property)]:[],he(x.subject,vn,x.viaY1),...Re?[he(x.object,yn,Re.property)]:[],he(x.object,vn,x.viaY2),he(x.viaY1,Fe,x.viaY2)]],...Sn.length?{premiseTrusts:Sn,ruleConfidence:_c}:{}}})],ge=xe.map(x=>({id:he(x.subject,x.predicate,x.object),subject:x.subject,predicate:x.predicate,object:x.object,environments:x.justification,write:x})),ve=vf(p.concat(ge.map(x=>({id:x.id,subject:x.subject,predicate:x.predicate,object:x.object})))),V=new Map(p.map(x=>[x.id,x])),re=x=>is(x)||Is(x)||Cs(x),fe=x=>R!=="delta"||C!==null&&(C.has(x.subject)||C.has(x.object)),ce=p.filter(x=>re(x.predicate)&&yf(x.provenance)&&ar(x).length<r&&fe(x)).map(x=>({id:x.id,subject:x.subject,predicate:x.predicate,object:x.object,environments:ar(x),provenance:x.provenance})),wt=[...ge,...ce].sort((x,ue)=>x.subject.localeCompare(ue.subject)||x.predicate.localeCompare(ue.predicate)||x.object.localeCompare(ue.object)),Bt=0,Qe=!1,dn=0;for(let x of wt){if(dn>=n){Qe=!0;break}dn+=1;let ue=ve(x,{maxEnvironments:r+1}),{kept:Re,truncated:Sn}=cx(x.environments,ue,r);if(Sn&&(Qe=!0),!(Re.length<=x.environments.length)){if(Bt+=Re.length-x.environments.length,x.write){x.write.justification=Re;continue}xe.push({subject:x.subject,predicate:x.predicate,object:x.object,justification:Re,...$f(x.provenance,Re,Ys=>V.get(Ys)?.trust)||{}})}}let{ids:Kt}=await u(e,xe),Ut=[],It=0;for(let x of D)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.via,rule:cf}),It+=1;for(let x of J)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.via,rule:uf}),It+=1;for(let x of H)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.viaClass,rule:wc}),It+=1;for(let x of ne)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.viaValue,rule:$c}),It+=1;for(let x of Le)Ut.push({id:Kt[It],subject:x.subject,object:x.object,via:x.viaY1,rule:Ec}),It+=1;let Tr=Ut.length>=n;if(y===null&&d&&!Tr){let x=new Set(E);for(let ue of Kt)x.add(ue);await a.saveSyllogiseState(e,{version:1,factIds:[...x].sort(),completedAt:new Date().toISOString()})}return{derived:Ut,count:Ut.length,budget:n,depth:t,truncated:Tr,mode:R,deltaSize:M,environmentsAdded:Bt,alternatesTruncated:Qe}}function yf(e){let t=String(e||"").split(" | ").filter(Boolean);return t.length>0&&t.every(n=>n.startsWith("entailed:"))}function ax(e){let t=[],n=new Map,s=new Map,o=new Map,r=new Map,i=new Map;for(let u of e){let d=String(u.predicate||"").trim().toLowerCase();is(u.predicate)?t.push([u.subject,u.object]):Is(u.predicate)?(n.has(u.subject)||n.set(u.subject,new Set),n.get(u.subject).add(u.object)):Cs(u.predicate)?(s.has(u.subject)||s.set(u.subject,new Set),s.get(u.subject).add(u.object),s.has(u.object)||s.set(u.object,new Set),s.get(u.object).add(u.subject)):fo(u.predicate)?o.set(u.subject,u.object):cr(u.predicate)?r.set(u.subject,u.object):Sc.has(d)||(i.has(u.subject)||i.set(u.subject,[]),i.get(u.subject).push([ee(u.predicate),u.object]))}let a=$n(t),l=(u,d)=>u!==d&&a(u).has(d),c=u=>{let d=o.get(u),m=r.get(u);return d&&m?{property:ee(d),target:m}:null};return u=>{if(is(u.predicate)){if(l(u.subject,u.object))return!0;let d=c(u.subject),m=c(u.object);return!!(d&&m&&d.property===m.property&&l(d.target,m.target))}if(Is(u.predicate)){for(let m of n.get(u.subject)||[])if(l(m,u.object))return!0;let d=c(u.object);if(d){for(let[m,p]of i.get(u.subject)||[])if(m===d.property){for(let f of n.get(p)||[])if(f===d.target||l(f,d.target))return!0}}return!1}if(Cs(u.predicate)){for(let d of n.get(u.subject)||[])for(let m of[d,...a(d)])if(s.get(m)?.has(u.object))return!0;return!1}return!0}}function vf(e){let t=new Set,n=[],s=new Map,o=new Map,r=new Set,i=new Map,a=new Map,l=new Map,c=new Map;for(let p of e){if(!p||!p.subject||!p.predicate||!p.object)continue;p.id&&t.add(p.id);let f=String(p.predicate||"").trim().toLowerCase();is(p.predicate)?(n.push([p.subject,p.object]),s.has(p.subject)||s.set(p.subject,new Set),s.get(p.subject).add(p.object)):Is(p.predicate)?(o.has(p.subject)||o.set(p.subject,new Set),o.get(p.subject).add(p.object)):Cs(p.predicate)?(r.add(`${p.subject}${Ie}${p.object}`),i.has(p.subject)||i.set(p.subject,new Set),i.get(p.subject).add(p.object),i.has(p.object)||i.set(p.object,new Set),i.get(p.object).add(p.subject)):fo(p.predicate)?a.set(p.subject,p.object):cr(p.predicate)?l.set(p.subject,p.object):Sc.has(f)||(c.has(p.subject)||c.set(p.subject,[]),c.get(p.subject).push([p.predicate,p.object]))}let u=$n(n),d=p=>s.get(p)||new Set,m=p=>{let f=a.get(p),g=l.get(p);return f&&g?{property:f,propertyKey:ee(f),target:g}:null};return(p,{maxEnvironments:f=pi}={})=>{let g=[],h=new Set,b=w=>{if(g.length>=f||p.id&&w.includes(p.id)||!w.every($=>t.has($)))return;let v=[...w].sort().join(" ");h.has(v)||(h.add(v),g.push(w))};if(is(p.predicate)){for(let w of[...d(p.subject)].sort()){if(g.length>=f)break;w===p.subject||w===p.object||d(w).has(p.object)&&b([he(p.subject,Fe,w),he(w,Fe,p.object)])}if(g.length<f){let w=m(p.subject),v=m(p.object);w&&v&&w.propertyKey===v.propertyKey&&w.target!==v.target&&d(w.target).has(v.target)&&b([he(p.subject,yn,w.property),he(p.subject,vn,w.target),he(p.object,yn,v.property),he(p.object,vn,v.target),he(w.target,Fe,v.target)])}return g}if(Is(p.predicate)){for(let v of[...o.get(p.subject)||[]].sort()){if(g.length>=f)break;v!==p.object&&d(v).has(p.object)&&b([he(p.subject,At,v),he(v,Fe,p.object)])}let w=m(p.object);if(w){let v=[...c.get(p.subject)||[]].filter(([$])=>ee($)===w.propertyKey).sort(($,k)=>$[0].localeCompare(k[0])||$[1].localeCompare(k[1]));for(let[$,k]of v){if(g.length>=f)break;for(let y of[...o.get(k)||[]].sort()){if(g.length>=f)break;y!==w.target&&!d(y).has(w.target)||b([he(p.subject,$,k),he(k,At,y),he(p.object,yn,w.propertyKey),he(p.object,vn,w.target),...y!==w.target?[he(y,Fe,w.target)]:[]])}}}return g}if(Cs(p.predicate)){let w=[];for(let v of o.get(p.subject)||[])for(let $ of[v,...u(v)])(i.get($)||new Set).has(p.object)&&w.push([v,$]);w.sort((v,$)=>v[0].localeCompare($[0])||v[1].localeCompare($[1]));for(let[v,$]of w){if(g.length>=f)break;let k=r.has(`${$}${Ie}${p.object}`),[y,j]=k?[$,p.object]:[p.object,$];b([he(p.subject,At,v),he(y,po,j),...$!==v?[he(v,Fe,$)]:[]])}return g}return g}}function cx(e,t,n){let s=[],o=new Set,r=!1;for(let i of[...e||[],...t||[]]){if(!Array.isArray(i)||!i.length)continue;let a=[...i].sort().join(" ");if(!o.has(a)){if(s.length>=n){r=!0;continue}o.add(a),s.push(i)}}return{kept:s,truncated:r}}function $f(e,t,n){let s;for(let i of String(e||"").split(" | ")){let a=lx.get(i);if(a!==void 0){s=a;break}}if(s===void 0)return null;let o=null,r=-1;for(let i of t||[]){let a=i.map(c=>n(c)).filter(c=>typeof c=="number");if(a.length!==i.length)continue;let l=Math.min(...a);l>r&&(r=l,o=a)}return o?{premiseTrusts:o,ruleConfidence:s}:null}async function ux(e,t,n,{budget:s=50,depth:o=32,maxEnvironments:r=pi,store:i}={}){let{loadMemory:a,readFactRows:l,removeFacts:c}=af(i,["loadMemory","readFactRows","removeFacts"],"retractSubClassOf"),u=typeof i?.appendFacts=="function"?i.appendFacts:null,d=ee(t),m=ee(n),p=he(d,Fe,m),f=await a(e),g=l(f),h=new Map(g.map(R=>[R.id,R]));if(!h.has(p))return{retracted:[],count:0,budget:s,depth:o,truncated:!1,found:!1};let b=g.filter(R=>ar(R).length&&yf(R.provenance)),w=new Map;for(let R of b)for(let S of ar(R))for(let A of S)w.has(A)||w.set(A,new Set),w.get(A).add(R.id);let v=new Set([p]),$=[p],k=new Map,y=!1,j=0,E=[p];for(;j<o;j+=1){let R=new Set;for(let te of E)for(let F of w.get(te)||[])v.has(F)||R.add(F);let S=[...R].map(te=>h.get(te)).sort((te,F)=>te.subject.localeCompare(F.subject)||te.predicate.localeCompare(F.predicate)||te.object.localeCompare(F.object));if(!S.length)break;let A=g.filter(te=>!v.has(te.id)&&!R.has(te.id)),M=new Set(A.map(te=>te.id)),T=vf(A),P=ax(A),G=!1,K=!1;E=[];for(let te of S){if(v.size>=s){K=!0;break}let F=ar(te),D=F.filter(W=>W.every(C=>M.has(C)));if(D.length){D.length!==F.length&&k.set(te.id,D);continue}let B=T(te,{maxEnvironments:r});if(B.length){k.set(te.id,B);continue}P(te)||(v.add(te.id),$.push(te.id),E.push(te.id),G=!0)}if(K){y=!0;break}if(!G)break}!y&&j>=o&&(y=b.some(R=>!v.has(R.id)&&R.justification.some(S=>v.has(S))));let{removed:_}=await c(e,$);if(u){let R=[...k.entries()].filter(([S])=>!v.has(S)).sort((S,A)=>S[0].localeCompare(A[0])).map(([S,A])=>{let M=h.get(S);return{subject:M.subject,predicate:M.predicate,object:M.object,justification:A,...$f(M.provenance,A,T=>h.get(T)?.trust)||{}}});R.length&&await u(e,R)}return{retracted:_,count:_.length,budget:s,depth:o,truncated:y,found:!0}}function Rc(e,t,n,s,{maxHops:o=6}={}){let r=t instanceof Set?t:new Set(t||[]),i=new Map;for(let[c,u]of s||[])!c||!u||c===u||(i.has(c)||i.set(c,new Set),i.get(c).add(u));let a=[];for(let[c,u]of n||[])c===e&&u&&a.push({node:u,path:[{subject:c,predicate:At,object:u}]});for(let c of i.get(e)||[])a.push({node:c,path:[{subject:e,predicate:Fe,object:c}]});let l=new Set([e]);for(let c=1;c<=o&&a.length;c+=1){for(let{node:d,path:m}of a)if(r.has(d))return m;if(c===o)break;let u=[];for(let{node:d,path:m}of a)if(!l.has(d)){l.add(d);for(let p of i.get(d)||[])l.has(p)||u.push({node:p,path:[...m,{subject:d,predicate:Fe,object:p}]})}a=u}return null}var Fe,cf,lf,At,uf,df,po,wc,yc,vc,yn,vn,$c,xc,kc,pi,Ie,is,Is,Cs,fo,cr,Y$,Sc,Q$,Z$,Ec,jc,_c,tx,sx,ar,lx,Ft=L(()=>{en();Fe="rdfs:subClassOf",cf="subClassOf",lf=`entailed:${cf}`,At="rdf:type",uf="type",df=`entailed:${uf}`,po="owl:disjointWith",wc="disjointWith",yc=`entailed:${wc}`,vc=.95,yn="owl:onProperty",vn="owl:someValuesFrom",$c="someValuesFrom",xc=`entailed:${$c}`,kc=.95,pi=4,Ie="\u241F",is=e=>String(e||"").trim().toLowerCase()==="rdfs:subclassof",Is=e=>String(e||"").trim().toLowerCase()==="rdf:type",Cs=e=>String(e||"").trim().toLowerCase()==="owl:disjointwith",fo=e=>String(e||"").trim().toLowerCase()==="owl:onproperty",cr=e=>String(e||"").trim().toLowerCase()==="owl:somevaluesfrom",Y$=e=>String(e||"").trim().toLowerCase()==="owl:onclass",Sc=new Set(["rdfs:subclassof","rdf:type","owl:disjointwith","owl:onproperty","owl:somevaluesfrom","owl:intersectionof"]);Q$="has",Z$={"owl:cardinality":"exactly","owl:mincardinality":"min","owl:maxcardinality":"max"};Ec="someValuesFromSubsumption",jc=`entailed:${Ec}`,_c=.95;tx=.95;sx=.95;ar=e=>e.environments||(Array.isArray(e.justification)&&e.justification.length?[e.justification]:[]);lx=new Map([[yc,vc],[xc,kc],[jc,_c]])});function bo(e){let t=String(e||""),n=xf.get(t);return n||(t.startsWith(Ac)?mo+t.slice(Ac.length):t)}function kf(e){let t=String(e||""),n=dx.get(t);return n||(t.startsWith(mo)?Ac+t.slice(mo.length):null)}function jf(e,t,n,s,o){let r=null;for(let i of e){if(i===t)return[];let a=Rc(i,new Set([t]),n,s,{maxHops:o});a&&(!r||a.length<r.length)&&(r=a)}return r}function hi(e,t,n,{maxHops:s=3}={}){let o=go(e),r=go(t),i=Array.isArray(n)?n:[],{typeEdges:a,subClassEdges:l}=Ef(i),c=i.filter(b=>(b.predicate===mi||b.predicate===ho)&&r.has(b.object)),u=[];for(let b of c){let w=b.predicate===ho?"negative":"positive";if(o.has(b.subject)){u.push({fact:b,polarity:w,hops:0,chain:null});continue}let v=jf(o,b.subject,a,l,s);v&&v.length&&u.push({fact:b,polarity:w,hops:v.length,chain:v})}if(!u.length)return{verdict:"none",hops:0,positive:[],negative:[],chain:null,overrides:null,baseRate:Cc(o,r,i,{maxHops:s})};u.sort((b,w)=>b.hops-w.hops||(w.fact.trust||0)-(b.fact.trust||0));let d=u[0].hops,m=u.filter(b=>b.hops===d),p=m.filter(b=>b.polarity==="positive").map(b=>b.fact),f=m.filter(b=>b.polarity==="negative").map(b=>b.fact),g=f.length&&!p.length?"negative":"positive",h=u.find(b=>b.hops>d&&b.polarity!==g)||null;return{verdict:p.length&&f.length?"both":f.length?"no":"yes",hops:d,positive:p,negative:f,chain:u[0].chain,overrides:h?{fact:h.fact,chain:h.chain}:null,baseRate:null}}function Cc(e,t,n,{maxHops:s=3}={}){let o=go(e),r=go(t),i=Array.isArray(n)?n:[],a=i.filter(g=>g.predicate===Fe||g.predicate===At),l=a.filter(g=>o.has(g.subject)).map(g=>g.object);if(!l.length)return null;let c=l[0],u=[...new Set(a.filter(g=>g.object===c&&!o.has(g.subject)).map(g=>g.subject))],d=g=>{let h=i.find(b=>b.subject===g&&r.has(b.object)&&(b.predicate===mi||b.predicate===ho));return h?{name:g,polarity:h.predicate===ho?"negative":"positive",fact:h}:{name:g,polarity:"unknown",fact:null}},m=u.map(d),{typeEdges:p,subClassEdges:f}=Ef(i);return{klass:c,kinds:u.length,positive:m.filter(g=>g.polarity==="positive"),negative:m.filter(g=>g.polarity==="negative"),unknown:m.filter(g=>g.polarity==="unknown"),chain:jf(o,c,p,f,s)}}function Ic(e,t,{exclude:n=[],maxHops:s=3}={}){let o=go(e),r=go(n),i=Array.isArray(t)?t:[],a=new Set,l=[];for(let c of i)c.predicate!==mi||!o.has(c.object)||r.has(c.subject)||a.has(c.subject)||(a.add(c.subject),hi(new Set([c.subject]),o,i,{maxHops:s}).verdict==="yes"&&l.push(c));return l.sort(px)}var mo,Ac,fi,xf,dx,Sf,mi,ho,Tc,px,go,Ef,Oc=L(()=>{Ft();mo="mgxneg:",Ac="mgx:",fi="mgxneg:subClassOf",xf=new Map([[Fe,fi]]),dx=new Map([...xf].map(([e,t])=>[t,e]));Sf=e=>String(e||"").startsWith(mo),mi="mgx:capableOf",ho=bo(mi),Tc=6,px=(e,t)=>(t.trust||0)-(e.trust||0)||String(e.subject).localeCompare(String(t.subject)),go=e=>e instanceof Set?e:new Set(Array.isArray(e)?e:[e]),Ef=e=>({typeEdges:e.filter(t=>t.predicate===At).map(t=>[t.subject,t.object]),subClassEdges:e.filter(t=>t.predicate===Fe).map(t=>[t.subject,t.object])})});function wo(e,t){let n=(e?.attributes||[]).find(s=>s?.prop===t);return n?String(n.value??""):void 0}function gx(e,t){(!e?.class||!fx.has(e.class))&&t.push(`must have a class from the closed vocabulary Utterance | Fact | Session | Source | Rule (got ${JSON.stringify(e?.class)})`)}function bx(e,t){for(let s of["rdf:subject","rdf:predicate","rdf:object"])gi(wo(e,s))||t.push(`a Fact needs a non-empty ${s}`);for(let s of["rdf:subject","rdf:object"]){let o=wo(e,s);o!==void 0&&hx.test(o)&&t.push(`a Fact's ${s} must be a single term, not text spanning a sentence boundary (got ${JSON.stringify(o)})`)}let n=wo(e,"mgx:factProvenance");n!==void 0&&!gi(n)&&t.push("mgx:factProvenance, when present, must be non-empty")}function wx(e,t){gi(wo(e,"mgx:ruleName"))||t.push("a Rule needs a non-empty mgx:ruleName");let n=wo(e,"mgx:ruleKind");if(!n||!_f.has(n)){t.push(`a Rule's mgx:ruleKind must be one of ${[..._f].join(" | ")} (got ${JSON.stringify(n)})`);return}for(let s of mx[n])gi(wo(e,s))||t.push(`a ${n} Rule needs a non-empty ${s}`)}function yx(e){let t=[];return gx(e,t),e?.class==="Fact"&&bx(e,t),e?.class==="Rule"&&wx(e,t),{ok:t.length===0,violations:t}}function Lc(e){let t=yx(e);if(!t.ok){let n=new Error(`SHACL validation failed for ${e?.class} "${e?.id}": ${t.violations.join(" | ")}`);throw n.violations=t.violations,n}}var fx,_f,mx,hx,gi,Rf=L(()=>{fx=new Set(["Utterance","Fact","Session","Source","Rule"]),_f=new Set(["compose2","filter","recursive","action-signature","action-precond","action-effect","action-constraint"]),mx={compose2:["mgx:ruleBase1","mgx:ruleBase2"],filter:["mgx:ruleBase1","mgx:ruleFilterProperty"],recursive:["mgx:ruleBaseCase","mgx:ruleRecStep"],"action-signature":["mgx:ruleActionSubjectClass","mgx:ruleActionTargetClass"],"action-precond":["mgx:ruleActionPrecondShape","mgx:ruleActionPrecondPredicate","mgx:ruleActionPrecondRole","mgx:ruleActionPrecondScope"],"action-effect":["mgx:ruleActionEffectPredicate","mgx:ruleActionEffectSubject"],"action-constraint":["mgx:ruleActionConstraintLeft","mgx:ruleActionConstraintRight","mgx:ruleActionConstraintGuard"]},hx=/[.!?]\s+\w/;gi=e=>typeof e=="string"&&e.trim().length>0});var Af={};En(Af,{access:()=>xx,appendFile:()=>Ex,basename:()=>Bx,copyFile:()=>Ix,createInterface:()=>Vx,createReadStream:()=>Lx,createRequire:()=>vx,createWriteStream:()=>Nx,default:()=>Kx,dirname:()=>Fx,existsSync:()=>Mx,fileURLToPath:()=>Wx,isAbsolute:()=>zx,join:()=>Px,mkdir:()=>jx,mkdtemp:()=>_x,randomBytes:()=>qx,readFile:()=>kx,readFileSync:()=>$x,readdir:()=>Ox,rename:()=>Rx,resolve:()=>Dx,rm:()=>Tx,sep:()=>Ux,spawnSync:()=>Gx,stat:()=>Cx,tmpdir:()=>Hx,unlink:()=>Ax,writeFile:()=>Sx});var rt,vx,$x,xx,kx,Sx,Ex,jx,_x,Rx,Ax,Tx,Cx,Ix,Ox,Lx,Nx,Mx,Px,Fx,Dx,zx,Bx,Ux,Wx,qx,Gx,Vx,Hx,Kx,Tf=L(()=>{rt=e=>()=>{throw new Error(e+" unavailable in the browser ask bundle")},vx=rt("createRequire"),$x=rt("readFileSync"),xx=rt("access"),kx=rt("readFile"),Sx=rt("writeFile"),Ex=rt("appendFile"),jx=rt("mkdir"),_x=rt("mkdtemp"),Rx=rt("rename"),Ax=rt("unlink"),Tx=rt("rm"),Cx=rt("stat"),Ix=rt("copyFile"),Ox=rt("readdir"),Lx=rt("createReadStream"),Nx=rt("createWriteStream"),Mx=()=>!1,Px=(...e)=>e.join("/"),Fx=e=>String(e).replace(/\/[^/]*$/,""),Dx=(...e)=>e.join("/"),zx=e=>String(e).startsWith("/"),Bx=e=>String(e).split("/").pop(),Ux="/",Wx=e=>String(e),qx=rt("randomBytes"),Gx=rt("spawnSync"),Vx=rt("createInterface"),Hx=()=>"/tmp",Kx={}});var Yx,lr,Nc=L(()=>{Yx=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i,lr=class e extends Date{#t=!1;#n=!1;#e=null;constructor(t){let n=!0,s=!0,o="Z";if(typeof t=="string"){let r=t.match(Yx);r?(r[1]||(n=!1,t=`0000-01-01T${t}`),s=!!r[2],s&&t[10]===" "&&(t=t.replace(" ","T")),r[2]&&+r[2]>23?t="":(o=r[3]||null,t=t.toUpperCase(),!o&&s&&(t+="Z"))):t=""}super(t),isNaN(this.getTime())||(this.#t=n,this.#n=s,this.#e=o)}isDateTime(){return this.#t&&this.#n}isLocal(){return!this.#t||!this.#n||!this.#e}isDate(){return this.#t&&!this.#n}isTime(){return this.#n&&!this.#t}isValid(){return this.#t||this.#n}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#e===null)return t.slice(0,-1);if(this.#e==="Z")return t;let n=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return n=this.#e[0]==="-"?n:-n,new Date(this.getTime()-n*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(t,n="Z"){let s=new e(t);return s.#e=n,s}static wrapAsLocalDateTime(t){let n=new e(t);return n.#e=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#n=!1,n.#e=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#t=!1,n.#e=null,n}}});function Xx(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function Jx(e,t,n){let s=e.split(/\r\n|\n|\r/g),o="",r=(Math.log10(t+1)|0)+1;for(let i=t-1;i<=t+1;i++){let a=s[i-1];a&&(o+=i.toString().padEnd(r," "),o+=": ",o+=a,o+=`
86
86
  `,i===t&&(o+=" ".repeat(r+n+2),o+=`^
87
87
  `))}return o}var pe,Os=L(()=>{pe=class extends Error{line;column;codeblock;constructor(t,n){let[s,o]=Xx(n.toml,n.ptr),r=Jx(n.toml,s,o);super(`Invalid TOML document: ${t}
88
88
 
@@ -145,30 +145,30 @@ ${[...i.negative,...i.positive].map(ae).join(`
145
145
  ${d.join(`
146
146
  `)}`,replace:!0,miss:!0}}let c=Ic(r,n,{exclude:new Set([...o,i.klass])});if(c.length){let u=c.slice(0,Tc),d=c.slice(u.length);return{text:`${l} ${a}, and nothing I know about ${i.klass} says whether one can ${t}. I do know ${c.length} thing${c.length===1?"":"s"} that can ${t}${d.length?` (first ${u.length} shown)`:""}:
147
147
  ${u.map(ae).join(`
148
- `)}`,replace:!0,miss:!0,...d.length?{pending:{items:d.map(ae),noun:"facts"}}:{}}}return{text:`${l} ${a}, but nothing I remember says whether any kind of ${i.klass} can ${t}.`,replace:!0,miss:!0}}function bj(e){let t=String(e||"").toLowerCase().trim().replace(/\s+/g," ");if(t==="best")return"better";if(t==="worst")return"worse";let n=t.match(/^(most|least)\s+([a-z][\w-]*)$/);return n?`${n[1]==="most"?"more":"less"} ${n[2]}`:/[a-z]est$/.test(t)&&t.length>4?`${t.slice(0,-3)}er`:null}function ln(e){let t=new Set,n=[];for(let s of e){let o=`${s.subject}|${s.predicate}|${s.object}`;t.has(o)||(t.add(o),n.push(s))}return n}async function Gg(e,t,n,s,o={},r=null,i=null){return Vg(await kj(e,t,n,s,o,r,i),n,t)}function Vg(e,t,n){if(!e||e.goal!==void 0)return e;let s=String(n||"").trim(),o=Hl(t?.parsed);if(!o&&e.generalVerbQuery&&(o=ug),!o){let r=s.match(Kl),i=r?null:Zi(s).match(Ug)||Wg(s),a=r?r[2]:i?i[1]:null;a&&!Xl.has(a.toLowerCase())&&(o=ug)}if(!o){let r=s.match(Kg);r&&(o=Hl({shape:"meta",object:r[1]}))}return o?{...e,goal:o}:e}async function kj(e,t,n,s,o={},r=null,i=null){let a,l;try{({normFactTerm:a,normFactPredicate:l}=await Promise.resolve().then(()=>(Ge(),ls)))}catch{return null}let c=String(t).trim(),u=c.match(aj);if(u){let F=Y(a,u[1]),D=(await mt(e,r)).filter(B=>B.predicate==="mgx:usedFor"&&F.has(B.object));if(D.length){let W=Ye(ln(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
148
+ `)}`,replace:!0,miss:!0,...d.length?{pending:{items:d.map(ae),noun:"facts"}}:{}}}return{text:`${l} ${a}, but nothing I remember says whether any kind of ${i.klass} can ${t}.`,replace:!0,miss:!0}}function bj(e){let t=String(e||"").toLowerCase().trim().replace(/\s+/g," ");if(t==="best")return"better";if(t==="worst")return"worse";let n=t.match(/^(most|least)\s+([a-z][\w-]*)$/);return n?`${n[1]==="most"?"more":"less"} ${n[2]}`:/[a-z]est$/.test(t)&&t.length>4?`${t.slice(0,-3)}er`:null}function un(e){let t=new Set,n=[];for(let s of e){let o=`${s.subject}|${s.predicate}|${s.object}`;t.has(o)||(t.add(o),n.push(s))}return n}async function Gg(e,t,n,s,o={},r=null,i=null){return Vg(await kj(e,t,n,s,o,r,i),n,t)}function Vg(e,t,n){if(!e||e.goal!==void 0)return e;let s=String(n||"").trim(),o=Hl(t?.parsed);if(!o&&e.generalVerbQuery&&(o=ug),!o){let r=s.match(Kl),i=r?null:Zi(s).match(Ug)||Wg(s),a=r?r[2]:i?i[1]:null;a&&!Xl.has(a.toLowerCase())&&(o=ug)}if(!o){let r=s.match(Kg);r&&(o=Hl({shape:"meta",object:r[1]}))}return o?{...e,goal:o}:e}async function kj(e,t,n,s,o={},r=null,i=null){let a,l;try{({normFactTerm:a,normFactPredicate:l}=await Promise.resolve().then(()=>(Ge(),ls)))}catch{return null}let c=String(t).trim(),u=c.match(aj);if(u){let F=Y(a,u[1]),D=(await mt(e,r)).filter(B=>B.predicate==="mgx:usedFor"&&F.has(B.object));if(D.length){let W=Ye(un(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
149
149
  \u2026and ${I.length} more \u2014 say 'more' to see them.`:"";return{text:C.join(`
150
- `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}}for(let{predicate:F,re:D}of yj){let B=c.match(D);if(!B)continue;let W=Y(a,B[1]),C=(await mt(e,r)).filter(ie=>ie.predicate===F&&W.has(ie.object));if(!C.length)continue;let O=Ye(ln(C),o).map(ae),N=O.slice(0,je),q=O.slice(je),U=q.length?`
150
+ `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}}for(let{predicate:F,re:D}of yj){let B=c.match(D);if(!B)continue;let W=Y(a,B[1]),C=(await mt(e,r)).filter(ie=>ie.predicate===F&&W.has(ie.object));if(!C.length)continue;let O=Ye(un(C),o).map(ae),N=O.slice(0,je),q=O.slice(je),U=q.length?`
151
151
  \u2026and ${q.length} more \u2014 say 'more' to see them.`:"";return{text:N.join(`
152
- `)+U,replace:!0,...q.length?{pending:{items:q,noun:"facts"}}:{}}}let d=c.match(hj),m=d?null:c.match(gj),p=d?d[1]:m?.[2],f=d?d[2]:m?.[1],g=p&&f?bj(f):null;if(g){let F=`mgx:${g.replace(/\s+/g,"-")}-than`,D=await mt(e,r),B=Y(a,p),W=[...B].sort((O,N)=>O.length-N.length)[0],C=O=>B.has(O)||O.startsWith(`${W}-`)||O.startsWith(`${W} `)||D.some(N=>Gn.has(N.predicate)&&N.subject===O&&B.has(N.object)),I=ln(D.filter(O=>O.predicate===F&&Gs(O))).filter(O=>O.subject!==O.object&&C(O.subject)&&C(O.object));if(I.length){let O=new Set,N=new Map;for(let X of I)O.add(X.subject),O.add(X.object),N.set(X.object,(N.get(X.object)||0)+1),N.has(X.subject)||N.set(X.subject,N.get(X.subject)||0);let q=new Map(N),U=[],ie=null;for(;q.size;){let X=[...q.keys()].filter(oe=>q.get(oe)===0);if(X.length!==1){ie=X.length===0?{text:`I can't order the ${W}s \u2014 the "${g} than" facts I have loop back on themselves, so no ${f} exists. /memory to inspect them.`,replace:!0,miss:!0}:{text:`I can't pick the ${f} ${W} from what I know \u2014 nothing compares ${X[0]} and ${X[1]}. Teach me, e.g. "${X[0]} is ${g} than ${X[1]}".`,replace:!0,miss:!0};break}let J=X[0];U.push(J),q.delete(J);for(let oe of I)oe.subject===J&&q.has(oe.object)&&q.set(oe.object,q.get(oe.object)-1)}if(ie)return ie;let se=U.slice(0,-1).map((X,J)=>I.find(oe=>oe.subject===X&&oe.object===U[J+1]));if(se.every(Boolean)){let X=se.map(J=>`${Ct(J)}${J.provenance?` (source: ${J.provenance})`:""}`).join("; ");return{text:`${U[0]} \u2014 ${X}; so ${U[0]} is the ${f} ${W}`,replace:!0}}}}let h=s?c.match(cj):null;if(h){let F=Y(a,h[1]),D=(await mt(e,r)).filter(B=>yg.test(B.predicate)&&F.has(B.subject));if(D.length){let W=Ye(ln(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
152
+ `)+U,replace:!0,...q.length?{pending:{items:q,noun:"facts"}}:{}}}let d=c.match(hj),m=d?null:c.match(gj),p=d?d[1]:m?.[2],f=d?d[2]:m?.[1],g=p&&f?bj(f):null;if(g){let F=`mgx:${g.replace(/\s+/g,"-")}-than`,D=await mt(e,r),B=Y(a,p),W=[...B].sort((O,N)=>O.length-N.length)[0],C=O=>B.has(O)||O.startsWith(`${W}-`)||O.startsWith(`${W} `)||D.some(N=>Gn.has(N.predicate)&&N.subject===O&&B.has(N.object)),I=un(D.filter(O=>O.predicate===F&&Gs(O))).filter(O=>O.subject!==O.object&&C(O.subject)&&C(O.object));if(I.length){let O=new Set,N=new Map;for(let X of I)O.add(X.subject),O.add(X.object),N.set(X.object,(N.get(X.object)||0)+1),N.has(X.subject)||N.set(X.subject,N.get(X.subject)||0);let q=new Map(N),U=[],ie=null;for(;q.size;){let X=[...q.keys()].filter(oe=>q.get(oe)===0);if(X.length!==1){ie=X.length===0?{text:`I can't order the ${W}s \u2014 the "${g} than" facts I have loop back on themselves, so no ${f} exists. /memory to inspect them.`,replace:!0,miss:!0}:{text:`I can't pick the ${f} ${W} from what I know \u2014 nothing compares ${X[0]} and ${X[1]}. Teach me, e.g. "${X[0]} is ${g} than ${X[1]}".`,replace:!0,miss:!0};break}let J=X[0];U.push(J),q.delete(J);for(let oe of I)oe.subject===J&&q.has(oe.object)&&q.set(oe.object,q.get(oe.object)-1)}if(ie)return ie;let se=U.slice(0,-1).map((X,J)=>I.find(oe=>oe.subject===X&&oe.object===U[J+1]));if(se.every(Boolean)){let X=se.map(J=>`${Ct(J)}${J.provenance?` (source: ${J.provenance})`:""}`).join("; ");return{text:`${U[0]} \u2014 ${X}; so ${U[0]} is the ${f} ${W}`,replace:!0}}}}let h=s?c.match(cj):null;if(h){let F=Y(a,h[1]),D=(await mt(e,r)).filter(B=>yg.test(B.predicate)&&F.has(B.subject));if(D.length){let W=Ye(un(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
153
153
  \u2026and ${I.length} more \u2014 say 'more' to see them.`:"";return{text:C.join(`
154
- `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}}let b=c.match(lj);if(b){let F=b[1].toLowerCase(),D=Y(a,b[2].replace(/^(?:an?|the)\s+/i,"").trim()),B=(await mt(e,r)).filter(W=>yg.test(W.predicate)&&W.predicate.endsWith(`-${F}`)&&D.has(W.object));if(B.length){let C=Ye(ln(B),o).map(ae),I=C.slice(0,je),O=C.slice(je),N=O.length?`
154
+ `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}}let b=c.match(lj);if(b){let F=b[1].toLowerCase(),D=Y(a,b[2].replace(/^(?:an?|the)\s+/i,"").trim()),B=(await mt(e,r)).filter(W=>yg.test(W.predicate)&&W.predicate.endsWith(`-${F}`)&&D.has(W.object));if(B.length){let C=Ye(un(B),o).map(ae),I=C.slice(0,je),O=C.slice(je),N=O.length?`
155
155
  \u2026and ${O.length} more \u2014 say 'more' to see them.`:"";return{text:I.join(`
156
156
  `)+N,replace:!0,...O.length?{pending:{items:O,noun:"facts"}}:{}}}}let w=n?.parsed?.shape==="meta"?n.parsed.object:null,v=n?.parsed&&n.parsed.node!=="miss";if(!w&&s&&!v&&!Sg.test(c)){let F=c.match(Kg)||c.match(/^what\s+(?:does|do)\s+(.+?)\s+means?[?.!\s]*$/i);F&&(w=gs(F[1]))}if(!w&&n?.ambiguous&&Array.isArray(n.candidateParses)){let F=n.candidateParses.find(D=>D?.shape==="meta"&&D.object);F&&(w=gs(String(F.object)))}if(w){let F=BE(w),{predicate:D}=F,B=F.subject.replace(/^(?:the|an?)\s+/i,"").trim()||F.subject,W=!1;if(D&&qn.test(B)){if(!i){let oe=String(Vs[D]||"").replace(/^(?:is|are)\s+/,"");return{text:`not sure what "${B.toLowerCase()}" refers to yet \u2014 name the subject directly, e.g. "what is a <name>${oe?` ${oe}`:""}".`,replace:s,miss:!0,selfContainedMiss:!0}}B=i,W=!0}let C=Y(a,B),I=(await mt(e,r)).filter(oe=>C.has(oe.subject)&&!mg.has(oe.predicate)),O=D?I.filter(oe=>l(oe.predicate)===D):I;if(!O.length){if(D&&(I.length||W))return{text:`I don't have any "${Vs[D]}" facts about ${B}.`,replace:s,...I.length?{}:{miss:!0}};if(!D){let oe=Ye((await mt(e,r)).filter(H=>C.has(H.object)),o);if(oe.length){let H=oe.map(ae),le=H.slice(0,je),ne=H.slice(je),_e=ne.length?`
157
157
  \u2026and ${ne.length} more \u2014 say 'more' to see them.`:"";return{text:le.join(`
158
158
  `)+_e,replace:s,...ne.length?{pending:{items:ne,noun:"facts"}}:{}}}}return null}O=Ye(O,o);let N=await mt(e,r),{lines:q,grouped:U}=gg(O,N,C),ie=!D&&q.length>WE?await qE(B,O,N,q):null;if(ie)return{...ie,replace:s};if(U)return{...U,replace:s};let se=q.slice(0,je),X=q.slice(je),J=X.length?`
159
159
  \u2026and ${X.length} more \u2014 say 'more' to see them.`:"";return{text:se.join(`
160
- `)+J,replace:s,...X.length?{pending:{items:X,noun:"facts"}}:{}}}if(!s)return null;let $=c.match(_E);if($){let D=`mgx:${$[2].toLowerCase().replace(/\s+/g,"-")}-than`,B=await Gl(e),W=se=>{let X=se.replace(/^(?:an?|the)\s+/i,"").trim();return i&&qn.test(X)?i:X},C=W($[1]),I=W($[3]),O=Y(a,C),N=Y(a,I),q=B.find(se=>se.predicate===D&&O.has(se.subject)&&N.has(se.object));if(q){let se=B.find(J=>J.predicate===D&&O.has(J.object)&&N.has(J.subject)),X=se?` \u2014 though you also told me the opposite: ${ae(se)}. Both are stored; I won't silently pick one.`:"";return{text:`yes \u2014 ${ae(q)}${X}`,replace:!0}}let U=B.filter(se=>se.predicate===D&&(O.has(se.subject)||O.has(se.object)));return{text:`I can't confirm that \u2014 nothing I remember compares them that way.${U.length?` I do know: ${U.slice(0,3).map(ae).join("; ")}.`:""} If it's true, teach me: "${C} is ${$[2].toLowerCase()} than ${I}".`,replace:!0,miss:!0}}for(let{predicate:F,phrase:D,re:B}of $j){let W=c.match(B);if(!W)continue;let C=await Gl(e),I=Y(a,W[1]),O=Y(a,W[2]),N=C.find(U=>U.predicate===F&&I.has(U.subject)&&O.has(U.object));if(N)return{text:`yes \u2014 ${ae(N)}`,replace:!0};let q=C.filter(U=>U.predicate===F&&I.has(U.subject));if(q.length){let U=q.slice(0,3).map(ae).join("; ");return{text:`I can't confirm that \u2014 nothing I remember says ${W[1]} ${D} ${W[2]}. I do know: ${U}.`,replace:!0,miss:!0}}if(!n?.parsed&&C.some(U=>I.has(U.subject)))return{text:`I can't confirm that \u2014 nothing I remember says ${W[1]} ${D} ${W[2]}.`,replace:!0,miss:!0};break}let k=c.match(ps)||Yl(c);if(k){let F=Y(a,k[1]),D=Y(a,k[2]),B=await mt(e,r),W=N=>F.has(N.subject)&&D.has(N.object),{DISJOINT_PREDICATE:C}=await Promise.resolve().then(()=>(Ft(),tn)),I=N=>F.has(N.subject)||F.has(N.object)||D.has(N.subject)||D.has(N.object);return B.some(N=>N.predicate===C&&Gs(N)&&I(N))?null:zg(B.find(N=>Gn.has(N.predicate)&&W(N)),B.find(N=>N.predicate===fi&&W(N)))}let y=Jl(c),j=y.match(sj);if(j){let F=await mt(e,r),D=j[1],B=xg(j[2],j[3],F);if(B&&y!==$g(c)&&(B=vg(B)),B&&D)return{text:`I can't speak for ${D.trim()} ${j[2]} \u2014 what I remember is generic, not universal. ${B.text}.`,replace:!0};if(B)return B;let W=Y(a,j[2]),C=F.filter(I=>I.predicate==="mgx:capableOf"&&W.has(I.subject));if(C.length){let I=C.slice(0,3).map(ae).join("; ");return{text:`I can't confirm that \u2014 nothing I remember says ${j[2]} can ${j[3]}. I do know: ${I}. If it's true, teach me: "a ${C[0].subject} can ${j[3]}".`,replace:!0,miss:!0}}return kg(j[2],j[3],F)}let E=c.match(oj);if(E){let F=Y(a,E[1]),D=Y(a,E[2]),B=new Set(["mgx:hasA","tmct:has"]),W=await Gl(e),C=q=>W.find(U=>B.has(U.predicate)&&q.has(U.subject)&&D.has(U.object)),I=C(F);if(I)return{text:`yes \u2014 ${ae(I)}`,replace:!0};let O=[{terms:F,chain:[]}],N=new Set;for(let q=0;q<4;q+=1){let U=[];for(let{terms:ie,chain:se}of O){let X=W.filter(J=>Gn.has(J.predicate)&&ie.has(J.subject)&&!N.has(J.object));for(let J of X){if(N.has(J.object))continue;N.add(J.object);let oe=[...se,J],H=C(Y(a,J.object));if(H)return{text:`yes \u2014 ${[...oe.map(ae),ae(H)].join("; ")}`,replace:!0};U.push({terms:Y(a,J.object),chain:oe})}}if(!U.length)break;O=U}return null}let _=Jl(c),R=_.match(uj);if(R){let F=await mt(e,r),D=!!R[1],B=Y(a,R[2]),W=Y(a,R[3]),C=xg(R[2],R[3],F);if(C&&_!==$g(c)&&(C=vg(C)),C&&D)return{text:`I can't speak for ${R[1].trim()} ${R[2]} \u2014 what I remember is generic, not universal. ${C.text}.`,replace:!0};if(C)return C;if(s){let I=F.filter(N=>N.predicate==="mgx:capableOf"&&B.has(N.subject));if(I.length){let N=I.slice(0,3).map(ae).join("; ");return{text:`I can't confirm that \u2014 nothing I remember says ${R[2]} can ${R[3]}. I do know: ${N}. If it's true, teach me: "a ${I[0].subject} can ${R[3]}".`,replace:!0,miss:!0}}let O=kg(R[2],R[3],F);if(O)return O;if(!/\s/.test(R[2].trim())&&!F.some(N=>B.has(N.subject)||B.has(N.object))){let N=nu(Qi(R[2]));return{text:`I can't confirm that \u2014 I don't know anything about "${R[2]}" yet. Teach me "a ${N} can ${R[3]}" (or "a ${N} cannot ${R[3]}") and I'll remember it.`,replace:!0,miss:!0}}}}let S=c.match(rj);if(S){let F=Y(a,S[1]),D=(await mt(e,r)).filter(N=>(N.predicate==="mgx:capableOf"||N.predicate===ho)&&F.has(N.subject));if(!D.length)return null;let W=Ye(ln(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
160
+ `)+J,replace:s,...X.length?{pending:{items:X,noun:"facts"}}:{}}}if(!s)return null;let $=c.match(_E);if($){let D=`mgx:${$[2].toLowerCase().replace(/\s+/g,"-")}-than`,B=await Gl(e),W=se=>{let X=se.replace(/^(?:an?|the)\s+/i,"").trim();return i&&qn.test(X)?i:X},C=W($[1]),I=W($[3]),O=Y(a,C),N=Y(a,I),q=B.find(se=>se.predicate===D&&O.has(se.subject)&&N.has(se.object));if(q){let se=B.find(J=>J.predicate===D&&O.has(J.object)&&N.has(J.subject)),X=se?` \u2014 though you also told me the opposite: ${ae(se)}. Both are stored; I won't silently pick one.`:"";return{text:`yes \u2014 ${ae(q)}${X}`,replace:!0}}let U=B.filter(se=>se.predicate===D&&(O.has(se.subject)||O.has(se.object)));return{text:`I can't confirm that \u2014 nothing I remember compares them that way.${U.length?` I do know: ${U.slice(0,3).map(ae).join("; ")}.`:""} If it's true, teach me: "${C} is ${$[2].toLowerCase()} than ${I}".`,replace:!0,miss:!0}}for(let{predicate:F,phrase:D,re:B}of $j){let W=c.match(B);if(!W)continue;let C=await Gl(e),I=Y(a,W[1]),O=Y(a,W[2]),N=C.find(U=>U.predicate===F&&I.has(U.subject)&&O.has(U.object));if(N)return{text:`yes \u2014 ${ae(N)}`,replace:!0};let q=C.filter(U=>U.predicate===F&&I.has(U.subject));if(q.length){let U=q.slice(0,3).map(ae).join("; ");return{text:`I can't confirm that \u2014 nothing I remember says ${W[1]} ${D} ${W[2]}. I do know: ${U}.`,replace:!0,miss:!0}}if(!n?.parsed&&C.some(U=>I.has(U.subject)))return{text:`I can't confirm that \u2014 nothing I remember says ${W[1]} ${D} ${W[2]}.`,replace:!0,miss:!0};break}let k=c.match(ps)||Yl(c);if(k){let F=Y(a,k[1]),D=Y(a,k[2]),B=await mt(e,r),W=N=>F.has(N.subject)&&D.has(N.object),{DISJOINT_PREDICATE:C}=await Promise.resolve().then(()=>(Ft(),tn)),I=N=>F.has(N.subject)||F.has(N.object)||D.has(N.subject)||D.has(N.object);return B.some(N=>N.predicate===C&&Gs(N)&&I(N))?null:zg(B.find(N=>Gn.has(N.predicate)&&W(N)),B.find(N=>N.predicate===fi&&W(N)))}let y=Jl(c),j=y.match(sj);if(j){let F=await mt(e,r),D=j[1],B=xg(j[2],j[3],F);if(B&&y!==$g(c)&&(B=vg(B)),B&&D)return{text:`I can't speak for ${D.trim()} ${j[2]} \u2014 what I remember is generic, not universal. ${B.text}.`,replace:!0};if(B)return B;let W=Y(a,j[2]),C=F.filter(I=>I.predicate==="mgx:capableOf"&&W.has(I.subject));if(C.length){let I=C.slice(0,3).map(ae).join("; ");return{text:`I can't confirm that \u2014 nothing I remember says ${j[2]} can ${j[3]}. I do know: ${I}. If it's true, teach me: "a ${C[0].subject} can ${j[3]}".`,replace:!0,miss:!0}}return kg(j[2],j[3],F)}let E=c.match(oj);if(E){let F=Y(a,E[1]),D=Y(a,E[2]),B=new Set(["mgx:hasA","tmct:has"]),W=await Gl(e),C=q=>W.find(U=>B.has(U.predicate)&&q.has(U.subject)&&D.has(U.object)),I=C(F);if(I)return{text:`yes \u2014 ${ae(I)}`,replace:!0};let O=[{terms:F,chain:[]}],N=new Set;for(let q=0;q<4;q+=1){let U=[];for(let{terms:ie,chain:se}of O){let X=W.filter(J=>Gn.has(J.predicate)&&ie.has(J.subject)&&!N.has(J.object));for(let J of X){if(N.has(J.object))continue;N.add(J.object);let oe=[...se,J],H=C(Y(a,J.object));if(H)return{text:`yes \u2014 ${[...oe.map(ae),ae(H)].join("; ")}`,replace:!0};U.push({terms:Y(a,J.object),chain:oe})}}if(!U.length)break;O=U}return null}let _=Jl(c),R=_.match(uj);if(R){let F=await mt(e,r),D=!!R[1],B=Y(a,R[2]),W=Y(a,R[3]),C=xg(R[2],R[3],F);if(C&&_!==$g(c)&&(C=vg(C)),C&&D)return{text:`I can't speak for ${R[1].trim()} ${R[2]} \u2014 what I remember is generic, not universal. ${C.text}.`,replace:!0};if(C)return C;if(s){let I=F.filter(N=>N.predicate==="mgx:capableOf"&&B.has(N.subject));if(I.length){let N=I.slice(0,3).map(ae).join("; ");return{text:`I can't confirm that \u2014 nothing I remember says ${R[2]} can ${R[3]}. I do know: ${N}. If it's true, teach me: "a ${I[0].subject} can ${R[3]}".`,replace:!0,miss:!0}}let O=kg(R[2],R[3],F);if(O)return O;if(!/\s/.test(R[2].trim())&&!F.some(N=>B.has(N.subject)||B.has(N.object))){let N=nu(Qi(R[2]));return{text:`I can't confirm that \u2014 I don't know anything about "${R[2]}" yet. Teach me "a ${N} can ${R[3]}" (or "a ${N} cannot ${R[3]}") and I'll remember it.`,replace:!0,miss:!0}}}}let S=c.match(rj);if(S){let F=Y(a,S[1]),D=(await mt(e,r)).filter(N=>(N.predicate==="mgx:capableOf"||N.predicate===ho)&&F.has(N.subject));if(!D.length)return null;let W=Ye(un(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
161
161
  \u2026and ${I.length} more \u2014 say 'more' to see them.`:"";return{text:C.join(`
162
- `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}let A=c.match(fj);if(A){let F=Y(a,A[1]),D=Y(a,A[2]),B=await mt(e,r),W=ln(B.filter(C=>C.predicate==="mgx:capableOf"&&D.has(C.object))).filter(C=>hi(new Set([C.subject]),D,B).verdict==="yes");if(W.length){let{findIsaChain:C,SUBCLASS_PREDICATE:I,TYPE_PREDICATE:O}=await Promise.resolve().then(()=>(Ft(),tn)),N=B.filter(Q=>Q.predicate===I),q=B.filter(Q=>Q.predicate===O),U=N.map(Q=>[Q.subject,Q.object]),ie=q.map(Q=>[Q.subject,Q.object]),se=Q=>(Q.predicate===I?N:q).find(xe=>xe.subject===Q.subject&&xe.object===Q.object),X=new Map,J=W.filter(Q=>F.has(Q.subject)?!0:(X.has(Q.subject)||X.set(Q.subject,C(Q.subject,F,ie,U,{maxHops:3})),!!X.get(Q.subject))),H=Ye(J.length?J:W,o).map(Q=>{let xe=J.length?X.get(Q.subject):null;if(!xe||xe.length<2)return ae(Q);let ge=xe.map(se);if(!ge.every(Boolean))return ae(Q);let ve=ge.map(V=>`${Ct(V)}${V.provenance?` (source: ${V.provenance})`:""}`).join("; ");return`${ae(Q)} \u2014 via: ${ve}`}),le=H.slice(0,je),ne=H.slice(je),_e=ne.length?`
162
+ `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}let A=c.match(fj);if(A){let F=Y(a,A[1]),D=Y(a,A[2]),B=await mt(e,r),W=un(B.filter(C=>C.predicate==="mgx:capableOf"&&D.has(C.object))).filter(C=>hi(new Set([C.subject]),D,B).verdict==="yes");if(W.length){let{findIsaChain:C,SUBCLASS_PREDICATE:I,TYPE_PREDICATE:O}=await Promise.resolve().then(()=>(Ft(),tn)),N=B.filter(Q=>Q.predicate===I),q=B.filter(Q=>Q.predicate===O),U=N.map(Q=>[Q.subject,Q.object]),ie=q.map(Q=>[Q.subject,Q.object]),se=Q=>(Q.predicate===I?N:q).find(xe=>xe.subject===Q.subject&&xe.object===Q.object),X=new Map,J=W.filter(Q=>F.has(Q.subject)?!0:(X.has(Q.subject)||X.set(Q.subject,C(Q.subject,F,ie,U,{maxHops:3})),!!X.get(Q.subject))),H=Ye(J.length?J:W,o).map(Q=>{let xe=J.length?X.get(Q.subject):null;if(!xe||xe.length<2)return ae(Q);let ge=xe.map(se);if(!ge.every(Boolean))return ae(Q);let ve=ge.map(V=>`${Ct(V)}${V.provenance?` (source: ${V.provenance})`:""}`).join("; ");return`${ae(Q)} \u2014 via: ${ve}`}),le=H.slice(0,je),ne=H.slice(je),_e=ne.length?`
163
163
  \u2026and ${ne.length} more \u2014 say 'more' to see them.`:"";return{text:(J.length?"":`nothing I remember ties these to "${A[1]}", but:
164
164
  `)+le.join(`
165
- `)+_e,replace:!0,...ne.length?{pending:{items:ne,noun:"facts"}}:{}}}}let M=c.match(pj);if(M&&M[1].trim().split(/\s+/).at(-1)?.toLowerCase()!=="do"){let F=Y(a,M[1]),D=(await mt(e,r)).filter(B=>B.predicate==="mgxneg:capableOf"&&F.has(B.object));if(D.length){let W=Ye(ln(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
165
+ `)+_e,replace:!0,...ne.length?{pending:{items:ne,noun:"facts"}}:{}}}}let M=c.match(pj);if(M&&M[1].trim().split(/\s+/).at(-1)?.toLowerCase()!=="do"){let F=Y(a,M[1]),D=(await mt(e,r)).filter(B=>B.predicate==="mgxneg:capableOf"&&F.has(B.object));if(D.length){let W=Ye(un(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
166
166
  \u2026and ${I.length} more \u2014 say 'more' to see them.`:"";return{text:C.join(`
167
- `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}return{text:`nothing I remember says anything cannot ${M[1].trim()}.`,replace:!0,miss:!0}}let T=c.match(dj);if(T&&T[1].trim().split(/\s+/).at(-1)?.toLowerCase()!=="do"){let F=Y(a,T[1]),D=Ic(F,await mt(e,r));if(D.length){let W=Ye(ln(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
167
+ `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}return{text:`nothing I remember says anything cannot ${M[1].trim()}.`,replace:!0,miss:!0}}let T=c.match(dj);if(T&&T[1].trim().split(/\s+/).at(-1)?.toLowerCase()!=="do"){let F=Y(a,T[1]),D=Ic(F,await mt(e,r));if(D.length){let W=Ye(un(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
168
168
  \u2026and ${I.length} more \u2014 say 'more' to see them.`:"";return{text:C.join(`
169
- `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}}let P=c.match(ij);if(P&&!xj.has(P[1].trim().split(/\s+/)[0]?.toLowerCase())){let F=Y(a,P[1]),D=(await mt(e,r)).filter(N=>N.predicate==="mgx:hasA"&&F.has(N.object));if(!D.length)return null;let W=Ye(ln(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
169
+ `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}}let P=c.match(ij);if(P&&!xj.has(P[1].trim().split(/\s+/)[0]?.toLowerCase())){let F=Y(a,P[1]),D=(await mt(e,r)).filter(N=>N.predicate==="mgx:hasA"&&F.has(N.object));if(!D.length)return null;let W=Ye(un(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
170
170
  \u2026and ${I.length} more \u2014 say 'more' to see them.`:"";return{text:C.join(`
171
- `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}let G=c.match(Sg),K=n?.parsed?.shape==="reverse"&&n.parsed.kind==="inherits"?n.parsed.object:G?.[1];if(K){let F=Y(a,K),D=(await mt(e,r)).filter(N=>Gn.has(N.predicate)&&F.has(N.object));if(!D.length)return null;let W=Ye(ln(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
171
+ `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}let G=c.match(Sg),K=n?.parsed?.shape==="reverse"&&n.parsed.kind==="inherits"?n.parsed.object:G?.[1];if(K){let F=Y(a,K),D=(await mt(e,r)).filter(N=>Gn.has(N.predicate)&&F.has(N.object));if(!D.length)return null;let W=Ye(un(D),o).map(ae),C=W.slice(0,je),I=W.slice(je),O=I.length?`
172
172
  \u2026and ${I.length} more \u2014 say 'more' to see them.`:"";return{text:C.join(`
173
173
  `)+O,replace:!0,...I.length?{pending:{items:I,noun:"facts"}}:{}}}let te=c.match(nj);if(te){let F=Y(a,te[1]),D=await mt(e,r),B=V=>!String(V.provenance||"").includes("corpus:")&&!String(V.provenance||"").includes("web:"),W=D.filter(V=>Gn.has(V.predicate)&&B(V)),C=new Set,I=F;for(let V=0;V<8&&I.size;V+=1){let re=new Set;for(let ce of W)I.has(ce.object)&&!C.has(ce.subject)&&re.add(ce.subject);if(!re.size)break;for(let ce of re)C.add(ce);let fe=new Set;for(let ce of re)for(let wt of Y(a,ce))fe.add(wt);I=fe}let O=D.filter(V=>F.has(V.subject)||F.has(V.object)||C.has(V.subject));if(!O.length){let V=a(te[1]).split(/\s+/).filter(re=>re.length>=4&&!Bg.has(re));if(V.length){let re=ce=>new Set(String(ce||"").split(/\s+/)),fe=ce=>{let wt=re(ce);return V.some(Bt=>wt.has(Bt))};O=D.filter(ce=>fe(ce.subject)||fe(ce.object))}}if(O=O.filter(V=>!mg.has(V.predicate)),!O.length)return null;let{findConsistencyViolations:N,TYPE_PREDICATE:q,SUBCLASS_PREDICATE:U,DISJOINT_PREDICATE:ie}=await Promise.resolve().then(()=>(Ft(),tn)),se=V=>!V.provenance?.includes("corpus:")&&!V.provenance?.includes("web:"),X=D.filter(V=>V.predicate===q&&se(V)).map(V=>[V.subject,V.object]),J=D.filter(V=>V.predicate===U&&se(V)).map(V=>[V.subject,V.object]),oe=D.filter(V=>V.predicate===ie&&se(V)).map(V=>[V.subject,V.object]);if(oe.length){let re=N(X,J,oe,{focus:F,budget:5}).find(fe=>F.has(fe.subject));if(re)return{text:`I can't answer that \u2014 what I've been told about ${re.subject} is inconsistent: it's taught to be both ${re.classA} and ${re.classB}, but ${re.viaA} and ${re.viaB} are disjoint (${re.viaA} owl:disjointWith ${re.viaB}). I'd need one of those retracted before I can answer honestly.`,replace:!0}}let H=O.find(V=>F.has(V.subject)||F.has(V.object)),le=H?F.has(H.subject)?H.subject:H.object:te[1].trim(),ne=O.some(V=>C.has(V.subject)&&!F.has(V.subject)&&!F.has(V.object));O=Ye(O,o);let _e=`${O.length} remembered fact${O.length===1?"":"s"} about ${le}${ne?" (including its known subtypes)":""}:`,{lines:Le,grouped:Q}=gg(O,D,F,{indent:" "});if(Q)return{...Q,text:`${_e}
174
174
  ${Q.text}`};let xe=Le.slice(0,je),ge=Le.slice(je),ve=ge.length?`
@@ -179,8 +179,8 @@ ${xe.join(`
179
179
  `)+q,replace:!0,...N.length?{pending:{items:N,noun:"facts"}}:{}}};if(Oj.test(c)){let C=Ye(m.length?m:d,i);return C.length?f(C):null}let g=u.match(Kl);if(g){let C=g[1].trim(),I=qn.test(C)?r||null:C,O=g[2].trim().toLowerCase(),N=g[3].trim();if(I&&!Xl.has(O)){let q=Fl(d),{findIsaChain:U}=await Promise.resolve().then(()=>(Ft(),tn)),ie=Le=>{let Q=String(Le||"").trim().toLowerCase(),xe=[];for(let ge of d){let ve=ql(ge.predicate);if(!ve)continue;if(ve===Q){xe.push({fact:ge,aliasFacts:[]});continue}let V=Dl(U,ve,new Set([Q]),q,{maxHops:2});if(!V)continue;let re=V.map(fe=>d.find(ce=>ce.predicate===Rr&&ce.subject===fe.subject&&ce.object===fe.object));re.every(Boolean)&&xe.push({fact:ge,aliasFacts:re})}return xe},{loadMemory:se,findRuleByName:X,resolveRelationChase:J}=await Promise.resolve().then(()=>(Ge(),ls)),{findActionPath:oe}=await Promise.resolve().then(()=>(Es(),Dr)),H=await se(e),ne=await J(H,O,I,N,{relationFactsFor:ie,renderFactLine:ae,factPhrase:Ct,factTermVariants:Y,byTrust:p,rows:d,HAS_PROPERTY_PREDICATE:Pl,findActionPath:oe});return ne?{text:`yes \u2014 ${ne.citation.join("; ")}`,replace:!0}:ie(O).length>0||!!X(H,O)?{text:`I know the '${O}' relation, but I can't confirm ${I} is the ${O} of ${N} from what you've told me.`,replace:!0}:{text:`I don't know a relation or rule called '${O}' yet.`,replace:!0}}}let h=Zi(u).match(Ug)||Wg(u,C=>{let I=Y(l,C);return d.some(O=>I.has(O.subject)||I.has(O.object))});if(h){let C=h[1].trim().toLowerCase(),I=h[2].trim(),O=qn.test(I)?r||null:I;if(O&&!Xl.has(C)){let N=Fl(d),{findIsaChain:q}=await Promise.resolve().then(()=>(Ft(),tn)),U=Le=>{let Q=String(Le||"").trim().toLowerCase(),xe=[];for(let ge of d){let ve=ql(ge.predicate);if(!ve)continue;if(ve===Q){xe.push({fact:ge,aliasFacts:[]});continue}let V=Dl(q,ve,new Set([Q]),N,{maxHops:2});if(!V)continue;let re=V.map(fe=>d.find(ce=>ce.predicate===Rr&&ce.subject===fe.subject&&ce.object===fe.object));re.every(Boolean)&&xe.push({fact:ge,aliasFacts:re})}return xe},{loadMemory:ie,findRuleByName:se,resolveRelationChaseReverse:X}=await Promise.resolve().then(()=>(Ge(),ls)),J=await ie(e),{findReachableSet:oe}=await Promise.resolve().then(()=>(Es(),Dr)),le=await X(J,C,O,{relationFactsFor:U,renderFactLine:ae,factPhrase:Ct,factTermVariants:Y,byTrust:p,rows:d,HAS_PROPERTY_PREDICATE:Pl,findReachableSet:oe});return le.length?{text:le.map(Q=>`${Q.subject} \u2014 ${Q.citation.join("; ")}`).join(`
180
180
  `),replace:!0}:U(C).length>0||!!se(J,C)?{text:/^what\b/i.test(Zi(u))?`I don't know what the ${C} of ${O} is from what you've told me.`:`I don't know anyone who is the ${C} of ${O} from what you've told me.`,replace:!0}:{text:`I don't know a relation or rule called '${C}' yet.`,replace:!0}}}{let C=u.match(Fj);if(C){let I=Y(l,C[1]),O=Ye(d.filter(N=>I.has(N.subject)||I.has(N.object)),i);if(O.length){let N=O.map(ae),q=N.slice(0,je),U=N.slice(je),ie=U.length?`
181
181
  \u2026and ${U.length} more \u2014 say 'more' to see them.`:"";return{text:q.join(`
182
- `)+ie,replace:!0,...U.length?{pending:{items:U,noun:"facts"}}:{}}}}}let b=u.match(QE);if(b){let C=nu(b[1].trim().toLowerCase()),I=b[2].trim(),O=qn.test(I)?r||null:I;if(O){let{loadMemory:N,findRuleByName:q,RULE_KIND_PROP:U,RULE_KIND_RECURSIVE:ie}=await Promise.resolve().then(()=>(Ge(),ls)),se=await N(e),X=q(se,C),J=X?.attributes?.find(oe=>oe.prop===U)?.value;if(X&&J===ie){let oe=X.attributes.find(ne=>ne.prop==="mgx:ruleBaseCase")?.value,H=X.attributes.find(ne=>ne.prop==="mgx:ruleRecStep")?.value,le=l(O);if(oe&&H&&le){let ne=Fl(d),{findIsaChain:_e}=await Promise.resolve().then(()=>(Ft(),tn)),Le=V=>{let re=String(V||"").trim().toLowerCase(),fe=[];for(let ce of d){let wt=ql(ce.predicate);if(!wt)continue;if(wt===re){fe.push({fact:ce,aliasFacts:[]});continue}let Bt=Dl(_e,wt,new Set([re]),ne,{maxHops:2});if(!Bt)continue;let Qe=Bt.map(un=>d.find(Kt=>Kt.predicate===Rr&&Kt.subject===un.subject&&Kt.object===un.object));Qe.every(Boolean)&&fe.push({fact:ce,aliasFacts:Qe})}return fe},{findReachableSet:Q}=await Promise.resolve().then(()=>(Es(),Dr)),ve=Q({entity:le,hop:0},V=>{let re=V.hop===0?oe:H;return Le(re).filter(fe=>fe.fact.subject===V.entity).map(fe=>({action:fe,nextState:{entity:fe.fact.object,hop:V.hop+1}}))},{maxDepth:20,stateKey:V=>V.entity});if(ve.length)return{text:ve.map(({node:re,path:fe})=>{let ce=new Set,wt=[];for(let Bt of fe.actions){wt.push(ae(Bt.fact));for(let Qe of Bt.aliasFacts){let un=Qe.id||`${Qe.subject}|${Qe.predicate}|${Qe.object}`;ce.has(un)||(ce.add(un),wt.push(`${Ct(Qe)}${Qe.provenance?` (source: ${Qe.provenance})`:""}`))}}return`${re.entity} \u2014 ${wt.join("; ")}`}).join(`
183
- `),replace:!0}}}return null}}let w=c.match(wg),v=c.match(ps)||Yl(c)||w&&`is ${w[1].trim()} a ${w[2].trim()}`.match(ps);if(v){let C=Y(l,Xt(v[2])),I=r&&qn.test(v[1].trim())?r:v[1],O=new Set(Y(l,I));if([...O].some(z=>C.has(z))){let z=Xt(v[2]).trim();return{text:`yes \u2014 ${Co(z)} ${z} is ${Co(z)} ${z}, trivially: every kind is a kind of itself.`,replace:!0}}let N=await Lj(o,I);if(N)for(let z of Y(l,N))O.add(z);let{findIsaChain:q,deriveDisjointViolations:U,SUBCLASS_PREDICATE:ie,TYPE_PREDICATE:se,DISJOINT_PREDICATE:X}=await Promise.resolve().then(()=>(Ft(),tn)),J=Gs,oe=m.filter(z=>z.predicate===ie&&J(z)),H=m.filter(z=>z.predicate===se&&J(z)),le=oe.map(z=>[z.subject,z.object]),ne=H.map(z=>[z.subject,z.object]),_e=m.filter(z=>z.predicate===ie),Le=m.filter(z=>z.predicate===se),Q=Le.map(z=>[z.subject,z.object]),xe=_e.map(z=>[z.subject,z.object]),ge=d.filter(z=>z.predicate===X&&J(z)),ve=ge.map(z=>[z.subject,z.object]),V=ge.length?U(Q.concat(xe),xe,ve,{budget:20,focus:new Set([...O,...C])}):[],re=z=>{let be=V.find(Ne=>Ne.subject===z&&C.has(Ne.object));if(!be)return null;let we=m.filter(Ne=>C.has(Ne.object)&&(Ne.subject===be.viaClass||Ne.subject===be.subject)).sort(p)[0],Ee=ge.find(Ne=>Ne.subject===be.viaClass&&Ne.object===be.object||Ne.subject===be.object&&Ne.object===be.viaClass);return!we||!Ee?null:GE(we,Ee)},fe=m.filter(z=>O.has(z.subject)&&C.has(z.object)).sort(p)[0],ce=d.filter(z=>z.predicate===fi&&O.has(z.subject)&&C.has(z.object)).sort(p)[0],wt=ge.find(z=>O.has(z.subject)&&C.has(z.object)||O.has(z.object)&&C.has(z.subject));if(fe&&!ce){let z=re(fe.subject);if(z)return z}let Bt=zg(fe,ce||wt);if(Bt)return Bt;if(ge.length){let z=Ee=>{let Ne=new Set(Ee),_t=new Set(Ee);for(let Te=0;Te<8&&_t.size;Te+=1){let ye=new Set;for(let[Ze,ms]of xe)_t.has(Ze)&&!Ne.has(ms)&&ye.add(ms);if(!ye.size)break;for(let Ze of ye)Ne.add(Ze);_t=ye}return Ne},be=z(C),we=V.find(Ee=>O.has(Ee.subject)&&be.has(Ee.object)&&!z([Ee.viaClass]).has(Ee.object)&&!z([Ee.object]).has(Ee.viaClass));if(we){let Ee=m.filter(ye=>O.has(ye.subject)&&ye.object===we.viaClass).sort(p)[0],Ne=ge.find(ye=>ye.subject===we.viaClass&&ye.object===we.object||ye.subject===we.object&&ye.object===we.viaClass),_t=!C.has(we.object),Te=_t?m.filter(ye=>C.has(ye.subject)&&ye.object===we.object).sort(p)[0]:null;if(Ee&&Ne&&(!_t||Te)){let ye=Xt(v[2]).trim();return{text:`no \u2014 ${[Ee,...Te?[Te]:[]].map(ae).join("; ")}; and ${Ct(Ne)}${Ne.provenance?` (source: ${Ne.provenance})`:""} \u2014 so ${I} can never be ${Co(ye)} ${ye}.`,replace:!0}}}}let Qe=await _r(o,I);if(Qe){let z=new Map;for(let we of Ji(o,Qe.id))for(let Ee of Y(l,we.label))!O.has(Ee)&&!z.has(Ee)&&z.set(Ee,we.label);let be=m.filter(we=>z.has(we.subject)&&C.has(we.object)).sort(p)[0];if(be)return{text:`yes \u2014 the code graph says ${Qe.label} inherits ${z.get(be.subject)}, and ${ae(be)}`,replace:!0}}let un=z=>(z.predicate===ie?oe:H).find(be=>be.subject===z.subject&&be.object===z.object);for(let z of O){let be=q(z,C,ne,le,{maxHops:2});if(!be)continue;let we=re(z);if(we)return we;let Ee=be.map(un);if(Ee.every(Boolean))return{text:`yes \u2014 ${Yi(Ee)}`,replace:!0}}let Kt=z=>(z.predicate===ie?_e:Le).find(be=>be.subject===z.subject&&be.object===z.object);for(let z of O){let be=q(z,C,Q,xe,{maxHops:2});if(!be)continue;let we=re(z);if(we)return we;let Ee=be.map(Kt);if(Ee.every(Boolean)&&Ee.some(J))return{text:`yes \u2014 ${Yi(Ee)}`,replace:!0}}let Ut=I.match(/^(.*\S)\s+not$/i),It=Ut&&[Ut[0],r&&qn.test(Ut[1].trim())?r:Ut[1]];if(It){let z=Y(l,It[1]),be=C,we=m.filter(Te=>z.has(Te.subject)&&be.has(Te.object)).sort(p)[0];if(we)return{text:`no \u2014 ${ae(we)}`,replace:!0};let Ee=ge.find(Te=>z.has(Te.subject)&&be.has(Te.object)||z.has(Te.object)&&be.has(Te.subject));if(Ee)return{text:`yes \u2014 ${ae(Ee)}`,replace:!0};let Ne=It[1].trim(),_t=Xt(v[2]).trim();return{text:`I can't confirm that either way \u2014 nothing I remember links ${Ne} and ${_t}. If no ${Ne} is a ${_t}, teach me: "no ${Ne} is a ${_t}".`,replace:!0,miss:!0}}if(ge.length){let z=U(ne.concat(le),le,ve,{budget:10});for(let be of O){let we=z.find(Te=>Te.subject===be&&C.has(Te.object));if(!we)continue;let Ee=H.concat(oe).find(Te=>Te.subject===we.subject&&Te.object===we.viaType),Ne=ge.find(Te=>Te.subject===we.viaClass&&Te.object===we.object||Te.subject===we.object&&Te.object===we.viaClass),_t=[Ee,Ne].filter(Boolean).map(ae);return{text:`no \u2014 ${_t.length?_t.join("; "):`${we.viaClass} and ${we.object} are disjoint.`}`,replace:!0}}}let{deriveSomeValuesFromApplication:Tr,ON_PROPERTY_PREDICATE:x,SOME_VALUES_FROM_PREDICATE:ue,deriveSomeValuesFromSubsumption:Re,ENTAILED_SCM_SVF_PROVENANCE:Sn,SCM_SVF_RULE_CONFIDENCE:Ys,entailedTrustFrom:au}=await Promise.resolve().then(()=>(Ft(),tn)),cu=d.filter(z=>z.predicate===x&&J(z)),lu=d.filter(z=>z.predicate===ue&&J(z));if(cu.length&&lu.length){let z=new Map(lu.map(ye=>[ye.subject,ye.object])),be=cu.map(ye=>({restriction:ye.subject,property:ye.object,target:z.get(ye.subject)})).filter(ye=>ye.target),we=new Set([ie,se,X,x,ue,"owl:intersectionOf"]),Ee=d.filter(ye=>J(ye)&&!we.has(ye.predicate)),Ne=Ee.map(ye=>[ye.subject,ye.predicate,ye.object]),_t=Tr(Ne,ne,le,be,{budget:10});for(let ye of O){let Ze=_t.find(rn=>rn.subject===ye&&C.has(rn.object));if(!Ze)continue;let ms=Ee.find(rn=>rn.subject===Ze.subject&&rn.predicate===Ze.viaProperty&&rn.object===Ze.viaValue),hs=H.find(rn=>rn.subject===Ze.viaValue&&rn.object===Ze.viaType),Oo=[ms,hs].filter(Boolean).map(ae);return{text:`yes \u2014 ${Oo.length?Oo.join("; "):`${Ze.subject} ${Ze.viaProperty} ${Ze.viaValue}, and ${Ze.viaValue} is a ${Ze.viaType}.`}`,replace:!0}}let Te=be.length>1?Re(be,le,{budget:10}):[];if(Te.length){let ye=le.concat(Te.map(ke=>[ke.subject,ke.object])),Ze=new Map(be.map(ke=>[ke.restriction,ke])),ms=new Map;for(let ke of d)ms.set(`${ke.subject}\0${ke.predicate}\0${ke.object}`,ke.trust);let hs=(ke,dn,Ot)=>ms.get(`${ke}\0${dn}\0${Ot}`),Oo=new Map;for(let ke of Te){let dn=Ze.get(ke.subject),Ot=Ze.get(ke.object),Wt=[dn&&hs(ke.subject,x,dn.property),hs(ke.subject,ue,ke.viaY1),Ot&&hs(ke.object,x,Ot.property),hs(ke.object,ue,ke.viaY2),hs(ke.viaY1,ie,ke.viaY2)].filter(pb=>typeof pb=="number"),Ir=au(Wt,Ys);Ir!==null&&Oo.set(`${ke.subject}\0${ke.object}`,Ir)}let rn=ke=>{if(ke.predicate!==ie)return H.find(Wt=>Wt.subject===ke.subject&&Wt.object===ke.object);let dn=oe.find(Wt=>Wt.subject===ke.subject&&Wt.object===ke.object);if(dn)return dn;let Ot=Te.find(Wt=>Wt.subject===ke.subject&&Wt.object===ke.object);return Ot?{subject:Ot.subject,predicate:ie,object:Ot.object,provenance:Sn,trust:Oo.get(`${Ot.subject}\0${Ot.object}`)}:void 0};for(let ke of O){let dn=q(ke,C,ne,ye,{maxHops:3});if(!dn)continue;let Ot=dn.map(rn);if(Ot.every(Boolean)){let Wt=au(Ot.map(Ir=>Ir.trust),1);return{text:`yes \u2014 ${Yi(Ot)}`,replace:!0,...Wt!==null?{trust:Wt}:{}}}}}}let ub=Y(l,I),uu=m.filter(z=>ub.has(z.subject)).sort(p),fs=I.trim(),Cr=Xt(v[2]).trim(),db=[...O].some(z=>q(z,C,ne,le,{maxHops:ZE}));if(uu.length){let z=uu.slice(0,3).map(ae).join("; "),be=db?`The facts to settle it are here, but the chain is longer than I follow while answering. Run "/syllogise ${fs}", then ask me again.`:`If it's true, teach me: "${fs} is a kind of ${Cr}".`;return{text:`I can't confirm that \u2014 nothing I remember says ${fs} is a ${Cr}. I do know: ${z}. ${be}`,replace:!0,miss:!0}}let du=m.filter(z=>O.has(z.object)&&C.has(z.subject)).sort(p)[0];return du?{text:`I can't confirm that \u2014 what I know runs the other way: ${ae(du)}. A kind doesn't reverse. If it's true, teach me: "every ${fs} is a ${Cr}".`,replace:!0,miss:!0}:!Qe&&!N&&!SE(fs)&&!d.some(z=>O.has(z.subject)||O.has(z.object))?{text:`I can't confirm that \u2014 I don't know "${fs}" at all yet. If it's true, teach me: "${fs} is a kind of ${Cr}".`,replace:!0,miss:!0}:null}let $=c.match(jj);if($){let[,C,I,O]=$,{SUBCLASS_PREDICATE:N,ON_PROPERTY_PREDICATE:q,buildCardinalityRestrictions:U,proveCardinalityAtLeast:ie,CARDINALITY_RULE_CONFIDENCE:se,entailedTrustFrom:X}=await Promise.resolve().then(()=>(Ft(),tn)),J=Gs,oe=m.filter(ne=>ne.predicate===N&&J(ne)).map(ne=>[ne.subject,ne.object]),H=d.filter(ne=>(ne.predicate===q||Eg.has(ne.predicate))&&J(ne)),le=U(H);if(le.length){let ne=Y(l,C.trim()),_e=Y(l,O.trim()),Le=Number(I),Q=bg(ne,_e,(xe,ge)=>ie(oe,le,xe,ge,Le,{}));if(Q){let xe=d.find(ce=>ce.predicate===N&&ce.subject===Q.viaClass&&ce.object===Q.viaRestriction),ge=xe?.provenance?` (source: ${xe.provenance})`:"",ve=Q.kind==="exactly"?"exactly":"at least",V=(ce,wt)=>`${ce}${wt===1?"":"s"}`,re=[xe?.trust,...H.filter(ce=>ce.subject===Q.viaRestriction).map(ce=>ce.trust),...Q.viaClass!==Q.subject?[m.find(ce=>ce.predicate===N&&ce.subject===Q.subject&&ce.object===Q.viaClass)?.trust]:[]].filter(ce=>typeof ce=="number"),fe=X(re,se);return{text:`yes \u2014 every ${Q.viaClass} has ${ve} ${Q.n} ${V(Q.object,Q.n)}${ge}, so at least ${Le} follows.`,replace:!0,...fe!==null?{trust:fe}:{}}}}}let k=c.match(_j);if(k){let[,C,I]=k,{SUBCLASS_PREDICATE:O,ON_PROPERTY_PREDICATE:N,buildCardinalityRestrictions:q,proveMaxCardinalityZeroDenial:U,CAX_MAXC0_RULE_CONFIDENCE:ie,entailedTrustFrom:se}=await Promise.resolve().then(()=>(Ft(),tn)),X=Gs,J=m.filter(le=>le.predicate===O&&X(le)).map(le=>[le.subject,le.object]),oe=d.filter(le=>(le.predicate===N||Eg.has(le.predicate))&&X(le)),H=q(oe);if(H.length){let le=Y(l,C.trim()),ne=Y(l,I.trim()),_e=bg(le,ne,(Le,Q)=>U(J,H,Le,Q,{}));if(_e){let Le=d.find(ve=>ve.predicate===O&&ve.subject===_e.viaClass&&ve.object===_e.viaRestriction),Q=Le?.provenance?` (source: ${Le.provenance})`:"",xe=[Le?.trust,...oe.filter(ve=>ve.subject===_e.viaRestriction).map(ve=>ve.trust),..._e.viaClass!==_e.subject?[m.find(ve=>ve.predicate===O&&ve.subject===_e.subject&&ve.object===_e.viaClass)?.trust]:[]].filter(ve=>typeof ve=="number"),ge=se(xe,ie);return{text:`no \u2014 every ${_e.viaClass} has at most 0 ${_e.object}${Q}.`,replace:!0,...ge!==null?{trust:ge}:{}}}}}let y=c.match(Rj);if(y){let C=Y(l,y[1]),I=d.filter(O=>O.predicate===Ml&&C.has(O.subject)).sort(p);return I.length?f(I):null}let j=u.match(Aj);if(j){let[,C,I]=j,O=Y(l,C.trim()),N=Y(l,I.replace(/^an?\s+/i,"").trim()),q=d.filter(U=>U.predicate===Ml&&N.has(U.subject)&&O.has(U.object)).sort(p)[0];return q?{text:`yes \u2014 ${ae(q)}`,replace:!0}:{text:`no \u2014 no remembered fact says ${C.trim().toLowerCase()} owns/maintains ${I.trim()}.`,replace:!0}}let E=u.match(Tj);if(E){let[,C,I]=E,O=Y(l,C.replace(/^an?\s+/i,"").trim()),N=Y(l,I.trim()),q=d.filter(U=>U.predicate===Ml&&O.has(U.subject)&&N.has(U.object)).sort(p)[0];return q?{text:`yes \u2014 ${ae(q)}`,replace:!0}:{text:`no \u2014 no remembered fact says ${C.trim().toLowerCase()} is owned by ${I.trim()}.`,replace:!0}}let _=u.match(Cj);if(_){let[,C,I]=_,O=Y(l,C.trim()),N=Y(l,`${I.trim()} method`),q=d.filter(U=>U.predicate===Fs&&O.has(U.subject)&&N.has(U.object)).sort(p)[0];return q?{text:`yes \u2014 ${ae(q)}`,replace:!0}:null}let R=u.match(Ij);if(R){let C=Y(l,R[1].trim()),I=d.filter(O=>O.predicate===Fs&&C.has(O.subject)&&/ method$/.test(O.object)).sort(p);return I.length?f(I):null}let S=u.match(jg);if(S){let C=S[1].trim(),I=Rg.test(C)||_g.test(C)?null:qn.test(C)?r||null:C,O=S[2].trim().toLowerCase();if(I){let N=Y(l,I),q=new Map,U=null;if(o){let H=await _r(o,I);if(U=H,H)for(let le of Ji(o,H.id))for(let ne of Y(l,le.label))!N.has(ne)&&!q.has(ne)&&q.set(ne,le.label),N.add(ne)}let ie=H=>H.predicate===Pl&&l(H.object)===O||H.predicate===`tmct:${O}`&&H.object==="true",se=l(I).split(/\s+/).filter(H=>H.length>=4&&!Bg.has(H)),X=H=>se.some(le=>new Set(String(H.subject||"").split(/\s+/)).has(le)),J=H=>N.has(H.subject)||se.length&&X(H),oe=d.filter(H=>J(H)&&ie(H)).sort(p)[0];if(oe){let H=q.get(oe.subject);return{text:H?`yes \u2014 the code graph says ${U.label} inherits ${H}, and ${ae(oe)}`:`yes \u2014 ${ae(oe)}`,replace:!0}}{let{findIsaChain:H,SUBCLASS_PREDICATE:le,TYPE_PREDICATE:ne}=await Promise.resolve().then(()=>(Ft(),tn)),_e=Gs,Le=d.filter(re=>re.predicate===le&&_e(re)),Q=d.filter(re=>re.predicate===ne&&_e(re)),xe=Le.map(re=>[re.subject,re.object]),ge=Q.map(re=>[re.subject,re.object]),ve=re=>(re.predicate===le?Le:Q).find(fe=>fe.subject===re.subject&&fe.object===re.object),V=Y(l,O);for(let re of N){let fe=H(re,V,ge,xe,{maxHops:2});if(!fe)continue;let ce=fe.map(ve);if(ce.every(Boolean))return{text:`yes \u2014 ${Yi(ce)}`,replace:!0}}}if(d.some(J)&&!n?.parsed)return{text:`I don't have a fact saying ${HE(I)} is ${O}.`,replace:!0};if(!n?.parsed&&!fg.test(O))return Ag(I,O)}}let A=Jl(c).match(IE);if(A&&!Bl.test(c)){let[,C,I,O]=A,N=I.toLowerCase();if(!zl.test(N)&&!Wl.test(N)){let q=C.trim(),U=NE(await Ul(N),O),ie=U.object.replace(/^an?\s+/i,"").trim();if(q&&ie){let se=U.predicate,X=Y(l,q),J=Y(l,ie),oe=[se,bo(se)],H=d.filter(ne=>oe.includes(ne.predicate)&&X.has(ne.subject)&&J.has(ne.object)).sort(p)[0];if(H)return{text:`${Sf(H.predicate)?"no":"yes"} \u2014 ${ae(H)}`,replace:!0,generalVerbQuery:!0};let le=d.filter(ne=>oe.includes(ne.predicate)&&X.has(ne.subject));if(le.length){let ne=le.slice(0,3).map(ae).join("; ");return{text:`I can't confirm that \u2014 nothing I remember says ${Ct({subject:q,predicate:se,object:ie})}. I do know: ${ne}.`,replace:!0,miss:!0}}return null}}}let M=c.match(OE);if(M&&!Bl.test(c)){let[,C,I]=M,[O,N]=I.toLowerCase().split(/\s+/);if(!zl.test(O)&&!Wl.test(O)){let q=C.trim();if(q){let U=await Ul(O);N&&/^mgx:[a-z]+$/.test(U)&&(U=`${U}-${N}`);let ie=Y(l,q),se=[U,bo(U)],X=Ye(d.filter(J=>se.includes(J.predicate)&&ie.has(J.subject)),i);if(X.length)return{...f(X),generalVerbQuery:!0}}}}let T=c.match(/^(?:what|who)\s+([a-z]+)\s+(on|in|at|onto|upon|under|over|beside|near|behind|above|below|inside|outside)\s+(.+?)[?.!\s]*$/i);if(T&&!Bl.test(c)){let[,C,I,O]=T,N=C.toLowerCase();if(!zl.test(N)&&!Wl.test(N)&&!CE.test(N)){let q=await Ul(N);/^mgx:[a-z]+$/.test(q)&&(q=`${q}-${I.toLowerCase()}`);let U=Y(l,O.replace(/^(?:an?|the)\s+/i,"").trim()),ie=Ye(d.filter(se=>se.predicate===q&&U.has(se.object)),i);if(ie.length)return{...f(ie),generalVerbQuery:!0}}}let P=c.match(Sj);if(P){let C=Y(l,P[1]),I=Ye(d.filter(se=>C.has(se.subject)||C.has(se.object)),i);if(!I.length)return null;let O=C.has(I[0].subject)?I[0].subject:I[0].object,N=I.map(se=>` ${ae(se)}`),q=N.slice(0,je),U=N.slice(je),ie=U.length?`
182
+ `)+ie,replace:!0,...U.length?{pending:{items:U,noun:"facts"}}:{}}}}}let b=u.match(QE);if(b){let C=nu(b[1].trim().toLowerCase()),I=b[2].trim(),O=qn.test(I)?r||null:I;if(O){let{loadMemory:N,findRuleByName:q,RULE_KIND_PROP:U,RULE_KIND_RECURSIVE:ie}=await Promise.resolve().then(()=>(Ge(),ls)),se=await N(e),X=q(se,C),J=X?.attributes?.find(oe=>oe.prop===U)?.value;if(X&&J===ie){let oe=X.attributes.find(ne=>ne.prop==="mgx:ruleBaseCase")?.value,H=X.attributes.find(ne=>ne.prop==="mgx:ruleRecStep")?.value,le=l(O);if(oe&&H&&le){let ne=Fl(d),{findIsaChain:_e}=await Promise.resolve().then(()=>(Ft(),tn)),Le=V=>{let re=String(V||"").trim().toLowerCase(),fe=[];for(let ce of d){let wt=ql(ce.predicate);if(!wt)continue;if(wt===re){fe.push({fact:ce,aliasFacts:[]});continue}let Bt=Dl(_e,wt,new Set([re]),ne,{maxHops:2});if(!Bt)continue;let Qe=Bt.map(dn=>d.find(Kt=>Kt.predicate===Rr&&Kt.subject===dn.subject&&Kt.object===dn.object));Qe.every(Boolean)&&fe.push({fact:ce,aliasFacts:Qe})}return fe},{findReachableSet:Q}=await Promise.resolve().then(()=>(Es(),Dr)),ve=Q({entity:le,hop:0},V=>{let re=V.hop===0?oe:H;return Le(re).filter(fe=>fe.fact.subject===V.entity).map(fe=>({action:fe,nextState:{entity:fe.fact.object,hop:V.hop+1}}))},{maxDepth:20,stateKey:V=>V.entity});if(ve.length)return{text:ve.map(({node:re,path:fe})=>{let ce=new Set,wt=[];for(let Bt of fe.actions){wt.push(ae(Bt.fact));for(let Qe of Bt.aliasFacts){let dn=Qe.id||`${Qe.subject}|${Qe.predicate}|${Qe.object}`;ce.has(dn)||(ce.add(dn),wt.push(`${Ct(Qe)}${Qe.provenance?` (source: ${Qe.provenance})`:""}`))}}return`${re.entity} \u2014 ${wt.join("; ")}`}).join(`
183
+ `),replace:!0}}}return null}}let w=c.match(wg),v=c.match(ps)||Yl(c)||w&&`is ${w[1].trim()} a ${w[2].trim()}`.match(ps);if(v){let C=Y(l,Xt(v[2])),I=r&&qn.test(v[1].trim())?r:v[1],O=new Set(Y(l,I));if([...O].some(z=>C.has(z))){let z=Xt(v[2]).trim();return{text:`yes \u2014 ${Co(z)} ${z} is ${Co(z)} ${z}, trivially: every kind is a kind of itself.`,replace:!0}}let N=await Lj(o,I);if(N)for(let z of Y(l,N))O.add(z);let{findIsaChain:q,deriveDisjointViolations:U,SUBCLASS_PREDICATE:ie,TYPE_PREDICATE:se,DISJOINT_PREDICATE:X}=await Promise.resolve().then(()=>(Ft(),tn)),J=Gs,oe=m.filter(z=>z.predicate===ie&&J(z)),H=m.filter(z=>z.predicate===se&&J(z)),le=oe.map(z=>[z.subject,z.object]),ne=H.map(z=>[z.subject,z.object]),_e=m.filter(z=>z.predicate===ie),Le=m.filter(z=>z.predicate===se),Q=Le.map(z=>[z.subject,z.object]),xe=_e.map(z=>[z.subject,z.object]),ge=d.filter(z=>z.predicate===X&&J(z)),ve=ge.map(z=>[z.subject,z.object]),V=ge.length?U(Q.concat(xe),xe,ve,{budget:20,focus:new Set([...O,...C])}):[],re=z=>{let be=V.find(Ne=>Ne.subject===z&&C.has(Ne.object));if(!be)return null;let we=m.filter(Ne=>C.has(Ne.object)&&(Ne.subject===be.viaClass||Ne.subject===be.subject)).sort(p)[0],Ee=ge.find(Ne=>Ne.subject===be.viaClass&&Ne.object===be.object||Ne.subject===be.object&&Ne.object===be.viaClass);return!we||!Ee?null:GE(we,Ee)},fe=m.filter(z=>O.has(z.subject)&&C.has(z.object)).sort(p)[0],ce=d.filter(z=>z.predicate===fi&&O.has(z.subject)&&C.has(z.object)).sort(p)[0],wt=ge.find(z=>O.has(z.subject)&&C.has(z.object)||O.has(z.object)&&C.has(z.subject));if(fe&&!ce){let z=re(fe.subject);if(z)return z}let Bt=zg(fe,ce||wt);if(Bt)return Bt;if(ge.length){let z=Ee=>{let Ne=new Set(Ee),_t=new Set(Ee);for(let Te=0;Te<8&&_t.size;Te+=1){let ye=new Set;for(let[Ze,ms]of xe)_t.has(Ze)&&!Ne.has(ms)&&ye.add(ms);if(!ye.size)break;for(let Ze of ye)Ne.add(Ze);_t=ye}return Ne},be=z(C),we=V.find(Ee=>O.has(Ee.subject)&&be.has(Ee.object)&&!z([Ee.viaClass]).has(Ee.object)&&!z([Ee.object]).has(Ee.viaClass));if(we){let Ee=m.filter(ye=>O.has(ye.subject)&&ye.object===we.viaClass).sort(p)[0],Ne=ge.find(ye=>ye.subject===we.viaClass&&ye.object===we.object||ye.subject===we.object&&ye.object===we.viaClass),_t=!C.has(we.object),Te=_t?m.filter(ye=>C.has(ye.subject)&&ye.object===we.object).sort(p)[0]:null;if(Ee&&Ne&&(!_t||Te)){let ye=Xt(v[2]).trim();return{text:`no \u2014 ${[Ee,...Te?[Te]:[]].map(ae).join("; ")}; and ${Ct(Ne)}${Ne.provenance?` (source: ${Ne.provenance})`:""} \u2014 so ${I} can never be ${Co(ye)} ${ye}.`,replace:!0}}}}let Qe=await _r(o,I);if(Qe){let z=new Map;for(let we of Ji(o,Qe.id))for(let Ee of Y(l,we.label))!O.has(Ee)&&!z.has(Ee)&&z.set(Ee,we.label);let be=m.filter(we=>z.has(we.subject)&&C.has(we.object)).sort(p)[0];if(be)return{text:`yes \u2014 the code graph says ${Qe.label} inherits ${z.get(be.subject)}, and ${ae(be)}`,replace:!0}}let dn=z=>(z.predicate===ie?oe:H).find(be=>be.subject===z.subject&&be.object===z.object);for(let z of O){let be=q(z,C,ne,le,{maxHops:2});if(!be)continue;let we=re(z);if(we)return we;let Ee=be.map(dn);if(Ee.every(Boolean))return{text:`yes \u2014 ${Yi(Ee)}`,replace:!0}}let Kt=z=>(z.predicate===ie?_e:Le).find(be=>be.subject===z.subject&&be.object===z.object);for(let z of O){let be=q(z,C,Q,xe,{maxHops:2});if(!be)continue;let we=re(z);if(we)return we;let Ee=be.map(Kt);if(Ee.every(Boolean)&&Ee.some(J))return{text:`yes \u2014 ${Yi(Ee)}`,replace:!0}}let Ut=I.match(/^(.*\S)\s+not$/i),It=Ut&&[Ut[0],r&&qn.test(Ut[1].trim())?r:Ut[1]];if(It){let z=Y(l,It[1]),be=C,we=m.filter(Te=>z.has(Te.subject)&&be.has(Te.object)).sort(p)[0];if(we)return{text:`no \u2014 ${ae(we)}`,replace:!0};let Ee=ge.find(Te=>z.has(Te.subject)&&be.has(Te.object)||z.has(Te.object)&&be.has(Te.subject));if(Ee)return{text:`yes \u2014 ${ae(Ee)}`,replace:!0};let Ne=It[1].trim(),_t=Xt(v[2]).trim();return{text:`I can't confirm that either way \u2014 nothing I remember links ${Ne} and ${_t}. If no ${Ne} is a ${_t}, teach me: "no ${Ne} is a ${_t}".`,replace:!0,miss:!0}}if(ge.length){let z=U(ne.concat(le),le,ve,{budget:10});for(let be of O){let we=z.find(Te=>Te.subject===be&&C.has(Te.object));if(!we)continue;let Ee=H.concat(oe).find(Te=>Te.subject===we.subject&&Te.object===we.viaType),Ne=ge.find(Te=>Te.subject===we.viaClass&&Te.object===we.object||Te.subject===we.object&&Te.object===we.viaClass),_t=[Ee,Ne].filter(Boolean).map(ae);return{text:`no \u2014 ${_t.length?_t.join("; "):`${we.viaClass} and ${we.object} are disjoint.`}`,replace:!0}}}let{deriveSomeValuesFromApplication:Tr,ON_PROPERTY_PREDICATE:x,SOME_VALUES_FROM_PREDICATE:ue,deriveSomeValuesFromSubsumption:Re,ENTAILED_SCM_SVF_PROVENANCE:Sn,SCM_SVF_RULE_CONFIDENCE:Ys,entailedTrustFrom:au}=await Promise.resolve().then(()=>(Ft(),tn)),cu=d.filter(z=>z.predicate===x&&J(z)),lu=d.filter(z=>z.predicate===ue&&J(z));if(cu.length&&lu.length){let z=new Map(lu.map(ye=>[ye.subject,ye.object])),be=cu.map(ye=>({restriction:ye.subject,property:ye.object,target:z.get(ye.subject)})).filter(ye=>ye.target),we=new Set([ie,se,X,x,ue,"owl:intersectionOf"]),Ee=d.filter(ye=>J(ye)&&!we.has(ye.predicate)),Ne=Ee.map(ye=>[ye.subject,ye.predicate,ye.object]),_t=Tr(Ne,ne,le,be,{budget:10});for(let ye of O){let Ze=_t.find(rn=>rn.subject===ye&&C.has(rn.object));if(!Ze)continue;let ms=Ee.find(rn=>rn.subject===Ze.subject&&rn.predicate===Ze.viaProperty&&rn.object===Ze.viaValue),hs=H.find(rn=>rn.subject===Ze.viaValue&&rn.object===Ze.viaType),Oo=[ms,hs].filter(Boolean).map(ae);return{text:`yes \u2014 ${Oo.length?Oo.join("; "):`${Ze.subject} ${Ze.viaProperty} ${Ze.viaValue}, and ${Ze.viaValue} is a ${Ze.viaType}.`}`,replace:!0}}let Te=be.length>1?Re(be,le,{budget:10}):[];if(Te.length){let ye=le.concat(Te.map(ke=>[ke.subject,ke.object])),Ze=new Map(be.map(ke=>[ke.restriction,ke])),ms=new Map;for(let ke of d)ms.set(`${ke.subject}\0${ke.predicate}\0${ke.object}`,ke.trust);let hs=(ke,pn,Ot)=>ms.get(`${ke}\0${pn}\0${Ot}`),Oo=new Map;for(let ke of Te){let pn=Ze.get(ke.subject),Ot=Ze.get(ke.object),Wt=[pn&&hs(ke.subject,x,pn.property),hs(ke.subject,ue,ke.viaY1),Ot&&hs(ke.object,x,Ot.property),hs(ke.object,ue,ke.viaY2),hs(ke.viaY1,ie,ke.viaY2)].filter(pb=>typeof pb=="number"),Ir=au(Wt,Ys);Ir!==null&&Oo.set(`${ke.subject}\0${ke.object}`,Ir)}let rn=ke=>{if(ke.predicate!==ie)return H.find(Wt=>Wt.subject===ke.subject&&Wt.object===ke.object);let pn=oe.find(Wt=>Wt.subject===ke.subject&&Wt.object===ke.object);if(pn)return pn;let Ot=Te.find(Wt=>Wt.subject===ke.subject&&Wt.object===ke.object);return Ot?{subject:Ot.subject,predicate:ie,object:Ot.object,provenance:Sn,trust:Oo.get(`${Ot.subject}\0${Ot.object}`)}:void 0};for(let ke of O){let pn=q(ke,C,ne,ye,{maxHops:3});if(!pn)continue;let Ot=pn.map(rn);if(Ot.every(Boolean)){let Wt=au(Ot.map(Ir=>Ir.trust),1);return{text:`yes \u2014 ${Yi(Ot)}`,replace:!0,...Wt!==null?{trust:Wt}:{}}}}}}let ub=Y(l,I),uu=m.filter(z=>ub.has(z.subject)).sort(p),fs=I.trim(),Cr=Xt(v[2]).trim(),db=[...O].some(z=>q(z,C,ne,le,{maxHops:ZE}));if(uu.length){let z=uu.slice(0,3).map(ae).join("; "),be=db?`The facts to settle it are here, but the chain is longer than I follow while answering. Run "/syllogise ${fs}", then ask me again.`:`If it's true, teach me: "${fs} is a kind of ${Cr}".`;return{text:`I can't confirm that \u2014 nothing I remember says ${fs} is a ${Cr}. I do know: ${z}. ${be}`,replace:!0,miss:!0}}let du=m.filter(z=>O.has(z.object)&&C.has(z.subject)).sort(p)[0];return du?{text:`I can't confirm that \u2014 what I know runs the other way: ${ae(du)}. A kind doesn't reverse. If it's true, teach me: "every ${fs} is a ${Cr}".`,replace:!0,miss:!0}:!Qe&&!N&&!SE(fs)&&!d.some(z=>O.has(z.subject)||O.has(z.object))?{text:`I can't confirm that \u2014 I don't know "${fs}" at all yet. If it's true, teach me: "${fs} is a kind of ${Cr}".`,replace:!0,miss:!0}:null}let $=c.match(jj);if($){let[,C,I,O]=$,{SUBCLASS_PREDICATE:N,ON_PROPERTY_PREDICATE:q,buildCardinalityRestrictions:U,proveCardinalityAtLeast:ie,CARDINALITY_RULE_CONFIDENCE:se,entailedTrustFrom:X}=await Promise.resolve().then(()=>(Ft(),tn)),J=Gs,oe=m.filter(ne=>ne.predicate===N&&J(ne)).map(ne=>[ne.subject,ne.object]),H=d.filter(ne=>(ne.predicate===q||Eg.has(ne.predicate))&&J(ne)),le=U(H);if(le.length){let ne=Y(l,C.trim()),_e=Y(l,O.trim()),Le=Number(I),Q=bg(ne,_e,(xe,ge)=>ie(oe,le,xe,ge,Le,{}));if(Q){let xe=d.find(ce=>ce.predicate===N&&ce.subject===Q.viaClass&&ce.object===Q.viaRestriction),ge=xe?.provenance?` (source: ${xe.provenance})`:"",ve=Q.kind==="exactly"?"exactly":"at least",V=(ce,wt)=>`${ce}${wt===1?"":"s"}`,re=[xe?.trust,...H.filter(ce=>ce.subject===Q.viaRestriction).map(ce=>ce.trust),...Q.viaClass!==Q.subject?[m.find(ce=>ce.predicate===N&&ce.subject===Q.subject&&ce.object===Q.viaClass)?.trust]:[]].filter(ce=>typeof ce=="number"),fe=X(re,se);return{text:`yes \u2014 every ${Q.viaClass} has ${ve} ${Q.n} ${V(Q.object,Q.n)}${ge}, so at least ${Le} follows.`,replace:!0,...fe!==null?{trust:fe}:{}}}}}let k=c.match(_j);if(k){let[,C,I]=k,{SUBCLASS_PREDICATE:O,ON_PROPERTY_PREDICATE:N,buildCardinalityRestrictions:q,proveMaxCardinalityZeroDenial:U,CAX_MAXC0_RULE_CONFIDENCE:ie,entailedTrustFrom:se}=await Promise.resolve().then(()=>(Ft(),tn)),X=Gs,J=m.filter(le=>le.predicate===O&&X(le)).map(le=>[le.subject,le.object]),oe=d.filter(le=>(le.predicate===N||Eg.has(le.predicate))&&X(le)),H=q(oe);if(H.length){let le=Y(l,C.trim()),ne=Y(l,I.trim()),_e=bg(le,ne,(Le,Q)=>U(J,H,Le,Q,{}));if(_e){let Le=d.find(ve=>ve.predicate===O&&ve.subject===_e.viaClass&&ve.object===_e.viaRestriction),Q=Le?.provenance?` (source: ${Le.provenance})`:"",xe=[Le?.trust,...oe.filter(ve=>ve.subject===_e.viaRestriction).map(ve=>ve.trust),..._e.viaClass!==_e.subject?[m.find(ve=>ve.predicate===O&&ve.subject===_e.subject&&ve.object===_e.viaClass)?.trust]:[]].filter(ve=>typeof ve=="number"),ge=se(xe,ie);return{text:`no \u2014 every ${_e.viaClass} has at most 0 ${_e.object}${Q}.`,replace:!0,...ge!==null?{trust:ge}:{}}}}}let y=c.match(Rj);if(y){let C=Y(l,y[1]),I=d.filter(O=>O.predicate===Ml&&C.has(O.subject)).sort(p);return I.length?f(I):null}let j=u.match(Aj);if(j){let[,C,I]=j,O=Y(l,C.trim()),N=Y(l,I.replace(/^an?\s+/i,"").trim()),q=d.filter(U=>U.predicate===Ml&&N.has(U.subject)&&O.has(U.object)).sort(p)[0];return q?{text:`yes \u2014 ${ae(q)}`,replace:!0}:{text:`no \u2014 no remembered fact says ${C.trim().toLowerCase()} owns/maintains ${I.trim()}.`,replace:!0}}let E=u.match(Tj);if(E){let[,C,I]=E,O=Y(l,C.replace(/^an?\s+/i,"").trim()),N=Y(l,I.trim()),q=d.filter(U=>U.predicate===Ml&&O.has(U.subject)&&N.has(U.object)).sort(p)[0];return q?{text:`yes \u2014 ${ae(q)}`,replace:!0}:{text:`no \u2014 no remembered fact says ${C.trim().toLowerCase()} is owned by ${I.trim()}.`,replace:!0}}let _=u.match(Cj);if(_){let[,C,I]=_,O=Y(l,C.trim()),N=Y(l,`${I.trim()} method`),q=d.filter(U=>U.predicate===Fs&&O.has(U.subject)&&N.has(U.object)).sort(p)[0];return q?{text:`yes \u2014 ${ae(q)}`,replace:!0}:null}let R=u.match(Ij);if(R){let C=Y(l,R[1].trim()),I=d.filter(O=>O.predicate===Fs&&C.has(O.subject)&&/ method$/.test(O.object)).sort(p);return I.length?f(I):null}let S=u.match(jg);if(S){let C=S[1].trim(),I=Rg.test(C)||_g.test(C)?null:qn.test(C)?r||null:C,O=S[2].trim().toLowerCase();if(I){let N=Y(l,I),q=new Map,U=null;if(o){let H=await _r(o,I);if(U=H,H)for(let le of Ji(o,H.id))for(let ne of Y(l,le.label))!N.has(ne)&&!q.has(ne)&&q.set(ne,le.label),N.add(ne)}let ie=H=>H.predicate===Pl&&l(H.object)===O||H.predicate===`tmct:${O}`&&H.object==="true",se=l(I).split(/\s+/).filter(H=>H.length>=4&&!Bg.has(H)),X=H=>se.some(le=>new Set(String(H.subject||"").split(/\s+/)).has(le)),J=H=>N.has(H.subject)||se.length&&X(H),oe=d.filter(H=>J(H)&&ie(H)).sort(p)[0];if(oe){let H=q.get(oe.subject);return{text:H?`yes \u2014 the code graph says ${U.label} inherits ${H}, and ${ae(oe)}`:`yes \u2014 ${ae(oe)}`,replace:!0}}{let{findIsaChain:H,SUBCLASS_PREDICATE:le,TYPE_PREDICATE:ne}=await Promise.resolve().then(()=>(Ft(),tn)),_e=Gs,Le=d.filter(re=>re.predicate===le&&_e(re)),Q=d.filter(re=>re.predicate===ne&&_e(re)),xe=Le.map(re=>[re.subject,re.object]),ge=Q.map(re=>[re.subject,re.object]),ve=re=>(re.predicate===le?Le:Q).find(fe=>fe.subject===re.subject&&fe.object===re.object),V=Y(l,O);for(let re of N){let fe=H(re,V,ge,xe,{maxHops:2});if(!fe)continue;let ce=fe.map(ve);if(ce.every(Boolean))return{text:`yes \u2014 ${Yi(ce)}`,replace:!0}}}if(d.some(J)&&!n?.parsed)return{text:`I don't have a fact saying ${HE(I)} is ${O}.`,replace:!0};if(!n?.parsed&&!fg.test(O))return Ag(I,O)}}let A=Jl(c).match(IE);if(A&&!Bl.test(c)){let[,C,I,O]=A,N=I.toLowerCase();if(!zl.test(N)&&!Wl.test(N)){let q=C.trim(),U=NE(await Ul(N),O),ie=U.object.replace(/^an?\s+/i,"").trim();if(q&&ie){let se=U.predicate,X=Y(l,q),J=Y(l,ie),oe=[se,bo(se)],H=d.filter(ne=>oe.includes(ne.predicate)&&X.has(ne.subject)&&J.has(ne.object)).sort(p)[0];if(H)return{text:`${Sf(H.predicate)?"no":"yes"} \u2014 ${ae(H)}`,replace:!0,generalVerbQuery:!0};let le=d.filter(ne=>oe.includes(ne.predicate)&&X.has(ne.subject));if(le.length){let ne=le.slice(0,3).map(ae).join("; ");return{text:`I can't confirm that \u2014 nothing I remember says ${Ct({subject:q,predicate:se,object:ie})}. I do know: ${ne}.`,replace:!0,miss:!0}}return null}}}let M=c.match(OE);if(M&&!Bl.test(c)){let[,C,I]=M,[O,N]=I.toLowerCase().split(/\s+/);if(!zl.test(O)&&!Wl.test(O)){let q=C.trim();if(q){let U=await Ul(O);N&&/^mgx:[a-z]+$/.test(U)&&(U=`${U}-${N}`);let ie=Y(l,q),se=[U,bo(U)],X=Ye(d.filter(J=>se.includes(J.predicate)&&ie.has(J.subject)),i);if(X.length)return{...f(X),generalVerbQuery:!0}}}}let T=c.match(/^(?:what|who)\s+([a-z]+)\s+(on|in|at|onto|upon|under|over|beside|near|behind|above|below|inside|outside)\s+(.+?)[?.!\s]*$/i);if(T&&!Bl.test(c)){let[,C,I,O]=T,N=C.toLowerCase();if(!zl.test(N)&&!Wl.test(N)&&!CE.test(N)){let q=await Ul(N);/^mgx:[a-z]+$/.test(q)&&(q=`${q}-${I.toLowerCase()}`);let U=Y(l,O.replace(/^(?:an?|the)\s+/i,"").trim()),ie=Ye(d.filter(se=>se.predicate===q&&U.has(se.object)),i);if(ie.length)return{...f(ie),generalVerbQuery:!0}}}let P=c.match(Sj);if(P){let C=Y(l,P[1]),I=Ye(d.filter(se=>C.has(se.subject)||C.has(se.object)),i);if(!I.length)return null;let O=C.has(I[0].subject)?I[0].subject:I[0].object,N=I.map(se=>` ${ae(se)}`),q=N.slice(0,je),U=N.slice(je),ie=U.length?`
184
184
  \u2026and ${U.length} more \u2014 say 'more' to see them.`:"";return{text:`${I.length} remembered fact${I.length===1?"":"s"} about ${O}:
185
185
  ${q.join(`
186
186
  `)}${ie}`,replace:!0,...U.length?{pending:{items:U.map(se=>se.trim()),noun:"facts"}}:{}}}let G=n?.parsed?.shape==="meta"?n.parsed.object:null,K=!1,te=c.match(Ej);if(te)G=te[1],K=!0;else if(!G&&!n?.parsed){let C=c.match(/^what\s+(?:is|are)\s+(?:an?\s+)?(.+?)[?.!\s]*$/i);C&&(G=C[1])}if(!G)return null;let F=Y(l,G),D=Ye(m.filter(C=>F.has(C.subject)),i),B=Ye(m.filter(C=>F.has(C.object)),i),W=K?D.length?D:B:B.length?B:D;return W.length?f(W):null}var Zl,SE,on,Ki,ug,Tg,Pz,dg,EE,Fz,Dz,Cg,Ig,Og,jE,pg,zz,Bz,Uz,Wz,qz,tu,Gz,_E,qe,Ml,Pl,Rr,RE,Gs,Vz,Hz,Kz,Yz,Xz,Jz,Qz,Zz,eB,tB,nB,sB,oB,rB,iB,fg,AE,ea,TE,aB,cB,su,Lg,lB,uB,dB,zl,Bl,CE,pB,IE,OE,Wl,LE,ME,fB,Ng,Mg,PE,mB,hB,gB,bB,ou,wB,yB,vB,Pg,$B,xB,FE,kB,SB,EB,Vs,mg,ru,Ct,zE,UE,WE,Xi,KE,Bg,jB,Kl,Ug,YE,XE,Zi,JE,QE,ps,Gn,ZE,ej,tj,Xl,wg,nj,je,sj,oj,rj,ij,aj,cj,yg,lj,uj,dj,pj,fj,$g,qg,hj,gj,wj,yj,vj,$j,Sg,xj,Sj,Ej,jj,_j,Eg,Rj,Aj,Tj,Cj,Ij,jg,qn,_g,Rg,Ag,Oj,Nj,Mj,_B,Kg,Fj,RB,Vl,Ql,Dj,AB,TB,Yg,CB,IB,OB,LB,NB,ta,MB,PB,FB,DB,zj,zB,BB,Hi=L(()=>{De();th();Lt();Ce();os();Mi();Pi();Bo();gl();oh();Ge();Oc();wl();lh();An();Jn();io();Qr();fl();ml();Ho();Ro();za();Di();mh();hh();xl();gh();kl();bh();wh();qi();ll();zh();qh();Ao();rg();Zr(void 0);Jr(Ni);Zl=new Set(["it","this","that","here"]),SE=e=>Zl.has(String(e||"").trim().toLowerCase()),on={imports:"understand a dependency/import relationship",uses:"understand a dependency/usage relationship (imports and/or calls)",calls:"understand a call relationship",callsSymbol:"understand a call relationship",defines:"locate what a module/class defines",contains:"understand class membership (methods/attributes)",tests:"assess test coverage",inherits:"understand a class hierarchy/inheritance relationship",touches:"understand commit/change history",touchesSymbol:"understand commit/change history",cochange:"understand change-coupling between modules",reexports:"understand a module's public exports/API surface"},Ki=e=>e?`${String(e).toLowerCase()}(s)`:"entities",ug="look up a taught fact about a subject/verb/object";Tg={find:{tool:"tmct_search",arg:"query",help:"lexical search across the graph"},search:{tool:"tmct_search",arg:"query",help:"alias of /find"},context:{tool:"tmct_context",arg:"symbol",help:"the sized edit bundle for a symbol (start here to change code)"},snippet:{tool:"tmct_snippet",arg:"symbol",help:"exact source of one function/class/method"},describe:{tool:"tmct_describe",arg:"symbol",help:"a symbol's definition, kind and relations"},signature:{tool:"tmct_signature",arg:"symbol",help:"a symbol's signature only"},members:{tool:"tmct_members",arg:"class",help:"the methods/attributes of a class"},subclasses:{tool:"tmct_subclasses",arg:"class",help:"the subclasses of a class"},impact:{tool:"tmct_impact",arg:"module",help:"what a change to this module or symbol reaches (impact closure)"},callers:{tool:"tmct_callers",arg:"symbol",help:"functions that call this symbol"},callees:{tool:"tmct_callees",arg:"symbol",help:"functions this symbol calls"},tests:{tool:"tmct_tests_for",arg:"symbol",help:"the tests covering this symbol"},untested:{tool:"tmct_untested",arg:null,help:"symbols with no covering test"},history:{tool:"tmct_history",arg:"symbol",help:"the commit history of this symbol"},exports:{tool:"tmct_exports",arg:"module",help:"a module's public exports"},arch:{tool:"tmct_architecture",arg:"package",help:"the architecture overview (optional package filter)",optional:!0}},Pz=new Set(["stats","memory","focus",...Object.keys(Tg)]),dg={Class:["class","classes"],Function:["function","functions"],Module:["module","modules"],Package:["package","packages"],Method:["method","methods"],Attribute:["attribute","attributes"],GlobalVariable:["variable","variables"],Commit:["commit","commits"],Session:["session","sessions"]},EE=new Set(["have","has","holds","hold"]),Fz=new RegExp(`\\b(?:${[...Object.keys(de),...Object.keys(Hn)].filter(e=>!EE.has(e)).sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\b`,"i"),Dz=new Set([...eh.map(e=>e.name),...Object.values(Tg).map(e=>e.tool)]),Cg=new Set(["hi","hello","hey","yo","hiya","howdy","sup","greetings","g'day","gday","hey there","hi there","hello there","good morning","good afternoon","good evening","morning","alright","you alright","alright mate","morning all","yeah nah","hey y'all","howdy there","hiya there","good day","good day to you","salutations","good to meet you","pleased to meet you","yo yo","ayy","wassup","sup fam","heya","hiya!","gm","ge"]),Ig=new Set(["thanks","thank you","thankyou","thx","ty","ta","cheers","nice one","much appreciated","cool thanks","many thanks","much obliged","ta very much","cheers mate","cheers for that","tks","sweet thanks","nice","brilliant","ta for that","cheers, that's everything for now, thanks","that's everything for now, thanks","that's all for now, thanks"]),Og=new Set(["bye","goodbye","quit","exit","see ya","see you","cya","later","farewell","peace","peace out","im off","i'm off","gtg","gotta go","catch you later","farewell then"]),jE=new Set(["ok","okay","cool","aight","fair enough","got it","gotcha","noted","sounds good","sure","cool cool","right","haha ok fair enough"]),pg=e=>e.replace(/(.)\1+/g,"$1");zz=eu(Cg),Bz=eu(Ig),Uz=eu(Og),Wz=new RegExp(`^(?:${[...jE].map(He).join("|")})\\s+(.+)$`,"i"),qz=[...Cg,...Ig,...Og,"what can you do","what do you do","help","how do you work","who are you","what are you","what is your name"],tu="(?:[a-z]+er|better|worse|(?:more|less)\\s+[a-z]+)",Gz=new RegExp(`^(?:the\\s+|an?\\s+)?([\\w'-]+(?:\\s+[\\w'-]+)?)\\s+(?:is|are)\\s+(${tu})\\s+than\\s+(.+)$`,"i"),_E=new RegExp(`^(?:is|are)\\s+(.+?)\\s+(${tu})\\s+than\\s+(.+?)[?.!\\s]*$`,"i"),qe="on|in|at|onto|upon|under|over|beside|near|behind|above|below|inside|outside",Ml="mgx:ownedBy",Pl="mgx:hasProperty",Rr="rdfs:subClassOf",RE=new Set(["operator","teach","entailed"]),Gs=e=>!!e.sourceTypes?.some(t=>RE.has(t));Vz=new RegExp(`^you\\s+(?:can|may)\\s+([a-z]+)\\s+an?\\s+([a-z][\\w-]*)\\s+(${qe})\\s+an?\\s+([a-z][\\w-]*)[.!?]*$`,"i"),Hz=new RegExp(`^an?\\s+([a-z][\\w-]*)\\s+(?:can|may)\\s+be\\s+([a-z]+)\\s+(${qe})\\s+an?\\s+([a-z][\\w-]*)[.!?]*$`,"i"),Kz=new RegExp(`^to\\s+([a-z]+)\\s+an?\\s+([a-z][\\w-]*)\\s+(${qe})\\s+an?\\s+([a-z][\\w-]*)\\s*,?\\s*nothing\\s+may\\s+([a-z]+)\\s+(${qe})\\s+the\\s+([a-z][\\w-]*)[.!?]*$`,"i"),Yz=new RegExp(`^to\\s+([a-z]+)\\s+an?\\s+([a-z][\\w-]*)\\s+(${qe})\\s+an?\\s+([a-z][\\w-]*)\\s*,?\\s*the\\s+([a-z][\\w-]*)\\s+must\\s+be\\s+(${tu})\\s+than\\s+the\\s+([a-z][\\w-]*)[.!?]*$`,"i"),Xz=new RegExp(`^([a-z]+ing)\\s+an?\\s+([a-z][\\w-]*)\\s+(${qe})\\s+an?\\s+([a-z][\\w-]*)\\s+makes\\s+(?:it|the\\s+([a-z][\\w-]*))\\s+([a-z]+)\\s+(${qe})\\s+the\\s+([a-z][\\w-]*)[.!?]*$`,"i"),Jz=new RegExp(`^to\\s+([a-z]+)\\s+an?\\s+([a-z][\\w-]*)\\s+(${qe})\\s+an?\\s+([a-z][\\w-]*)\\s*,?\\s*the\\s+([a-z][\\w-]*)\\s+may\\s+not\\s+be\\s+with\\s+the\\s+([a-z][\\w-]*)\\s+without\\s+the\\s+([a-z][\\w-]*)[.!?]*$`,"i"),Qz=new RegExp(`^the\\s+goal\\s+is\\s+that\\s+(?:(every|each|all)\\s+)?([\\w-]+)\\s+([a-z]+s)\\s+(${qe})\\s+([\\w-]+)[.!?]*$`,"i"),Zz=new RegExp(`^(?:the\\s+goal\\s+is\\s+for|i\\s+want)\\s+(?:(every|each|all)\\s+)?([\\w-]+)\\s+to\\s+([a-z]+)\\s+(${qe})\\s+([\\w-]+)[.!?]*$`,"i"),eB=new RegExp(`^(?:the\\s+goal\\s+is\\s+for|i\\s+want)\\s+(?:(every|each|all)\\s+)?([\\w-]+)\\s+(${qe})\\s+([\\w-]+)[.!?]*$`,"i"),tB=new RegExp(`^(?:can|could)\\s+you\\s+([a-z]+)\\s+an?\\s+([a-z][\\w-]*)\\s+(${qe})\\s+an?\\s+([a-z][\\w-]*)[?.!]*$`,"i"),nB=new RegExp(`^(?:get|put|place|stack)\\s+(?:(every|each|all|both)\\s+)?(?:the\\s+)?([\\w-]+?)\\s+(${qe})\\s+([\\w-]+)[?.!]*$`,"i"),sB=new RegExp(`^the\\s+goal\\s+is\\s+(?:(every|each|all|both)\\s+)?(?:the\\s+)?([\\w-]+?)\\s+(${qe})\\s+([\\w-]+)[?.!]*$`,"i"),oB=new RegExp(`^(?:(every|each|all)\\s+)?([\\w-]+)\\s+([a-z]+s)\\s+(${qe})\\s+([\\w-]+)$`,"i"),rB=new RegExp(`^(?:what|who)\\s+([a-z']+)\\s+(${qe})\\s+(.+?)[?.!\\s]*$`,"i"),iB=new RegExp(`^what\\s+(?:does|do|is)\\s+([\\w-]+)\\s+([a-z]+)(?:\\s+(${qe}))?[?.!\\s]*$`,"i"),fg=/^(?:anywhere|everywhere|nowhere|somewhere)$/i,AE=new Set(["bus","gas","plus","minus","surplus","lens","bias","atlas","canvas","virus","bonus","campus","census","chorus","circus","focus","status","iris","genius","sinus","walrus","cactus","fungus","radius","nucleus","alias","crocus","abacus","syllabus","octopus","platypus"]);ea="(?:(?:usually|often|sometimes|rarely|always|typically|generally|occasionally|frequently|normally|regularly|commonly|mostly|currently|still|also|really|actually|closely|strongly|directly)\\s+)?",TE="(?:cannot|can't|can not|does not|doesn't|do not|don't|never)",aB=new RegExp(`^(.+?)\\s+(${TE})\\s+(.+)$`,"i"),cB=new RegExp(`^([\\w'-]+)\\s+${ea}([a-z]+)\\s+(.+?)[.!?]*$`,"i"),su="connected|related|associated|linked|based|derived|composed|made|used|known|located|found|involved|concerned",Lg="with|to|from|by|of|in|on|for|as|about|into",lB=new RegExp(`^(?:the\\s+|an?\\s+)?([\\w'-]+(?:\\s+[\\w'-]+)?)\\s+(?:is|are|was|were)\\s+${ea}(${su})\\s+(${Lg})\\s+(.+)$`,"i"),uB=new RegExp(`^(?:the\\s+|an?\\s+)?([\\w'-]+(?:\\s+[\\w'-]+)?)\\s+(is|are|was|were)\\s+(?:an?\\s+)?([\\w'-]+)\\s+(${su})\\s+(${Lg})\\s+(.+)$`,"i"),dB=new RegExp(`^(?:the\\s+|an?\\s+)([\\w'-]+(?:\\s+[\\w'-]+)?)\\s+([a-z]+)\\s+(${qe})\\s+(.+?)[.!?]*$`,"i"),zl=/^(?:is|are|am|owns|maintains)$/i,Bl=/\b(?:is|are|am|owns|maintains)\b/i,CE=new RegExp("^(?:i|me|you|he|him|she|her|it|we|us|they|them|my|your|his|its|our|their|mine|yours|hers|ours|theirs|this|that|these|those|a|an|the|every|each|all|some|any|no|both|either|neither|in|on|at|to|from|by|with|for|of|about|into|onto|over|under|near|before|after|during|through|up|down|off|out|above|below|between|among|against|without|within|along|across|behind|beyond|upon|toward|towards|per|and|but|or|if|because|although|though|while|when|since|unless|until|whether|so|nor|than|as|what|who|whom|whose|which|where|why|how)$","i"),pB=new RegExp(`^(?:${vs.filter(e=>!/\s/.test(e)).join("|")})$`,"i");IE=new RegExp(`^(?:does|did)\\s+([\\w'-]+)\\s+${ea}([a-z]+)\\s+(.+?)[?.!\\s]*$`,"i"),OE=new RegExp(`^what\\s+(?:does|did)\\s+([\\w'-]+)\\s+${ea}([a-z]+(?:\\s+(?:${qe}))?)[?.!\\s]*$`,"i"),Wl=/^(?:be|own|maintain)$/i,LE=new RegExp(`^(${qe})\\s+(.+)$`,"i");ME=["first","second","third","then","next","finally","later","meanwhile","afterward","afterwards"],fB=new RegExp(`^(?:${ME.join("|")})\\b\\s*,?\\s+`,"i"),Ng=Object.freeze(["you","i","it","they","he","she","we"]),Mg=Object.freeze(["you're","i'm","it's","they're","he's","she's","we're"]),PE=Object.freeze([...Mg,...Ng]),mB=new RegExp(`^(?:every\\s+|each\\s+|all\\s+|some\\s+|a few\\s+|a\\s+|an\\s+)?(${PE.join("|")})\\s+\\S+`,"i"),hB=new RegExp(`^(?:every\\s+|each\\s+|all\\s+|some\\s+|a few\\s+|a\\s+|an\\s+)?(?:(${Ng.join("|")})\\s+(?:is|are|am|was|were)|(${Mg.join("|")}))\\s+(?:an?\\s+)?[\\w'-]+[.!?]*$`,"i"),gB=new RegExp(`^([\\w-]+)\\s+([a-z]+)s\\s+(${qe})\\s+([\\w-]+)$`,"i"),bB=new RegExp(`^forget\\s+(?:that\\s+)?([\\w-]+)\\s+([a-z]+)s\\s+(${qe})\\s+([\\w-]+)$`,"i"),ou="(?:\\s+(?:exactly|really|actually|anyway))?",wB=new RegExp(`^what\\s+does\\s+(.+?)\\s+do${ou}\\??$`,"i"),yB=new RegExp(`^what\\s+(.+?)\\s+does${ou}\\??$`,"i"),vB=new RegExp(`^what(?:'s|s|\\s+is)\\s+(.+?)\\s+do${ou}\\??$`,"i"),Pg="([A-Za-z][\\w'.-]*(?:\\s+[A-Za-z][\\w'.-]*){0,3})",$B=new RegExp(`^who\\s+(?:is|was)\\s+${Pg}$`,"i"),xB=new RegExp(`^what\\s+(?:did|has)\\s+${Pg}\\s+(?:touch(?:ed)?|chang(?:e|ed)|work(?:ed)?\\s+on|commit(?:ted)?)$`,"i"),FE="(?:good|bad|clean|messy|ugly|nice|great|terrible|awful|solid|elegant|readable|maintainable|well[- ]written|well[- ]structured|spaghetti|ok|okay|decent|healthy)",kB=new RegExp(`^is\\s+(?:this|the)\\s+code(?:base)?\\s+(?:any\\s+)?${FE}\\b`,"i"),SB=new RegExp("^(?:what\\s+time\\s+is\\s+it(?:\\s+(?:now|right\\s+now))?|what(?:'s|s|\\s+is)\\s+the\\s+time(?:\\s+(?:now|right\\s+now))?|what\\s+day\\s+is\\s+it(?:\\s+today)?|what(?:'s|s|\\s+is)\\s+(?:the\\s+)?(?:day|date)(?:\\s+today)?|what(?:'s|s|\\s+is)\\s+today'?s\\s+date|what(?:'s|s|\\s+is)\\s+the\\s+weather(?:\\s+like)?(?:\\s+(?:today|outside))?|how'?s\\s+the\\s+weather(?:\\s+like)?(?:\\s+(?:today|outside))?)\\??$","i");EB=new Set([...Object.keys(de).flatMap(e=>e.split(/[\s-]+/)),...Yt,...an,"owns","maintains"].filter(e=>e.length>=3)),Vs={"rdfs:subClassOf":"is a kind of","mgxneg:subClassOf":"is not a kind of","rdf:type":"is a","owl:disjointWith":"is not a","mgx:partOf":"is part of","mgx:hasA":"has","mgx:usedFor":"is used for","mgx:capableOf":"can","mgx:atLocation":"is found in","mgx:causes":"causes","mgx:hasProperty":"is","mgx:madeOf":"is made of","mgx:receivesAction":"can be","mgx:createdBy":"is created by","mgx:mannerOf":"is a way to","mgx:desires":"wants","mgx:locatedNear":"is typically near","mgx:motivatedByGoal":"is motivated by","mgx:obstructedBy":"can be prevented by","mgx:causesDesire":"makes you want to","mgx:hasSubevent":"involves","mgx:hasFirstSubevent":"begins with","mgx:hasLastSubevent":"ends with","mgx:hasPrerequisite":"requires","mgx:ownedBy":"is owned by","mgx:rendersAs":"renders as","mgx:synonym":"means the same as","mgx:antonym":"is the opposite of","mgx:similarTo":"is similar to","mgx:relatedTo":"is related to","mgx:symbolOf":"is a symbol of","mgx:currently-in":"is in","mgx:located-in":"is in","mgx:fixed-in":"is fixed in","mgx:stands-locked-in":"stands locked in","mgx:works-in":"works in"},mg=new Set(["mgx:hidden-in","mgx:is-objective","mgx:unlocks-with","mgx:is-npc","mgx:acts-on-turn","mgx:acts-toward","mgx:is-container","mgx:is-open"]),ru=new Set(["mgx:currently-in","mgx:located-in","mgx:fixed-in","mgx:stands-locked-in","mgx:works-in"]);Ct=e=>`${e.subject} ${Dg(e.predicate)} ${e.object}`;zE=Object.entries(Vs).filter(([e])=>!ru.has(e)).map(([e,t])=>{let n=/^(?:is|are)\s+(.+)$/i.exec(t);return n?{predicate:e,marker:n[1].trim().toLowerCase()}:null}).filter(e=>e&&e.marker.length>1).sort((e,t)=>t.marker.length-e.marker.length);UE=/ \(source: [^)]*\)$/;WE=8;Xi=null;KE=/^(?:every|each|all|any)\s+/i;Bg=new Set(["module","modules","class","classes","function","functions","method","methods","handler","handlers","controller","controllers","service","services","component","components","flow","flows","thing","things","item","items","object","objects","commit","commits"]),jB=new Set([["interpreter","compiler"],["string","thread"],["heart","kernel"],["battalion","heap"],["bash","sock"],["command","skill"],["docker","longshoreman"],["name","list"],["list","number"]].map(([e,t])=>[e,t].sort().join("|"))),Kl=/^(?:is|are|was|were)\s+([\w'-]+(?:\s+[A-Z][\w'-]*)?)\s+(?:the|an?)\s+([a-z][\w-]*)\s+of\s+([\w'-]+(?:\s+[A-Z][\w'-]*)?)[?.!\s]*$/i,Ug=/^(?:who|what)\s+(?:is|are)\s+(?:the|an?)\s+([a-z][\w-]*)\s+of\s+([\w'-]+(?:\s+[A-Z][\w'-]*)?)[?.!\s]*$/i,YE=/^(?:who|what)\s+(?:is|are|was|were)\s+([\w-]+(?:\s+[A-Z][\w-]*)?)'s\s+([a-z][\w-]*)[?.!\s]*$/i,XE=/^(who|what)'?s\s+/i,Zi=e=>String(e).replace(XE,(t,n)=>`${n} is `),JE=/^(?:who|what)\s+(?:is|are|was|were)\s+([\w-]{2,}?)s\s+([a-z][\w-]*)[?.!\s]*$/i;QE=/^list\s+(?:the\s+|all\s+)?([a-z][\w-]*)\s+of\s+([\w'-]+(?:\s+[A-Z][\w'-]*)?)[?.!\s]*$/i,ps=/^(?:is|are)\s+(?:an?\s+)?(.+?)\s+(?:a\s+kind\s+of|a\s+type\s+of|an?)\s+(.+?)[?.!\s]*$/i,Gn=new Set(["rdfs:subClassOf","rdf:type"]),ZE=6,ej=/^why\s+(?=(?:is|are)\b)/i,tj=/^explain\s+how\s+you\s+know\s+(?:that\s+)?(.+?)\s+(?:is|are)\s+(?:an?\s+)?(.+?)[?.!\s]*$/i;Xl=new Set(["kind","sort","type","subclass","superclass"]),wg=/^(?:so\s+)?(.+?)\s+(?:is|are)\s+(?:an?\s+)?(.+?)\s*,?\s*(?:now\s+)?(?:right|correct|yeah)\??$/i,nj=/^(?:what\s+do\s+you\s+know\s+about|what(?:'s|s|\s+is)\s+in\s+your\s+memory\s+about|what\s+do\s+you\s+remember\s+about)\s+(.+?)[?.!\s]*$/i,je=32,sj=/^(?:can|could)\s+(all\s+|every\s+)?(?:an?\s+)?([\w'-]+(?:\s+[\w'-]+)*?)\s+([a-z]+)[?.!\s]*$/i,oj=/^(?:does|do)\s+(?:an?\s+|the\s+)?(.+?)\s+have\s+(?:an?\s+|the\s+)?(.+?)[?.!\s]*$/i,rj=/^what\s+can\s+(?:an?\s+)?(.+?)\s+do[?.!\s]*$/i,ij=/^what\s+has\s+(?:an?\s+)?(.+?)[?.!\s]*$/i,aj=/^what\s+(?:(?:can\s+be|is)\s+used\s+for|is\s+for)\s+(.+?)[?.!\s]*$/i,cj=/^where(?:'s|\s+is|\s+are)\s+(.+?)(?:\s+now)?\s*[?.!]*$/i,yg=/^mgx:[a-z]+-(?:on|in|at|inside|under|below|above|near|beside|behind|by)$/,lj=new RegExp(`^what(?:'s|\\s+is|\\s+are)\\s+(${qe})\\s+(.+?)\\s*[?.!]*$`,"i"),uj=/^(?:do|does)\s+(all\s+|every\s+)?(?:an?\s+|the\s+)?([\w'-]+(?:\s+[\w'-]+)*?)\s+([a-z-]+)[?.!\s]*$/i,dj=/^what\s+can\s+(?!be\s)(.+?)[?.!\s]*$/i,pj=/^what\s+(?:cannot|can't|cant|can\s+not)\s+(.+?)[?.!\s]*$/i,fj=/^(?:which|what)\s+([\w'-]+(?:\s+[\w'-]+)*?)\s+can\s+(.+?)[?.!\s]*$/i;$g=e=>String(e||"").replace(/\s+/g," ").trim();qg="(?:most|least)\\s+[a-z][\\w-]*|[a-z][\\w-]*est|best|worst",hj=new RegExp(`^which\\s+([\\w'-]+)\\s+(?:is|are)\\s+(?:the\\s+)?(${qg})[?.!\\s]*$`,"i"),gj=new RegExp(`^what(?:'s|s|\\s+is)\\s+the\\s+(${qg})\\s+([\\w'-]+)[?.!\\s]*$`,"i");wj=new Set(["rdfs:subClassOf","rdf:type","mgx:hasA","mgx:capableOf","mgx:usedFor","mgx:ownedBy","owl:disjointWith","mgx:hasProperty","mgx:receivesAction"]),yj=Object.entries(Vs).filter(([e])=>!wj.has(e)&&!ru.has(e)).map(([e,t])=>({predicate:e,re:new RegExp(`^what\\s+${He(t)}\\s+(.+?)[?.!\\s]*$`,"i")})).sort((e,t)=>t.re.source.length-e.re.source.length),vj=new Set(["rdfs:subClassOf","rdf:type","owl:disjointWith","mgx:hasProperty","mgx:hasA","mgx:capableOf","mgx:ownedBy"]),$j=Object.entries(Vs).filter(([e])=>!vj.has(e)&&!ru.has(e)).map(([e,t])=>{let n;if(t==="can be")n=new RegExp("^can\\s+(?:an?\\s+|the\\s+)?(.+?)\\s+be\\s+(.+?)[?.!\\s]*$","i");else if(t.startsWith("is ")){let s=He(t.slice(3));n=new RegExp(`^(?:is|are)\\s+(?:an?\\s+|the\\s+)?(.+?)\\s+${s}\\s+(?:an?\\s+|the\\s+)?(.+?)[?.!\\s]*$`,"i")}else{let[s,...o]=t.split(" "),r=[Fg(s),...o].map(He).join("\\s+");n=new RegExp(`^(?:does|do)\\s+(?:an?\\s+|the\\s+)?(.+?)\\s+${r}\\s+(?:an?\\s+|the\\s+)?(.+?)[?.!\\s]*$`,"i")}return{predicate:e,phrase:t,re:n}}).sort((e,t)=>t.re.source.length-e.re.source.length),Sg=/^what\s+(?:inherits?\s+(?:from\s+)?(?:an?\s+)?|is\s+(?:an?\s+)?(?:kind|sort|type)\s+of\s+|is\s+(?:an?\s+)?subclass\s+of\s+)(.+?)[?.!\s]*$/i,xj=new Set(["changed","change","changes","updated","modified","happened","occurred"]);Sj=/^what\s+(?:did|have)\s+(?:i|we|you)\s+(?:told|tell|said|say)\s+(?:you|me|us)?\s*about\s+(.+?)[?.!\s]*$/i,Ej=/^what\s+kind\s+of\s+(?:thing|class|type|category|entity)?\s*(?:is|are)\s+(?:an?\s+)?(.+?)[?.!\s]*$/i,jj=/^does\s+every\s+(.+?)\s+have\s+at\s+least\s+(\d+)\s+(.+?)[?.!\s]*$/i,_j=/^does\s+an?\s+(.+?)\s+have\s+an?\s+(.+?)[?.!\s]*$/i,Eg=new Set(["owl:cardinality","owl:minCardinality","owl:maxCardinality","owl:onClass"]),Rj=/^who\s+(?:owns|maintains)\s+(.+?)[?.!\s]*$/i,Aj=/^(?:does|did)\s+([\w'-]+)\s+(?:owns?|maintains?)\s+(.+?)[?.!\s]*$/i,Tj=/^(?:is|are|was|were)\s+(.+?)\s+owned\s+by\s+([A-Za-z][\w'-]*(?:\s+[A-Z][\w'-]*)?)[?.!\s]*$/i,Cj=/^(?:does|did)\s+([\w'-]+)\s+(?:has|have)\s+an?\s+([a-z][\w-]*)\s+method[?.!\s]*$/i,Ij=/^what\s+methods\s+does\s+([\w'-]+)\s+have[?.!\s]*$/i,jg=/^(?:is|are|was|were)\s+(.+?)\s+([A-Za-z][\w-]*)[?.!\s]*$/i,qn=/^(?:it|this|that)$/i,_g=/^(?:it|this|that)(?:\s+one)?\s+(?:before|after)\b/i,Rg=/^(?:you|i|they|he|she|we)\b/i,Ag=(e,t)=>({text:`I don't know anything about "${e}" yet \u2014 teach me directly, e.g. "remember that ${Qi(e)} is ${t}".`,replace:!0}),Oj=/^(?:what\s+(?:did|have)\s+(?:i|we)\s+(?:told?|tell|said?|say)\s+(?:you|me|us)?(?:\s+(?:last\s+time|before|earlier|previously|already))?|what\s+facts?\s+do\s+you\s+(?:know|have|remember)|what\s+do\s+you\s+(?:know|remember)|what\s+have\s+you\s+(?:learned|learnt|remembered))[?.!\s]*$/i;Nj=/inherit|supertype|subclass|extend|specializ/i,Mj=8;_B=new RegExp(`\\b(?:${[...Zl].join("|")})\\b`,"i"),Kg=/^what\s+(?:is|are)\s+(?:an?\s+)?(.+?)[?.!\s]*$/i,Fj=/^who\s+(?:is|are|was|were)\s+(?:an?\s+|the\s+)?([\w'-]+)[?.!\s]*$/i,RB=new RegExp(`^(?:(?:the|a|an)\\s+)?(.+?)\\s+(${Object.keys(Be).join("|")})$`,"i"),Vl="(?:(?:can|could|would)\\s+you\\s+(?:please\\s+)?)?(?:(?:show|give)\\s+(?:me|us)\\s+|describe\\s+|explain\\s+|what(?:'s|s|\\s+is)\\s+)?",Ql="(?:of|for)\\s+(?:this|the)\\s+(?:app|codebase|repo|repository|project|code)",Dj=`(?:\\s+${Ql})?`,AB=[new RegExp(`^${Vl}the\\s+architecture(?:\\s+(?:overview|map|diagram))?${Dj}(?:\\s+here)?\\??$`,"i"),new RegExp(`^${Vl}architecture\\s+(?:${Ql}|overview|map|diagram)\\??$`,"i"),new RegExp(`^${Vl}(?:(?:an?|the)\\s+)?(?:overview|map|diagram)\\s+${Ql}(?:\\s+here)?\\??$`,"i")],TB={find:"locate a specific named entity",search:"locate a specific named entity",context:"gather the sized edit bundle for a symbol before changing code",snippet:"view a symbol's exact source",describe:"look up a symbol's definition and relations",signature:"view a symbol's signature",members:on.contains,subclasses:on.inherits,impact:"understand what a change to this module would reach (impact closure)",callers:on.calls,callees:on.calls,tests:on.tests,untested:on.tests,history:on.touches,exports:on.reexports,arch:"understand the overall architecture (package/module boundaries)",capabilities:"see what /plan can plan over \u2014 built-in query tools and taught actions",syllogise:"materialize the entailed facts that follow from what's remembered about one term",wiki:"toggle the live Wikipedia supplement for questions nothing local can answer",export:"write the memory store to a file, in the standard JSONL shape",ingest:"read a local text file and store every fact the recognizer grounds from it"},Yg="(?:changed?|modif(?:y|ied)|edits?|edited|touch(?:es|ed)?|updates?|updated|alters?|altered|deletes?|deleted|removes?|removed|drops?|dropped)",CB=new RegExp(`^what\\s+(?:would|will|might|could|does|do)?\\s*(?:breaks?|fails?|happens?|stops?\\s+working|is\\s+affected|are\\s+affected|gets?\\s+affected|be\\s+affected|is\\s+impacted|be\\s+impacted)\\s+if\\s+(?:i|we|you|one|someone)\\s+${Yg}\\s+(?:the\\s+)?(.+?)[?.!\\s]*$`,"i"),IB=new RegExp(`^if\\s+(?:i|we|you|one|someone)\\s+${Yg}\\s+(?:the\\s+)?(.+?),?\\s+what\\s+(?:would\\s+|will\\s+|might\\s+|could\\s+|does\\s+|do\\s+)?(?:breaks?|fails?|happens?|stops?\\s+working|is\\s+affected|are\\s+affected|gets?\\s+affected|be\\s+affected|would\\s+break|will\\s+break)[?.!\\s]*$`,"i"),OB=new RegExp("^what\\s+(?:is|are|gets?|would\\s+be|will\\s+be)\\s+(?:affected|impacted|broken)\\s+(?:by|when|if)\\s+(?:i\\s+|we\\s+|you\\s+)?(?:chang(?:e|es|ing)|edit(?:s|ing)?|modif(?:y|ies|ying)|touch(?:es|ing)?|updat(?:e|es|ing)|delet(?:e|es|ing)|remov(?:e|es|ing)|a\\s+change\\s+to)\\s+(?:the\\s+)?(.+?)[?.!\\s]*$","i"),LB=new RegExp("^(?:(?:can|could)\\s+(?:i|we|you|one|someone)\\s+safely|is\\s+it\\s+safe\\s+to)\\s+(?:change|edit|modify|touch|update|alter|delete|remove|drop)\\s+(?:the\\s+)?(.+?)[?.!\\s]*$","i"),NB=new RegExp("^(?:what(?:'s|\\s+is)\\s+the\\s+)?(?:blast\\s+radius|impact)\\s+(?:of|for)\\s+(?:chang(?:ing|es)\\s+|editing\\s+|modifying\\s+|touching\\s+|updating\\s+|deleting\\s+|removing\\s+)?(?:the\\s+)?(.+?)[?.!\\s]*$","i"),ta="as\\s+(?:its|the|an?)?\\s*(?:base\\s+class|parent\\s+class|base|parent)",MB=new RegExp(`^(.+?)\\s+uses?\\s+(?:which\\s+[\\w'-]+|what)\\s+${ta}\\s*\\??$`,"i"),PB=new RegExp(`^what\\s+(?:does|do|did)\\s+(.+?)\\s+uses?\\s+${ta}\\s*\\??$`,"i"),FB=new RegExp(`^(?:does|do|did)\\s+(.+?)\\s+uses?\\s+(.+?)\\s+${ta}\\s*\\??$`,"i"),DB=new RegExp(`^(.+?)\\s+uses?\\s+(.+?)\\s+${ta}\\s*[.!]*$`,"i"),zj=Object.freeze([...Zl].filter(e=>e!=="here").concat("they")),zB=new RegExp(`^((?:is|are|can|could|does|do)\\s+|what\\s+(?:is|are)\\s+)(${zj.join("|")})\\b(\\s+\\S.*)?$`,"i"),BB=Z(".tmct","memory","corpus-seed.json")});Hi();Ge();ks();qi();var na={uninformativeClassMaxShare:.35,uninformativeClassMinSubjects:12,entailedDepthPenalty:.2,minoritySensePenalty:.5,minScore:.05,groupSplitThreshold:4,openerConceptCount:2,maxObjectsPerBodySentence:4,maxBodySentences:4,closerRootCount:2,budget:{chatReply:5,researchPanel:10,cliDigest:12,ledgerTerm:8}};var Qg=Object.freeze({"rdfs:subClassOf":"isa","rdf:type":"isa","mgx:atLocation":"location","mgx:locatedNear":"location","mgx:partOf":"partOf","mgx:capableOf":"capableOf","mgx:usedFor":"usedFor"}),Hs=Object.freeze(["isa","location","partOf","capableOf","usedFor","other"]),sa=e=>Qg[e]||"other",Uj=e=>Math.max(0,Math.min(1,e));function Xg(e){let t=(e.sourceTypes||[]).map(n=>Wo[n]??0);return t.length?Math.max(...t):typeof e.trust=="number"&&e.trust>0?e.trust:Wo.entailed}function Wj(e){return Array.isArray(e.environments)&&e.environments.length?!0:(e.sourceTypes||[]).includes("entailed")}function Jg(e,t){let n=Number(t?.totalSubjects)||0;return n<=0?0:(Number(t?.classSubjectCounts?.[e])||0)/n}function Zg(e,t,n={},s={}){let o={...na,...s.config||{}},r=Number.isInteger(s.budget)?s.budget:o.budget.chatReply,i=(t||[]).filter(y=>y&&y.object&&y.object!==e),a=[],l=(Number(n?.totalSubjects)||0)>=o.uninformativeClassMinSubjects,c=[];for(let y of i){if(sa(y.predicate)==="isa"){let j=Jg(y.object,n);if(l&&j>o.uninformativeClassMaxShare){a.push({row:y,family:"isa",reason:"uninformative-class",share:j});continue}}c.push(y)}let u=c.filter(y=>sa(y.predicate)==="isa").map(y=>y.object),d=Wi(u,{subClassEdges:n.subClassEdges||[],disjointEdges:n.disjointEdges||[]}),m=new Map,p=new Map;for(let y of d.clusters){let j=0;for(let E of y.objects){p.set(E,y.label);let _=c.find(R=>R.object===E&&sa(R.predicate)==="isa");j+=_?Xg(_):0}m.set(y.label,j)}let f=null,g=-1;for(let[y,j]of[...m].sort((E,_)=>E[0].localeCompare(_[0])))j>g&&(g=j,f=y);let h=[];for(let y of c){let j=sa(y.predicate),E=Xg(y),_={provenance:E};if(Wj(y)&&(E-=o.entailedDepthPenalty,_.entailed=!0),j==="isa"){let S=.6+.4*(1-Jg(y.object,n));E*=S,_.informativeness=S;let A=p.get(y.object);f&&A&&A!==f&&(E-=o.minoritySensePenalty,_.minoritySense=A)}E=Uj(E),h.push({row:y,family:j,score:E,reasons:_})}let b=[];for(let y of h)y.score<o.minScore?a.push({row:y.row,family:y.family,reason:"below-floor",score:y.score}):b.push(y);let w=new Map;for(let y of b)w.has(y.family)||w.set(y.family,[]),w.get(y.family).push(y);for(let y of w.values())y.sort((j,E)=>E.score-j.score||j.row.object.localeCompare(E.row.object));let v=Hs.filter(y=>w.has(y)).concat([...w.keys()].filter(y=>!Hs.includes(y)).sort()),$=[],k=!1;for(;$.length<r&&!k;){k=!0;for(let y of v){let j=w.get(y);if(j&&j.length&&($.push(j.shift()),k=!1,$.length>=r))break}}for(let y of v)for(let j of w.get(y)||[])a.push({row:j.row,family:j.family,reason:"over-budget",score:j.score});return $.sort((y,j)=>{let E=Hs.indexOf(y.family),_=Hs.indexOf(j.family);return E-_||j.score-y.score||y.row.object.localeCompare(j.row.object)}),{term:e,selected:$,cut:a,senses:{split:d.split,clusters:d.clusters,dominantLabel:f}}}var qj=/^[aeiou]/i;function oa(e){return qj.test(String(e||"").trim())?"an":"a"}function ra(e){let t=String(e||"").trim();return t&&(/(?:s|x|z|ch|sh)$/.test(t)?`${t}es`:/[^aeiou]y$/.test(t)?`${t.slice(0,-1)}ies`:`${t}s`)}function Io(e){let t=String(e||"");return t&&t[0].toUpperCase()+t.slice(1)}function Ar(e){let t=(e||[]).map(n=>String(n||"").trim()).filter(Boolean);return t.length===0?"":t.length===1?t[0]:t.length===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[t.length-1]}`}en();var Gj=new Set(["isa","location","partOf","capableOf","usedFor"]),Vj=new Set(["single","several","chained","group","closer"]),eb=(e,t)=>`${e}:${t}`;function iu(e){let t=new Map;for(let n of e||[]){if(!n||typeof n.family!="string"||!Gj.has(n.family)||typeof n.form!="string"||!Vj.has(n.form)||typeof n.template!="string"||!n.template.trim())continue;let s=eb(n.family,n.form);t.has(s)||t.set(s,{family:n.family,form:n.form,templates:[]});let o=t.get(s);o.templates.includes(n.template)||o.templates.push(n.template)}return t}var Ks=e=>`${oa(e)} ${e}`;function Hj(e){let t=(e||[]).map(o=>String(o||"").trim()).filter(Boolean);if(!t.length)return"";let n=Ks(t[0]),s=t.slice(1);return s.length?`${n}, and so ${Ar(s.map(Ks))}`:n}function Kj(e,t,n,s){let o=String(e||"").trim(),r=(t||[]).map(l=>String(l||"").trim()).filter(Boolean),i=r[0]||"",a=String(s||"").trim();return{TERM:o,TERM_CAP:Io(o),A_TERM:Ks(o),A_TERM_CAP:Io(Ks(o)),TERMS:ra(o),TERMS_CAP:Io(ra(o)),PRONOUN:"it",PRONOUN_CAP:"It",PARENT:a,A_PARENT:a?Ks(a):"",OBJECT:i,A_OBJECT:i?Ks(i):"",OBJECTS_A:Ar(r.map(Ks)),OBJECTS_PLURAL:Ar(r.map(ra)),OBJECTS_RAW:Ar(r),CHAIN:Hj(n&&n.length?n:r.slice(0,1))}}function Yj(e,t){return String(e).replace(/\{([A-Z_]+)\}/g,(n,s)=>s in t?t[s]:"").replace(/\s+/g," ").replace(/\s+([.,;])/g,"$1").trim()}function Vn(e,t,n,s={}){let o=(n||[]).filter(Boolean);if(!o.length)return null;let r=s.term??o[0].subject??"",i=s.form||(o.length>1?"several":"single"),a=e instanceof Map?e.get(eb(t,i)):null,l=a?a.templates:null;if(!l||!l.length)return null;let c=s.variantSeed??"",u=di(`${r}|${t}|${i}|${c}`)%l.length,d=s.objectsOverride||o.map(p=>p.object),m=Yj(l[u],Kj(r,d,s.chain,s.parent));return m?{text:m,rows:o,family:t,form:i}:null}var Xj=Hs.filter(e=>e!=="isa"&&e!=="other");function Jj(e){let t=new Map;for(let n of e||[])t.has(n.family)||t.set(n.family,[]),t.get(n.family).push(n.row);return t}function tb(e,t){let n=Math.max(1,Math.trunc(t)||1),s=[];for(let o=0;o<(e||[]).length;o+=n)s.push(e.slice(o,o+n));return s}function Qj(e,t){let n=l=>(t?.[l.object]||[])[1]||null,s=new Map;for(let l of e||[]){let c=n(l);c&&s.set(c,(s.get(c)||0)+1)}let o=new Map,r=[],i=[];for(let l of e||[]){let c=n(l);c&&s.get(c)>=2?(o.has(c)||(o.set(c,[]),r.push(c)),o.get(c).push(l)):i.push(l)}let a=r.map(l=>({parent:l,rows:o.get(l)}));return i.length&&a.push({parent:null,rows:i}),a}function Zj(e,t,n){let s=new Map,o=new Map;for(let l of t||[]){let c=e?.[l.object];if(!Array.isArray(c)||c.length<2)continue;let u=c[c.length-1];!u||u===l.object||(s.set(u,(s.get(u)||0)+1),o.has(u)||o.set(u,[]),o.get(u).push(l))}let r=[...s.keys()].sort((l,c)=>s.get(c)-s.get(l)||l.localeCompare(c)).slice(0,Math.max(0,n)),i=[],a=new Set;for(let l of r)for(let c of o.get(l)||[])a.has(c.id)||(a.add(c.id),i.push(c));return{roots:r,rows:i}}function e_(e,t,n,s,o){let r=[];if(!e.length)return r;if(e.length===1){let m=t[e[0].object],p=m&&m.length>1?"chained":"single",f=Vn(s,"isa",e,{term:n,form:p,chain:m});return f&&r.push({...f,role:"names-term",paragraph:"definition"}),r}if(e.length<=o.groupSplitThreshold){let m=Vn(s,"isa",e,{term:n,form:"several"});return m&&r.push({...m,role:"names-term",paragraph:"definition"}),r}let i=e.slice(0,o.openerConceptCount),a=e.slice(o.openerConceptCount),l=Vn(s,"isa",i,{term:n,form:i.length>1?"several":"single",variantSeed:n});l&&r.push({...l,role:"names-term",paragraph:"definition"});let c=[];for(let m of Qj(a,t))for(let p of tb(m.rows,o.maxObjectsPerBodySentence))c.push({parent:m.parent,rows:p});if(c.length>o.maxBodySentences){let m=c.slice(0,o.maxBodySentences),p=m[m.length-1];for(let f of c.slice(o.maxBodySentences))p.rows=p.rows.concat(f.rows);p.parent=null,c=m}for(let m of c){let p=m.parent?Vn(s,"isa",m.rows,{term:n,form:"group",parent:m.parent,variantSeed:m.parent}):Vn(s,"isa",m.rows,{term:n,form:"several",variantSeed:n});p&&r.push({...p,role:"describes-isa",paragraph:"definition"})}let{roots:u,rows:d}=Zj(t,e,o.closerRootCount);if(u.length){let m=Vn(s,"isa",d.length?d:e,{term:n,form:"closer",objectsOverride:u,variantSeed:n});m&&r.push({...m,role:"closes-isa",paragraph:"definition"})}return r}function t_(e,t){if(!e.length)return;let n=e[0];if(/\bnames-term\b/.test(n.role))return;let s=Io(`${oa(t)} ${t}`);n.text=n.text.replace(/^It\b/,s),n.role="names-term"}function n_(e,t){let n=[],s=null,o=null;for(let r of e)(!s||r.paragraph!==o||s.length>=t)&&(s=[],o=r.paragraph,n.push(s)),s.push(r);return n.map(r=>({sentences:r,text:r.map(i=>i.text).join(" ")}))}function nb(e,t,n={}){let s=e?.term||"",o=Number.isInteger(n.maxSentencesPerParagraph)?n.maxSentencesPerParagraph:3,r=n.chains||{},i={...na,...n.config||{}},a=Jj(e?.selected||[]),l=[];for(let u of e_(a.get("isa")||[],r,s,t,i))l.push(u);for(let u of Xj){let d=a.get(u);if(!(!d||!d.length))for(let m of tb(d,i.maxObjectsPerBodySentence)){let p=Vn(t,u,m,{term:s});p&&l.push({...p,role:"describes",paragraph:"description"})}}t_(l,s);let c=new Map;for(let u of l)for(let d of u.rows)c.has(d.id)||c.set(d.id,d);return{term:s,sentences:l,paragraphs:n_(l,o),provenanceRows:[...c.values()]}}var s_=e=>({subject:e.subject,predicate:e.predicate,object:e.object,sourceTypes:e.sourceTypes||[],provenance:e.provenance||""});function o_(e){let t=new Set,n=[];for(let s of e||[]){let o=s.provenance||(s.sourceTypes||[]).join(",");!o||t.has(o)||(t.add(o),n.push({provenance:s.provenance||"",sourceTypes:s.sourceTypes||[]}))}return n}var r_=Object.freeze({facts:"show the facts",chains:"show the chains"});function i_(e,t){let n=[...(e?.selected||[]).map(o=>o.row),...(e?.cut||[]).map(o=>o.row)].filter(Boolean),s=Object.entries(t||{}).filter(([,o])=>Array.isArray(o)&&o.length>1).map(([o,r])=>({object:o,chain:r}));return{escapes:r_,facts:n.map(s_),factCount:n.length,chains:s}}function sb(e,t,n={}){let s=t?.term||e?.term||"";return{kind:"term-article",term:s,headline:s,paragraphs:(t?.paragraphs||[]).map(o=>o.text).filter(Boolean),body:t?.paragraphs||[],sources:o_(t?.provenanceRows||[]),detail:i_(e,n.chains),provenanceRows:t?.provenanceRows||[]}}function ob(e,t,n={},s=new Map,o={}){let r=Zg(e,t,n,o),i=nb(r,s,o);return sb(r,i,o)}qi();var rb=new Set(["rdfs:subClassOf","rdf:type"]);function ib(e){let t=new Map,n=new Set,s=[],o=[];for(let i of e||[])!i||!i.predicate||(rb.has(i.predicate)?(n.add(i.subject),t.has(i.object)||t.set(i.object,new Set),t.get(i.object).add(i.subject),s.push([i.subject,i.object])):i.predicate==="owl:disjointWith"&&o.push([i.subject,i.object]));let r={};for(let[i,a]of t)r[i]=a.size;return{classSubjectCounts:r,totalSubjects:n.size,subClassEdges:s,disjointEdges:o}}function ab(e,t,n=6){let s=kr(e||[]),o={};for(let r of t||[]){if(r in o)continue;let i=Ui(r,s,{cap:n});i.length>1&&(o[r]=i)}return o}function cb(e){let t=[],n=new Set;for(let s of e||[])!s||!rb.has(s.predicate)||n.has(s.object)||(n.add(s.object),t.push(s.object));return t}Ge();Hi();function a_(e,t,n,s,o={}){let r=iu(s||[]);if(!r||r.size===0)return null;let i=t||[],a=ib(n||i),l=ab(a.subClassEdges,cb(i));return ob(e,i,a,r,{...o,chains:l})}function lb(e,t,n,s={}){let o=Dt(e||{individuals:[],objectProperties:[]}),r=Y(ee,t),i=o.filter(l=>r.has(l.subject));if(!i.length)return null;let a=a_(t,i,o,n,s);return c_(a)}function c_(e){if(!e||!Array.isArray(e.paragraphs)||!e.paragraphs.length)return null;let t=e.detail&&Array.isArray(e.detail.facts)?e.detail.facts:[];return{term:e.term||"",paragraphs:e.paragraphs.slice(),sources:[...new Set((e.sources||[]).map(n=>n.provenance).filter(Boolean))],facts:t,factCount:e.detail&&Number.isInteger(e.detail.factCount)?e.detail.factCount:t.length}}globalThis.tmctMemoryAsk={factAnswer:Gg,factReadBack:Hg,createInMemoryStore:Ri,normFactTerm:ee,digestTermFromPayloadBrowser:lb};})();