pando-ai 0.7.6 → 0.7.8

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,16 +1,16 @@
1
- import{c as gn,d as oe,e as B,f as dt}from"./chunk-WHHZYOEJ.mjs";import{a as fn}from"./chunk-RRIZV7YJ.mjs";var Z={getAbbrev(n,e="ts"){return n},getKindFromAbbrev(n,e="ts"){return n}};function Re(n){let e=`${n.sourceFile}#${n.sourceStart}-${n.sourceEnd}`,t=n.refKind??"",r=n.refName??"",i=n.targetFile??"",s=n.targetStart!=null&&n.targetEnd!=null?`#${n.targetStart}-${n.targetEnd}`:"",o=n.targetNodeId??"",l=`${e}:REF:${t}:${r}|${i}${s}|${o}`;return dt(l)}function pt(n){let e=[],t=new Set,r=i=>{!i?.name||t.has(i.name)||(t.add(i.name),e.push(i))};for(let i of n.exports??[])r(i);for(let i of n.explicitExports??[])r({name:i});for(let i of n.modulePublic??[])r({name:i});return e}function he(n,e,t){let r=new Date().toISOString();return{payload:{lang:n,fileRel:e,preDeleted:!1,exportRows:[],nodeRows:[],referenceRows:[],symbolMentionRows:[],importRows:[],importBindingRows:[],fileRow:[e,t?.mtime??null,t?.size??null,"failed",r],fts:null,fullyIndexed:!1},fileSize:t?.size,mtime:t?.mtime}}function ye(n){let{lang:e,fileRel:t,content:r,meta:i,preDeleted:s,parsed:o,resolveNodeId:l,exportKind:c,fullyIndexed:u}=n,m=[],p=o.nodes??[],C=p.map(a=>{let f=`${t}#${a.start}-${a.end}:${Z.getAbbrev(a.kind,e)}`;return(e==="c"||e==="cpp"||e==="java"||e==="clojure")&&a.name?`${f}:${a.name}`:f});for(let a=0;a<p.length;a+=1){let f=p[a],h=f.rawKind??f.kind,N=f.rawKindSource??"cli",g=f.containerRawKind??f.containerKind??null,y=f.containerRawKindSource??(g?"cli":null),E=f.scopeChain??null,P=Array.isArray(E)?JSON.stringify(E):typeof E=="string"?E:null,j=C[a],S=typeof f.parentIndex=="number"?C[f.parentIndex]??null:f.parentNodeId??null,x=f.metadata&&Object.keys(f.metadata).length?JSON.stringify(f.metadata):null;m.push([j,f.name,f.kind,h,N,f.semanticKind??null,f.start,f.end,typeof f.isExported=="number"?f.isExported:0,f.containerKind??null,g,y,typeof f.paramCount=="number"?f.paramCount:null,f.qualifiedName??null,P,f.symbolKey??null,x,S,f.role??null,typeof f.indexInParent=="number"?f.indexInParent:null,typeof f.depth=="number"?f.depth:0,typeof f.bodyStart=="number"?f.bodyStart:null,typeof f.bodyEnd=="number"?f.bodyEnd:null])}let I=[],K=new Set;for(let a of pt(o)){if(!a.name||K.has(a.name))continue;K.add(a.name);let f=a.nodeId??(l?l(a.name):null);I.push([t,a.name,f??null,a.isReexport?1:0,a.reexportFrom??null,a.reexportName??null,a.exportKind??c??"cli",a.targetSymbolKey??null])}let R=[],F=[],O=new Map,U=new Map;for(let a of m){let f=a[0]!=null?String(a[0]):null,h=a[13]!=null?String(a[13]):null,N=a[15]!=null?String(a[15]):null;f&&(h&&!O.has(h)&&O.set(h,f),N&&!U.has(N)&&U.set(N,f))}if(oe()&&e==="clojure"&&(o.references??[]).length>0){let a=Array.from(O.keys()).slice(0,10),f=Array.from(U.keys()).slice(0,10),h=(o.references??[]).slice(0,10).map(g=>g.containerQualifiedName),N={file:t,nodeCount:m.length,refCount:(o.references??[]).length,nodeQualifiedNames:a,nodeSymbolKeys:f,refContainers:h,qualifiedNameMapSize:O.size,symbolKeyMapSize:U.size};try{console.error("[CliPayload][CLOJURE-DEBUG] source_node_id lookup context",N)}catch{}}for(let a of o.references??[]){let f=a.targetNodeId??(l&&a.refName?l(a.refName):null),h=a.targetFile??(f?t:null),N=a.sourceNodeId??(a.containerQualifiedName?O.get(a.containerQualifiedName)??null:null)??(a.containerQualifiedName?U.get(a.containerQualifiedName)??null:null),g=Re({sourceFile:t,sourceStart:a.sourceStart,sourceEnd:a.sourceEnd,refKind:a.refKind,refName:a.refName,targetFile:h??null,targetStart:a.targetStart??null,targetEnd:a.targetEnd??null,targetNodeId:f??a.targetNodeId??null}),y=a.metadata&&Object.keys(a.metadata).length?JSON.stringify(a.metadata):null;R.push([g,t,N,a.refName??null,a.refKind,a.sourceStart,a.sourceEnd,f??a.targetNodeId??null,h??null,f||a.targetNodeId||a.targetFile?"resolved":"unresolved",a.receiverName??null,typeof a.arity=="number"?a.arity:null,a.containerQualifiedName??null,a.targetSymbolKey??null,a.confidence??null,y])}for(let a of o.symbolMentions??[]){let f=typeof a?.name=="string"?a.name.trim():"";if(!f)continue;let h=typeof a?.mentionKind=="string"&&a.mentionKind.trim().length>0?a.mentionKind.trim():"reference",N=typeof a?.count=="number"&&Number.isFinite(a.count)&&a.count>0?Math.floor(a.count):1;F.push([f,h,a.targetSymbolKey??null,a.containerQualifiedName??null,N])}if(oe()&&e==="clojure"&&R.length>0){let a=R.reduce((h,N)=>h+(N?.[2]!=null?1:0),0),f=R.reduce((h,N)=>h+(N?.[12]!=null?1:0),0);try{console.error("[CliPayload] clojure source-node summary",{file:t,refs:R.length,sourceNodeCount:a,containerCount:f,sample:R.slice(0,5).map(h=>({sourceNodeId:h[2]==null?null:String(h[2]),refName:h[3],refKind:h[4],containerQualifiedName:h[12]}))})}catch{}}let z=[];for(let a of o.imports??[])z.push([t,a.module??null,a.isTypeOnly??0]);let V=[];for(let a of o.importBindings??[])V.push([t,a.module??null,a.kind,a.localName,a.importedName,a.isTypeOnly??0]);let fe=new Date().toISOString(),H=[t,i?.mtime??null,i?.size??null,"completed",fe,u?1:0];return{payload:{lang:e,fileRel:t,preDeleted:!!s,exportRows:I,nodeRows:m,referenceRows:R,symbolMentionRows:F,importRows:z,importBindingRows:V,fileRow:H,fts:typeof r=="string"?{blobOid:t,content:r}:null,fullyIndexed:!!u},fileSize:i?.size,mtime:i?.mtime}}var be=["ts","js","python","c","cpp","csharp","dart","java","clojure"];function Be(n){return typeof n=="string"&&be.includes(n)}gn();function mt(){let n=process.env.PANDO_ENABLED_LANGUAGES;if(n&&n.trim().length>0){let t=n.split(",").map(r=>r.trim()).filter(r=>r.length>0).filter(Be);if(t.length>0)return ft(t)}return[...be]}function ft(n){let e=new Set;for(let t of n)Be(t)&&e.add(t);return be.filter(t=>e.has(t))}function gt(n){let e=new Set(ft(n)),t={};for(let r of be){if(e.has(r)){t[r]={enabled:!0,source:"embedded"};continue}t[r]={enabled:!1,source:"none",reason:"disabled by language support config"}}return{byLanguage:t}}import Je from"path";import Nn from"fs";import{Project as Pn,Node as Q}from"ts-morph";import{Node as d,SyntaxKind as ae}from"ts-morph";import*as X from"typescript";import{SyntaxKind as xe}from"ts-morph";var $e={LINE_COMMENT:{kind:9001,name:"LineComment",triviaKind:xe.SingleLineCommentTrivia},BLOCK_COMMENT:{kind:9002,name:"BlockComment",triviaKind:xe.MultiLineCommentTrivia},JSDOC_COMMENT:{kind:9003,name:"JSDocComment",triviaKind:xe.MultiLineCommentTrivia}};function ht(n,e){return n===xe.SingleLineCommentTrivia?$e.LINE_COMMENT:n===xe.MultiLineCommentTrivia&&e.startsWith("/**")?$e.JSDOC_COMMENT:$e.BLOCK_COMMENT}import{Node as T}from"ts-morph";var yt={TS_MORPH:"ts-morph",PYTHON_AST:"python-ast",CLANG:"clang",ROSLYN:"roslyn",JAVA_AST:"java-ast",CLI:"cli",UNKNOWN:"unknown"},bt=(n,e)=>T.isFunctionDeclaration(n)||T.isFunctionExpression(n)||T.isArrowFunction(n)?{kind:"Function",semanticKind:"function"}:T.isGetAccessorDeclaration(n)||T.isSetAccessorDeclaration(n)?{kind:"Method",semanticKind:"property"}:T.isMethodDeclaration(n)||T.isMethodSignature(n)||T.isConstructorDeclaration(n)?{kind:"Method",semanticKind:"method"}:T.isClassDeclaration(n)||T.isClassExpression(n)?{kind:"Class",semanticKind:"class"}:T.isInterfaceDeclaration(n)?{kind:"Interface",semanticKind:"interface"}:T.isEnumDeclaration(n)?{kind:"Enum",semanticKind:"enum"}:T.isEnumMember(n)?{kind:"EnumMember",semanticKind:"enum"}:T.isTypeAliasDeclaration(n)?{kind:"TypeAlias",semanticKind:"type"}:T.isModuleDeclaration(n)?{kind:"Namespace",semanticKind:"namespace"}:T.isPropertyDeclaration(n)||T.isPropertySignature(n)?{kind:"Field",semanticKind:"property"}:T.isVariableDeclaration(n)?{kind:"Variable",semanticKind:"variable"}:{kind:e,semanticKind:null};function xt(n){try{let e=n.getKindName?.();if(typeof e=="string"&&e.trim())return e}catch{}return"Unknown"}function Ie(n){let e=xt(n),t=bt(n,e);return{kind:t.kind,semanticKind:t.semanticKind,rawKind:e,rawKindSource:yt.TS_MORPH}}function St(n){let e=xt(n);return{kind:bt(n,e).kind,rawKind:e,rawKindSource:yt.TS_MORPH}}function Ae(n,e){if(!n.kind||!n.kind.trim())throw new Error(`Invalid normalized kind: missing kind ${e?JSON.stringify(e):""}`);if(!n.rawKind||!n.rawKind.trim())throw new Error(`Invalid normalized kind: missing rawKind ${e?JSON.stringify(e):""}`);if(!n.rawKindSource||!String(n.rawKindSource).trim())throw new Error(`Invalid normalized kind: missing rawKindSource ${e?JSON.stringify(e):""}`)}function hn(n){if(n.kind==="local"){let r=n.isDefault?"default":n.name;return r?{name:r,priority:n.isDefault?4:3}:null}if(n.kind==="alias")return n.exported?{name:n.exported,priority:2}:null;let e=n.isNamespace??!1,t=n.alias||n.name||(e?"*":null);return t?{name:t,priority:e?0:1}:null}function yn(n){if(n.length<2)return n;let e=new Map;for(let t of n){let r=hn(t);if(!r)continue;let i=e.get(r.name);(!i||r.priority>i.priority)&&e.set(r.name,{record:t,priority:r.priority})}return Array.from(e.values()).map(t=>t.record)}function Se(n){try{if(n&&typeof n.getName=="function"){let e=n.getName();if(typeof e=="string"&&e.length>0)return e}}catch{}return null}function bn(n){try{let e=n?.getBody?.();if(!e||typeof e.getStart!="function"||typeof e.getEnd!="function")return null;let t=typeof e.getKindName=="function"?String(e.getKindName()):"",r=t==="Block"||t==="ModuleBlock",i=e.getStart(),s=e.getEnd(),o=r?i+1:i,l=r?s-1:s;return!Number.isFinite(o)||!Number.isFinite(l)||l<o?null:{start:o,end:l}}catch{return null}}function xn(n){let e=n.getParent?.();if(!e)return null;try{if(d.isIfStatement(e)){if(e.getExpression()===n)return"condition";if(e.getThenStatement()===n)return"then";if(e.getElseStatement()===n)return"else"}if(d.isReturnStatement(e)&&e.getExpression?.()===n)return"value";if(d.isVariableDeclaration(e)){if(e.getNameNode?.()===n)return"name";if(e.getInitializer?.()===n)return"initializer"}if(d.isCallExpression(e)||d.isNewExpression(e)){if(e.getExpression?.()===n)return"callee";if((e.getArguments?.()??[]).indexOf(n)>=0)return"argument"}if(d.isPropertyAccessExpression(e)){if(e.getExpression()===n)return"object";if(e.getNameNode()===n)return"property"}}catch{return null}return null}function ze(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}function Sn(n){try{if(d.isFunctionDeclaration(n)||d.isMethodDeclaration(n)||d.isConstructorDeclaration(n)||d.isFunctionExpression(n)||d.isArrowFunction(n)){let e=n.getParameters?.();if(Array.isArray(e))return e.length}}catch{}return null}function Cn(n){try{return d.isIdentifier(n)?n.getSymbol():d.isPropertyAccessExpression(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol?.()}catch{return}}function ke(n,e){try{return typeof n?.hasModifier=="function"&&n.hasModifier(e)}catch{return!1}}function Ct(n){try{return n.getModuleSpecifierValue?.()??null}catch{try{return n.getModuleSpecifier?.()?.getLiteralText?.()??null}catch{return null}}}function vn(n,e,t){if(!d.isImportDeclaration(n))return;let i={moduleSpecifier:Ct(n),isTypeOnly:n.isTypeOnly(),namedImports:[]};try{let s=n.getDefaultImport();if(s){let o=s.getText();i.defaultImport=o,t(o,s)}}catch{}try{let s=n.getNamespaceImport();if(s){let o=s.getText();i.namespaceImport=o,t(o,s)}}catch{}try{n.getNamedImports().forEach(s=>{try{let o=s.getName(),l=s.getAliasNode(),c=l?l.getText():void 0;o&&(i.namedImports.push({name:o,alias:c||void 0}),t(c||o,s.getNameNode()))}catch{}})}catch{}e.push(i)}function En(n,e){if(d.isExportDeclaration(n)){let t=Ct(n);if(t){if(n.getNamedExports().length>0)try{n.getNamedExports().forEach(r=>{try{let i=r.getName(),s=r.getAliasNode(),o=s?s.getText():void 0;e.push({kind:"reexport",moduleSpecifier:t,name:i||void 0,alias:o||void 0,isNamespace:!1})}catch{}})}catch{}else if(n.isNamespaceExport())try{let i=n.getNamespaceExport()?.getName();e.push({kind:"reexport",moduleSpecifier:t,name:i||"*",alias:i||void 0,isNamespace:!0})}catch{e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0})}else e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0});return}try{n.getNamedExports().forEach(r=>{try{let i=r.getName();if(!i)return;let s=r.getAliasNode(),o=s?s.getText():i;e.push({kind:"alias",local:i,exported:o})}catch{}})}catch{}return}if(d.isExportAssignment(n))try{let t=n.getExpression();if(t&&d.isIdentifier(t)){let r=t.getText();e.push({kind:"alias",local:r,exported:"default"})}}catch{}}function wn(n,e,t,r){if(!ke(n,ae.ExportKeyword))return;let i=ke(n,ae.DefaultKeyword);if(d.isVariableStatement(n)){try{let s=n.getDeclarationList().getDeclarations();for(let o of s){let l=Se(o)??o.getName?.()??null;if(l){t(l,o);let c=r(o);c&&e.push({kind:"local",name:l,isDefault:i,nodeId:c})}}}catch{}return}if(d.isFunctionDeclaration(n)||d.isClassDeclaration(n)||d.isInterfaceDeclaration(n)||d.isEnumDeclaration(n)||d.isTypeAliasDeclaration(n)||d.isModuleDeclaration(n)){let s=Se(n)||(i?"default":null),o=r(n);o&&e.push({kind:"local",name:s??"default",isDefault:i,nodeId:o})}}function vt(n,e,t,r){let i=[],s=[],o=[],l=new Set,c=new Map,u=[],m=[],C=(r?.emitMode??"light")==="full",I=new Map,K=new Map,R=new Map,F=[{node:n,id:null,kind:"module",rawKind:"SourceFile",rawKindSource:"ts-morph",name:null,isExported:!1}],O=a=>{if(!a)return null;try{return e(a)}catch{return null}},U=a=>{let f=a.getParent?.();for(;f;){let h=I.get(f);if(h)return h;f=f.getParent?.()}return null},z=(a,f)=>{if(a&&(l.has(a)||l.add(a),f&&!c.has(a))){let h=O(f);h&&c.set(a,h)}},V=a=>d.isFunctionDeclaration(a)||d.isFunctionExpression(a)||d.isArrowFunction(a)||d.isClassDeclaration(a)||d.isClassExpression(a)||d.isInterfaceDeclaration(a)||d.isEnumDeclaration(a)||d.isEnumMember(a)||d.isTypeAliasDeclaration(a)||d.isModuleDeclaration(a)||d.isMethodDeclaration(a)||d.isMethodSignature(a)||d.isPropertyDeclaration(a)||d.isPropertySignature(a)||d.isGetAccessorDeclaration(a)||d.isSetAccessorDeclaration(a)||d.isConstructorDeclaration(a)||d.isVariableDeclaration(a),fe=a=>d.isSourceFile(a)||d.isFunctionDeclaration(a)||d.isFunctionExpression(a)||d.isArrowFunction(a)||d.isMethodDeclaration(a)||d.isConstructorDeclaration(a)||d.isClassDeclaration(a)||d.isClassExpression(a)||d.isModuleDeclaration(a),H=a=>{let f=Se(a);if(f)return f;if(d.isConstructorDeclaration(a))return"constructor";if(d.isArrowFunction(a)||d.isFunctionExpression(a)){let h=a.getParent();try{if(d.isVariableDeclaration(h))return h.getName();if(d.isPropertyAssignment(h)||d.isPropertyDeclaration(h)||d.isPropertySignature(h))return h.getName?.()??null;if(d.isShorthandPropertyAssignment(h))return h.getNameNode()?.getText()??null;if(d.isExportAssignment(h))return"default"}catch{}}if(d.isEnumMember(a))try{return a.getName()}catch{return null}if(d.isVariableDeclaration(a))try{return a.getName()}catch{return null}return null},Y=a=>{let f=F[F.length-1],h=f?.id??null,N=f?.kind??"module",g=f?.name??null;if(d.isImportDeclaration(a))vn(a,u,z);else if(d.isImportEqualsDeclaration(a))try{let S=a.getModuleReference();if(S&&d.isExternalModuleReference(S)){let x=S.getExpression(),v;if(x&&d.isStringLiteral(x))v=x.getLiteralText();else if(x){let w=x.getText();v=typeof w=="string"?w.replace(/^['"]|['"]$/g,""):void 0}if(v){let M=a.getNameNode()?.getText(),_={moduleSpecifier:v,isTypeOnly:!1,namedImports:[]};M&&(_.defaultImport=M,z(M,a)),u.push(_)}}}catch{}(d.isExportDeclaration(a)||d.isExportAssignment(a))&&En(a,m),wn(a,m,z,O);let y=V(a),E=C||y,P=y?H(a):null;if(E){let S=e(a);y&&s.push({nodeId:S,node:a});let x=U(a),v=x==null?null:K.get(x)??0;x!=null&&v!=null&&K.set(x,v+1),I.set(a,S);let w=x?(R.get(x)??-1)+1:0;R.set(S,w);let M=ke(a,ae.ExportKeyword)||f?.isExported||!1,_=y?a.getNameNode?.()?.getText?.()??null:null,D=P??(y?Se(a)??_:Se(a));P?z(P,a):D&&z(D,a);let A=ze(a),L=Sn(a),k=Ie(a);Ae(k,{source:"ts-node-collector",file:n.getFilePath(),name:D??null});let J=bn(a);i.push({nodeId:S,nodeName:D??null,containerId:h,containerKind:N,containerRawKind:f?.rawKind??null,containerRawKindSource:f?.rawKindSource??null,containerName:g,isExported:M,kind:k.kind,rawKind:k.rawKind,rawKindSource:k.rawKindSource,semanticKind:k.semanticKind??null,start:A.start,end:A.end,paramCount:L,metadata:null,parentNodeId:x,role:xn(a),indexInParent:v,depth:w,bodyStart:J?.start??null,bodyEnd:J?.end??null})}if(d.isCallExpression(a)||d.isNewExpression(a)){let S=a.getExpression(),x=null,v,w;try{if(w=Cn(S),d.isIdentifier(S))x=S.getText();else if(d.isPropertyAccessExpression(S)){x=S.getName();let D=S.getExpression();d.isIdentifier(D)&&(v=D.getText())}}catch{}let M="";try{M=S.getText()}catch{}let _=ze(a);if(o.push({name:x,kind:d.isNewExpression(a)?"new":"call",containerId:h,containerKind:N,containerName:g,expression:M,objectName:v,symbol:w,start:_.start,end:_.end}),d.isCallExpression(a))try{if(d.isIdentifier(S)&&S.getText()==="require"){let A=a.getArguments()[0],L;if(A&&(d.isStringLiteral(A)||d.isNoSubstitutionTemplateLiteral(A)))try{L=A.getLiteralText()}catch{let k=A.getText();L=typeof k=="string"?k.replace(/^['"]|['"]$/g,""):void 0}if(L){let k={moduleSpecifier:L,isTypeOnly:!1,namedImports:[]},J=a.getParent();if(J&&d.isVariableDeclaration(J)){let Pe=J.getNameNode();try{if(d.isIdentifier(Pe)){let ge=Pe.getText();ge&&(k.defaultImport=ge,z(ge,J))}}catch{}}u.push(k)}}else if(S?.getKind?.()===ae.ImportKeyword){let A=a.getArguments()[0],L;if(A&&(d.isStringLiteral(A)||d.isNoSubstitutionTemplateLiteral(A)))try{L=A.getLiteralText()}catch{let k=A.getText();L=typeof k=="string"?k.replace(/^['"]|['"]$/g,""):void 0}L&&u.push({moduleSpecifier:L,isTypeOnly:!1,namedImports:[]})}}catch{}}if(d.isCallExpression(a)){let S=a.getExpression();try{if(d.isIdentifier(S)&&S.getText()==="require"){let x=a.getParent();if(!(x&&d.isExternalModuleReference(x))){let w=a.getArguments()[0],M;if(w&&(d.isStringLiteral(w)||d.isNoSubstitutionTemplateLiteral(w)))try{M=w.getLiteralText()}catch{M=w.getText().replace(/^['"]|['"]$/g,"")}if(M){let _={moduleSpecifier:M,isTypeOnly:!1,namedImports:[]};if(x&&d.isVariableDeclaration(x)){let D=x.getNameNode();try{if(d.isIdentifier(D)){let A=D.getText();A&&(_.defaultImport=A,z(A,x))}}catch{}}u.push(_)}}}else if(S?.getKind?.()===ae.ImportKeyword){let v=a.getArguments()[0],w;if(v&&(d.isStringLiteral(v)||d.isNoSubstitutionTemplateLiteral(v)))try{w=v.getLiteralText()}catch{w=v.getText().replace(/^['"]|['"]$/g,"")}w&&u.push({moduleSpecifier:w,isTypeOnly:!1,namedImports:[]})}}catch{}}let j=!1;if(fe(a)){let S=O(a)??e(a),x=St(a);F.push({node:a,id:S,kind:x.kind,rawKind:x.rawKind,rawKindSource:x.rawKindSource,name:P??g,isExported:ke(a,ae.ExportKeyword)||f?.isExported||!1}),j=!0}a.forEachChild(Y),j&&F.pop()};if(C){let a=e(n);I.set(n,a),R.set(a,0);let f=ze(n);i.push({nodeId:a,nodeName:n.getBaseName?.()??null,containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:"SourceFile",rawKind:"SourceFile",rawKindSource:"ts-morph",semanticKind:"file",start:f.start,end:f.end,paramCount:null,metadata:null,parentNodeId:null,role:null,indexInParent:null,depth:0,bodyStart:f.start,bodyEnd:f.end})}if(n.forEachChild(Y),r?.includeComments===!0||C||process.env.AST_INDEX_COMMENTS==="1")try{let a=n.getFullText(),f=X.createScanner(X.ScriptTarget.Latest,!1,X.LanguageVariant.Standard,a),h=new Set;for(let N=f.scan();N!==X.SyntaxKind.EndOfFileToken;N=f.scan()){if(N!==X.SyntaxKind.SingleLineCommentTrivia&&N!==X.SyntaxKind.MultiLineCommentTrivia)continue;let g=f.getTokenPos(),y=f.getTextPos(),E=`${g}-${y}`;if(h.has(E)||(h.add(E),t.has(E)))continue;t.add(E);let P=a.substring(g,y),j=ht(N,P),x=e({getKindName:()=>j.name,getKind:()=>j.kind,getPos:()=>g,getEnd:()=>y,getStart:()=>g,getFullStart:()=>g,getText:()=>P,getSourceFile:()=>n,getParent:()=>n,__isComment:!0,__commentPosition:"standalone",__attachedTo:null},"COM"),v=I.get(n)??null,w=C&&v!=null?K.get(v)??0:null;C&&v!=null&&w!=null&&K.set(v,w+1),i.push({nodeId:x,nodeName:P.substring(0,100),containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:j.name,rawKind:j.name,rawKindSource:"ts-morph",semanticKind:null,start:g,end:y,paramCount:null,metadata:null,parentNodeId:v,role:"comment",indexInParent:w,depth:C?1:0,bodyStart:null,bodyEnd:null})}}catch{}return{nodes:i,symbolCandidateNodes:s,references:o,declaredNames:l,localDeclarations:c,imports:u,exports:yn(m)}}function Et(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}var Rn=100;function In(n,e,t,r){let{start:i,end:s}=Et(e),o=Ie(e);Ae(o,{source:"ts-node-id",file:n,kind:o.kind});let l=r||Z.getAbbrev(o.kind,t);return`${n}#${i}-${s}:${l}`}function An(n,e){return Je.relative(n,e).replace(/\\/g,"/")}function wt(n,e){if(!n)return null;let t=n;try{let m=n.getAliasedSymbol();m&&(t=m)}catch{}let r=[];try{r=t.getDeclarations()??[]}catch{r=[]}if(!r.length)return null;let s=r.slice().sort((m,p)=>{let C=m.getSourceFile().getFilePath(),I=p.getSourceFile().getFilePath();if(C!==I)return C.localeCompare(I);let K=m.getStart(!1),R=p.getStart(!1);return K!==R?K-R:m.getEnd()-p.getEnd()})[0],o=An(e,s.getSourceFile().getFilePath()),l=s.getStart(!1),c=s.getEnd(),u="";try{u=t.getEscapedName()}catch{try{u=t.getName()}catch{u=""}}return`${o}#${l}-${c}:${u}`}function kn(n){try{return Q.isVariableDeclaration(n)||Q.isEnumMember(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol()}catch{return}}function Mn(n,e){let t=n.getDescendantAtPos(e);if(!t)return;let r=t;if(!Q.isCallExpression(r)&&!Q.isNewExpression(r)&&(r=t.getFirstAncestor(s=>Q.isCallExpression(s)||Q.isNewExpression(s))??void 0),!r||!Q.isCallExpression(r)&&!Q.isNewExpression(r))return;let i=r.getExpression();try{return Q.isIdentifier(i)?i.getSymbol():Q.isPropertyAccessExpression(i)?i.getNameNode().getSymbol()??i.getSymbol():i.getSymbol()}catch{return}}async function Dn(n){let{sf:e,fileRel:t,content:r,preDeleted:i,meta:s,projectRoot:o,lang:l}=n,c=n.emitMode??"light",m=vt(e,(g,y)=>In(t,g,l,y),new Set,{includeComments:c==="full",emitMode:c}),p=new Map;for(let{nodeId:g,node:y}of m.symbolCandidateNodes){let E=wt(kn(y),o);E&&(p.has(g)||p.set(g,E))}let C=[],I=new Map,K=m.exports.filter(g=>g.kind!=="reexport"),R=m.exports.filter(g=>g.kind==="reexport");for(let g of K)if(g.kind==="local"){let y=g.isDefault?"default":g.name;if(!y||I.has(y))continue;let E=g.nodeId;C.push([t,y,E,0,null,null,g.isDefault?"default":"named"]),I.set(y,E)}else if(g.kind==="alias"){let y=g.exported;if(!y||I.has(y))continue;C.push([t,y,null,0,null,g.local,"alias"]),I.set(y,"alias")}for(let g of R){let y=g.moduleSpecifier;if(!y)continue;let E=y;if(g.isNamespace){let P=g.alias||"*";if(I.has(P))continue;C.push([t,P,null,1,E,g.name||P,"reexport_star"]),I.set(P,"reexport")}else{let P=g.alias||g.name;if(!P||I.has(P))continue;C.push([t,P,null,1,E,g.name||P,"reexport_named"]),I.set(P,"reexport")}}let F=[],O=typeof r=="string"?r:null;if(O==null)try{let g=e.getFullText();O=typeof g=="string"?g:null}catch{O=null}for(let g of m.nodes){let{nodeId:y,nodeName:E,containerKind:P,containerRawKind:j,containerRawKindSource:S,isExported:x,kind:v,rawKind:w,rawKindSource:M,semanticKind:_,start:D,end:A,paramCount:L,metadata:k,parentNodeId:J,role:Pe,indexInParent:ge,depth:cn,bodyStart:un,bodyEnd:dn}=g,pn=k&&Object.keys(k).length?JSON.stringify(k):null,mn=p.get(y)??null;F.push([y,E??null,v,w??v,M??null,_??null,D,A,x?1:0,P??"module",j??P??"module",S??null,L,null,null,mn,pn,J??null,Pe??null,ge??null,cn??0,un??null,dn??null])}let U=[];for(let g of m.references){let{name:y,kind:E,containerId:P,containerName:j,expression:S,objectName:x,start:v,end:w}=g,M=null,_=null,D=wt(g.symbol??Mn(e,v),o),A=y?m.localDeclarations.get(y):void 0;A&&(M=A,_=t,D||(D=p.get(A)??null));let L=Re({sourceFile:t,sourceStart:v,sourceEnd:w,refKind:E,refName:y,targetFile:_,targetNodeId:M}),k={};S&&(k.expression=S),x&&(k.objectName=x),j&&(k.containerName=j);let J=Object.keys(k).length?JSON.stringify(k):null;U.push([L,t,P,y,E,v,w,M,_,M?"resolved":"unresolved",x??null,null,null,D,J])}let z=[],V=[];for(let g of m.imports){let y=g.moduleSpecifier??null;z.push([t,y,g.isTypeOnly?1:0]),g.defaultImport&&V.push([t,y,"default",g.defaultImport,"default",g.isTypeOnly?1:0]),g.namespaceImport&&V.push([t,y,"namespace",g.namespaceImport,"*",g.isTypeOnly?1:0]);for(let E of g.namedImports){let P=E.alias||E.name;V.push([t,y,"named",P,E.name,g.isTypeOnly?1:0])}}let fe=Je.join(o,t),H=s?.size,Y=s?.mtime;if(H===void 0||Y===void 0)try{let g=Nn.statSync(fe);H=g.size,Y=Math.floor(g.mtimeMs)}catch{}let a=new Date().toISOString(),f=c==="full",h=[t,Y??null,H??null,"completed",a,f?1:0],N=null;if(typeof O=="string")N={blobOid:t,content:O};else try{let g=e.getFullText?.();typeof g=="string"&&(N={blobOid:t,content:g})}catch(g){console.log(`[TypescriptIndexer] Failed to compute FTS payload for ${t}:`,g?.message??g)}return{payload:{lang:l,fileRel:t,preDeleted:i,exportRows:C,nodeRows:F,referenceRows:U,importRows:z,importBindingRows:V,fileRow:h,fts:N,fullyIndexed:f},fileSize:H,mtime:Y}}var qe=class{constructor(e,t){this.project=null;this.filesProcessed=0;this.projectRoot=e,this.lang=t}getProject(){return this.project||(this.project=new Pn({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0})),this.project}disposeProject(){if(this.project){try{let e=this.project.getLanguageService().compilerObject;typeof e?.dispose=="function"&&e.dispose()}catch{}this.project=null}}async process(e){let t=this.getProject(),r;try{let i=t.createSourceFile(Je.join(this.projectRoot,e.relPath),e.content,{overwrite:!0});r=await Dn({sf:i,fileRel:e.relPath,content:e.content,preDeleted:!!e.preDeleted,meta:e.meta,projectRoot:this.projectRoot,lang:e.lang,emitMode:e.emitMode??"light"})}catch(i){this.disposeProject(),this.filesProcessed=0;let s=i?.message||String(i);throw new Error(`TypeScript parser failed for ${e.relPath}: ${s}`)}return this.filesProcessed++,this.filesProcessed>=Rn&&(this.disposeProject(),this.filesProcessed=0),{payload:r.payload,fileSize:r.fileSize,mtime:r.mtime}}};function Tn(n){return n==="ts"?[".ts",".tsx",".mts",".cts"]:n==="js"?[".js",".jsx",".mjs",".cjs"]:[]}function We(n){return{id:n,extensions:Tn(n),indexingMode:"worker",createIndexer:e=>new qe(e,n)}}import De from"fs";import ee from"path";import{spawn as Ln}from"child_process";import Kn from"fs";var le=class{constructor(e=5e3){this.maxEntries=e;this.cache=new Map}get(e,t){let r=this.cache.get(e);if(!r)return null;let i=t?.mtime??null,s=t?.size??null;return i!=null&&s!=null&&r.mtime===i&&r.size===s?r.result:null}set(e,t,r){let i=t?.mtime??null,s=t?.size??null;this.cache.set(e,{mtime:i,size:s,result:r}),this.cache.size>this.maxEntries&&this.cache.clear()}};var Ue=class{constructor(e,t,r,i){this.projectRoot=e;this.lang=t;this.parse=r;this.exportKind=i;this.cache=new le}async process(e){let t=e.meta?.mtime,r=e.meta?.size;if(t==null||r==null)try{let o=Kn.statSync(e.absPath);t=Math.floor(o.mtimeMs),r=o.size}catch{}let i=e.emitMode==="full"?null:this.cache.get(e.absPath,{mtime:t,size:r});if(i)return ye({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:i,resolveNodeId:Nt(e.relPath,i,this.lang),exportKind:this.exportKind??"cli",fullyIndexed:e.emitMode==="full"});let s=null;try{s=await this.parse({absPath:e.absPath,relPath:e.relPath,content:e.content,meta:{mtime:t,size:r},projectRoot:this.projectRoot,lang:this.lang,emitMode:e.emitMode??"light"})}catch(o){try{console.log(`[CliContract:${this.lang}] parse threw for ${e.relPath}: ${o?.message||String(o)}`)}catch{}return he(this.lang,e.relPath,{mtime:t,size:r})}return!s||s.error?he(this.lang,e.relPath,{mtime:t,size:r}):(e.emitMode!=="full"&&this.cache.set(e.absPath,{mtime:t,size:r},s),ye({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:s,resolveNodeId:Nt(e.relPath,s,this.lang),exportKind:this.exportKind??"cli",fullyIndexed:e.emitMode==="full"}))}};function Nt(n,e,t){let r=new Map;for(let i of e.nodes??[]){if(!i.name||r.has(i.name))continue;let s=`${n}#${i.start}-${i.end}:${Z.getAbbrev(i.kind,t)}`;r.set(i.name,s)}return i=>r.get(i)??null}function G(n){return{id:n.id,extensions:n.extensions,indexingMode:"worker",createIndexer:e=>new Ue(e,n.id,n.parse,n.exportKind),resolveSpan:n.resolve?async(e,t,r)=>n.resolve({projectRoot:e,absPath:t,nodePath:r,lang:n.id}):void 0}}import _n from"fs";import Me from"path";var Xe=null;function On(n){for(let e of n)if(_n.existsSync(e))return e;return null}function q(n){let e=Xe?.toolsRoot??process.env.PANDO_TOOLS_ROOT,t=Xe?.runtimeRoot??process.env.PANDO_RUNTIME_ROOT,r=Xe?.resourcesRoot??process.env.PANDO_RESOURCES_ROOT,i=[e?Me.join(e,n):null,t?Me.join(t,"tools",n):null,r?Me.join(r,"tools",n):null,Me.resolve(process.cwd(),"tools",n)].filter(s=>!!s);return On(i)}function W(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
2
- `)}catch{}}var Fn=Number(process.env.PANDO_PYTHON_WORKER_PARSE_TIMEOUT_MS||18e4),jn=Number(process.env.PANDO_PYTHON_WORKER_RESOLVE_TIMEOUT_MS||6e4),de=class extends Error{constructor(t,r){super(t);this.fatal=r;this.name="PythonWorkerRequestError"}},Te=class{constructor(e,t){this.interpreter=e;this.scriptPath=t;this.buffer=Buffer.alloc(0);this.pending=new Map;this.requestQueue=Promise.resolve();this.seq=1;this.closed=!1;if(this.proc=Ln(this.interpreter,["-u",this.scriptPath],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw new Error("python worker stdio unavailable");this.proc.stdout.on("data",r=>this.onData(r)),this.proc.stderr.on("data",r=>{W(`[PythonWorker] ${r.toString("utf8").trim()}`)}),this.proc.stdin.on("error",r=>this.handleError(r)),this.proc.on("error",r=>this.handleError(r)),this.proc.on("exit",r=>this.handleError(new Error(`python worker exited with code ${r}`))),this.ready=this.ping()}handleError(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.timeout&&clearTimeout(t.timeout),t.summary&&W("[PythonCliAdapter] worker error",{interpreter:this.interpreter,error:e.message,...t.summary}),t.reject(e);this.pending.clear();try{this.proc.stdin?.end()}catch{}try{this.proc.kill()}catch{}}}onData(e){for(this.buffer=Buffer.concat([this.buffer,e]);this.buffer.length>=4;){let t=this.buffer.readUInt32BE(0);if(this.buffer.length<4+t)return;let r=this.buffer.slice(4,4+t);this.buffer=this.buffer.slice(4+t);let i=null;try{i=JSON.parse(r.toString("utf8"))}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),s.timeout&&clearTimeout(s.timeout),i.ok?s.resolve(i):s.reject(new de(i.error||"python worker error",!1)))}}sendMessage(e){if(this.closed)throw new Error("python worker is closed");let t=Buffer.from(JSON.stringify(e),"utf8"),r=Buffer.alloc(4);r.writeUInt32BE(t.length,0),this.proc.stdin.write(r),this.proc.stdin.write(t)}async requestRaw(e,t,r=1e4){let i=this.seq++,s={id:i,op:e,...t},o={op:e,id:i};return typeof t?.path=="string"&&(o.path=t.path),typeof t?.nodePath=="string"&&(o.nodePath=t.nodePath),typeof t?.content_b64=="string"&&(o.contentBytes=t.content_b64.length),new Promise((l,c)=>{let u=setTimeout(()=>{this.pending.delete(i);let m=new de(`python worker timeout (${e})`,!0);W("[PythonCliAdapter] worker timeout",{op:e,id:i,timeoutMs:r,pending:this.pending.size,interpreter:this.interpreter,...o}),c(m),this.handleError(m)},r);this.pending.set(i,{resolve:l,reject:c,timeout:u,summary:o}),this.pending.size%200===0&&W("[PythonCliAdapter] worker pending",{op:e,pending:this.pending.size,interpreter:this.interpreter});try{this.sendMessage(s)}catch(m){clearTimeout(u),this.pending.delete(i),c(m)}})}async enqueueRequest(e){let t=this.requestQueue.catch(()=>{}),r,i=new Promise(s=>{r=s});this.requestQueue=t.then(()=>i),await t;try{return await e()}finally{r()}}async request(e,t,r=1e4){await this.ready;let i=Date.now();return this.enqueueRequest(async()=>{let s=Date.now()-i,o=Date.now();s>2e3&&W("[PythonCliAdapter] worker queued",{op:e,queueMs:s,interpreter:this.interpreter,path:t?.path});let l=await this.requestRaw(e,t,r),c=Date.now()-o;return c>2e3&&W("[PythonCliAdapter] worker slow",{op:e,ms:c,queueMs:s,pending:this.pending.size,interpreter:this.interpreter,path:t?.path}),l})}async ping(){await this.requestRaw("ping",{},5e3)}async parse(e){let t=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("parse",{path:e.path,content_b64:t,encoding:e.encoding,emit_mode:e.emitMode??"light"},Fn);return r.nodes?r:null}async resolve(e){let t=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("resolve",{path:e.path,nodePath:e.nodePath,content_b64:t,encoding:e.encoding},jn);return typeof r.start=="number"&&typeof r.end=="number"?r:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.timeout&&clearTimeout(t.timeout),t.reject(new Error("python worker client closed"));this.pending.clear();let e=this.proc;try{e.stdin?.end()}catch{}try{e.kill()}catch{}}};function Pt(n){let e=ee.resolve(n,"tools/python-indexer/pando_python_worker.py");if(De.existsSync(e))return e;let t=q("python-indexer/pando_python_worker.py");if(t)return t;let r=ee.resolve(__dirname,"../../../../../tools/python-indexer/pando_python_worker.py");return De.existsSync(r)?r:null}var ue=new Map;function ce(n){try{return De.readFileSync(n,"utf8")}catch{return null}}function Ce(n){if(!n)return null;let e=n.match(/(\d+)\.(\d+)/);return e?{major:Number(e[1]),minor:Number(e[2])}:null}function Bn(n){let e=ce(ee.join(n,"pyproject.toml"));if(e){let l=e.match(/requires-python\s*=\s*"([^"]+)"/i),c=Ce(l?.[1]??null);if(c)return c}let t=ce(ee.join(n,"setup.cfg"));if(t){let l=t.match(/python_requires\s*=\s*([\w\d\.<>~=\s]+)/i),c=Ce(l?.[1]??null);if(c)return c}let r=ce(ee.join(n,"setup.py"));if(r){let l=r.match(/python_requires\s*=\s*['\"]([^'\"]+)['\"]/i),c=Ce(l?.[1]??null);if(c)return c}let i=ce(ee.join(n,"tox.ini"));if(i){let l=i.match(/envlist\s*=\s*([^\n]+)/i);if(l&&l[1]){let c=l[1].split(/[,\s]+/).filter(Boolean);for(let u of c){let m=u.match(/py(\d)(\d)/i);if(m)return{major:Number(m[1]),minor:Number(m[2])}}}}let s=ce(ee.join(n,".python-version"));if(s){let l=Ce(s.trim());if(l)return l}let o=ce(ee.join(n,"runtime.txt"));if(o){let l=o.match(/python-(\d+\.\d+)/i),c=Ce(l?.[1]??null);if(c)return c}return null}function Rt(n){return Bn(n)?.major===2?["python2","python","python3"]:["python3","python","python2"]}async function $n(n,e,t,r){let i=Pt(n);if(!i)return null;let s=Rt(n);for(let o of s){let l=`${o}::${i}`,c=ue.get(l);if(!c)try{c=new Te(o,i),ue.set(l,c)}catch{continue}try{let u=await c.parse({path:e,content:t,encoding:"utf-8",emitMode:r});if(u)return u}catch(u){let m=u?.message||String(u),p=u instanceof de?u.fatal:/timeout|closed|exited|EPIPE|ENOENT|spawn/i.test(m);W("[PythonCliAdapter] worker parse error",{file:e,interpreter:o,script:i,fatal:p,error:m}),p&&ue.delete(l)}}return null}async function zn(n,e,t,r){let i=Pt(n);if(!i)return null;let s=Rt(n);for(let o of s){let l=`${o}::${i}`,c=ue.get(l);if(!c)try{c=new Te(o,i),ue.set(l,c)}catch{continue}try{let u=await c.resolve({path:e,nodePath:r,content:t,encoding:"utf-8"});if(u)return u}catch(u){let m=u?.message||String(u),p=u instanceof de?u.fatal:/timeout|closed|exited|EPIPE|ENOENT|spawn/i.test(m);W("[PythonCliAdapter] worker resolve error",{file:e,interpreter:o,nodePath:r,script:i,fatal:p,error:m}),p&&ue.delete(l)}}return null}async function qn(n){let e=Date.now(),t=!1,r=null;try{r=await $n(n.projectRoot,n.absPath,n.content,n.emitMode??"light"),t=!!r}catch{}if(!r){W(`[PythonCliAdapter] parse failed for ${n.relPath} via python worker`);let o=Date.now()-e;return o>2e3&&W("[PythonCliAdapter] parse slow (failed)",{file:n.relPath,ms:o}),null}let i=[];for(let o of r.references||[]){let l={};o.expression&&(l.expression=o.expression),o.objectName&&(l.objectName=o.objectName),o.containerName&&(l.containerName=o.containerName),o.containerKind&&(l.containerKind=o.containerKind),i.push({sourceStart:o.start,sourceEnd:o.end,refKind:o.kind,refName:o.name,receiverName:o.receiverName??o.objectName??null,arity:typeof o.arity=="number"?o.arity:null,containerQualifiedName:o.containerQualifiedName??null,targetSymbolKey:o.targetSymbolKey??null,metadata:Object.keys(l).length?l:null})}let s=Date.now()-e;return s>2e3&&W("[PythonCliAdapter] parse slow",{file:n.relPath,ms:s,usedWorker:t}),{nodes:r.nodes,imports:r.imports,importBindings:r.importBindings,references:i,modulePublic:r.modulePublic??void 0,explicitExports:r.explicitExports??void 0}}function It(){return G({id:"python",extensions:[".py",".pyw",".pyi"],exportKind:"named",parse:({absPath:n,relPath:e,projectRoot:t,content:r,emitMode:i})=>qn({absPath:n,relPath:e,projectRoot:t,content:r,emitMode:i}),resolve:async({absPath:n,nodePath:e,projectRoot:t})=>{try{let r=De.readFileSync(n,"utf8"),i=await zn(t,n,r,e);if(i)return i}catch{}return null}})}import At from"fs";import kt from"path";import{spawn as Jn,spawnSync as Wi}from"child_process";var Wn=256e3,Un=32;function ne(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
3
- `)}catch{}}var Qe=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=Jn(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("csharp indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{ne(`[CSharpIndexer] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`csharp indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
1
+ import{c as xn,d as ae,e as B,f as mt}from"./chunk-WHHZYOEJ.mjs";import{a as bn}from"./chunk-RRIZV7YJ.mjs";var Z={getAbbrev(n,e="ts"){return n},getKindFromAbbrev(n,e="ts"){return n}};function Ie(n){let e=`${n.sourceFile}#${n.sourceStart}-${n.sourceEnd}`,t=n.refKind??"",r=n.refName??"",i=n.targetFile??"",s=n.targetStart!=null&&n.targetEnd!=null?`#${n.targetStart}-${n.targetEnd}`:"",o=n.targetNodeId??"",l=`${e}:REF:${t}:${r}|${i}${s}|${o}`;return mt(l)}function ft(n){let e=[],t=new Set,r=i=>{!i?.name||t.has(i.name)||(t.add(i.name),e.push(i))};for(let i of n.exports??[])r(i);for(let i of n.explicitExports??[])r({name:i});for(let i of n.modulePublic??[])r({name:i});return e}function ye(n,e,t){let r=new Date().toISOString();return{payload:{lang:n,fileRel:e,preDeleted:!1,exportRows:[],nodeRows:[],referenceRows:[],symbolMentionRows:[],importRows:[],importBindingRows:[],fileRow:[e,t?.mtime??null,t?.size??null,"failed",r],fts:null,fullyIndexed:!1},fileSize:t?.size,mtime:t?.mtime}}function be(n){let{lang:e,fileRel:t,content:r,meta:i,preDeleted:s,parsed:o,resolveNodeId:l,exportKind:c,fullyIndexed:u}=n,m=[],p=o.nodes??[],C=p.map(a=>{let f=`${t}#${a.start}-${a.end}:${Z.getAbbrev(a.kind,e)}`;return(e==="c"||e==="cpp"||e==="java"||e==="clojure")&&a.name?`${f}:${a.name}`:f});for(let a=0;a<p.length;a+=1){let f=p[a],h=f.rawKind??f.kind,P=f.rawKindSource??"cli",g=f.containerRawKind??f.containerKind??null,y=f.containerRawKindSource??(g?"cli":null),E=f.scopeChain??null,N=Array.isArray(E)?JSON.stringify(E):typeof E=="string"?E:null,j=C[a],S=typeof f.parentIndex=="number"?C[f.parentIndex]??null:f.parentNodeId??null,x=f.metadata&&Object.keys(f.metadata).length?JSON.stringify(f.metadata):null;m.push([j,f.name,f.kind,h,P,f.semanticKind??null,f.start,f.end,typeof f.isExported=="number"?f.isExported:0,f.containerKind??null,g,y,typeof f.paramCount=="number"?f.paramCount:null,f.qualifiedName??null,N,f.symbolKey??null,x,S,f.role??null,typeof f.indexInParent=="number"?f.indexInParent:null,typeof f.depth=="number"?f.depth:0,typeof f.bodyStart=="number"?f.bodyStart:null,typeof f.bodyEnd=="number"?f.bodyEnd:null])}let I=[],K=new Set;for(let a of ft(o)){if(!a.name||K.has(a.name))continue;K.add(a.name);let f=a.nodeId??(l?l(a.name):null);I.push([t,a.name,f??null,a.isReexport?1:0,a.reexportFrom??null,a.reexportName??null,a.exportKind??c??"cli",a.targetSymbolKey??null])}let R=[],F=[],O=new Map,U=new Map;for(let a of m){let f=a[0]!=null?String(a[0]):null,h=a[13]!=null?String(a[13]):null,P=a[15]!=null?String(a[15]):null;f&&(h&&!O.has(h)&&O.set(h,f),P&&!U.has(P)&&U.set(P,f))}if(ae()&&e==="clojure"&&(o.references??[]).length>0){let a=Array.from(O.keys()).slice(0,10),f=Array.from(U.keys()).slice(0,10),h=(o.references??[]).slice(0,10).map(g=>g.containerQualifiedName),P={file:t,nodeCount:m.length,refCount:(o.references??[]).length,nodeQualifiedNames:a,nodeSymbolKeys:f,refContainers:h,qualifiedNameMapSize:O.size,symbolKeyMapSize:U.size};try{console.error("[CliPayload][CLOJURE-DEBUG] source_node_id lookup context",P)}catch{}}for(let a of o.references??[]){let f=a.targetNodeId??(l&&a.refName?l(a.refName):null),h=a.targetFile??(f?t:null),P=a.sourceNodeId??(a.containerQualifiedName?O.get(a.containerQualifiedName)??null:null)??(a.containerQualifiedName?U.get(a.containerQualifiedName)??null:null),g=Ie({sourceFile:t,sourceStart:a.sourceStart,sourceEnd:a.sourceEnd,refKind:a.refKind,refName:a.refName,targetFile:h??null,targetStart:a.targetStart??null,targetEnd:a.targetEnd??null,targetNodeId:f??a.targetNodeId??null}),y=a.metadata&&Object.keys(a.metadata).length?JSON.stringify(a.metadata):null;R.push([g,t,P,a.refName??null,a.refKind,a.sourceStart,a.sourceEnd,f??a.targetNodeId??null,h??null,f||a.targetNodeId||a.targetFile?"resolved":"unresolved",a.receiverName??null,typeof a.arity=="number"?a.arity:null,a.containerQualifiedName??null,a.targetSymbolKey??null,a.confidence??null,y])}for(let a of o.symbolMentions??[]){let f=typeof a?.name=="string"?a.name.trim():"";if(!f)continue;let h=typeof a?.mentionKind=="string"&&a.mentionKind.trim().length>0?a.mentionKind.trim():"reference",P=typeof a?.count=="number"&&Number.isFinite(a.count)&&a.count>0?Math.floor(a.count):1;F.push([f,h,a.targetSymbolKey??null,a.containerQualifiedName??null,P])}if(ae()&&e==="clojure"&&R.length>0){let a=R.reduce((h,P)=>h+(P?.[2]!=null?1:0),0),f=R.reduce((h,P)=>h+(P?.[12]!=null?1:0),0);try{console.error("[CliPayload] clojure source-node summary",{file:t,refs:R.length,sourceNodeCount:a,containerCount:f,sample:R.slice(0,5).map(h=>({sourceNodeId:h[2]==null?null:String(h[2]),refName:h[3],refKind:h[4],containerQualifiedName:h[12]}))})}catch{}}let z=[];for(let a of o.imports??[])z.push([t,a.module??null,a.isTypeOnly??0]);let H=[];for(let a of o.importBindings??[])H.push([t,a.module??null,a.kind,a.localName,a.importedName,a.isTypeOnly??0]);let ge=new Date().toISOString(),V=[t,i?.mtime??null,i?.size??null,"completed",ge,u?1:0];return{payload:{lang:e,fileRel:t,preDeleted:!!s,exportRows:I,nodeRows:m,referenceRows:R,symbolMentionRows:F,importRows:z,importBindingRows:H,fileRow:V,fts:typeof r=="string"?{blobOid:t,content:r}:null,fullyIndexed:!!u},fileSize:i?.size,mtime:i?.mtime}}var xe=["ts","js","python","c","cpp","csharp","dart","java","clojure"];function ze(n){return typeof n=="string"&&xe.includes(n)}xn();function gt(){let n=process.env.PANDO_ENABLED_LANGUAGES;if(n&&n.trim().length>0){let t=n.split(",").map(r=>r.trim()).filter(r=>r.length>0).filter(ze);if(t.length>0)return ht(t)}return[...xe]}function ht(n){let e=new Set;for(let t of n)ze(t)&&e.add(t);return xe.filter(t=>e.has(t))}function yt(n){let e=new Set(ht(n)),t={};for(let r of xe){if(e.has(r)){t[r]={enabled:!0,source:"embedded"};continue}t[r]={enabled:!1,source:"none",reason:"disabled by language support config"}}return{byLanguage:t}}import Ue from"path";import An from"fs";import{Project as kn,Node as G}from"ts-morph";import{Node as d,SyntaxKind as le}from"ts-morph";import*as X from"typescript";import{SyntaxKind as Se}from"ts-morph";var qe={LINE_COMMENT:{kind:9001,name:"LineComment",triviaKind:Se.SingleLineCommentTrivia},BLOCK_COMMENT:{kind:9002,name:"BlockComment",triviaKind:Se.MultiLineCommentTrivia},JSDOC_COMMENT:{kind:9003,name:"JSDocComment",triviaKind:Se.MultiLineCommentTrivia}};function bt(n,e){return n===Se.SingleLineCommentTrivia?qe.LINE_COMMENT:n===Se.MultiLineCommentTrivia&&e.startsWith("/**")?qe.JSDOC_COMMENT:qe.BLOCK_COMMENT}import{Node as T}from"ts-morph";var xt={TS_MORPH:"ts-morph",PYTHON_AST:"python-ast",CLANG:"clang",ROSLYN:"roslyn",JAVA_AST:"java-ast",CLI:"cli",UNKNOWN:"unknown"},St=(n,e)=>T.isFunctionDeclaration(n)||T.isFunctionExpression(n)||T.isArrowFunction(n)?{kind:"Function",semanticKind:"function"}:T.isGetAccessorDeclaration(n)||T.isSetAccessorDeclaration(n)?{kind:"Method",semanticKind:"property"}:T.isMethodDeclaration(n)||T.isMethodSignature(n)||T.isConstructorDeclaration(n)?{kind:"Method",semanticKind:"method"}:T.isClassDeclaration(n)||T.isClassExpression(n)?{kind:"Class",semanticKind:"class"}:T.isInterfaceDeclaration(n)?{kind:"Interface",semanticKind:"interface"}:T.isEnumDeclaration(n)?{kind:"Enum",semanticKind:"enum"}:T.isEnumMember(n)?{kind:"EnumMember",semanticKind:"enum"}:T.isTypeAliasDeclaration(n)?{kind:"TypeAlias",semanticKind:"type"}:T.isModuleDeclaration(n)?{kind:"Namespace",semanticKind:"namespace"}:T.isPropertyDeclaration(n)||T.isPropertySignature(n)?{kind:"Field",semanticKind:"property"}:T.isVariableDeclaration(n)?{kind:"Variable",semanticKind:"variable"}:{kind:e,semanticKind:null};function Ct(n){try{let e=n.getKindName?.();if(typeof e=="string"&&e.trim())return e}catch{}return"Unknown"}function Ae(n){let e=Ct(n),t=St(n,e);return{kind:t.kind,semanticKind:t.semanticKind,rawKind:e,rawKindSource:xt.TS_MORPH}}function vt(n){let e=Ct(n);return{kind:St(n,e).kind,rawKind:e,rawKindSource:xt.TS_MORPH}}function ke(n,e){if(!n.kind||!n.kind.trim())throw new Error(`Invalid normalized kind: missing kind ${e?JSON.stringify(e):""}`);if(!n.rawKind||!n.rawKind.trim())throw new Error(`Invalid normalized kind: missing rawKind ${e?JSON.stringify(e):""}`);if(!n.rawKindSource||!String(n.rawKindSource).trim())throw new Error(`Invalid normalized kind: missing rawKindSource ${e?JSON.stringify(e):""}`)}function Sn(n){if(n.kind==="local"){let r=n.isDefault?"default":n.name;return r?{name:r,priority:n.isDefault?4:3}:null}if(n.kind==="alias")return n.exported?{name:n.exported,priority:2}:null;let e=n.isNamespace??!1,t=n.alias||n.name||(e?"*":null);return t?{name:t,priority:e?0:1}:null}function Cn(n){if(n.length<2)return n;let e=new Map;for(let t of n){let r=Sn(t);if(!r)continue;let i=e.get(r.name);(!i||r.priority>i.priority)&&e.set(r.name,{record:t,priority:r.priority})}return Array.from(e.values()).map(t=>t.record)}function Ce(n){try{if(n&&typeof n.getName=="function"){let e=n.getName();if(typeof e=="string"&&e.length>0)return e}}catch{}return null}function vn(n){try{let e=n?.getBody?.();if(!e||typeof e.getStart!="function"||typeof e.getEnd!="function")return null;let t=typeof e.getKindName=="function"?String(e.getKindName()):"",r=t==="Block"||t==="ModuleBlock",i=e.getStart(),s=e.getEnd(),o=r?i+1:i,l=r?s-1:s;return!Number.isFinite(o)||!Number.isFinite(l)||l<o?null:{start:o,end:l}}catch{return null}}function En(n){let e=n.getParent?.();if(!e)return null;try{if(d.isIfStatement(e)){if(e.getExpression()===n)return"condition";if(e.getThenStatement()===n)return"then";if(e.getElseStatement()===n)return"else"}if(d.isReturnStatement(e)&&e.getExpression?.()===n)return"value";if(d.isVariableDeclaration(e)){if(e.getNameNode?.()===n)return"name";if(e.getInitializer?.()===n)return"initializer"}if(d.isCallExpression(e)||d.isNewExpression(e)){if(e.getExpression?.()===n)return"callee";if((e.getArguments?.()??[]).indexOf(n)>=0)return"argument"}if(d.isPropertyAccessExpression(e)){if(e.getExpression()===n)return"object";if(e.getNameNode()===n)return"property"}}catch{return null}return null}function Je(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}function wn(n){try{if(d.isFunctionDeclaration(n)||d.isMethodDeclaration(n)||d.isConstructorDeclaration(n)||d.isFunctionExpression(n)||d.isArrowFunction(n)){let e=n.getParameters?.();if(Array.isArray(e))return e.length}}catch{}return null}function Pn(n){try{return d.isIdentifier(n)?n.getSymbol():d.isPropertyAccessExpression(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol?.()}catch{return}}function Me(n,e){try{return typeof n?.hasModifier=="function"&&n.hasModifier(e)}catch{return!1}}function Et(n){try{return n.getModuleSpecifierValue?.()??null}catch{try{return n.getModuleSpecifier?.()?.getLiteralText?.()??null}catch{return null}}}function Nn(n,e,t){if(!d.isImportDeclaration(n))return;let i={moduleSpecifier:Et(n),isTypeOnly:n.isTypeOnly(),namedImports:[]};try{let s=n.getDefaultImport();if(s){let o=s.getText();i.defaultImport=o,t(o,s)}}catch{}try{let s=n.getNamespaceImport();if(s){let o=s.getText();i.namespaceImport=o,t(o,s)}}catch{}try{n.getNamedImports().forEach(s=>{try{let o=s.getName(),l=s.getAliasNode(),c=l?l.getText():void 0;o&&(i.namedImports.push({name:o,alias:c||void 0}),t(c||o,s.getNameNode()))}catch{}})}catch{}e.push(i)}function Rn(n,e){if(d.isExportDeclaration(n)){let t=Et(n);if(t){if(n.getNamedExports().length>0)try{n.getNamedExports().forEach(r=>{try{let i=r.getName(),s=r.getAliasNode(),o=s?s.getText():void 0;e.push({kind:"reexport",moduleSpecifier:t,name:i||void 0,alias:o||void 0,isNamespace:!1})}catch{}})}catch{}else if(n.isNamespaceExport())try{let i=n.getNamespaceExport()?.getName();e.push({kind:"reexport",moduleSpecifier:t,name:i||"*",alias:i||void 0,isNamespace:!0})}catch{e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0})}else e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0});return}try{n.getNamedExports().forEach(r=>{try{let i=r.getName();if(!i)return;let s=r.getAliasNode(),o=s?s.getText():i;e.push({kind:"alias",local:i,exported:o})}catch{}})}catch{}return}if(d.isExportAssignment(n))try{let t=n.getExpression();if(t&&d.isIdentifier(t)){let r=t.getText();e.push({kind:"alias",local:r,exported:"default"})}}catch{}}function In(n,e,t,r){if(!Me(n,le.ExportKeyword))return;let i=Me(n,le.DefaultKeyword);if(d.isVariableStatement(n)){try{let s=n.getDeclarationList().getDeclarations();for(let o of s){let l=Ce(o)??o.getName?.()??null;if(l){t(l,o);let c=r(o);c&&e.push({kind:"local",name:l,isDefault:i,nodeId:c})}}}catch{}return}if(d.isFunctionDeclaration(n)||d.isClassDeclaration(n)||d.isInterfaceDeclaration(n)||d.isEnumDeclaration(n)||d.isTypeAliasDeclaration(n)||d.isModuleDeclaration(n)){let s=Ce(n)||(i?"default":null),o=r(n);o&&e.push({kind:"local",name:s??"default",isDefault:i,nodeId:o})}}function wt(n,e,t,r){let i=[],s=[],o=[],l=new Set,c=new Map,u=[],m=[],C=(r?.emitMode??"light")==="full",I=new Map,K=new Map,R=new Map,F=[{node:n,id:null,kind:"module",rawKind:"SourceFile",rawKindSource:"ts-morph",name:null,isExported:!1}],O=a=>{if(!a)return null;try{return e(a)}catch{return null}},U=a=>{let f=a.getParent?.();for(;f;){let h=I.get(f);if(h)return h;f=f.getParent?.()}return null},z=(a,f)=>{if(a&&(l.has(a)||l.add(a),f&&!c.has(a))){let h=O(f);h&&c.set(a,h)}},H=a=>d.isFunctionDeclaration(a)||d.isFunctionExpression(a)||d.isArrowFunction(a)||d.isClassDeclaration(a)||d.isClassExpression(a)||d.isInterfaceDeclaration(a)||d.isEnumDeclaration(a)||d.isEnumMember(a)||d.isTypeAliasDeclaration(a)||d.isModuleDeclaration(a)||d.isMethodDeclaration(a)||d.isMethodSignature(a)||d.isPropertyDeclaration(a)||d.isPropertySignature(a)||d.isGetAccessorDeclaration(a)||d.isSetAccessorDeclaration(a)||d.isConstructorDeclaration(a)||d.isVariableDeclaration(a),ge=a=>d.isSourceFile(a)||d.isFunctionDeclaration(a)||d.isFunctionExpression(a)||d.isArrowFunction(a)||d.isMethodDeclaration(a)||d.isConstructorDeclaration(a)||d.isClassDeclaration(a)||d.isClassExpression(a)||d.isModuleDeclaration(a),V=a=>{let f=Ce(a);if(f)return f;if(d.isConstructorDeclaration(a))return"constructor";if(d.isArrowFunction(a)||d.isFunctionExpression(a)){let h=a.getParent();try{if(d.isVariableDeclaration(h))return h.getName();if(d.isPropertyAssignment(h)||d.isPropertyDeclaration(h)||d.isPropertySignature(h))return h.getName?.()??null;if(d.isShorthandPropertyAssignment(h))return h.getNameNode()?.getText()??null;if(d.isExportAssignment(h))return"default"}catch{}}if(d.isEnumMember(a))try{return a.getName()}catch{return null}if(d.isVariableDeclaration(a))try{return a.getName()}catch{return null}return null},Y=a=>{let f=F[F.length-1],h=f?.id??null,P=f?.kind??"module",g=f?.name??null;if(d.isImportDeclaration(a))Nn(a,u,z);else if(d.isImportEqualsDeclaration(a))try{let S=a.getModuleReference();if(S&&d.isExternalModuleReference(S)){let x=S.getExpression(),v;if(x&&d.isStringLiteral(x))v=x.getLiteralText();else if(x){let w=x.getText();v=typeof w=="string"?w.replace(/^['"]|['"]$/g,""):void 0}if(v){let M=a.getNameNode()?.getText(),_={moduleSpecifier:v,isTypeOnly:!1,namedImports:[]};M&&(_.defaultImport=M,z(M,a)),u.push(_)}}}catch{}(d.isExportDeclaration(a)||d.isExportAssignment(a))&&Rn(a,m),In(a,m,z,O);let y=H(a),E=C||y,N=y?V(a):null;if(E){let S=e(a);y&&s.push({nodeId:S,node:a});let x=U(a),v=x==null?null:K.get(x)??0;x!=null&&v!=null&&K.set(x,v+1),I.set(a,S);let w=x?(R.get(x)??-1)+1:0;R.set(S,w);let M=Me(a,le.ExportKeyword)||f?.isExported||!1,_=y?a.getNameNode?.()?.getText?.()??null:null,D=N??(y?Ce(a)??_:Ce(a));N?z(N,a):D&&z(D,a);let A=Je(a),L=wn(a),k=Ae(a);ke(k,{source:"ts-node-collector",file:n.getFilePath(),name:D??null});let J=vn(a);i.push({nodeId:S,nodeName:D??null,containerId:h,containerKind:P,containerRawKind:f?.rawKind??null,containerRawKindSource:f?.rawKindSource??null,containerName:g,isExported:M,kind:k.kind,rawKind:k.rawKind,rawKindSource:k.rawKindSource,semanticKind:k.semanticKind??null,start:A.start,end:A.end,paramCount:L,metadata:null,parentNodeId:x,role:En(a),indexInParent:v,depth:w,bodyStart:J?.start??null,bodyEnd:J?.end??null})}if(d.isCallExpression(a)||d.isNewExpression(a)){let S=a.getExpression(),x=null,v,w;try{if(w=Pn(S),d.isIdentifier(S))x=S.getText();else if(d.isPropertyAccessExpression(S)){x=S.getName();let D=S.getExpression();d.isIdentifier(D)&&(v=D.getText())}}catch{}let M="";try{M=S.getText()}catch{}let _=Je(a);if(o.push({name:x,kind:d.isNewExpression(a)?"new":"call",containerId:h,containerKind:P,containerName:g,expression:M,objectName:v,symbol:w,start:_.start,end:_.end}),d.isCallExpression(a))try{if(d.isIdentifier(S)&&S.getText()==="require"){let A=a.getArguments()[0],L;if(A&&(d.isStringLiteral(A)||d.isNoSubstitutionTemplateLiteral(A)))try{L=A.getLiteralText()}catch{let k=A.getText();L=typeof k=="string"?k.replace(/^['"]|['"]$/g,""):void 0}if(L){let k={moduleSpecifier:L,isTypeOnly:!1,namedImports:[]},J=a.getParent();if(J&&d.isVariableDeclaration(J)){let Re=J.getNameNode();try{if(d.isIdentifier(Re)){let he=Re.getText();he&&(k.defaultImport=he,z(he,J))}}catch{}}u.push(k)}}else if(S?.getKind?.()===le.ImportKeyword){let A=a.getArguments()[0],L;if(A&&(d.isStringLiteral(A)||d.isNoSubstitutionTemplateLiteral(A)))try{L=A.getLiteralText()}catch{let k=A.getText();L=typeof k=="string"?k.replace(/^['"]|['"]$/g,""):void 0}L&&u.push({moduleSpecifier:L,isTypeOnly:!1,namedImports:[]})}}catch{}}if(d.isCallExpression(a)){let S=a.getExpression();try{if(d.isIdentifier(S)&&S.getText()==="require"){let x=a.getParent();if(!(x&&d.isExternalModuleReference(x))){let w=a.getArguments()[0],M;if(w&&(d.isStringLiteral(w)||d.isNoSubstitutionTemplateLiteral(w)))try{M=w.getLiteralText()}catch{M=w.getText().replace(/^['"]|['"]$/g,"")}if(M){let _={moduleSpecifier:M,isTypeOnly:!1,namedImports:[]};if(x&&d.isVariableDeclaration(x)){let D=x.getNameNode();try{if(d.isIdentifier(D)){let A=D.getText();A&&(_.defaultImport=A,z(A,x))}}catch{}}u.push(_)}}}else if(S?.getKind?.()===le.ImportKeyword){let v=a.getArguments()[0],w;if(v&&(d.isStringLiteral(v)||d.isNoSubstitutionTemplateLiteral(v)))try{w=v.getLiteralText()}catch{w=v.getText().replace(/^['"]|['"]$/g,"")}w&&u.push({moduleSpecifier:w,isTypeOnly:!1,namedImports:[]})}}catch{}}let j=!1;if(ge(a)){let S=O(a)??e(a),x=vt(a);F.push({node:a,id:S,kind:x.kind,rawKind:x.rawKind,rawKindSource:x.rawKindSource,name:N??g,isExported:Me(a,le.ExportKeyword)||f?.isExported||!1}),j=!0}a.forEachChild(Y),j&&F.pop()};if(C){let a=e(n);I.set(n,a),R.set(a,0);let f=Je(n);i.push({nodeId:a,nodeName:n.getBaseName?.()??null,containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:"SourceFile",rawKind:"SourceFile",rawKindSource:"ts-morph",semanticKind:"file",start:f.start,end:f.end,paramCount:null,metadata:null,parentNodeId:null,role:null,indexInParent:null,depth:0,bodyStart:f.start,bodyEnd:f.end})}if(n.forEachChild(Y),r?.includeComments===!0||C||process.env.AST_INDEX_COMMENTS==="1")try{let a=n.getFullText(),f=X.createScanner(X.ScriptTarget.Latest,!1,X.LanguageVariant.Standard,a),h=new Set;for(let P=f.scan();P!==X.SyntaxKind.EndOfFileToken;P=f.scan()){if(P!==X.SyntaxKind.SingleLineCommentTrivia&&P!==X.SyntaxKind.MultiLineCommentTrivia)continue;let g=f.getTokenPos(),y=f.getTextPos(),E=`${g}-${y}`;if(h.has(E)||(h.add(E),t.has(E)))continue;t.add(E);let N=a.substring(g,y),j=bt(P,N),x=e({getKindName:()=>j.name,getKind:()=>j.kind,getPos:()=>g,getEnd:()=>y,getStart:()=>g,getFullStart:()=>g,getText:()=>N,getSourceFile:()=>n,getParent:()=>n,__isComment:!0,__commentPosition:"standalone",__attachedTo:null},"COM"),v=I.get(n)??null,w=C&&v!=null?K.get(v)??0:null;C&&v!=null&&w!=null&&K.set(v,w+1),i.push({nodeId:x,nodeName:N.substring(0,100),containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:j.name,rawKind:j.name,rawKindSource:"ts-morph",semanticKind:null,start:g,end:y,paramCount:null,metadata:null,parentNodeId:v,role:"comment",indexInParent:w,depth:C?1:0,bodyStart:null,bodyEnd:null})}}catch{}return{nodes:i,symbolCandidateNodes:s,references:o,declaredNames:l,localDeclarations:c,imports:u,exports:Cn(m)}}function Pt(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}var Mn=100;function Dn(n,e,t,r){let{start:i,end:s}=Pt(e),o=Ae(e);ke(o,{source:"ts-node-id",file:n,kind:o.kind});let l=r||Z.getAbbrev(o.kind,t);return`${n}#${i}-${s}:${l}`}function Tn(n,e){return Ue.relative(n,e).replace(/\\/g,"/")}function Nt(n,e){if(!n)return null;let t=n;try{let m=n.getAliasedSymbol();m&&(t=m)}catch{}let r=[];try{r=t.getDeclarations()??[]}catch{r=[]}if(!r.length)return null;let s=r.slice().sort((m,p)=>{let C=m.getSourceFile().getFilePath(),I=p.getSourceFile().getFilePath();if(C!==I)return C.localeCompare(I);let K=m.getStart(!1),R=p.getStart(!1);return K!==R?K-R:m.getEnd()-p.getEnd()})[0],o=Tn(e,s.getSourceFile().getFilePath()),l=s.getStart(!1),c=s.getEnd(),u="";try{u=t.getEscapedName()}catch{try{u=t.getName()}catch{u=""}}return`${o}#${l}-${c}:${u}`}function Kn(n){try{return G.isVariableDeclaration(n)||G.isEnumMember(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol()}catch{return}}function _n(n,e){let t=n.getDescendantAtPos(e);if(!t)return;let r=t;if(!G.isCallExpression(r)&&!G.isNewExpression(r)&&(r=t.getFirstAncestor(s=>G.isCallExpression(s)||G.isNewExpression(s))??void 0),!r||!G.isCallExpression(r)&&!G.isNewExpression(r))return;let i=r.getExpression();try{return G.isIdentifier(i)?i.getSymbol():G.isPropertyAccessExpression(i)?i.getNameNode().getSymbol()??i.getSymbol():i.getSymbol()}catch{return}}async function On(n){let{sf:e,fileRel:t,content:r,preDeleted:i,meta:s,projectRoot:o,lang:l}=n,c=n.emitMode??"light",m=wt(e,(g,y)=>Dn(t,g,l,y),new Set,{includeComments:c==="full",emitMode:c}),p=new Map;for(let{nodeId:g,node:y}of m.symbolCandidateNodes){let E=Nt(Kn(y),o);E&&(p.has(g)||p.set(g,E))}let C=[],I=new Map,K=m.exports.filter(g=>g.kind!=="reexport"),R=m.exports.filter(g=>g.kind==="reexport");for(let g of K)if(g.kind==="local"){let y=g.isDefault?"default":g.name;if(!y||I.has(y))continue;let E=g.nodeId;C.push([t,y,E,0,null,null,g.isDefault?"default":"named"]),I.set(y,E)}else if(g.kind==="alias"){let y=g.exported;if(!y||I.has(y))continue;C.push([t,y,null,0,null,g.local,"alias"]),I.set(y,"alias")}for(let g of R){let y=g.moduleSpecifier;if(!y)continue;let E=y;if(g.isNamespace){let N=g.alias||"*";if(I.has(N))continue;C.push([t,N,null,1,E,g.name||N,"reexport_star"]),I.set(N,"reexport")}else{let N=g.alias||g.name;if(!N||I.has(N))continue;C.push([t,N,null,1,E,g.name||N,"reexport_named"]),I.set(N,"reexport")}}let F=[],O=typeof r=="string"?r:null;if(O==null)try{let g=e.getFullText();O=typeof g=="string"?g:null}catch{O=null}for(let g of m.nodes){let{nodeId:y,nodeName:E,containerKind:N,containerRawKind:j,containerRawKindSource:S,isExported:x,kind:v,rawKind:w,rawKindSource:M,semanticKind:_,start:D,end:A,paramCount:L,metadata:k,parentNodeId:J,role:Re,indexInParent:he,depth:mn,bodyStart:fn,bodyEnd:gn}=g,hn=k&&Object.keys(k).length?JSON.stringify(k):null,yn=p.get(y)??null;F.push([y,E??null,v,w??v,M??null,_??null,D,A,x?1:0,N??"module",j??N??"module",S??null,L,null,null,yn,hn,J??null,Re??null,he??null,mn??0,fn??null,gn??null])}let U=[];for(let g of m.references){let{name:y,kind:E,containerId:N,containerName:j,expression:S,objectName:x,start:v,end:w}=g,M=null,_=null,D=Nt(g.symbol??_n(e,v),o),A=y?m.localDeclarations.get(y):void 0;A&&(M=A,_=t,D||(D=p.get(A)??null));let L=Ie({sourceFile:t,sourceStart:v,sourceEnd:w,refKind:E,refName:y,targetFile:_,targetNodeId:M}),k={};S&&(k.expression=S),x&&(k.objectName=x),j&&(k.containerName=j);let J=Object.keys(k).length?JSON.stringify(k):null;U.push([L,t,N,y,E,v,w,M,_,M?"resolved":"unresolved",x??null,null,null,D,J])}let z=[],H=[];for(let g of m.imports){let y=g.moduleSpecifier??null;z.push([t,y,g.isTypeOnly?1:0]),g.defaultImport&&H.push([t,y,"default",g.defaultImport,"default",g.isTypeOnly?1:0]),g.namespaceImport&&H.push([t,y,"namespace",g.namespaceImport,"*",g.isTypeOnly?1:0]);for(let E of g.namedImports){let N=E.alias||E.name;H.push([t,y,"named",N,E.name,g.isTypeOnly?1:0])}}let ge=Ue.join(o,t),V=s?.size,Y=s?.mtime;if(V===void 0||Y===void 0)try{let g=An.statSync(ge);V=g.size,Y=Math.floor(g.mtimeMs)}catch{}let a=new Date().toISOString(),f=c==="full",h=[t,Y??null,V??null,"completed",a,f?1:0],P=null;if(typeof O=="string")P={blobOid:t,content:O};else try{let g=e.getFullText?.();typeof g=="string"&&(P={blobOid:t,content:g})}catch(g){console.log(`[TypescriptIndexer] Failed to compute FTS payload for ${t}:`,g?.message??g)}return{payload:{lang:l,fileRel:t,preDeleted:i,exportRows:C,nodeRows:F,referenceRows:U,importRows:z,importBindingRows:H,fileRow:h,fts:P,fullyIndexed:f},fileSize:V,mtime:Y}}var We=class{constructor(e,t){this.project=null;this.filesProcessed=0;this.projectRoot=e,this.lang=t}getProject(){return this.project||(this.project=new kn({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0})),this.project}disposeProject(){if(this.project){try{let e=this.project.getLanguageService().compilerObject;typeof e?.dispose=="function"&&e.dispose()}catch{}this.project=null}}async process(e){let t=this.getProject(),r;try{let i=t.createSourceFile(Ue.join(this.projectRoot,e.relPath),e.content,{overwrite:!0});r=await On({sf:i,fileRel:e.relPath,content:e.content,preDeleted:!!e.preDeleted,meta:e.meta,projectRoot:this.projectRoot,lang:e.lang,emitMode:e.emitMode??"light"})}catch(i){this.disposeProject(),this.filesProcessed=0;let s=i?.message||String(i);throw new Error(`TypeScript parser failed for ${e.relPath}: ${s}`)}return this.filesProcessed++,this.filesProcessed>=Mn&&(this.disposeProject(),this.filesProcessed=0),{payload:r.payload,fileSize:r.fileSize,mtime:r.mtime}}};function Ln(n){return n==="ts"?[".ts",".tsx",".mts",".cts"]:n==="js"?[".js",".jsx",".mjs",".cjs"]:[]}function Xe(n){return{id:n,extensions:Ln(n),indexingMode:"worker",createIndexer:e=>new We(e,n)}}import Te from"fs";import ee from"path";import{spawn as $n}from"child_process";import Fn from"fs";var ce=class{constructor(e=5e3){this.maxEntries=e;this.cache=new Map}get(e,t){let r=this.cache.get(e);if(!r)return null;let i=t?.mtime??null,s=t?.size??null;return i!=null&&s!=null&&r.mtime===i&&r.size===s?r.result:null}set(e,t,r){let i=t?.mtime??null,s=t?.size??null;this.cache.set(e,{mtime:i,size:s,result:r}),this.cache.size>this.maxEntries&&this.cache.clear()}};var Ge=class{constructor(e,t,r,i){this.projectRoot=e;this.lang=t;this.parse=r;this.exportKind=i;this.cache=new ce}async process(e){let t=e.meta?.mtime,r=e.meta?.size;if(t==null||r==null)try{let o=Fn.statSync(e.absPath);t=Math.floor(o.mtimeMs),r=o.size}catch{}let i=e.emitMode==="full"?null:this.cache.get(e.absPath,{mtime:t,size:r});if(i)return be({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:i,resolveNodeId:Rt(e.relPath,i,this.lang),exportKind:this.exportKind??"cli",fullyIndexed:e.emitMode==="full"});let s=null;try{s=await this.parse({absPath:e.absPath,relPath:e.relPath,content:e.content,meta:{mtime:t,size:r},projectRoot:this.projectRoot,lang:this.lang,emitMode:e.emitMode??"light"})}catch(o){try{console.log(`[CliContract:${this.lang}] parse threw for ${e.relPath}: ${o?.message||String(o)}`)}catch{}return ye(this.lang,e.relPath,{mtime:t,size:r})}return!s||s.error?ye(this.lang,e.relPath,{mtime:t,size:r}):(e.emitMode!=="full"&&this.cache.set(e.absPath,{mtime:t,size:r},s),be({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:s,resolveNodeId:Rt(e.relPath,s,this.lang),exportKind:this.exportKind??"cli",fullyIndexed:e.emitMode==="full"}))}};function Rt(n,e,t){let r=new Map;for(let i of e.nodes??[]){if(!i.name||r.has(i.name))continue;let s=`${n}#${i.start}-${i.end}:${Z.getAbbrev(i.kind,t)}`;r.set(i.name,s)}return i=>r.get(i)??null}function Q(n){return{id:n.id,extensions:n.extensions,indexingMode:"worker",createIndexer:e=>new Ge(e,n.id,n.parse,n.exportKind),resolveSpan:n.resolve?async(e,t,r)=>n.resolve({projectRoot:e,absPath:t,nodePath:r,lang:n.id}):void 0}}import jn from"fs";import De from"path";var Qe=null;function Bn(n){for(let e of n)if(jn.existsSync(e))return e;return null}function q(n){let e=Qe?.toolsRoot??process.env.PANDO_TOOLS_ROOT,t=Qe?.runtimeRoot??process.env.PANDO_RUNTIME_ROOT,r=Qe?.resourcesRoot??process.env.PANDO_RESOURCES_ROOT,i=[e?De.join(e,n):null,t?De.join(t,"tools",n):null,r?De.join(r,"tools",n):null,De.resolve(process.cwd(),"tools",n)].filter(s=>!!s);return Bn(i)}function W(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
2
+ `)}catch{}}var zn=Number(process.env.PANDO_PYTHON_WORKER_PARSE_TIMEOUT_MS||18e4),qn=Number(process.env.PANDO_PYTHON_WORKER_RESOLVE_TIMEOUT_MS||6e4),pe=class extends Error{constructor(t,r){super(t);this.fatal=r;this.name="PythonWorkerRequestError"}},Ke=class{constructor(e,t){this.interpreter=e;this.scriptPath=t;this.buffer=Buffer.alloc(0);this.pending=new Map;this.requestQueue=Promise.resolve();this.seq=1;this.closed=!1;if(this.proc=$n(this.interpreter,["-u",this.scriptPath],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw new Error("python worker stdio unavailable");this.proc.stdout.on("data",r=>this.onData(r)),this.proc.stderr.on("data",r=>{W(`[PythonWorker] ${r.toString("utf8").trim()}`)}),this.proc.stdin.on("error",r=>this.handleError(r)),this.proc.on("error",r=>this.handleError(r)),this.proc.on("exit",r=>this.handleError(new Error(`python worker exited with code ${r}`))),this.ready=this.ping()}handleError(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.timeout&&clearTimeout(t.timeout),t.summary&&W("[PythonCliAdapter] worker error",{interpreter:this.interpreter,error:e.message,...t.summary}),t.reject(e);this.pending.clear();try{this.proc.stdin?.end()}catch{}try{this.proc.kill()}catch{}}}onData(e){for(this.buffer=Buffer.concat([this.buffer,e]);this.buffer.length>=4;){let t=this.buffer.readUInt32BE(0);if(this.buffer.length<4+t)return;let r=this.buffer.slice(4,4+t);this.buffer=this.buffer.slice(4+t);let i=null;try{i=JSON.parse(r.toString("utf8"))}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),s.timeout&&clearTimeout(s.timeout),i.ok?s.resolve(i):s.reject(new pe(i.error||"python worker error",!1)))}}sendMessage(e){if(this.closed)throw new Error("python worker is closed");let t=Buffer.from(JSON.stringify(e),"utf8"),r=Buffer.alloc(4);r.writeUInt32BE(t.length,0),this.proc.stdin.write(r),this.proc.stdin.write(t)}async requestRaw(e,t,r=1e4){let i=this.seq++,s={id:i,op:e,...t},o={op:e,id:i};return typeof t?.path=="string"&&(o.path=t.path),typeof t?.nodePath=="string"&&(o.nodePath=t.nodePath),typeof t?.content_b64=="string"&&(o.contentBytes=t.content_b64.length),new Promise((l,c)=>{let u=setTimeout(()=>{this.pending.delete(i);let m=new pe(`python worker timeout (${e})`,!0);W("[PythonCliAdapter] worker timeout",{op:e,id:i,timeoutMs:r,pending:this.pending.size,interpreter:this.interpreter,...o}),c(m),this.handleError(m)},r);this.pending.set(i,{resolve:l,reject:c,timeout:u,summary:o}),this.pending.size%200===0&&W("[PythonCliAdapter] worker pending",{op:e,pending:this.pending.size,interpreter:this.interpreter});try{this.sendMessage(s)}catch(m){clearTimeout(u),this.pending.delete(i),c(m)}})}async enqueueRequest(e){let t=this.requestQueue.catch(()=>{}),r,i=new Promise(s=>{r=s});this.requestQueue=t.then(()=>i),await t;try{return await e()}finally{r()}}async request(e,t,r=1e4){await this.ready;let i=Date.now();return this.enqueueRequest(async()=>{let s=Date.now()-i,o=Date.now();s>2e3&&W("[PythonCliAdapter] worker queued",{op:e,queueMs:s,interpreter:this.interpreter,path:t?.path});let l=await this.requestRaw(e,t,r),c=Date.now()-o;return c>2e3&&W("[PythonCliAdapter] worker slow",{op:e,ms:c,queueMs:s,pending:this.pending.size,interpreter:this.interpreter,path:t?.path}),l})}async ping(){await this.requestRaw("ping",{},5e3)}async parse(e){let t=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("parse",{path:e.path,content_b64:t,encoding:e.encoding,emit_mode:e.emitMode??"light"},zn);return r.nodes?r:null}async resolve(e){let t=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("resolve",{path:e.path,nodePath:e.nodePath,content_b64:t,encoding:e.encoding},qn);return typeof r.start=="number"&&typeof r.end=="number"?r:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.timeout&&clearTimeout(t.timeout),t.reject(new Error("python worker client closed"));this.pending.clear();let e=this.proc;try{e.stdin?.end()}catch{}try{e.kill()}catch{}}};function It(n){let e=ee.resolve(n,"tools/python-indexer/pando_python_worker.py");if(Te.existsSync(e))return e;let t=q("python-indexer/pando_python_worker.py");if(t)return t;let r=ee.resolve(__dirname,"../../../../../tools/python-indexer/pando_python_worker.py");return Te.existsSync(r)?r:null}var de=new Map;function ue(n){try{return Te.readFileSync(n,"utf8")}catch{return null}}function ve(n){if(!n)return null;let e=n.match(/(\d+)\.(\d+)/);return e?{major:Number(e[1]),minor:Number(e[2])}:null}function Jn(n){let e=ue(ee.join(n,"pyproject.toml"));if(e){let l=e.match(/requires-python\s*=\s*"([^"]+)"/i),c=ve(l?.[1]??null);if(c)return c}let t=ue(ee.join(n,"setup.cfg"));if(t){let l=t.match(/python_requires\s*=\s*([\w\d\.<>~=\s]+)/i),c=ve(l?.[1]??null);if(c)return c}let r=ue(ee.join(n,"setup.py"));if(r){let l=r.match(/python_requires\s*=\s*['\"]([^'\"]+)['\"]/i),c=ve(l?.[1]??null);if(c)return c}let i=ue(ee.join(n,"tox.ini"));if(i){let l=i.match(/envlist\s*=\s*([^\n]+)/i);if(l&&l[1]){let c=l[1].split(/[,\s]+/).filter(Boolean);for(let u of c){let m=u.match(/py(\d)(\d)/i);if(m)return{major:Number(m[1]),minor:Number(m[2])}}}}let s=ue(ee.join(n,".python-version"));if(s){let l=ve(s.trim());if(l)return l}let o=ue(ee.join(n,"runtime.txt"));if(o){let l=o.match(/python-(\d+\.\d+)/i),c=ve(l?.[1]??null);if(c)return c}return null}function At(n){return Jn(n)?.major===2?["python2","python","python3"]:["python3","python","python2"]}async function Wn(n,e,t,r){let i=It(n);if(!i)return null;let s=At(n);for(let o of s){let l=`${o}::${i}`,c=de.get(l);if(!c)try{c=new Ke(o,i),de.set(l,c)}catch{continue}try{let u=await c.parse({path:e,content:t,encoding:"utf-8",emitMode:r});if(u)return u}catch(u){let m=u?.message||String(u),p=u instanceof pe?u.fatal:/timeout|closed|exited|EPIPE|ENOENT|spawn/i.test(m);W("[PythonCliAdapter] worker parse error",{file:e,interpreter:o,script:i,fatal:p,error:m}),p&&de.delete(l)}}return null}async function Un(n,e,t,r){let i=It(n);if(!i)return null;let s=At(n);for(let o of s){let l=`${o}::${i}`,c=de.get(l);if(!c)try{c=new Ke(o,i),de.set(l,c)}catch{continue}try{let u=await c.resolve({path:e,nodePath:r,content:t,encoding:"utf-8"});if(u)return u}catch(u){let m=u?.message||String(u),p=u instanceof pe?u.fatal:/timeout|closed|exited|EPIPE|ENOENT|spawn/i.test(m);W("[PythonCliAdapter] worker resolve error",{file:e,interpreter:o,nodePath:r,script:i,fatal:p,error:m}),p&&de.delete(l)}}return null}async function Xn(n){let e=Date.now(),t=!1,r=null;try{r=await Wn(n.projectRoot,n.absPath,n.content,n.emitMode??"light"),t=!!r}catch{}if(!r){W(`[PythonCliAdapter] parse failed for ${n.relPath} via python worker`);let o=Date.now()-e;return o>2e3&&W("[PythonCliAdapter] parse slow (failed)",{file:n.relPath,ms:o}),null}let i=[];for(let o of r.references||[]){let l={};o.expression&&(l.expression=o.expression),o.objectName&&(l.objectName=o.objectName),o.containerName&&(l.containerName=o.containerName),o.containerKind&&(l.containerKind=o.containerKind),i.push({sourceStart:o.start,sourceEnd:o.end,refKind:o.kind,refName:o.name,receiverName:o.receiverName??o.objectName??null,arity:typeof o.arity=="number"?o.arity:null,containerQualifiedName:o.containerQualifiedName??null,targetSymbolKey:o.targetSymbolKey??null,metadata:Object.keys(l).length?l:null})}let s=Date.now()-e;return s>2e3&&W("[PythonCliAdapter] parse slow",{file:n.relPath,ms:s,usedWorker:t}),{nodes:r.nodes,imports:r.imports,importBindings:r.importBindings,references:i,modulePublic:r.modulePublic??void 0,explicitExports:r.explicitExports??void 0}}function kt(){return Q({id:"python",extensions:[".py",".pyw",".pyi"],exportKind:"named",parse:({absPath:n,relPath:e,projectRoot:t,content:r,emitMode:i})=>Xn({absPath:n,relPath:e,projectRoot:t,content:r,emitMode:i}),resolve:async({absPath:n,nodePath:e,projectRoot:t})=>{try{let r=Te.readFileSync(n,"utf8"),i=await Un(t,n,r,e);if(i)return i}catch{}return null}})}import Tt from"fs";import Kt from"path";import{spawn as Yn,spawnSync as es}from"child_process";var Gn=!1,_e=new Set,Mt=!1;function Qn(n){_e.add(n),Vn()}function Hn(n){_e.delete(n)}function te(n){return Qn(n),n.on?.("exit",()=>Hn(n)),n}function Dt(n="SIGKILL"){Gn=!0;for(let e of _e)try{e.kill(n)}catch{}_e.clear()}function Vn(){if(Mt)return;Mt=!0,process.on("exit",()=>{Dt("SIGKILL")});let n=()=>{Dt("SIGKILL")};process.once("SIGINT",n),process.once("SIGTERM",n),process.once("SIGHUP",n)}var Zn=256e3,er=32;function re(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
3
+ `)}catch{}}var He=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=Yn(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("csharp indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{re(`[CSharpIndexer] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`csharp indexer exited with code ${e}`))),te(this.proc)}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
4
4
  `);if(t<0)break;let r=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"csharp server error")))}}async request(e,t=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e};this.pending.set(r,{resolve:i,reject:s});try{this.proc.stdin.write(`${JSON.stringify(o)}
5
- `)}catch(l){if(this.pending.delete(r),t>0){try{this.handleExit(l)}catch{}return this.request(e,t-1).then(i,s)}s(l)}})}async parseBatch(e){let t=await this.request({op:"parse",files:e});return"results"in t?t.results.map(r=>r.ok&&r.result?r.result:null):"result"in t?[t.result]:e.map(()=>null)}async resolve(e){let t=await this.request({op:"resolve",...e});return"result"in t&&t.result&&typeof t.result.start=="number"?t.result:null}async resolveReferences(e){let t=await this.request({op:"resolve-references",...e});return"result"in t&&t.result?t.result:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.reject(new Error("csharp indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}},Ge=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((t,r)=>{this.queue.push({input:e,resolve:t,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],t=0;for(;this.queue.length&&e.length<Un;){let r=this.queue[0];if(e.length>0&&t+r.input.size>Wn)break;e.push(this.queue.shift()),t+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang,emitMode:i.input.emitMode})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,l=Date.now()-s.startedAt;l>2e3&&ne(`[${new Date().toISOString()}] [CSharpCliAdapter] parse slow`,{file:s.input.file,ms:l,path:"custom",ok:!!o}),o||ne(`[${new Date().toISOString()}] [CSharpCliAdapter] parse failed`,{file:s.input.file,ms:l,path:"custom"}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},Mt=new Map,Dt=new Map;function Xn(n){let e=process.platform==="win32"?".cmd":"",t=q(`csharp-indexer/bin/pando-csharp-indexer${e}`);if(t)return t;if(n){let i=kt.resolve(n,"tools/csharp-indexer/bin/pando-csharp-indexer"+e);if(At.existsSync(i))return i}let r=kt.resolve(__dirname,"../../../../../tools/csharp-indexer/bin/pando-csharp-indexer"+e);return At.existsSync(r)?r:null}function Tt(n){let e=process.env.PANDO_CSHARP_INDEXER_CMD||Xn(n);if(!e)return null;let t=Mt.get(e);t||(t=new Qe(e),Mt.set(e,t));let r=Dt.get(e);return r||(r=new Ge(t),Dt.set(e,r)),{client:t,batcher:r}}async function Qn(n,e,t,r){let i=Tt(e);if(!i)return null;try{return await i.batcher.enqueue({file:n,root:e,lang:"csharp",size:t,emitMode:r})}catch(s){return ne(`[${new Date().toISOString()}] [CSharpCliAdapter] parse error`,{file:n,error:s?.message||s,path:"custom"}),null}}async function Gn(n,e,t,r){let i=await Qn(n,e,t,r);return i||null}function Kt(){return G({id:"csharp",extensions:[".cs",".csx",".cshtml",".razor"],parse:({absPath:n,projectRoot:e,content:t,meta:r,emitMode:i})=>{let s=r?.size??Buffer.byteLength(t,"utf8");return Gn(n,e,s,i??"light")},resolve:({absPath:n,nodePath:e,projectRoot:t})=>{let r=Date.now(),i=Tt(t);return i?i.client.resolve({file:n,root:t,lang:"csharp",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&ne(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve slow`,{file:n,ms:o}),s||ne(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve failed`,{file:n,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return ne(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve error`,{file:n,ms:o,nodePath:e,error:s?.message||s}),null}):null}})}import{spawnSync as or}from"child_process";import ar from"fs";import Ye from"path";import $ from"fs";import b from"path";var ve=new Map,Vn=["include","src","lib","libs","third_party","third-party","deps","vendor","build","build/src","build_pando","build_pando/src"],Ve=["build","out","build-debug","build-release","cmake-build-debug","cmake-build-release","build_pando"],Lt=new Set([".c",".cc",".cpp",".cxx",".c++",".cp",".m",".mm"]),Ft=new Set([".h",".hh",".hpp",".hxx",".h++",".inl",".ipp",".tcc"]);function me(n){let e=[],t="",r=null,i=!1;for(let s=0;s<n.length;s+=1){let o=n[s];if(i){t+=o,i=!1;continue}if(o==="\\"){i=!0;continue}if(r){o===r?r=null:t+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(o===" "||o===`
6
- `||o===" "||o==="\r"){t&&(e.push(t),t="");continue}t+=o}return t&&e.push(t),e}function Hn(n,e){let t=[];for(let r=0;r<n.length;r+=1){let i=n[r];if(i==="-c")continue;if(i==="-o"){r+=1;continue}if(i===e)continue;let s=b.extname(i).toLowerCase();Lt.has(s)||t.push(i)}return t}function jt(n,e){return b.isAbsolute(n)?b.resolve(n):e?b.resolve(e,n):b.resolve(n)}function Yn(n){try{let e=$.readFileSync(n,"utf8"),t=JSON.parse(e),r=new Map,i=[];for(let s of t){let o=s.directory?b.resolve(s.directory):void 0,l=s.file?jt(s.file,o):null;if(!l)continue;let c=o??b.dirname(l),u=Array.isArray(s.arguments)?s.arguments:s.command?me(s.command):[];if(u.length===0)continue;let p={args:Hn(u.slice(1),l),cwd:c,file:l};r.set(l,p),i.push(p)}return{map:r,entries:i}}catch{return null}}function Zn(n){try{let e=$.readFileSync(n,"utf8");return me(e.replace(/\r/g,`
7
- `))}catch{return null}}function Bt(n){let e=b.join(n,"compile_commands.json");if($.existsSync(e))return e;for(let o of Ve){let l=b.join(n,o,"compile_commands.json");if($.existsSync(l))return l}let t=Ve.map(o=>b.join(n,o)).filter(o=>$.existsSync(o));t.push(n);let r=10,i=new Set,s=(o,l)=>{if(l>r)return null;let c=b.resolve(o);if(i.has(c))return null;i.add(c);try{let u=$.readdirSync(o,{withFileTypes:!0});for(let m of u)if(m.isFile()&&m.name==="compile_commands.json")return b.join(o,m.name);for(let m of u){if(!m.isDirectory()||m.name==="node_modules"||m.name.startsWith("."))continue;let p=s(b.join(o,m.name),l+1);if(p)return p}}catch{}return null};for(let o of t){let l=s(o,0);if(l)return l}return null}function er(n,e){let t=b.resolve(n),r=b.resolve(e);for(;;){let i=Bt(t);if(i)return i;if(t===r)break;let s=b.dirname(t);if(s===t)break;t=s}return null}function $t(n){let e=b.join(n,"compile_flags.txt");if($.existsSync(e))return e;for(let t of Ve){let r=b.join(n,t,"compile_flags.txt");if($.existsSync(r))return r}return null}function tr(n,e){let t=b.resolve(n),r=b.resolve(e);for(;;){let i=$t(t);if(i)return i;if(t===r)break;let s=b.dirname(t);if(s===t)break;t=s}return null}function Ee(n){if(n)try{return $.statSync(n).mtimeMs}catch{return}}function nr(n){let e=[],t=new Set([".clangd","CMakeLists.txt","meson.build","meson_options.txt","Makefile","makefile","GNUmakefile","configure.ac","configure.in"]),r=5,i=200,s=(o,l)=>{if(l>r||e.length>=i)return;let c;try{c=$.readdirSync(o,{withFileTypes:!0})}catch{return}for(let u of c){if(e.length>=i)break;let m=b.join(o,u.name);u.isFile()&&(t.has(u.name)||u.name.endsWith(".cmake"))&&e.push(m)}for(let u of c){if(e.length>=i)break;u.isDirectory()&&(u.name==="node_modules"||u.name===".git"||u.name===".pando"||u.name.startsWith(".cache")||s(b.join(o,u.name),l+1))}};return s(n,0),e}function te(n,e,t){if(!t)return;let r=t.trim();!r||e.has(r)||(e.add(r),n.push(r))}function pe(n,e,t,r){let i=r.trim().replace(/^["']|["']$/g,"");if(!i||i.startsWith("$")||i.includes("${")||i.includes("<"))return;let s=b.isAbsolute(i)?i:b.resolve(t,i);$.existsSync(s)&&te(n,e,`-I${s}`)}function _t(n){let e=[],t=new Set,r;for(let i of nr(n)){let s=Ee(i);s&&(!r||s>r)&&(r=s);let o="";try{o=$.readFileSync(i,"utf8")}catch{continue}let l=b.dirname(i),c=o.replace(/#[^\n]*/g," "),u=me(c.replace(/[()[\]{},;]/g," "));for(let m=0;m<u.length;m+=1){let p=u[m];(p==="-I"||p==="-isystem"||p==="/I")&&u[m+1]?(pe(e,t,l,u[m+1]),m+=1):p.startsWith("-I")&&p.length>2||p.startsWith("/I")&&p.length>2?pe(e,t,l,p.slice(2)):p.startsWith("-isystem")&&p.length>8?pe(e,t,l,p.slice(8)):p.startsWith("-D")||p.startsWith("/D")?te(e,t,p.startsWith("/D")?`-D${p.slice(2)}`:p):p.startsWith("-std=")&&te(e,t,p)}for(let m of o.matchAll(/\b(?:target_)?include_directories\s*\(([^)]*)\)/gims))for(let p of me(m[1].replace(/[()[\]{},;]/g," ")))/^(PRIVATE|PUBLIC|INTERFACE|SYSTEM|BEFORE|AFTER)$/i.test(p)||pe(e,t,l,p);for(let m of o.matchAll(/\b(?:add_compile_definitions|target_compile_definitions)\s*\(([^)]*)\)/gims))for(let p of me(m[1].replace(/[()[\]{},;]/g," ")))/^(PRIVATE|PUBLIC|INTERFACE)$/i.test(p)||p.includes("$")||te(e,t,p.startsWith("-D")?p:`-D${p}`);for(let m of o.matchAll(/\binclude_directories\s*:\s*\[([^\]]*)\]/gims))for(let p of me(m[1].replace(/,/g," ")))pe(e,t,l,p)}return{args:e,mtime:r}}function rr(n,e){let t=b.resolve(n).split(b.sep),r=b.resolve(e).split(b.sep),i=0;for(;i<t.length&&i<r.length&&t[i]===r[i];)i+=1;return i}function ir(n,e){if(!n||n.length===0)return null;let t=b.dirname(e),r=b.extname(e).toLowerCase(),i=b.basename(e,r),s=null;for(let o of n){let l=b.extname(o.file).toLowerCase();if(!Lt.has(l))continue;let c=b.dirname(o.file),u=b.basename(o.file,l),m=rr(e,o.file);c===t&&(m+=100),u===i&&(m+=50),Ft.has(r)&&(m+=20),(!s||m>s.score)&&(s={entry:o,score:m})}return s?.entry??null}function Ot(n,e){let t=e?`${b.resolve(n)}::${b.resolve(e)}`:b.resolve(n),r=ve.get(t);if(r){let K=Ee(r.commandsPath);if(r.commandsPath&&K&&r.commandsMtime&&K!==r.commandsMtime)ve.delete(t);else if(r.flagsPath){let R=Ee(r.flagsPath);if(R&&r.flagsMtime&&R!==r.flagsMtime)ve.delete(t);else return r}else if(r.projectConfigFlags){let R=_t(e??n);if(r.projectConfigMtime&&R.mtime&&r.projectConfigMtime!==R.mtime)ve.delete(t);else return r}else return r}let i=e?er(e,n):Bt(n),s=i?Yn(i)??void 0:void 0,o=s?.map,l=s?.entries,c=Ee(i),u=o?null:e?tr(e,n):$t(n),m=u?Zn(u)??void 0:void 0,p=Ee(u),C=!o&&!m?_t(e??n):void 0,I={commands:o,commandEntries:l,flags:m,projectConfigFlags:C?.args,commandsPath:i,commandsMtime:c,flagsPath:u,flagsMtime:p,projectConfigMtime:C?.mtime};return ve.set(t,I),I}function zt(n,e,t){let r=b.dirname(e),i=Ot(n);!i.commands&&!i.flags&&(!i.projectConfigFlags||i.projectConfigFlags.length===0)&&(i=Ot(n,r));let s=jt(e);if(i.commands){let o=i.commands.get(s);if(o)return{args:o.args,cwd:o.cwd,source:"compile_commands"};let l=ir(i.commandEntries,s);if(l)return{args:l.args,cwd:l.cwd,source:"compile_commands"}}return i.flags?{args:i.flags,cwd:n,source:"compile_flags"}:i.projectConfigFlags&&i.projectConfigFlags.length>0?{args:qt(i.projectConfigFlags,n,t),cwd:n,source:"project_config"}:He(n,t)}function sr(n){let e=[],t=new Set,r=l=>{let c=b.resolve(l);!t.has(c)&&$.existsSync(c)&&(t.add(c),e.push(c))};r(n);for(let l of Vn)r(b.join(n,l));let i=Number(process.env.PANDO_CLANG_FALLBACK_INCLUDE_DEPTH||"5"),s=Number(process.env.PANDO_CLANG_FALLBACK_INCLUDE_MAX_DIRS||"300"),o=(l,c)=>{if(c>i||e.length>=s)return;let u;try{u=$.readdirSync(l,{withFileTypes:!0})}catch{return}u.some(p=>p.isFile()&&Ft.has(b.extname(p.name).toLowerCase()))&&r(l);for(let p of u){if(e.length>=s)break;p.isDirectory()&&(p.name==="node_modules"||p.name===".git"||p.name===".pando"||p.name.startsWith(".cache")||o(b.join(l,p.name),c+1))}};return o(n,0),e}function qt(n,e,t){let r=[...n],i=new Set(r);r.some(s=>s.startsWith("-std="))||te(r,i,"-std="+(t==="cpp"?"c++20":"c17"));for(let s of sr(e))te(r,i,`-I${s}`);for(let s of["-ferror-limit=0","-Wno-everything","-fparse-all-comments","-fms-extensions"])te(r,i,s);return t==="cpp"&&te(r,i,"-fdelayed-template-parsing"),r}function He(n,e){return{args:qt([],n,e),cwd:n,source:"fallback"}}var is=(()=>{let n=Number(process.env.PANDO_CLANG_AST_MAX_BUFFER_BYTES||"");if(Number.isFinite(n)&&n>0)return Math.floor(n);let e=Number(process.env.PANDO_CLANG_AST_MAX_BUFFER_MB||"");return Number.isFinite(e)&&e>0?Math.floor(e*1024*1024):1536*1024*1024})();function lr(){let n=process.env.PANDO_CLANG_INDEXER_CMD;if(n&&n.trim())return n.trim();let e=q("clang-indexer/bin/pando-clang-indexer");if(e)return e;let t=[process.env.PANDO_TOOLS_ROOT?Ye.join(process.env.PANDO_TOOLS_ROOT,"clang-indexer","bin","pando-clang-indexer"):null,process.env.PANDO_RUNTIME_ROOT?Ye.join(process.env.PANDO_RUNTIME_ROOT,"tools","clang-indexer","bin","pando-clang-indexer"):null,typeof __dirname=="string"?Ye.resolve(__dirname,"..","..","..","..","..","tools","clang-indexer","bin","pando-clang-indexer"):null].filter(r=>!!r);for(let r of t)try{if(ar.existsSync(r))return r}catch{}return"pando-clang-indexer"}function cr(n){if(!n)return null;let e=n;(e.startsWith("SyntaxError:")||e.startsWith("CompileError:"))&&(e=e.substring(e.indexOf(":")+1)),e.includes("#")&&(e=e.split("#")[1]);let t=e.lastIndexOf(":"),r=t>=0?e.slice(0,t):e,[i,s]=r.split("-"),o=Number(i),l=Number(s);return!Number.isFinite(o)||!Number.isFinite(l)||l<o?null:{start:o,end:l}}function Ze(n){return G({id:n,extensions:[],parse:({absPath:e,relPath:t,content:r,projectRoot:i})=>{let s=zt(i,e,n),o=u=>["--file",e,"--project-root",i,"--lang",n,"--cwd",u.cwd,"--",...u.args,"-fsyntax-only","-fno-color-diagnostics","-fno-diagnostics-color",...u.source==="fallback"?["-x",n==="cpp"?"c++":"c"]:[]],l=u=>{let m=lr(),p=or(m,o(u),{encoding:"utf8",cwd:u.cwd,maxBuffer:32*1024*1024});if(p.error){try{console.error(`[ClangAdapter] pando-clang-indexer spawn failed ${JSON.stringify({file:e,command:m,error:p.error.message})}`)}catch{}return null}if(p.status!==0){try{console.error(`[ClangAdapter] pando-clang-indexer failed ${JSON.stringify({file:e,status:p.status,stderr:(p.stderr||"").trim().slice(0,4e3)})}`)}catch{}return null}try{return JSON.parse(p.stdout||"{}")}catch(C){try{console.error(`[ClangAdapter] pando-clang-indexer emitted invalid JSON ${JSON.stringify({file:e,stdoutBytes:(p.stdout||"").length,stderr:(p.stderr||"").trim().slice(0,4e3),error:C instanceof Error?C.message:String(C)})}`)}catch{}return null}},c=l(s);return!c&&s.source!=="fallback"&&(c=l(He(i,n))),!c||c.error?null:c},resolve:({absPath:e,nodePath:t,projectRoot:r})=>{try{let i=fn("fs").readFileSync(e,"utf8"),s=cr(t);return s?{start:s.start,end:s.end,bodyStart:null,bodyEnd:null,text:i.slice(s.start,s.end)}:null}catch{return null}}})}import et from"fs";import tt from"path";import{spawn as ur,spawnSync as cs}from"child_process";var dr=256e3,pr=32;function re(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
8
- `)}catch{}}var nt=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=ur(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("dart indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{re(`[DartIndexer] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`dart indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
5
+ `)}catch(l){if(this.pending.delete(r),t>0){try{this.handleExit(l)}catch{}return this.request(e,t-1).then(i,s)}s(l)}})}async parseBatch(e){let t=await this.request({op:"parse",files:e});return"results"in t?t.results.map(r=>r.ok&&r.result?r.result:null):"result"in t?[t.result]:e.map(()=>null)}async resolve(e){let t=await this.request({op:"resolve",...e});return"result"in t&&t.result&&typeof t.result.start=="number"?t.result:null}async resolveReferences(e){let t=await this.request({op:"resolve-references",...e});return"result"in t&&t.result?t.result:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.reject(new Error("csharp indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}},Ve=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((t,r)=>{this.queue.push({input:e,resolve:t,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],t=0;for(;this.queue.length&&e.length<er;){let r=this.queue[0];if(e.length>0&&t+r.input.size>Zn)break;e.push(this.queue.shift()),t+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang,emitMode:i.input.emitMode})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,l=Date.now()-s.startedAt;l>2e3&&re(`[${new Date().toISOString()}] [CSharpCliAdapter] parse slow`,{file:s.input.file,ms:l,path:"custom",ok:!!o}),o||re(`[${new Date().toISOString()}] [CSharpCliAdapter] parse failed`,{file:s.input.file,ms:l,path:"custom"}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},_t=new Map,Ot=new Map;function tr(n){let e=process.platform==="win32"?".cmd":"",t=q(`csharp-indexer/bin/pando-csharp-indexer${e}`);if(t)return t;if(n){let i=Kt.resolve(n,"tools/csharp-indexer/bin/pando-csharp-indexer"+e);if(Tt.existsSync(i))return i}let r=Kt.resolve(__dirname,"../../../../../tools/csharp-indexer/bin/pando-csharp-indexer"+e);return Tt.existsSync(r)?r:null}function Lt(n){let e=process.env.PANDO_CSHARP_INDEXER_CMD||tr(n);if(!e)return null;let t=_t.get(e);t||(t=new He(e),_t.set(e,t));let r=Ot.get(e);return r||(r=new Ve(t),Ot.set(e,r)),{client:t,batcher:r}}async function nr(n,e,t,r){let i=Lt(e);if(!i)return null;try{return await i.batcher.enqueue({file:n,root:e,lang:"csharp",size:t,emitMode:r})}catch(s){return re(`[${new Date().toISOString()}] [CSharpCliAdapter] parse error`,{file:n,error:s?.message||s,path:"custom"}),null}}async function rr(n,e,t,r){let i=await nr(n,e,t,r);return i||null}function Ft(){return Q({id:"csharp",extensions:[".cs",".csx",".cshtml",".razor"],parse:({absPath:n,projectRoot:e,content:t,meta:r,emitMode:i})=>{let s=r?.size??Buffer.byteLength(t,"utf8");return rr(n,e,s,i??"light")},resolve:({absPath:n,nodePath:e,projectRoot:t})=>{let r=Date.now(),i=Lt(t);return i?i.client.resolve({file:n,root:t,lang:"csharp",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&re(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve slow`,{file:n,ms:o}),s||re(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve failed`,{file:n,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return re(`[${new Date().toISOString()}] [CSharpCliAdapter] resolve error`,{file:n,ms:o,nodePath:e,error:s?.message||s}),null}):null}})}import{spawnSync as fr}from"child_process";import gr from"fs";import et from"path";import $ from"fs";import b from"path";var Ee=new Map,ir=["include","src","lib","libs","third_party","third-party","deps","vendor","build","build/src","build_pando","build_pando/src"],Ye=["build","out","build-debug","build-release","cmake-build-debug","cmake-build-release","build_pando"],$t=new Set([".c",".cc",".cpp",".cxx",".c++",".cp",".m",".mm"]),zt=new Set([".h",".hh",".hpp",".hxx",".h++",".inl",".ipp",".tcc"]);function fe(n){let e=[],t="",r=null,i=!1;for(let s=0;s<n.length;s+=1){let o=n[s];if(i){t+=o,i=!1;continue}if(o==="\\"){i=!0;continue}if(r){o===r?r=null:t+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(o===" "||o===`
6
+ `||o===" "||o==="\r"){t&&(e.push(t),t="");continue}t+=o}return t&&e.push(t),e}function sr(n,e){let t=[];for(let r=0;r<n.length;r+=1){let i=n[r];if(i==="-c")continue;if(i==="-o"){r+=1;continue}if(i===e)continue;let s=b.extname(i).toLowerCase();$t.has(s)||t.push(i)}return t}function qt(n,e){return b.isAbsolute(n)?b.resolve(n):e?b.resolve(e,n):b.resolve(n)}function or(n){try{let e=$.readFileSync(n,"utf8"),t=JSON.parse(e),r=new Map,i=[];for(let s of t){let o=s.directory?b.resolve(s.directory):void 0,l=s.file?qt(s.file,o):null;if(!l)continue;let c=o??b.dirname(l),u=Array.isArray(s.arguments)?s.arguments:s.command?fe(s.command):[];if(u.length===0)continue;let p={args:sr(u.slice(1),l),cwd:c,file:l};r.set(l,p),i.push(p)}return{map:r,entries:i}}catch{return null}}function ar(n){try{let e=$.readFileSync(n,"utf8");return fe(e.replace(/\r/g,`
7
+ `))}catch{return null}}function Jt(n){let e=b.join(n,"compile_commands.json");if($.existsSync(e))return e;for(let o of Ye){let l=b.join(n,o,"compile_commands.json");if($.existsSync(l))return l}let t=Ye.map(o=>b.join(n,o)).filter(o=>$.existsSync(o));t.push(n);let r=10,i=new Set,s=(o,l)=>{if(l>r)return null;let c=b.resolve(o);if(i.has(c))return null;i.add(c);try{let u=$.readdirSync(o,{withFileTypes:!0});for(let m of u)if(m.isFile()&&m.name==="compile_commands.json")return b.join(o,m.name);for(let m of u){if(!m.isDirectory()||m.name==="node_modules"||m.name.startsWith("."))continue;let p=s(b.join(o,m.name),l+1);if(p)return p}}catch{}return null};for(let o of t){let l=s(o,0);if(l)return l}return null}function lr(n,e){let t=b.resolve(n),r=b.resolve(e);for(;;){let i=Jt(t);if(i)return i;if(t===r)break;let s=b.dirname(t);if(s===t)break;t=s}return null}function Wt(n){let e=b.join(n,"compile_flags.txt");if($.existsSync(e))return e;for(let t of Ye){let r=b.join(n,t,"compile_flags.txt");if($.existsSync(r))return r}return null}function cr(n,e){let t=b.resolve(n),r=b.resolve(e);for(;;){let i=Wt(t);if(i)return i;if(t===r)break;let s=b.dirname(t);if(s===t)break;t=s}return null}function we(n){if(n)try{return $.statSync(n).mtimeMs}catch{return}}function ur(n){let e=[],t=new Set([".clangd","CMakeLists.txt","meson.build","meson_options.txt","Makefile","makefile","GNUmakefile","configure.ac","configure.in"]),r=5,i=200,s=(o,l)=>{if(l>r||e.length>=i)return;let c;try{c=$.readdirSync(o,{withFileTypes:!0})}catch{return}for(let u of c){if(e.length>=i)break;let m=b.join(o,u.name);u.isFile()&&(t.has(u.name)||u.name.endsWith(".cmake"))&&e.push(m)}for(let u of c){if(e.length>=i)break;u.isDirectory()&&(u.name==="node_modules"||u.name===".git"||u.name===".pando"||u.name.startsWith(".cache")||s(b.join(o,u.name),l+1))}};return s(n,0),e}function ne(n,e,t){if(!t)return;let r=t.trim();!r||e.has(r)||(e.add(r),n.push(r))}function me(n,e,t,r){let i=r.trim().replace(/^["']|["']$/g,"");if(!i||i.startsWith("$")||i.includes("${")||i.includes("<"))return;let s=b.isAbsolute(i)?i:b.resolve(t,i);$.existsSync(s)&&ne(n,e,`-I${s}`)}function jt(n){let e=[],t=new Set,r;for(let i of ur(n)){let s=we(i);s&&(!r||s>r)&&(r=s);let o="";try{o=$.readFileSync(i,"utf8")}catch{continue}let l=b.dirname(i),c=o.replace(/#[^\n]*/g," "),u=fe(c.replace(/[()[\]{},;]/g," "));for(let m=0;m<u.length;m+=1){let p=u[m];(p==="-I"||p==="-isystem"||p==="/I")&&u[m+1]?(me(e,t,l,u[m+1]),m+=1):p.startsWith("-I")&&p.length>2||p.startsWith("/I")&&p.length>2?me(e,t,l,p.slice(2)):p.startsWith("-isystem")&&p.length>8?me(e,t,l,p.slice(8)):p.startsWith("-D")||p.startsWith("/D")?ne(e,t,p.startsWith("/D")?`-D${p.slice(2)}`:p):p.startsWith("-std=")&&ne(e,t,p)}for(let m of o.matchAll(/\b(?:target_)?include_directories\s*\(([^)]*)\)/gims))for(let p of fe(m[1].replace(/[()[\]{},;]/g," ")))/^(PRIVATE|PUBLIC|INTERFACE|SYSTEM|BEFORE|AFTER)$/i.test(p)||me(e,t,l,p);for(let m of o.matchAll(/\b(?:add_compile_definitions|target_compile_definitions)\s*\(([^)]*)\)/gims))for(let p of fe(m[1].replace(/[()[\]{},;]/g," ")))/^(PRIVATE|PUBLIC|INTERFACE)$/i.test(p)||p.includes("$")||ne(e,t,p.startsWith("-D")?p:`-D${p}`);for(let m of o.matchAll(/\binclude_directories\s*:\s*\[([^\]]*)\]/gims))for(let p of fe(m[1].replace(/,/g," ")))me(e,t,l,p)}return{args:e,mtime:r}}function dr(n,e){let t=b.resolve(n).split(b.sep),r=b.resolve(e).split(b.sep),i=0;for(;i<t.length&&i<r.length&&t[i]===r[i];)i+=1;return i}function pr(n,e){if(!n||n.length===0)return null;let t=b.dirname(e),r=b.extname(e).toLowerCase(),i=b.basename(e,r),s=null;for(let o of n){let l=b.extname(o.file).toLowerCase();if(!$t.has(l))continue;let c=b.dirname(o.file),u=b.basename(o.file,l),m=dr(e,o.file);c===t&&(m+=100),u===i&&(m+=50),zt.has(r)&&(m+=20),(!s||m>s.score)&&(s={entry:o,score:m})}return s?.entry??null}function Bt(n,e){let t=e?`${b.resolve(n)}::${b.resolve(e)}`:b.resolve(n),r=Ee.get(t);if(r){let K=we(r.commandsPath);if(r.commandsPath&&K&&r.commandsMtime&&K!==r.commandsMtime)Ee.delete(t);else if(r.flagsPath){let R=we(r.flagsPath);if(R&&r.flagsMtime&&R!==r.flagsMtime)Ee.delete(t);else return r}else if(r.projectConfigFlags){let R=jt(e??n);if(r.projectConfigMtime&&R.mtime&&r.projectConfigMtime!==R.mtime)Ee.delete(t);else return r}else return r}let i=e?lr(e,n):Jt(n),s=i?or(i)??void 0:void 0,o=s?.map,l=s?.entries,c=we(i),u=o?null:e?cr(e,n):Wt(n),m=u?ar(u)??void 0:void 0,p=we(u),C=!o&&!m?jt(e??n):void 0,I={commands:o,commandEntries:l,flags:m,projectConfigFlags:C?.args,commandsPath:i,commandsMtime:c,flagsPath:u,flagsMtime:p,projectConfigMtime:C?.mtime};return Ee.set(t,I),I}function Ut(n,e,t){let r=b.dirname(e),i=Bt(n);!i.commands&&!i.flags&&(!i.projectConfigFlags||i.projectConfigFlags.length===0)&&(i=Bt(n,r));let s=qt(e);if(i.commands){let o=i.commands.get(s);if(o)return{args:o.args,cwd:o.cwd,source:"compile_commands"};let l=pr(i.commandEntries,s);if(l)return{args:l.args,cwd:l.cwd,source:"compile_commands"}}return i.flags?{args:i.flags,cwd:n,source:"compile_flags"}:i.projectConfigFlags&&i.projectConfigFlags.length>0?{args:Xt(i.projectConfigFlags,n,t),cwd:n,source:"project_config"}:Ze(n,t)}function mr(n){let e=[],t=new Set,r=l=>{let c=b.resolve(l);!t.has(c)&&$.existsSync(c)&&(t.add(c),e.push(c))};r(n);for(let l of ir)r(b.join(n,l));let i=Number(process.env.PANDO_CLANG_FALLBACK_INCLUDE_DEPTH||"5"),s=Number(process.env.PANDO_CLANG_FALLBACK_INCLUDE_MAX_DIRS||"300"),o=(l,c)=>{if(c>i||e.length>=s)return;let u;try{u=$.readdirSync(l,{withFileTypes:!0})}catch{return}u.some(p=>p.isFile()&&zt.has(b.extname(p.name).toLowerCase()))&&r(l);for(let p of u){if(e.length>=s)break;p.isDirectory()&&(p.name==="node_modules"||p.name===".git"||p.name===".pando"||p.name.startsWith(".cache")||o(b.join(l,p.name),c+1))}};return o(n,0),e}function Xt(n,e,t){let r=[...n],i=new Set(r);r.some(s=>s.startsWith("-std="))||ne(r,i,"-std="+(t==="cpp"?"c++20":"c17"));for(let s of mr(e))ne(r,i,`-I${s}`);for(let s of["-ferror-limit=0","-Wno-everything","-fparse-all-comments","-fms-extensions"])ne(r,i,s);return t==="cpp"&&ne(r,i,"-fdelayed-template-parsing"),r}function Ze(n,e){return{args:Xt([],n,e),cwd:n,source:"fallback"}}var fs=(()=>{let n=Number(process.env.PANDO_CLANG_AST_MAX_BUFFER_BYTES||"");if(Number.isFinite(n)&&n>0)return Math.floor(n);let e=Number(process.env.PANDO_CLANG_AST_MAX_BUFFER_MB||"");return Number.isFinite(e)&&e>0?Math.floor(e*1024*1024):1536*1024*1024})();function hr(){let n=process.env.PANDO_CLANG_INDEXER_CMD;if(n&&n.trim())return n.trim();let e=q("clang-indexer/bin/pando-clang-indexer");if(e)return e;let t=[process.env.PANDO_TOOLS_ROOT?et.join(process.env.PANDO_TOOLS_ROOT,"clang-indexer","bin","pando-clang-indexer"):null,process.env.PANDO_RUNTIME_ROOT?et.join(process.env.PANDO_RUNTIME_ROOT,"tools","clang-indexer","bin","pando-clang-indexer"):null,typeof __dirname=="string"?et.resolve(__dirname,"..","..","..","..","..","tools","clang-indexer","bin","pando-clang-indexer"):null].filter(r=>!!r);for(let r of t)try{if(gr.existsSync(r))return r}catch{}return"pando-clang-indexer"}function yr(n){if(!n)return null;let e=n;(e.startsWith("SyntaxError:")||e.startsWith("CompileError:"))&&(e=e.substring(e.indexOf(":")+1)),e.includes("#")&&(e=e.split("#")[1]);let t=e.lastIndexOf(":"),r=t>=0?e.slice(0,t):e,[i,s]=r.split("-"),o=Number(i),l=Number(s);return!Number.isFinite(o)||!Number.isFinite(l)||l<o?null:{start:o,end:l}}function tt(n){return Q({id:n,extensions:[],parse:({absPath:e,relPath:t,content:r,projectRoot:i})=>{let s=Ut(i,e,n),o=u=>["--file",e,"--project-root",i,"--lang",n,"--cwd",u.cwd,"--",...u.args,"-fsyntax-only","-fno-color-diagnostics","-fno-diagnostics-color",...u.source==="fallback"?["-x",n==="cpp"?"c++":"c"]:[]],l=u=>{let m=hr(),p=fr(m,o(u),{encoding:"utf8",cwd:u.cwd,maxBuffer:32*1024*1024});if(p.error){try{console.error(`[ClangAdapter] pando-clang-indexer spawn failed ${JSON.stringify({file:e,command:m,error:p.error.message})}`)}catch{}return null}if(p.status!==0){try{console.error(`[ClangAdapter] pando-clang-indexer failed ${JSON.stringify({file:e,status:p.status,stderr:(p.stderr||"").trim().slice(0,4e3)})}`)}catch{}return null}try{return JSON.parse(p.stdout||"{}")}catch(C){try{console.error(`[ClangAdapter] pando-clang-indexer emitted invalid JSON ${JSON.stringify({file:e,stdoutBytes:(p.stdout||"").length,stderr:(p.stderr||"").trim().slice(0,4e3),error:C instanceof Error?C.message:String(C)})}`)}catch{}return null}},c=l(s);return!c&&s.source!=="fallback"&&(c=l(Ze(i,n))),!c||c.error?null:c},resolve:({absPath:e,nodePath:t,projectRoot:r})=>{try{let i=bn("fs").readFileSync(e,"utf8"),s=yr(t);return s?{start:s.start,end:s.end,bodyStart:null,bodyEnd:null,text:i.slice(s.start,s.end)}:null}catch{return null}}})}import nt from"fs";import rt from"path";import{spawn as br,spawnSync as xs}from"child_process";var xr=256e3,Sr=32;function ie(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
8
+ `)}catch{}}var it=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=br(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("dart indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{ie(`[DartIndexer] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`dart indexer exited with code ${e}`))),te(this.proc)}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
9
9
  `);if(t<0)break;let r=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"dart server error")))}}async request(e,t=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e};this.pending.set(r,{resolve:i,reject:s});try{this.proc.stdin.write(`${JSON.stringify(o)}
10
- `)}catch(l){if(this.pending.delete(r),t>0){try{this.handleExit(l)}catch{}return this.request(e,t-1).then(i,s)}s(l)}})}async parseBatch(e){let t=await this.request({op:"parse",files:e});return"results"in t&&Array.isArray(t.results)?t.results.map(r=>r.ok&&r.result?r.result:null):"result"in t&&t.result?[t.result]:e.map(()=>null)}async resolve(e){let t=await this.request({op:"resolve",...e});return"result"in t&&t.result&&typeof t.result.start=="number"?t.result:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.reject(new Error("dart indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}},rt=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((t,r)=>{this.queue.push({input:e,resolve:t,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],t=0;for(;this.queue.length&&e.length<pr;){let r=this.queue[0];if(e.length>0&&t+r.input.size>dr)break;e.push(this.queue.shift()),t+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,l=Date.now()-s.startedAt;l>2e3&&re(`[${new Date().toISOString()}] [DartCliAdapter] parse slow`,{file:s.input.file,ms:l,ok:!!o}),o||re(`[${new Date().toISOString()}] [DartCliAdapter] parse failed`,{file:s.input.file,ms:l}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},Jt=new Map,Wt=new Map;function mr(n){let e=process.platform==="win32"?".cmd":"",t=q(`dart-indexer/bin/pando-dart-indexer${e}`);if(t)return t;if(n){let s=tt.resolve(n,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(et.existsSync(s))return s}let r=process.env.PANDO_EXTENSION_ROOT;if(r){let s=tt.resolve(r,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(et.existsSync(s))return s}let i=tt.resolve(process.cwd(),"tools/dart-indexer/bin/pando-dart-indexer"+e);return et.existsSync(i)?i:null}function Ut(n){let e=process.env.PANDO_DART_INDEXER_CMD||mr(n);if(!e)return null;let t=Jt.get(e);t||(t=new nt(e),Jt.set(e,t));let r=Wt.get(e);return r||(r=new rt(t),Wt.set(e,r)),{client:t,batcher:r}}async function fr(n,e,t){let r=Ut(e);if(!r)return null;try{return await r.batcher.enqueue({file:n,root:e,lang:"dart",size:t})}catch(i){return re(`[${new Date().toISOString()}] [DartCliAdapter] parse error`,{file:n,error:i?.message||i}),null}}function Xt(){return G({id:"dart",extensions:[".dart"],parse:async({absPath:n,projectRoot:e,content:t,meta:r})=>{let i=r?.size??Buffer.byteLength(t,"utf8");return fr(n,e,i)},resolve:({absPath:n,nodePath:e,projectRoot:t})=>{let r=Date.now(),i=Ut(t);return i?i.client.resolve({file:n,root:t,lang:"dart",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&re(`[${new Date().toISOString()}] [DartCliAdapter] resolve slow`,{file:n,ms:o}),s||re(`[${new Date().toISOString()}] [DartCliAdapter] resolve failed`,{file:n,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return re(`[${new Date().toISOString()}] [DartCliAdapter] resolve error`,{file:n,ms:o,nodePath:e,error:s?.message||s}),null}):null},exportKind:"dart"})}import it from"fs";import we from"path";import{spawn as gr,spawnSync as hs}from"child_process";var hr=256e3,yr=32;function se(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
11
- `)}catch{}}var st=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=gr(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("java indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{se(`[JavaCliAdapter] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`java indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
10
+ `)}catch(l){if(this.pending.delete(r),t>0){try{this.handleExit(l)}catch{}return this.request(e,t-1).then(i,s)}s(l)}})}async parseBatch(e){let t=await this.request({op:"parse",files:e});return"results"in t&&Array.isArray(t.results)?t.results.map(r=>r.ok&&r.result?r.result:null):"result"in t&&t.result?[t.result]:e.map(()=>null)}async resolve(e){let t=await this.request({op:"resolve",...e});return"result"in t&&t.result&&typeof t.result.start=="number"?t.result:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.reject(new Error("dart indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}},st=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((t,r)=>{this.queue.push({input:e,resolve:t,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],t=0;for(;this.queue.length&&e.length<Sr;){let r=this.queue[0];if(e.length>0&&t+r.input.size>xr)break;e.push(this.queue.shift()),t+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,l=Date.now()-s.startedAt;l>2e3&&ie(`[${new Date().toISOString()}] [DartCliAdapter] parse slow`,{file:s.input.file,ms:l,ok:!!o}),o||ie(`[${new Date().toISOString()}] [DartCliAdapter] parse failed`,{file:s.input.file,ms:l}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},Gt=new Map,Qt=new Map;function Cr(n){let e=process.platform==="win32"?".cmd":"",t=q(`dart-indexer/bin/pando-dart-indexer${e}`);if(t)return t;if(n){let s=rt.resolve(n,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(nt.existsSync(s))return s}let r=process.env.PANDO_EXTENSION_ROOT;if(r){let s=rt.resolve(r,"tools/dart-indexer/bin/pando-dart-indexer"+e);if(nt.existsSync(s))return s}let i=rt.resolve(process.cwd(),"tools/dart-indexer/bin/pando-dart-indexer"+e);return nt.existsSync(i)?i:null}function Ht(n){let e=process.env.PANDO_DART_INDEXER_CMD||Cr(n);if(!e)return null;let t=Gt.get(e);t||(t=new it(e),Gt.set(e,t));let r=Qt.get(e);return r||(r=new st(t),Qt.set(e,r)),{client:t,batcher:r}}async function vr(n,e,t){let r=Ht(e);if(!r)return null;try{return await r.batcher.enqueue({file:n,root:e,lang:"dart",size:t})}catch(i){return ie(`[${new Date().toISOString()}] [DartCliAdapter] parse error`,{file:n,error:i?.message||i}),null}}function Vt(){return Q({id:"dart",extensions:[".dart"],parse:async({absPath:n,projectRoot:e,content:t,meta:r})=>{let i=r?.size??Buffer.byteLength(t,"utf8");return vr(n,e,i)},resolve:({absPath:n,nodePath:e,projectRoot:t})=>{let r=Date.now(),i=Ht(t);return i?i.client.resolve({file:n,root:t,lang:"dart",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&ie(`[${new Date().toISOString()}] [DartCliAdapter] resolve slow`,{file:n,ms:o}),s||ie(`[${new Date().toISOString()}] [DartCliAdapter] resolve failed`,{file:n,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return ie(`[${new Date().toISOString()}] [DartCliAdapter] resolve error`,{file:n,ms:o,nodePath:e,error:s?.message||s}),null}):null},exportKind:"dart"})}import ot from"fs";import Pe from"path";import{spawn as Er,spawnSync as Rs}from"child_process";var wr=256e3,Pr=32;function oe(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
11
+ `)}catch{}}var at=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=Er(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("java indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{oe(`[JavaCliAdapter] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`java indexer exited with code ${e}`))),te(this.proc)}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
12
12
  `);if(t<0)break;let r=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(clearTimeout(s.timer),this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"java server error")))}}async request(e,t=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e},l=setTimeout(()=>{this.pending.delete(r),s(new Error("java indexer request timed out after 30s"))},3e4);this.pending.set(r,{resolve:i,reject:s,timer:l});try{this.proc.stdin.write(`${JSON.stringify(o)}
13
- `)}catch(c){if(clearTimeout(l),this.pending.delete(r),t>0){try{this.handleExit(c)}catch{}return this.request(e,t-1).then(i,s)}s(c)}})}async parseBatch(e){let t=await this.request({op:"parse",files:e});return"results"in t?t.results.map(r=>r.ok&&r.result?r.result:null):"result"in t?[t.result]:e.map(()=>null)}async resolve(e){let t=await this.request({op:"resolve",...e});return"result"in t&&t.result&&typeof t.result.start=="number"?t.result:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(new Error("java indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}},ot=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((t,r)=>{this.queue.push({input:e,resolve:t,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],t=0;for(;this.queue.length&&e.length<yr;){let r=this.queue[0];if(e.length>0&&t+r.input.size>hr)break;e.push(this.queue.shift()),t+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang,emitMode:i.input.emitMode})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,l=Date.now()-s.startedAt;l>2e3&&se(`[${new Date().toISOString()}] [JavaCliAdapter] parse slow`,{file:s.input.file,ms:l,path:"custom",ok:!!o}),o||se(`[${new Date().toISOString()}] [JavaCliAdapter] parse failed`,{file:s.input.file,ms:l,path:"custom"}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},Qt=new Map,Gt=new Map;function br(){return typeof __dirname=="string"?__dirname:process.cwd()}var ie,xr;function Sr(n){if(ie!==void 0&&xr===n)return ie;let e=process.platform==="win32"?".cmd":"",t="tools/java-indexer/bin/pando-java-indexer"+e,r=q(`java-indexer/bin/pando-java-indexer${e}`);if(r)return ie=r,r;if(n){let s=we.resolve(n,t);if(it.existsSync(s))return ie=s,s}let i=br();for(let s=0;s<8;s++){let o=we.join(i,t);if(it.existsSync(o))return ie=o,o;let l=we.dirname(i);if(l===i)break;i=l}i=process.cwd();for(let s=0;s<8;s++){let o=we.join(i,t);if(it.existsSync(o))return ie=o,o;let l=we.dirname(i);if(l===i)break;i=l}return ie=null,null}function Vt(n){let e=process.env.PANDO_JAVA_INDEXER_CMD||Sr(n);if(!e)return null;let t=Qt.get(e);t||(t=new st(e),Qt.set(e,t));let r=Gt.get(e);return r||(r=new ot(t),Gt.set(e,r)),{client:t,batcher:r}}async function Cr(n,e,t,r){let i=Vt(e);if(!i)return null;try{return await i.batcher.enqueue({file:n,root:e,lang:"java",size:t,emitMode:r})}catch(s){return se(`[${new Date().toISOString()}] [JavaCliAdapter] parse error`,{file:n,error:s?.message||s,path:"custom"}),null}}async function vr(n,e,t,r){let i=await Cr(n,e,t,r);return i||null}function Ht(){return G({id:"java",extensions:[".java"],exportKind:"named",parse:({absPath:n,projectRoot:e,content:t,meta:r,emitMode:i})=>{let s=r?.size??Buffer.byteLength(t,"utf8");return vr(n,e,s,i??"light")},resolve:({absPath:n,nodePath:e,projectRoot:t})=>{let r=Date.now(),i=Vt(t);return i?i.client.resolve({file:n,root:t,lang:"java",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&se(`[${new Date().toISOString()}] [JavaCliAdapter] resolve slow`,{file:n,ms:o}),s||se(`[${new Date().toISOString()}] [JavaCliAdapter] resolve failed`,{file:n,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return se(`[${new Date().toISOString()}] [JavaCliAdapter] resolve error`,{file:n,ms:o,nodePath:e,error:s?.message||s}),null}):null}})}import Mr from"fs";import Ir from"os";import{spawn as Er}from"child_process";import at from"fs";import lt from"path";function Yt(n,e){let t=process.platform==="win32"?".cmd":"",r=n==="clojure-editor"?"pando-clojure-editor":"pando-clojure-indexer",i=q(`${n}/bin/${r}${t}`);if(i)return i;if(e){let l=lt.resolve(e,`tools/${n}/bin/${r}${t}`);if(at.existsSync(l))return l}let s=process.env.PANDO_EXTENSION_ROOT;if(s){let l=lt.resolve(s,`tools/${n}/bin/${r}${t}`);if(at.existsSync(l))return l}let o=lt.resolve(process.cwd(),`tools/${n}/bin/${r}${t}`);return at.existsSync(o)?o:null}var _e=3e4,wr=Math.max(_e,Number(process.env.PANDO_CLOJURE_PARSE_TIMEOUT_MS||`${300*1e3}`)),Nr=Math.max(_e,Number(process.env.PANDO_CLOJURE_CHANGE_SIGNATURE_TIMEOUT_MS||`${300*1e3}`)),Zt="__PANDO_CLOJURE_INDEX__";function Pr(...n){if(!oe())return;let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");B("ClojureIndexer",e)}function Ne(n,e){oe()&&B("ClojureIndex",n,e)}function Rr(n,e=0){let t=Math.max(1,n.length),r=Math.ceil(Math.max(0,e)/(32*1024))*500,i=15e3+t*2500+r;return Math.max(_e,Math.min(wr,i))}var Ke=class{constructor(e,t){this.cmd=e;this.projectRoot=t;this.proc=null;this.buffer="";this.stderrBuffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,Ne("node.server.spawn",{projectRoot:this.projectRoot,cmd:this.cmd}),this.proc=Er(this.cmd,["--server"],{cwd:this.projectRoot,stdio:["pipe","pipe","pipe"],env:{...process.env,PANDO_PROJECT_ROOT:this.projectRoot}}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("clojure indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>this.onStderr(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`clojure indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){Ne("node.server.exit",{projectRoot:this.projectRoot,error:e?.message||String(e),pendingRequestCount:this.pending.size}),this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(e);this.pending.clear(),this.proc=null}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
13
+ `)}catch(c){if(clearTimeout(l),this.pending.delete(r),t>0){try{this.handleExit(c)}catch{}return this.request(e,t-1).then(i,s)}s(c)}})}async parseBatch(e){let t=await this.request({op:"parse",files:e});return"results"in t?t.results.map(r=>r.ok&&r.result?r.result:null):"result"in t?[t.result]:e.map(()=>null)}async resolve(e){let t=await this.request({op:"resolve",...e});return"result"in t&&t.result&&typeof t.result.start=="number"?t.result:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(new Error("java indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}},lt=class{constructor(e){this.client=e;this.queue=[];this.scheduled=!1}enqueue(e){return new Promise((t,r)=>{this.queue.push({input:e,resolve:t,reject:r,startedAt:Date.now()}),this.scheduled||(this.scheduled=!0,setImmediate(()=>this.flush()))})}async flush(){for(this.scheduled=!1;this.queue.length;){let e=[],t=0;for(;this.queue.length&&e.length<Pr;){let r=this.queue[0];if(e.length>0&&t+r.input.size>wr)break;e.push(this.queue.shift()),t+=r.input.size}try{let r=await this.client.parseBatch(e.map(i=>({file:i.input.file,root:i.input.root,lang:i.input.lang,emitMode:i.input.emitMode})));for(let i=0;i<e.length;i+=1){let s=e[i],o=r[i]??null,l=Date.now()-s.startedAt;l>2e3&&oe(`[${new Date().toISOString()}] [JavaCliAdapter] parse slow`,{file:s.input.file,ms:l,path:"custom",ok:!!o}),o||oe(`[${new Date().toISOString()}] [JavaCliAdapter] parse failed`,{file:s.input.file,ms:l,path:"custom"}),s.resolve(o)}}catch(r){for(let i of e)i.reject(r)}}}},Yt=new Map,Zt=new Map;function Nr(){return typeof __dirname=="string"?__dirname:process.cwd()}var se,Rr;function Ir(n){if(se!==void 0&&Rr===n)return se;let e=process.platform==="win32"?".cmd":"",t="tools/java-indexer/bin/pando-java-indexer"+e,r=q(`java-indexer/bin/pando-java-indexer${e}`);if(r)return se=r,r;if(n){let s=Pe.resolve(n,t);if(ot.existsSync(s))return se=s,s}let i=Nr();for(let s=0;s<8;s++){let o=Pe.join(i,t);if(ot.existsSync(o))return se=o,o;let l=Pe.dirname(i);if(l===i)break;i=l}i=process.cwd();for(let s=0;s<8;s++){let o=Pe.join(i,t);if(ot.existsSync(o))return se=o,o;let l=Pe.dirname(i);if(l===i)break;i=l}return se=null,null}function en(n){let e=process.env.PANDO_JAVA_INDEXER_CMD||Ir(n);if(!e)return null;let t=Yt.get(e);t||(t=new at(e),Yt.set(e,t));let r=Zt.get(e);return r||(r=new lt(t),Zt.set(e,r)),{client:t,batcher:r}}async function Ar(n,e,t,r){let i=en(e);if(!i)return null;try{return await i.batcher.enqueue({file:n,root:e,lang:"java",size:t,emitMode:r})}catch(s){return oe(`[${new Date().toISOString()}] [JavaCliAdapter] parse error`,{file:n,error:s?.message||s,path:"custom"}),null}}async function kr(n,e,t,r){let i=await Ar(n,e,t,r);return i||null}function tn(){return Q({id:"java",extensions:[".java"],exportKind:"named",parse:({absPath:n,projectRoot:e,content:t,meta:r,emitMode:i})=>{let s=r?.size??Buffer.byteLength(t,"utf8");return kr(n,e,s,i??"light")},resolve:({absPath:n,nodePath:e,projectRoot:t})=>{let r=Date.now(),i=en(t);return i?i.client.resolve({file:n,root:t,lang:"java",nodePath:e}).then(s=>{let o=Date.now()-r;return o>2e3&&oe(`[${new Date().toISOString()}] [JavaCliAdapter] resolve slow`,{file:n,ms:o}),s||oe(`[${new Date().toISOString()}] [JavaCliAdapter] resolve failed`,{file:n,ms:o,nodePath:e}),s}).catch(s=>{let o=Date.now()-r;return oe(`[${new Date().toISOString()}] [JavaCliAdapter] resolve error`,{file:n,ms:o,nodePath:e,error:s?.message||s}),null}):null}})}import jr from"fs";import Or from"os";import{spawn as Mr}from"child_process";import ct from"fs";import ut from"path";function nn(n,e){let t=process.platform==="win32"?".cmd":"",r=n==="clojure-editor"?"pando-clojure-editor":"pando-clojure-indexer",i=q(`${n}/bin/${r}${t}`);if(i)return i;if(e){let l=ut.resolve(e,`tools/${n}/bin/${r}${t}`);if(ct.existsSync(l))return l}let s=process.env.PANDO_EXTENSION_ROOT;if(s){let l=ut.resolve(s,`tools/${n}/bin/${r}${t}`);if(ct.existsSync(l))return l}let o=ut.resolve(process.cwd(),`tools/${n}/bin/${r}${t}`);return ct.existsSync(o)?o:null}var Le=3e4,Dr=Math.max(Le,Number(process.env.PANDO_CLOJURE_PARSE_TIMEOUT_MS||`${300*1e3}`)),Tr=Math.max(Le,Number(process.env.PANDO_CLOJURE_CHANGE_SIGNATURE_TIMEOUT_MS||`${300*1e3}`)),rn="__PANDO_CLOJURE_INDEX__";function Kr(...n){if(!ae())return;let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");B("ClojureIndexer",e)}function Ne(n,e){ae()&&B("ClojureIndex",n,e)}function _r(n,e=0){let t=Math.max(1,n.length),r=Math.ceil(Math.max(0,e)/(32*1024))*500,i=15e3+t*2500+r;return Math.max(Le,Math.min(Dr,i))}var Oe=class{constructor(e,t){this.cmd=e;this.projectRoot=t;this.proc=null;this.buffer="";this.stderrBuffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,Ne("node.server.spawn",{projectRoot:this.projectRoot,cmd:this.cmd}),this.proc=Mr(this.cmd,["--server"],{cwd:this.projectRoot,stdio:["pipe","pipe","pipe"],env:{...process.env,PANDO_PROJECT_ROOT:this.projectRoot}}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("clojure indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>this.onStderr(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`clojure indexer exited with code ${e}`))),te(this.proc)}}handleExit(e){if(!this.closed){Ne("node.server.exit",{projectRoot:this.projectRoot,error:e?.message||String(e),pendingRequestCount:this.pending.size}),this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(e);this.pending.clear(),this.proc=null}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
14
14
  `);if(t<0)break;let r=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(clearTimeout(s.timer),this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"clojure server error")))}}onStderr(e){for(this.stderrBuffer+=e.toString("utf8");;){let t=this.stderrBuffer.indexOf(`
15
- `);if(t<0)break;let r=this.stderrBuffer.slice(0,t).trim();if(this.stderrBuffer=this.stderrBuffer.slice(t+1),!!r){if(r.startsWith(Zt)){let i=r.slice(Zt.length);try{let s=JSON.parse(i);Ne(s.event||"jvm.trace",s)}catch(s){B("ClojureIndexer","stderr trace parse failed",{error:s?.message||String(s),line:r})}continue}Pr(r)}}}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(new Error("clojure indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}async request(e,t){this.ensureProcess();let r=this.seq++,i=t?.retry??1,s=t?.timeoutMs??_e,o=Date.now();return new Promise((l,c)=>{let u={id:r,...e},m=setTimeout(()=>{this.pending.delete(r),c(new Error(`clojure indexer request timed out after ${s}ms`))},s);this.pending.set(r,{resolve:p=>{Ne("node.client.request.complete",{projectRoot:this.projectRoot,id:r,op:e.op,durationMs:Date.now()-o}),l(p)},reject:c,timer:m});try{Ne("node.client.request.start",{projectRoot:this.projectRoot,id:r,op:e.op,timeoutMs:s}),this.proc.stdin.write(`${JSON.stringify(u)}
16
- `)}catch(p){if(clearTimeout(m),this.pending.delete(r),i>0){try{this.handleExit(p)}catch{}return this.request(e,{retry:i-1,timeoutMs:s}).then(l,c)}c(p)}})}async parseBatch(e,t){let r=Rr(e,t?.batchBytes??0),i=await this.request({op:"parse",files:e,analysisMode:t.emitMode==="full"?"full":"index",traceBatchId:t?.batchId,traceBatchBytes:t?.batchBytes},{timeoutMs:r});return"results"in i?i.results.map(s=>s.ok&&s.result?s.result:null):[]}async resolve(e){let t=await this.request({op:"resolve",...e});if("result"in t){let r=t.result;if(r&&typeof r.start=="number"&&typeof r.end=="number")return r}return null}async changeSignature(e){let t=await this.request({op:"change-signature",...e},{timeoutMs:Nr});return"result"in t&&t.result||null}},en=new Map;function tn(n){return process.env.PANDO_CLOJURE_INDEXER_CMD||Yt("clojure-indexer",n)}function nn(n){let e=tn(n);return e?new Ke(e,n):null}function rn(n){let e=tn(n);if(!e)return null;let t=`${e}::${n}`,r=en.get(t);return r||(r=new Ke(e,n),en.set(t,r)),r}function Ar(){let n=Number(process.env.PANDO_CLOJURE_ANALYZER_POOL_SIZE||"");if(Number.isFinite(n)&&n>=1)return Math.max(1,Math.floor(n));let e=Math.max(1,Ir.cpus()?.length||4);return Math.max(3,Math.min(8,Math.ceil(e/2)))}var kr=Ar();function Oe(n,e){B("ClojureIndex",n,e)}function Le(n,e){B("IndexTiming",n,e)}var Fe=class{constructor(e,t,r=kr){this.projectRoot=e;this.purpose=t;this.clients=[];this.idleClients=[];this.queue=[];this.inFlight=new Set;this.drainWaiters=[];this.batchSeq=1;this.closed=!1;let i=Math.max(1,r);for(let s=0;s<i;s+=1){let o=nn(e);if(!o)break;this.clients.push(o),this.idleClients.push(o)}if(!this.clients.length)throw new Error("clojure indexer command unavailable");Oe("node.pool.init",{projectRoot:e,purpose:t,configuredPoolSize:i,actualClientCount:this.clients.length})}submit(e,t){return this.closed?Promise.reject(new Error("clojure analyzer pool is closed")):new Promise((r,i)=>{this.queue.push({batchId:this.batchSeq++,batchKey:e,files:t,enqueuedAt:Date.now(),resolve:r,reject:i}),this.pump()})}async flush(){for(;this.queue.length||this.inFlight.size;)await new Promise(e=>this.drainWaiters.push(e))}async close(){if(!this.closed){await this.flush(),this.closed=!0;for(let e of this.clients)try{e.close()}catch{}this.clients.length=0,this.idleClients.length=0}}pump(){for(;!this.closed&&this.queue.length&&this.idleClients.length;){let e=this.queue.shift(),t=this.idleClients.shift(),r=this.runJob(t,e).finally(()=>{this.inFlight.delete(r),this.closed||this.idleClients.push(t),this.pump(),this.notifyIfIdle()});this.inFlight.add(r)}this.notifyIfIdle()}async runJob(e,t){let r=t.files.reduce((o,l)=>o+Math.max(0,l.size||0),0),i=Date.now(),s=Math.max(0,i-t.enqueuedAt);Oe("node.pool-batch.start",{batchId:t.batchId,batchKey:t.batchKey,purpose:this.purpose,fileCount:t.files.length,batchBytes:r,queueWaitMs:s,queuedBatchCount:this.queue.length,inFlightCount:this.inFlight.size});try{let o=await this.parseFiles(e,t.files,t.batchId,r);Le("clojure-pool.job.complete",{projectRoot:this.projectRoot,batchId:t.batchId,batchKey:t.batchKey,purpose:this.purpose,fileCount:t.files.length,batchBytes:r,queueWaitMs:s,durationMs:Date.now()-i}),Oe("node.pool-batch.complete",{batchId:t.batchId,batchKey:t.batchKey,purpose:this.purpose,fileCount:t.files.length,batchBytes:r,durationMs:Date.now()-i,successCount:Array.from(o.values()).filter(l=>!("error"in l)).length,errorCount:Array.from(o.values()).filter(l=>"error"in l).length}),t.resolve(o)}catch(o){let l=o instanceof Error?o:new Error(String(o));Oe("node.pool-batch.error",{batchId:t.batchId,batchKey:t.batchKey,fileCount:t.files.length,batchBytes:r,durationMs:Date.now()-i,error:l.message}),t.reject(l)}}async parseFiles(e,t,r,i){let s=Date.now();try{let o=await e.parseBatch(t.map(c=>({file:c.absPath,root:this.projectRoot,lang:c.lang,emitMode:c.emitMode})),{batchId:r,batchBytes:i,purpose:this.purpose,emitMode:t.some(c=>c.emitMode==="full")?"full":"light"});Le("clojure-parse-batch.complete",{projectRoot:this.projectRoot,batchId:r,fileCount:t.length,batchBytes:i,purpose:this.purpose,durationMs:Date.now()-s,split:!1});let l=new Map;for(let c=0;c<t.length;c+=1){let u=t[c],m=o[c]??null;m?l.set(u.fileKey,m):(B("IndexingAudit","clojure analysis returned no result",{projectRoot:this.projectRoot,batchId:r,file:u.absPath}),l.set(u.fileKey,{error:`clojure analysis returned no result for ${u.absPath}`}))}return l}catch(o){if(t.length>1){let u=Date.now(),m=Math.ceil(t.length/2),p=t.slice(0,m),C=t.slice(m),I=await this.parseFiles(e,p,r,p.reduce((R,F)=>R+Math.max(0,F.size||0),0)),K=await this.parseFiles(e,C,r,C.reduce((R,F)=>R+Math.max(0,F.size||0),0));return Le("clojure-parse-batch.split",{projectRoot:this.projectRoot,batchId:r,fileCount:t.length,batchBytes:i,purpose:this.purpose,durationMs:Date.now()-u,leftCount:p.length,rightCount:C.length,error:o instanceof Error?o.message:String(o)}),new Map([...I,...K])}let l=o instanceof Error?o:new Error(String(o));Le("clojure-parse-batch.error",{projectRoot:this.projectRoot,batchId:r,fileCount:t.length,batchBytes:i,purpose:this.purpose,durationMs:Date.now()-s,error:l.message});let c=new Map;for(let u of t)B("IndexingAudit","clojure analysis request failed",{projectRoot:this.projectRoot,batchId:r,file:u.absPath,error:l.message}),c.set(u.fileKey,{error:l.message});return c}}notifyIfIdle(){if(this.queue.length||this.inFlight.size)return;let e=this.drainWaiters.splice(0,this.drainWaiters.length);for(let t of e)try{t()}catch{}}};function Dr(n,e){if(typeof e?.size=="number"&&typeof e?.mtime=="number")return{size:e.size,mtime:e.mtime};try{let t=Mr.statSync(n);return{size:typeof e?.size=="number"?e.size:t.size,mtime:typeof e?.mtime=="number"?e.mtime:Math.floor(t.mtimeMs)}}catch{return{size:e?.size,mtime:e?.mtime}}}function Tr(n,e){let t=new Map;for(let r of e.nodes??[]){if(!r.name||r.containerKind||t.has(r.name))continue;let i=`${n}#${r.start}-${r.end}:${Z.getAbbrev(r.kind,"clojure")}:${r.name}`;t.set(r.name,i)}return r=>t.get(r)??null}function Kr(n){let e=n?.error;return typeof e=="string"&&e.trim().length>0?e.trim():null}var je=class{constructor(e,t){this.projectRoot=e;this.purpose=t;this.cache=new le;this.pool=new Fe(e,t)}prepare(e){let t=Dr(e.absPath,e.meta),r=e.emitMode??"light",i=r==="full"?null:this.cache.get(e.absPath,t);return{fileKey:e.relPath,absPath:e.absPath,relPath:e.relPath,meta:t,preDeleted:e.preDeleted,lang:e.lang,emitMode:r,cachedParsed:i??void 0}}batchKey(e){return`${this.projectRoot}::clojure::${this.purpose}::${e.emitMode}`}async analyzeBatch(e){let t=new Map,r=e.filter(s=>!s.cachedParsed);for(let s of e)s.cachedParsed&&t.set(s.fileKey,s.cachedParsed);if(!r.length)return t;let i=await this.pool.submit(this.batchKey(r[0]),r.map(s=>({fileKey:s.fileKey,absPath:s.absPath,lang:s.lang,size:s.meta?.size??0,emitMode:s.emitMode})));for(let s of r){let o=i.get(s.fileKey)??{error:`missing clojure analysis result for ${s.relPath}`};s.emitMode!=="full"&&!("error"in o)&&this.cache.set(s.absPath,s.meta??{},o),t.set(s.fileKey,o)}return t}buildProcessedFile(e,t,r){let i=Kr(r);return i?(B("IndexingAudit","clojure batch analysis failed",{projectRoot:this.projectRoot,relPath:e.relPath,error:i}),he("clojure",e.relPath,t.meta)):ye({lang:"clojure",fileRel:e.relPath,content:e.content,meta:t.meta,preDeleted:e.preDeleted,parsed:r,resolveNodeId:Tr(e.relPath,r),exportKind:"cli",fullyIndexed:t.emitMode==="full"})}async flush(){await this.pool.flush()}async close(){await this.pool.close()}};function _r(){return{maxFilesPerBatch:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_FILES||"24")),maxBatchBytes:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_BYTES||`${4*1024*1024}`)),maxWaitMs:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_WAIT_MS||"10")),maxPendingFiles:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_PENDING_FILES||"512")),maxPendingBytes:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_PENDING_BYTES||`${16*1024*1024}`))}}function Or(...n){let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");B("ClojureCliAdapter",e)}function sn(){return{id:"clojure",extensions:[".clj",".cljc",".cljs"],indexingMode:"batch",createBatchIndexer:(n,e)=>new je(n,e),getBatchSchedulerOptions:_r,resolveSpan:(n,e,t)=>{let r=rn(n);return r?r.resolve({file:e,root:n,lang:"clojure",nodePath:t}).catch(i=>(Or(`[${new Date().toISOString()}] [ClojureCliAdapter] resolve error`,{file:e,nodePath:t,error:i?.message||i}),null)):null}}}function io(n){return n.indexingMode==="worker"&&typeof n.createIndexer=="function"}var ct={ts:We("ts"),js:We("js"),python:It(),c:{...Ze("c"),extensions:[".c",".i",".inc"]},cpp:{...Ze("cpp"),extensions:[".cc",".cpp",".cxx",".c++",".cp",".ccm",".cppm",".cxxm",".ixx",".hpp",".h",".hh",".hxx",".h++",".ii",".inl",".ipp",".tcc",".tpp",".txx"]},csharp:Kt(),dart:Xt(),java:Ht(),clojure:sn()},on=new Map;for(let n of Object.values(ct))for(let e of n.extensions)on.set(e,n.id);function Lr(){return gt(mt())}function so(n){let e=n.toLowerCase().match(/\.[a-z0-9+]+$/);return e?on.get(e[0])??null:null}function oo(n){return ct[n]}function ao(n){let e=n??Lr(),t=new Set;for(let[i,s]of Object.entries(e.byLanguage))s.enabled&&t.add(i);let r=new Set;for(let i of Object.values(ct))if(t.has(i.id))for(let s of i.extensions)r.add(s);return r}import Fr from"fs";import an from"path";import{promises as jr}from"fs";import{execFileSync as Br}from"child_process";import go from"ignore";function ut(n){return n.replace(/\\/g,"/")}function ln(n,e){let t=n.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(!t.length)return[];let r=e?`${e}/`:"";return t.map(s=>s.startsWith("\\#")||s.startsWith("\\!")?s.slice(1):s).filter(s=>!s.startsWith("#")).map(s=>{let o=s.startsWith("!"),l=o?s.slice(1):s;if(!l)return s;if((l.endsWith("/")?l.slice(0,-1):l).includes("/")){if(!r&&l.startsWith("/"))return o?`!${l}`:l;let p=l.startsWith("/")?l.slice(1):l,C=r?`${r}${p}`:p;return o?`!${C}`:C}let m=r?`${r}**/${l}`:l;return o?`!${m}`:m})}function ho(n,e){let t=an.join(n,".gitignore");try{let r=Fr.readFileSync(t,"utf8");return ln(r,e)}catch{return[]}}async function yo(n,e){let t=an.join(n,".gitignore");try{let r=await jr.readFile(t,"utf8");return ln(r,e)}catch{return[]}}function $r(n){let e=new Set,t=new Set;for(let r of n){let i=ut(r).replace(/^\/+/,"");if(!i)continue;e.add(i);let s=i.split("/");s.pop();let o="";for(let l of s)o=o?`${o}/${l}`:l,t.add(o)}return{files:e,dirs:t,hasFile(r){return e.has(ut(r))},hasDescendant(r){return t.has(ut(r).replace(/\/+$/,""))}}}function bo(n){try{let t=Br("git",["-C",n,"ls-files","-z"],{encoding:"buffer",stdio:["ignore","pipe","ignore"],maxBuffer:67108864}).toString("utf8").split("\0").filter(Boolean);return t.length?$r(t):null}catch{return null}}function zr(n,e="Operation cancelled"){let t=typeof n=="string"&&n.trim()?n.trim():n instanceof Error&&n.message.trim()?n.message.trim():e,r=new Error(t);return r.name="AbortError",r.code="ABORT_ERR",r}function So(n,e){if(n?.aborted)throw zr(n.reason,e)}export{he as a,io as b,Lr as c,so as d,oo as e,ao as f,So as g,ho as h,yo as i,bo as j};
15
+ `);if(t<0)break;let r=this.stderrBuffer.slice(0,t).trim();if(this.stderrBuffer=this.stderrBuffer.slice(t+1),!!r){if(r.startsWith(rn)){let i=r.slice(rn.length);try{let s=JSON.parse(i);Ne(s.event||"jvm.trace",s)}catch(s){B("ClojureIndexer","stderr trace parse failed",{error:s?.message||String(s),line:r})}continue}Kr(r)}}}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)clearTimeout(t.timer),t.reject(new Error("clojure indexer client closed"));this.pending.clear();let e=this.proc;if(this.proc=null,!!e){try{e.stdin?.end()}catch{}try{e.kill()}catch{}}}async request(e,t){this.ensureProcess();let r=this.seq++,i=t?.retry??1,s=t?.timeoutMs??Le,o=Date.now();return new Promise((l,c)=>{let u={id:r,...e},m=setTimeout(()=>{this.pending.delete(r),c(new Error(`clojure indexer request timed out after ${s}ms`))},s);this.pending.set(r,{resolve:p=>{Ne("node.client.request.complete",{projectRoot:this.projectRoot,id:r,op:e.op,durationMs:Date.now()-o}),l(p)},reject:c,timer:m});try{Ne("node.client.request.start",{projectRoot:this.projectRoot,id:r,op:e.op,timeoutMs:s}),this.proc.stdin.write(`${JSON.stringify(u)}
16
+ `)}catch(p){if(clearTimeout(m),this.pending.delete(r),i>0){try{this.handleExit(p)}catch{}return this.request(e,{retry:i-1,timeoutMs:s}).then(l,c)}c(p)}})}async parseBatch(e,t){let r=_r(e,t?.batchBytes??0),i=await this.request({op:"parse",files:e,analysisMode:t.emitMode==="full"?"full":"index",traceBatchId:t?.batchId,traceBatchBytes:t?.batchBytes},{timeoutMs:r});return"results"in i?i.results.map(s=>s.ok&&s.result?s.result:null):[]}async resolve(e){let t=await this.request({op:"resolve",...e});if("result"in t){let r=t.result;if(r&&typeof r.start=="number"&&typeof r.end=="number")return r}return null}async changeSignature(e){let t=await this.request({op:"change-signature",...e},{timeoutMs:Tr});return"result"in t&&t.result||null}},sn=new Map;function on(n){return process.env.PANDO_CLOJURE_INDEXER_CMD||nn("clojure-indexer",n)}function an(n){let e=on(n);return e?new Oe(e,n):null}function ln(n){let e=on(n);if(!e)return null;let t=`${e}::${n}`,r=sn.get(t);return r||(r=new Oe(e,n),sn.set(t,r)),r}function Lr(){let n=Number(process.env.PANDO_CLOJURE_ANALYZER_POOL_SIZE||"");if(Number.isFinite(n)&&n>=1)return Math.max(1,Math.floor(n));let e=Math.max(1,Or.cpus()?.length||4);return Math.max(3,Math.min(8,Math.ceil(e/2)))}var Fr=Lr();function Fe(n,e){B("ClojureIndex",n,e)}function je(n,e){B("IndexTiming",n,e)}var Be=class{constructor(e,t,r=Fr){this.projectRoot=e;this.purpose=t;this.clients=[];this.idleClients=[];this.queue=[];this.inFlight=new Set;this.drainWaiters=[];this.batchSeq=1;this.closed=!1;let i=Math.max(1,r);for(let s=0;s<i;s+=1){let o=an(e);if(!o)break;this.clients.push(o),this.idleClients.push(o)}if(!this.clients.length)throw new Error("clojure indexer command unavailable");Fe("node.pool.init",{projectRoot:e,purpose:t,configuredPoolSize:i,actualClientCount:this.clients.length})}submit(e,t){return this.closed?Promise.reject(new Error("clojure analyzer pool is closed")):new Promise((r,i)=>{this.queue.push({batchId:this.batchSeq++,batchKey:e,files:t,enqueuedAt:Date.now(),resolve:r,reject:i}),this.pump()})}async flush(){for(;this.queue.length||this.inFlight.size;)await new Promise(e=>this.drainWaiters.push(e))}async close(){if(!this.closed){await this.flush(),this.closed=!0;for(let e of this.clients)try{e.close()}catch{}this.clients.length=0,this.idleClients.length=0}}pump(){for(;!this.closed&&this.queue.length&&this.idleClients.length;){let e=this.queue.shift(),t=this.idleClients.shift(),r=this.runJob(t,e).finally(()=>{this.inFlight.delete(r),this.closed||this.idleClients.push(t),this.pump(),this.notifyIfIdle()});this.inFlight.add(r)}this.notifyIfIdle()}async runJob(e,t){let r=t.files.reduce((o,l)=>o+Math.max(0,l.size||0),0),i=Date.now(),s=Math.max(0,i-t.enqueuedAt);Fe("node.pool-batch.start",{batchId:t.batchId,batchKey:t.batchKey,purpose:this.purpose,fileCount:t.files.length,batchBytes:r,queueWaitMs:s,queuedBatchCount:this.queue.length,inFlightCount:this.inFlight.size});try{let o=await this.parseFiles(e,t.files,t.batchId,r);je("clojure-pool.job.complete",{projectRoot:this.projectRoot,batchId:t.batchId,batchKey:t.batchKey,purpose:this.purpose,fileCount:t.files.length,batchBytes:r,queueWaitMs:s,durationMs:Date.now()-i}),Fe("node.pool-batch.complete",{batchId:t.batchId,batchKey:t.batchKey,purpose:this.purpose,fileCount:t.files.length,batchBytes:r,durationMs:Date.now()-i,successCount:Array.from(o.values()).filter(l=>!("error"in l)).length,errorCount:Array.from(o.values()).filter(l=>"error"in l).length}),t.resolve(o)}catch(o){let l=o instanceof Error?o:new Error(String(o));Fe("node.pool-batch.error",{batchId:t.batchId,batchKey:t.batchKey,fileCount:t.files.length,batchBytes:r,durationMs:Date.now()-i,error:l.message}),t.reject(l)}}async parseFiles(e,t,r,i){let s=Date.now();try{let o=await e.parseBatch(t.map(c=>({file:c.absPath,root:this.projectRoot,lang:c.lang,emitMode:c.emitMode})),{batchId:r,batchBytes:i,purpose:this.purpose,emitMode:t.some(c=>c.emitMode==="full")?"full":"light"});je("clojure-parse-batch.complete",{projectRoot:this.projectRoot,batchId:r,fileCount:t.length,batchBytes:i,purpose:this.purpose,durationMs:Date.now()-s,split:!1});let l=new Map;for(let c=0;c<t.length;c+=1){let u=t[c],m=o[c]??null;m?l.set(u.fileKey,m):(B("IndexingAudit","clojure analysis returned no result",{projectRoot:this.projectRoot,batchId:r,file:u.absPath}),l.set(u.fileKey,{error:`clojure analysis returned no result for ${u.absPath}`}))}return l}catch(o){if(t.length>1){let u=Date.now(),m=Math.ceil(t.length/2),p=t.slice(0,m),C=t.slice(m),I=await this.parseFiles(e,p,r,p.reduce((R,F)=>R+Math.max(0,F.size||0),0)),K=await this.parseFiles(e,C,r,C.reduce((R,F)=>R+Math.max(0,F.size||0),0));return je("clojure-parse-batch.split",{projectRoot:this.projectRoot,batchId:r,fileCount:t.length,batchBytes:i,purpose:this.purpose,durationMs:Date.now()-u,leftCount:p.length,rightCount:C.length,error:o instanceof Error?o.message:String(o)}),new Map([...I,...K])}let l=o instanceof Error?o:new Error(String(o));je("clojure-parse-batch.error",{projectRoot:this.projectRoot,batchId:r,fileCount:t.length,batchBytes:i,purpose:this.purpose,durationMs:Date.now()-s,error:l.message});let c=new Map;for(let u of t)B("IndexingAudit","clojure analysis request failed",{projectRoot:this.projectRoot,batchId:r,file:u.absPath,error:l.message}),c.set(u.fileKey,{error:l.message});return c}}notifyIfIdle(){if(this.queue.length||this.inFlight.size)return;let e=this.drainWaiters.splice(0,this.drainWaiters.length);for(let t of e)try{t()}catch{}}};function Br(n,e){if(typeof e?.size=="number"&&typeof e?.mtime=="number")return{size:e.size,mtime:e.mtime};try{let t=jr.statSync(n);return{size:typeof e?.size=="number"?e.size:t.size,mtime:typeof e?.mtime=="number"?e.mtime:Math.floor(t.mtimeMs)}}catch{return{size:e?.size,mtime:e?.mtime}}}function $r(n,e){let t=new Map;for(let r of e.nodes??[]){if(!r.name||r.containerKind||t.has(r.name))continue;let i=`${n}#${r.start}-${r.end}:${Z.getAbbrev(r.kind,"clojure")}:${r.name}`;t.set(r.name,i)}return r=>t.get(r)??null}function zr(n){let e=n?.error;return typeof e=="string"&&e.trim().length>0?e.trim():null}var $e=class{constructor(e,t){this.projectRoot=e;this.purpose=t;this.cache=new ce;this.pool=new Be(e,t)}prepare(e){let t=Br(e.absPath,e.meta),r=e.emitMode??"light",i=r==="full"?null:this.cache.get(e.absPath,t);return{fileKey:e.relPath,absPath:e.absPath,relPath:e.relPath,meta:t,preDeleted:e.preDeleted,lang:e.lang,emitMode:r,cachedParsed:i??void 0}}batchKey(e){return`${this.projectRoot}::clojure::${this.purpose}::${e.emitMode}`}async analyzeBatch(e){let t=new Map,r=e.filter(s=>!s.cachedParsed);for(let s of e)s.cachedParsed&&t.set(s.fileKey,s.cachedParsed);if(!r.length)return t;let i=await this.pool.submit(this.batchKey(r[0]),r.map(s=>({fileKey:s.fileKey,absPath:s.absPath,lang:s.lang,size:s.meta?.size??0,emitMode:s.emitMode})));for(let s of r){let o=i.get(s.fileKey)??{error:`missing clojure analysis result for ${s.relPath}`};s.emitMode!=="full"&&!("error"in o)&&this.cache.set(s.absPath,s.meta??{},o),t.set(s.fileKey,o)}return t}buildProcessedFile(e,t,r){let i=zr(r);return i?(B("IndexingAudit","clojure batch analysis failed",{projectRoot:this.projectRoot,relPath:e.relPath,error:i}),ye("clojure",e.relPath,t.meta)):be({lang:"clojure",fileRel:e.relPath,content:e.content,meta:t.meta,preDeleted:e.preDeleted,parsed:r,resolveNodeId:$r(e.relPath,r),exportKind:"cli",fullyIndexed:t.emitMode==="full"})}async flush(){await this.pool.flush()}async close(){await this.pool.close()}};function qr(){return{maxFilesPerBatch:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_FILES||"24")),maxBatchBytes:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_BYTES||`${4*1024*1024}`)),maxWaitMs:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_WAIT_MS||"10")),maxPendingFiles:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_PENDING_FILES||"512")),maxPendingBytes:Math.max(1,Number(process.env.PANDO_CLOJURE_BATCH_MAX_PENDING_BYTES||`${16*1024*1024}`))}}function Jr(...n){let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");B("ClojureCliAdapter",e)}function cn(){return{id:"clojure",extensions:[".clj",".cljc",".cljs"],indexingMode:"batch",createBatchIndexer:(n,e)=>new $e(n,e),getBatchSchedulerOptions:qr,resolveSpan:(n,e,t)=>{let r=ln(n);return r?r.resolve({file:e,root:n,lang:"clojure",nodePath:t}).catch(i=>(Jr(`[${new Date().toISOString()}] [ClojureCliAdapter] resolve error`,{file:e,nodePath:t,error:i?.message||i}),null)):null}}}function bo(n){return n.indexingMode==="worker"&&typeof n.createIndexer=="function"}var dt={ts:Xe("ts"),js:Xe("js"),python:kt(),c:{...tt("c"),extensions:[".c",".i",".inc"]},cpp:{...tt("cpp"),extensions:[".cc",".cpp",".cxx",".c++",".cp",".ccm",".cppm",".cxxm",".ixx",".hpp",".h",".hh",".hxx",".h++",".ii",".inl",".ipp",".tcc",".tpp",".txx"]},csharp:Ft(),dart:Vt(),java:tn(),clojure:cn()},un=new Map;for(let n of Object.values(dt))for(let e of n.extensions)un.set(e,n.id);function Wr(){return yt(gt())}function xo(n){let e=n.toLowerCase().match(/\.[a-z0-9+]+$/);return e?un.get(e[0])??null:null}function So(n){return dt[n]}function Co(n){let e=n??Wr(),t=new Set;for(let[i,s]of Object.entries(e.byLanguage))s.enabled&&t.add(i);let r=new Set;for(let i of Object.values(dt))if(t.has(i.id))for(let s of i.extensions)r.add(s);return r}import Ur from"fs";import dn from"path";import{promises as Xr}from"fs";import{execFileSync as Gr}from"child_process";import Io from"ignore";function pt(n){return n.replace(/\\/g,"/")}function pn(n,e){let t=n.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(!t.length)return[];let r=e?`${e}/`:"";return t.map(s=>s.startsWith("\\#")||s.startsWith("\\!")?s.slice(1):s).filter(s=>!s.startsWith("#")).map(s=>{let o=s.startsWith("!"),l=o?s.slice(1):s;if(!l)return s;if((l.endsWith("/")?l.slice(0,-1):l).includes("/")){if(!r&&l.startsWith("/"))return o?`!${l}`:l;let p=l.startsWith("/")?l.slice(1):l,C=r?`${r}${p}`:p;return o?`!${C}`:C}let m=r?`${r}**/${l}`:l;return o?`!${m}`:m})}function Ao(n,e){let t=dn.join(n,".gitignore");try{let r=Ur.readFileSync(t,"utf8");return pn(r,e)}catch{return[]}}async function ko(n,e){let t=dn.join(n,".gitignore");try{let r=await Xr.readFile(t,"utf8");return pn(r,e)}catch{return[]}}function Qr(n){let e=new Set,t=new Set;for(let r of n){let i=pt(r).replace(/^\/+/,"");if(!i)continue;e.add(i);let s=i.split("/");s.pop();let o="";for(let l of s)o=o?`${o}/${l}`:l,t.add(o)}return{files:e,dirs:t,hasFile(r){return e.has(pt(r))},hasDescendant(r){return t.has(pt(r).replace(/\/+$/,""))}}}function Mo(n){try{let t=Gr("git",["-C",n,"ls-files","-z"],{encoding:"buffer",stdio:["ignore","pipe","ignore"],maxBuffer:67108864}).toString("utf8").split("\0").filter(Boolean);return t.length?Qr(t):null}catch{return null}}function Hr(n,e="Operation cancelled"){let t=typeof n=="string"&&n.trim()?n.trim():n instanceof Error&&n.message.trim()?n.message.trim():e,r=new Error(t);return r.name="AbortError",r.code="ABORT_ERR",r}function To(n,e){if(n?.aborted)throw Hr(n.reason,e)}export{ye as a,bo as b,Wr as c,xo as d,So as e,Co as f,To as g,Ao as h,ko as i,Mo as j};
@@ -1 +1 @@
1
- import{a as B,b as L,c as q,d as R,e as C,f as z,i as F,j as N}from"./chunk-5PZD6HGD.mjs";import"./chunk-WHHZYOEJ.mjs";import{c as X}from"./chunk-RRIZV7YJ.mjs";import{parentPort as l,threadId as ne}from"worker_threads";import K from"fs";import _ from"path";import{promises as G}from"fs";import H from"ignore";import{createHash as se}from"crypto";var te=Math.max(1,Number(process.env.PANDO_BATCH_INDEX_MAX_FILES||"64")),re=Math.max(1,Number(process.env.PANDO_BATCH_INDEX_MAX_BYTES||`${1024*1024}`)),ce=Math.max(1,Number(process.env.PANDO_BATCH_INDEX_MAX_WAIT_MS||"15")),le=Math.max(te,Number(process.env.PANDO_BATCH_INDEX_MAX_PENDING_FILES||"256")),he=Math.max(re,Number(process.env.PANDO_BATCH_INDEX_MAX_PENDING_BYTES||`${8*1024*1024}`));var be=1*1024*1024,Me=Math.max(3e4,Number(process.env.PANDO_WORKER_INIT_TIMEOUT_MS||12e4)),ie=Math.max(1e3,Number(process.env.PANDO_ACTIVE_CONTEXT_STALL_LOG_MS||1e4)),We=Math.max(ie,Number(process.env.PANDO_ACTIVE_CONTEXT_STALL_FAIL_MS||6e5)),Be=q();function U(e,t){return Buffer.from(e).toString(t)}function D(e,t,o,r,d,u){let m=Buffer.from(e),n=se("sha1").update(m).digest("hex"),i=u??m.toString(d),c=i?i.split(/\r?\n/).length:0;return{relPath:t,size:o,mtime:r,objectId:n,lineCount:c,encoding:d}}if(!l)throw new Error("Indexer worker must be spawned as a worker thread");X();function h(e,t){try{if(t===void 0){console.error(`[${new Date().toISOString()}] [IndexerWorker] ${e}`);return}console.error(`[${new Date().toISOString()}] [IndexerWorker] ${e} ${JSON.stringify({pid:process.pid,threadId:ne,...t&&typeof t=="object"&&!Array.isArray(t)?t:{details:t}})}`)}catch{}}h("module loaded",{cwd:process.cwd(),hasParentPort:!!l,envWorkerRoot:process.env.PANDO_WORKER_SCRIPT_DIR??null,envRuntimeRoot:process.env.PANDO_RUNTIME_ROOT??null});var J=new Map,E="",T="index",b=new Map,v=new Set;function Y(e,t){return _.relative(e,t).replace(/\\/g,"/")}function ae(e,t){let o=(t||[]).map(r=>typeof r=="string"?r.trim():"").filter(Boolean).map(r=>r.replace(/^[\\/]+/,"").replace(/[\\/]+$/,"")).map(r=>r.endsWith("/")?r:`${r}/`);return o.length?r=>{let d=Y(e,r);if(!d||d.startsWith(".."))return!1;let u=d.endsWith("/")?d:`${d}/`;return o.some(m=>u.startsWith(m))}:null}async function oe(e){await new Promise(t=>{b.set(e,t)})}l.on("message",async e=>{if(e.cmd==="scan-ack"){let t=b.get(e.requestId);if(t){b.delete(e.requestId);try{t()}catch{}}return}if(e.cmd==="scan-cancel"){v.add(e.requestId);let t=b.get(e.requestId);if(t){b.delete(e.requestId);try{t()}catch{}}return}if(e.cmd==="init"){try{h("init received",{mode:e.mode??"index",projectRoot:typeof e.projectRoot=="string"?e.projectRoot:null}),typeof e.projectRoot=="string"&&(E=e.projectRoot),T=e.mode??"index",h("init completed",{mode:T,projectRoot:E}),l.postMessage({type:"ready"})}catch(t){h("init failed",{error:t?.message||String(t),stack:t?.stack??null}),l.postMessage({type:"error",message:`init failed: ${t?.message||t}`,stack:t?.stack})}return}if(e.cmd==="scan"){let t=e.requestId,o=typeof e.projectRoot=="string"?e.projectRoot:E;if(h("scan received",{requestId:t,projectRoot:o||null,batchSize:e.batchSize??null,maxFileBytes:e.maxFileBytes??null,excludeDirs:Array.isArray(e.excludeDirs)?e.excludeDirs.slice(0,20):[]}),!o){l.postMessage({type:"error",requestId:t,message:"worker not initialized"});return}let r=Math.max(1,Math.min(500,Number(e.batchSize||100))),d=Math.max(1,Number(e.maxFileBytes||1*1024*1024)),u=e.languageSupport,m=z(u),n=ae(o,e.excludeDirs??[]),i=N(o),c=new Set(["node_modules",".git",".pando-data"]),S=a=>a.replace(/\\/g,"/"),w=await F(o,""),g=H().add(w),f=[{dir:o,relDir:"",rules:w,ig:g}],y=0,s=0,p=[],x=async()=>{p.length&&(l.postMessage({type:"scan:batch",requestId:t,files:p}),p=[],await oe(t))};try{for(;f.length&&!v.has(t);){let a=f.pop(),$=[];try{$=await G.readdir(a.dir,{withFileTypes:!0})}catch{s+=1;continue}for(let k of $){if(v.has(t))break;let I=_.join(a.dir,k.name);if(k.isSymbolicLink?.()){s+=1;continue}if(k.isDirectory()){if(c.has(k.name)){s+=1;continue}if(n?.(I)){s+=1;continue}let Q=a.relDir?`${a.relDir}/${k.name}`:k.name,W=S(Q);if(a.ig.ignores(W)&&!i?.hasDescendant(W)){s+=1;continue}let A=a.rules.slice(),j=await F(I,W);j.length&&A.push(...j);let Z=H().add(A);f.push({dir:I,relDir:W,rules:A,ig:Z});continue}if(!k.isFile()){s+=1;continue}if(n?.(I)){s+=1;continue}let P=Y(o,I);if(!P||P.startsWith("..")){s+=1;continue}if(a.ig.ignores(P)&&!i?.hasFile(P)){s+=1;continue}let V=_.extname(k.name).toLowerCase();if(!m.has(V)){s+=1;continue}let O=R(P);if(!O){s+=1;continue}let M;try{M=await G.stat(I)}catch{s+=1;continue}if(M.size>d){s+=1;continue}p.push({relPath:P,absPath:I,mtimeMs:Math.floor(M.mtimeMs),size:M.size,lang:O}),y+=1,p.length>=r&&await x()}}v.has(t)||await x(),l.postMessage({type:"scan:done",requestId:t,discovered:y,skipped:s,cancelled:v.has(t)}),h("scan complete",{requestId:t,discovered:y,skipped:s,cancelled:v.has(t)})}catch(a){h("scan failed",{requestId:t,error:a?.message||String(a),stack:a?.stack??null}),l.postMessage({type:"error",requestId:t,message:a?.message||String(a),stack:a?.stack})}finally{v.delete(t),b.delete(t)}return}if(e.cmd==="process"){let t=e.role??T,o=typeof e.projectRoot=="string"?e.projectRoot:E;if(!o){l.postMessage({type:"error",requestId:e.requestId,message:"worker not initialized"});return}let{file:r}=e,d=r.encoding??"utf8",u=r.sharedBuffer,m={size:r.size,mtime:r.mtime};try{let n=r.lang??"ts",i,c,S=()=>{if(c&&typeof i=="string")return{content:i,sharedBuffer:c};if(u instanceof SharedArrayBuffer)return c=u,i=U(u,d),{content:i,sharedBuffer:c};if(u instanceof ArrayBuffer){let x=Buffer.from(u),a=new SharedArrayBuffer(x.byteLength);return new Uint8Array(a).set(x),c=a,i=x.toString(d),{content:i,sharedBuffer:c}}let s=K.readFileSync(r.absPath),p=new SharedArrayBuffer(s.byteLength);return new Uint8Array(p).set(s),c=p,i=s.toString(d),{content:i,sharedBuffer:c}},w=()=>{let s=B(n,r.relPath,m),p=S();l.postMessage({type:"result",requestId:e.requestId,role:"index",relPath:r.relPath,result:{payload:s.payload,meta:{size:s.fileSize,mtime:s.mtime},snapshotSummary:D(p.sharedBuffer,r.relPath,r.size,r.mtime,d,p.content)}})},g=`${o}:${n}`,f=J.get(g);if(!f)try{h("creating language indexer",{role:t,requestId:e.requestId,lang:n,projectRoot:o});let s=C(n);if(!L(s))throw new Error(`${n} is not a worker-indexed language`);f=s.createIndexer(o),J.set(g,f),h("language indexer ready",{role:t,requestId:e.requestId,lang:n,projectRoot:o})}catch(s){h("language indexer create failed",{role:t,requestId:e.requestId,lang:n,error:s?.message||String(s),stack:s?.stack??null}),w();return}({content:i,sharedBuffer:c}=S());let y;try{y=await f.process({absPath:r.absPath,relPath:r.relPath,content:i,meta:m,preDeleted:!!r.preDeleted,lang:n,emitMode:r.emitMode})}catch(s){h("process failed",{role:t,requestId:e.requestId,lang:n,relPath:r.relPath,error:s?.message||String(s),stack:s?.stack??null}),w();return}l.postMessage({type:"result",requestId:e.requestId,role:"index",relPath:r.relPath,result:{payload:y.payload,meta:{size:y.fileSize,mtime:y.mtime},snapshotSummary:D(c,r.relPath,r.size,r.mtime,d,i)}})}catch(n){h("process wrapper failed",{role:t,requestId:e.requestId,relPath:r.relPath,error:n?.message||String(n),stack:n?.stack??null});try{let i=r.lang??"ts",c=K.readFileSync(r.absPath),S=new SharedArrayBuffer(c.byteLength);new Uint8Array(S).set(c);let w=c.toString(d),g=B(i,r.relPath,m);l.postMessage({type:"result",requestId:e.requestId,role:"index",relPath:r.relPath,result:{payload:g.payload,meta:{size:g.fileSize,mtime:g.mtime},snapshotSummary:D(S,r.relPath,r.size,r.mtime,d,w)}})}catch(i){l.postMessage({type:"error",requestId:e.requestId,message:i?.message||n?.message||String(i??n),stack:i?.stack??n?.stack})}}return}e.cmd==="close"&&l.postMessage({type:"closed"})});process.on("uncaughtException",e=>{try{l.postMessage({type:"error",message:e?.message||String(e),stack:e?.stack})}catch{}});process.on("unhandledRejection",e=>{try{l.postMessage({type:"error",message:String(e)})}catch{}});
1
+ import{a as B,b as L,c as q,d as R,e as C,f as z,i as F,j as N}from"./chunk-G2RN6IZH.mjs";import"./chunk-WHHZYOEJ.mjs";import{c as X}from"./chunk-RRIZV7YJ.mjs";import{parentPort as l,threadId as ne}from"worker_threads";import K from"fs";import _ from"path";import{promises as G}from"fs";import H from"ignore";import{createHash as se}from"crypto";var te=Math.max(1,Number(process.env.PANDO_BATCH_INDEX_MAX_FILES||"64")),re=Math.max(1,Number(process.env.PANDO_BATCH_INDEX_MAX_BYTES||`${1024*1024}`)),ce=Math.max(1,Number(process.env.PANDO_BATCH_INDEX_MAX_WAIT_MS||"15")),le=Math.max(te,Number(process.env.PANDO_BATCH_INDEX_MAX_PENDING_FILES||"256")),he=Math.max(re,Number(process.env.PANDO_BATCH_INDEX_MAX_PENDING_BYTES||`${8*1024*1024}`));var be=1*1024*1024,Me=Math.max(3e4,Number(process.env.PANDO_WORKER_INIT_TIMEOUT_MS||12e4)),ie=Math.max(1e3,Number(process.env.PANDO_ACTIVE_CONTEXT_STALL_LOG_MS||1e4)),We=Math.max(ie,Number(process.env.PANDO_ACTIVE_CONTEXT_STALL_FAIL_MS||6e5)),Be=q();function U(e,t){return Buffer.from(e).toString(t)}function D(e,t,o,r,d,u){let m=Buffer.from(e),n=se("sha1").update(m).digest("hex"),i=u??m.toString(d),c=i?i.split(/\r?\n/).length:0;return{relPath:t,size:o,mtime:r,objectId:n,lineCount:c,encoding:d}}if(!l)throw new Error("Indexer worker must be spawned as a worker thread");X();function h(e,t){try{if(t===void 0){console.error(`[${new Date().toISOString()}] [IndexerWorker] ${e}`);return}console.error(`[${new Date().toISOString()}] [IndexerWorker] ${e} ${JSON.stringify({pid:process.pid,threadId:ne,...t&&typeof t=="object"&&!Array.isArray(t)?t:{details:t}})}`)}catch{}}h("module loaded",{cwd:process.cwd(),hasParentPort:!!l,envWorkerRoot:process.env.PANDO_WORKER_SCRIPT_DIR??null,envRuntimeRoot:process.env.PANDO_RUNTIME_ROOT??null});var J=new Map,E="",T="index",b=new Map,v=new Set;function Y(e,t){return _.relative(e,t).replace(/\\/g,"/")}function ae(e,t){let o=(t||[]).map(r=>typeof r=="string"?r.trim():"").filter(Boolean).map(r=>r.replace(/^[\\/]+/,"").replace(/[\\/]+$/,"")).map(r=>r.endsWith("/")?r:`${r}/`);return o.length?r=>{let d=Y(e,r);if(!d||d.startsWith(".."))return!1;let u=d.endsWith("/")?d:`${d}/`;return o.some(m=>u.startsWith(m))}:null}async function oe(e){await new Promise(t=>{b.set(e,t)})}l.on("message",async e=>{if(e.cmd==="scan-ack"){let t=b.get(e.requestId);if(t){b.delete(e.requestId);try{t()}catch{}}return}if(e.cmd==="scan-cancel"){v.add(e.requestId);let t=b.get(e.requestId);if(t){b.delete(e.requestId);try{t()}catch{}}return}if(e.cmd==="init"){try{h("init received",{mode:e.mode??"index",projectRoot:typeof e.projectRoot=="string"?e.projectRoot:null}),typeof e.projectRoot=="string"&&(E=e.projectRoot),T=e.mode??"index",h("init completed",{mode:T,projectRoot:E}),l.postMessage({type:"ready"})}catch(t){h("init failed",{error:t?.message||String(t),stack:t?.stack??null}),l.postMessage({type:"error",message:`init failed: ${t?.message||t}`,stack:t?.stack})}return}if(e.cmd==="scan"){let t=e.requestId,o=typeof e.projectRoot=="string"?e.projectRoot:E;if(h("scan received",{requestId:t,projectRoot:o||null,batchSize:e.batchSize??null,maxFileBytes:e.maxFileBytes??null,excludeDirs:Array.isArray(e.excludeDirs)?e.excludeDirs.slice(0,20):[]}),!o){l.postMessage({type:"error",requestId:t,message:"worker not initialized"});return}let r=Math.max(1,Math.min(500,Number(e.batchSize||100))),d=Math.max(1,Number(e.maxFileBytes||1*1024*1024)),u=e.languageSupport,m=z(u),n=ae(o,e.excludeDirs??[]),i=N(o),c=new Set(["node_modules",".git",".pando-data"]),S=a=>a.replace(/\\/g,"/"),w=await F(o,""),g=H().add(w),f=[{dir:o,relDir:"",rules:w,ig:g}],y=0,s=0,p=[],x=async()=>{p.length&&(l.postMessage({type:"scan:batch",requestId:t,files:p}),p=[],await oe(t))};try{for(;f.length&&!v.has(t);){let a=f.pop(),$=[];try{$=await G.readdir(a.dir,{withFileTypes:!0})}catch{s+=1;continue}for(let k of $){if(v.has(t))break;let I=_.join(a.dir,k.name);if(k.isSymbolicLink?.()){s+=1;continue}if(k.isDirectory()){if(c.has(k.name)){s+=1;continue}if(n?.(I)){s+=1;continue}let Q=a.relDir?`${a.relDir}/${k.name}`:k.name,W=S(Q);if(a.ig.ignores(W)&&!i?.hasDescendant(W)){s+=1;continue}let A=a.rules.slice(),j=await F(I,W);j.length&&A.push(...j);let Z=H().add(A);f.push({dir:I,relDir:W,rules:A,ig:Z});continue}if(!k.isFile()){s+=1;continue}if(n?.(I)){s+=1;continue}let P=Y(o,I);if(!P||P.startsWith("..")){s+=1;continue}if(a.ig.ignores(P)&&!i?.hasFile(P)){s+=1;continue}let V=_.extname(k.name).toLowerCase();if(!m.has(V)){s+=1;continue}let O=R(P);if(!O){s+=1;continue}let M;try{M=await G.stat(I)}catch{s+=1;continue}if(M.size>d){s+=1;continue}p.push({relPath:P,absPath:I,mtimeMs:Math.floor(M.mtimeMs),size:M.size,lang:O}),y+=1,p.length>=r&&await x()}}v.has(t)||await x(),l.postMessage({type:"scan:done",requestId:t,discovered:y,skipped:s,cancelled:v.has(t)}),h("scan complete",{requestId:t,discovered:y,skipped:s,cancelled:v.has(t)})}catch(a){h("scan failed",{requestId:t,error:a?.message||String(a),stack:a?.stack??null}),l.postMessage({type:"error",requestId:t,message:a?.message||String(a),stack:a?.stack})}finally{v.delete(t),b.delete(t)}return}if(e.cmd==="process"){let t=e.role??T,o=typeof e.projectRoot=="string"?e.projectRoot:E;if(!o){l.postMessage({type:"error",requestId:e.requestId,message:"worker not initialized"});return}let{file:r}=e,d=r.encoding??"utf8",u=r.sharedBuffer,m={size:r.size,mtime:r.mtime};try{let n=r.lang??"ts",i,c,S=()=>{if(c&&typeof i=="string")return{content:i,sharedBuffer:c};if(u instanceof SharedArrayBuffer)return c=u,i=U(u,d),{content:i,sharedBuffer:c};if(u instanceof ArrayBuffer){let x=Buffer.from(u),a=new SharedArrayBuffer(x.byteLength);return new Uint8Array(a).set(x),c=a,i=x.toString(d),{content:i,sharedBuffer:c}}let s=K.readFileSync(r.absPath),p=new SharedArrayBuffer(s.byteLength);return new Uint8Array(p).set(s),c=p,i=s.toString(d),{content:i,sharedBuffer:c}},w=()=>{let s=B(n,r.relPath,m),p=S();l.postMessage({type:"result",requestId:e.requestId,role:"index",relPath:r.relPath,result:{payload:s.payload,meta:{size:s.fileSize,mtime:s.mtime},snapshotSummary:D(p.sharedBuffer,r.relPath,r.size,r.mtime,d,p.content)}})},g=`${o}:${n}`,f=J.get(g);if(!f)try{h("creating language indexer",{role:t,requestId:e.requestId,lang:n,projectRoot:o});let s=C(n);if(!L(s))throw new Error(`${n} is not a worker-indexed language`);f=s.createIndexer(o),J.set(g,f),h("language indexer ready",{role:t,requestId:e.requestId,lang:n,projectRoot:o})}catch(s){h("language indexer create failed",{role:t,requestId:e.requestId,lang:n,error:s?.message||String(s),stack:s?.stack??null}),w();return}({content:i,sharedBuffer:c}=S());let y;try{y=await f.process({absPath:r.absPath,relPath:r.relPath,content:i,meta:m,preDeleted:!!r.preDeleted,lang:n,emitMode:r.emitMode})}catch(s){h("process failed",{role:t,requestId:e.requestId,lang:n,relPath:r.relPath,error:s?.message||String(s),stack:s?.stack??null}),w();return}l.postMessage({type:"result",requestId:e.requestId,role:"index",relPath:r.relPath,result:{payload:y.payload,meta:{size:y.fileSize,mtime:y.mtime},snapshotSummary:D(c,r.relPath,r.size,r.mtime,d,i)}})}catch(n){h("process wrapper failed",{role:t,requestId:e.requestId,relPath:r.relPath,error:n?.message||String(n),stack:n?.stack??null});try{let i=r.lang??"ts",c=K.readFileSync(r.absPath),S=new SharedArrayBuffer(c.byteLength);new Uint8Array(S).set(c);let w=c.toString(d),g=B(i,r.relPath,m);l.postMessage({type:"result",requestId:e.requestId,role:"index",relPath:r.relPath,result:{payload:g.payload,meta:{size:g.fileSize,mtime:g.mtime},snapshotSummary:D(S,r.relPath,r.size,r.mtime,d,w)}})}catch(i){l.postMessage({type:"error",requestId:e.requestId,message:i?.message||n?.message||String(i??n),stack:i?.stack??n?.stack})}}return}e.cmd==="close"&&l.postMessage({type:"closed"})});process.on("uncaughtException",e=>{try{l.postMessage({type:"error",message:e?.message||String(e),stack:e?.stack})}catch{}});process.on("unhandledRejection",e=>{try{l.postMessage({type:"error",message:String(e)})}catch{}});
@@ -1,4 +1,4 @@
1
- import{g as I,h as Q,j as ct}from"./chunk-5PZD6HGD.mjs";import{a as V,b as at,c as J,e as R}from"./chunk-WHHZYOEJ.mjs";import{a as Z,b as Pt}from"./chunk-MKW3R262.mjs";import{a as kt,c as lt}from"./chunk-RRIZV7YJ.mjs";import{parentPort as j}from"worker_threads";import st from"path";import*as o from"fs";import*as M from"path";import*as u from"isomorphic-git";function xt(){return new Date().toISOString()}function X(r,t,e){let n=`[${xt()}] [${r.toUpperCase()}] ${t}`;if(!e)return n;try{return n+" "+JSON.stringify(e)}catch{return n}}var B={debug:(r,t)=>{try{process.stderr.write(X("debug",r,t)+`
1
+ import{g as I,h as Q,j as ct}from"./chunk-G2RN6IZH.mjs";import{a as V,b as at,c as J,e as R}from"./chunk-WHHZYOEJ.mjs";import{a as Z,b as Pt}from"./chunk-MKW3R262.mjs";import{a as kt,c as lt}from"./chunk-RRIZV7YJ.mjs";import{parentPort as j}from"worker_threads";import st from"path";import*as o from"fs";import*as M from"path";import*as u from"isomorphic-git";function xt(){return new Date().toISOString()}function X(r,t,e){let n=`[${xt()}] [${r.toUpperCase()}] ${t}`;if(!e)return n;try{return n+" "+JSON.stringify(e)}catch{return n}}var B={debug:(r,t)=>{try{process.stderr.write(X("debug",r,t)+`
2
2
  `)}catch{}},info:(r,t)=>{try{process.stderr.write(X("info",r,t)+`
3
3
  `)}catch{}},warn:(r,t)=>{try{process.stderr.write(X("warn",r,t)+`
4
4
  `)}catch{}},error:(r,t)=>{try{process.stderr.write(X("error",r,t)+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pando-ai",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "AI coding firewall for Codex and Claude Code: supervised launchers, Pando MCP, policy enforcement, Claude hooks, and local provider gateway.",
5
5
  "bin": {
6
6
  "pando-ai": "bin/pando-ai.js"