galaxyrepowatch 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -435,7 +435,7 @@ Project '${_.projectName}' (${N4[_.projectKind]}) ${o}
|
|
|
435
435
|
`&&(!_||_.length===0||bnt(_,o))){let{lineText:u,absolutePosition:g}=s.textStorage.getAbsolutePositionAndLineText(t.line);if(u&&u.search("\\S")<0){let d=i.getIndentationAtPosition(n,o,c),h=0,S,T;for(S=0,T=u.length;S<T;S++)if(u.charAt(S)===" ")h++;else if(u.charAt(S)===" ")h+=c.tabSize;else break;if(d!==h){let k=g+S;_.push({span:$c(g,k),newText:yl.getIndentationString(d,c)})}}}if(_)return _.map(u=>({start:s.positionToLineOffset(u.span.start),end:s.positionToLineOffset(gc(u.span)),newText:u.newText?u.newText:""}))}getCompletions(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getPosition(t,o),_=s.getLanguageService().getCompletionsAtPosition(i,c,{...dpe(this.getPreferences(i)),triggerCharacter:t.triggerCharacter,triggerKind:t.triggerKind,includeExternalModuleExports:t.includeExternalModuleExports,includeInsertTextCompletions:t.includeInsertTextCompletions},s.projectService.getFormatCodeOptions(i));if(_===void 0)return;if(n==="completions-full")return _;let u=t.prefix||"",g=zi(_.entries,h=>{if(_.isMemberCompletion||ts(h.name.toLowerCase(),u.toLowerCase())){let S=h.replacementSpan?Qm(h.replacementSpan,o):void 0;return{...h,replacementSpan:S,hasAction:h.hasAction||void 0,symbol:void 0}}});return n==="completions"?(_.metadata&&(g.metadata=_.metadata),g):{..._,optionalReplacementSpan:_.optionalReplacementSpan&&Qm(_.optionalReplacementSpan,o),entries:g}}getCompletionEntryDetails(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getPosition(t,o),_=s.projectService.getFormatCodeOptions(i),u=!!this.getPreferences(i).displayPartsForJSDoc,g=zi(t.entryNames,d=>{let{name:h,source:S,data:T}=typeof d=="string"?{name:d,source:void 0,data:void 0}:d;return s.getLanguageService().getCompletionEntryDetails(i,c,h,_,S,this.getPreferences(i),T?ia(T,Fnt):void 0)});return n?u?g:g.map(d=>({...d,tags:this.mapJSDocTagInfo(d.tags,s,!1)})):g.map(d=>({...d,codeActions:Er(d.codeActions,h=>this.mapCodeAction(h)),documentation:this.mapDisplayParts(d.documentation,s),tags:this.mapJSDocTagInfo(d.tags,s,u)}))}getCompileOnSaveAffectedFileList(t){let n=this.getProjects(t,!0,!0),i=this.projectService.getScriptInfo(t.file);return i?Tnt(i,s=>this.projectService.getScriptInfoForPath(s),n,(s,o)=>{if(!s.compileOnSaveEnabled||!s.languageServiceEnabled||s.isOrphan())return;let c=s.getCompilationSettings();if(!(c.noEmit||Gl(o.fileName)&&!vnt(c)))return{projectFileName:s.getProjectName(),fileNames:s.getCompileOnSaveAffectedFileList(o),projectUsesOutFile:!!c.outFile}}):Ll}emitFile(t){let{file:n,project:i}=this.getFileAndProject(t);if(i||l0.ThrowNoProject(),!i.languageServiceEnabled)return t.richResponse?{emitSkipped:!0,diagnostics:[]}:!1;let s=i.getScriptInfo(n),{emitSkipped:o,diagnostics:c}=i.emitFile(s,(_,u,g)=>this.host.writeFile(_,u,g));return t.richResponse?{emitSkipped:o,diagnostics:t.includeLinePosition?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(c):c.map(_=>j8(_,!0))}:!o}getSignatureHelpItems(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getPosition(t,o),_=s.getLanguageService().getSignatureHelpItems(i,c,t),u=!!this.getPreferences(i).displayPartsForJSDoc;if(_&&n){let g=_.applicableSpan;return{..._,applicableSpan:{start:o.positionToLineOffset(g.start),end:o.positionToLineOffset(g.start+g.length)},items:this.mapSignatureHelpItems(_.items,s,u)}}else return u||!_?_:{..._,items:_.items.map(g=>({...g,tags:this.mapJSDocTagInfo(g.tags,s,!1)}))}}toPendingErrorCheck(t){let n=yo(t),i=this.projectService.tryGetDefaultProjectForFile(n);return i&&{fileName:n,project:i}}getDiagnostics(t,n,i){this.suppressDiagnosticEvents||i.length>0&&this.updateErrorCheck(t,i,n)}change(t){let n=this.projectService.getScriptInfo(t.file);E.assert(!!n),n.textStorage.switchToScriptVersionCache();let i=n.lineOffsetToPosition(t.line,t.offset),s=n.lineOffsetToPosition(t.endLine,t.endOffset);i>=0&&(this.changeSeq++,this.projectService.applyChangesToFile(n,yY({span:{start:i,length:s-i},newText:t.insertString})))}reload(t){let n=yo(t.file),i=t.tmpfile===void 0?void 0:yo(t.tmpfile),s=this.projectService.getScriptInfoForNormalizedPath(n);s&&(this.changeSeq++,s.reloadFromFile(i))}saveToTmp(t,n){let i=this.projectService.getScriptInfo(t);i&&i.saveTo(n)}closeClientFile(t){if(!t)return;let n=oa(t);this.projectService.closeClientFile(n)}mapLocationNavigationBarItems(t,n){return Er(t,i=>({text:i.text,kind:i.kind,kindModifiers:i.kindModifiers,spans:i.spans.map(s=>Qm(s,n)),childItems:this.mapLocationNavigationBarItems(i.childItems,n),indent:i.indent}))}getNavigationBarItems(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=s.getNavigationBarItems(i);return o?n?this.mapLocationNavigationBarItems(o,this.projectService.getScriptInfoForNormalizedPath(i)):o:void 0}toLocationNavigationTree(t,n){return{text:t.text,kind:t.kind,kindModifiers:t.kindModifiers,spans:t.spans.map(i=>Qm(i,n)),nameSpan:t.nameSpan&&Qm(t.nameSpan,n),childItems:Er(t.childItems,i=>this.toLocationNavigationTree(i,n))}}getNavigationTree(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=s.getNavigationTree(i);return o?n?this.toLocationNavigationTree(o,this.projectService.getScriptInfoForNormalizedPath(i)):o:void 0}getNavigateToItems(t,n){let i=this.getFullNavigateToItems(t);return n?Js(i,({project:s,navigateToItems:o})=>o.map(c=>{let _=s.getScriptInfo(c.fileName),u={name:c.name,kind:c.kind,kindModifiers:c.kindModifiers,isCaseSensitive:c.isCaseSensitive,matchKind:c.matchKind,file:c.fileName,start:_.positionToLineOffset(c.textSpan.start),end:_.positionToLineOffset(gc(c.textSpan))};return c.kindModifiers&&c.kindModifiers!==""&&(u.kindModifiers=c.kindModifiers),c.containerName&&c.containerName.length>0&&(u.containerName=c.containerName),c.containerKind&&c.containerKind.length>0&&(u.containerKind=c.containerKind),u})):Js(i,({navigateToItems:s})=>s)}getFullNavigateToItems(t){let{currentFileOnly:n,searchValue:i,maxResultCount:s,projectFileName:o}=t;if(n){E.assertIsDefined(t.file);let{file:S,project:T}=this.getFileAndProject(t);return[{project:T,navigateToItems:T.getLanguageService().getNavigateToItems(i,s,S)}]}let c=this.getHostPreferences(),_=[],u=new Map;if(!t.file&&!o)this.projectService.loadAncestorProjectTree(),this.projectService.forEachEnabledProject(S=>g(S));else{let S=this.getProjects(t);yNe(S,void 0,T=>g(T))}return _;function g(S){let T=S.getLanguageService().getNavigateToItems(i,s,void 0,S.isNonTsProject(),c.excludeLibrarySymbolsInNavTo),k=Fn(T,D=>d(D)&&!HH(I4(D),S));k.length&&_.push({project:S,navigateToItems:k})}function d(S){let T=S.name;if(!u.has(T))return u.set(T,[S]),!0;let k=u.get(T);for(let D of k)if(h(D,S))return!1;return k.push(S),!0}function h(S,T){return S===T?!0:!S||!T?!1:S.containerKind===T.containerKind&&S.containerName===T.containerName&&S.fileName===T.fileName&&S.isCaseSensitive===T.isCaseSensitive&&S.kind===T.kind&&S.kindModifiers===T.kindModifiers&&S.matchKind===T.matchKind&&S.name===T.name&&S.textSpan.start===T.textSpan.start&&S.textSpan.length===T.textSpan.length}}getSupportedCodeFixes(t){if(!t)return _G();if(t.file){let{file:i,project:s}=this.getFileAndProject(t);return s.getLanguageService().getSupportedCodeFixes(i)}let n=this.getProject(t.projectFileName);return n||l0.ThrowNoProject(),n.getLanguageService().getSupportedCodeFixes()}isLocation(t){return t.line!==void 0}extractPositionOrRange(t,n){let i,s;return this.isLocation(t)?i=o(t):s=this.getRange(t,n),E.checkDefined(i===void 0?s:i);function o(c){return c.position!==void 0?c.position:n.lineOffsetToPosition(c.line,c.offset)}}getRange(t,n){let{startPosition:i,endPosition:s}=this.getStartAndEndPosition(t,n);return{pos:i,end:s}}getApplicableRefactors(t){let{file:n,project:i}=this.getFileAndProject(t),s=i.getScriptInfoForNormalizedPath(n);return i.getLanguageService().getApplicableRefactors(n,this.extractPositionOrRange(t,s),this.getPreferences(n),t.triggerReason,t.kind,t.includeInteractiveActions).map(c=>({...c,actions:c.actions.map(_=>({..._,range:_.range?{start:XD({line:_.range.start.line,character:_.range.start.offset}),end:XD({line:_.range.end.line,character:_.range.end.offset})}:void 0}))}))}getEditsForRefactor(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=s.getScriptInfoForNormalizedPath(i),c=s.getLanguageService().getEditsForRefactor(i,this.getFormatOptions(i),this.extractPositionOrRange(t,o),t.refactor,t.action,this.getPreferences(i),t.interactiveRefactorArguments);if(c===void 0)return{edits:[]};if(n){let{renameFilename:_,renameLocation:u,edits:g}=c,d;if(_!==void 0&&u!==void 0){let h=s.getScriptInfoForNormalizedPath(yo(_));d=Fpe(Xk(h.getSnapshot()),_,u,g)}return{renameLocation:d,renameFilename:_,edits:this.mapTextChangesToCodeEdits(g),notApplicableReason:c.notApplicableReason}}return c}getMoveToRefactoringFileSuggestions(t){let{file:n,project:i}=this.getFileAndProject(t),s=i.getScriptInfoForNormalizedPath(n);return i.getLanguageService().getMoveToRefactoringFileSuggestions(n,this.extractPositionOrRange(t,s),this.getPreferences(n))}preparePasteEdits(t){let{file:n,project:i}=this.getFileAndProject(t);return i.getLanguageService().preparePasteEditsForFile(n,t.copiedTextSpan.map(s=>this.getRange({file:n,startLine:s.start.line,startOffset:s.start.offset,endLine:s.end.line,endOffset:s.end.offset},this.projectService.getScriptInfoForNormalizedPath(n))))}getPasteEdits(t){let{file:n,project:i}=this.getFileAndProject(t);if(A4(n))return;let s=t.copiedFrom?{file:t.copiedFrom.file,range:t.copiedFrom.spans.map(c=>this.getRange({file:t.copiedFrom.file,startLine:c.start.line,startOffset:c.start.offset,endLine:c.end.line,endOffset:c.end.offset},i.getScriptInfoForNormalizedPath(yo(t.copiedFrom.file))))}:void 0,o=i.getLanguageService().getPasteEdits({targetFile:n,pastedText:t.pastedText,pasteLocations:t.pasteLocations.map(c=>this.getRange({file:n,startLine:c.start.line,startOffset:c.start.offset,endLine:c.end.line,endOffset:c.end.offset},i.getScriptInfoForNormalizedPath(n))),copiedFrom:s,preferences:this.getPreferences(n)},this.getFormatOptions(n));return o&&this.mapPasteEditsAction(o)}organizeImports(t,n){E.assert(t.scope.type==="file");let{file:i,project:s}=this.getFileAndProject(t.scope.args),o=s.getLanguageService().organizeImports({fileName:i,mode:t.mode??(t.skipDestructiveCodeActions?"SortAndCombine":void 0),type:"file"},this.getFormatOptions(i),this.getPreferences(i));return n?this.mapTextChangesToCodeEdits(o):o}getEditsForFileRename(t,n){let i=yo(t.oldFilePath),s=yo(t.newFilePath),o=this.getHostFormatOptions(),c=this.getHostPreferences(),_=new Set,u=[];return this.projectService.loadAncestorProjectTree(),this.projectService.forEachEnabledProject(g=>{let d=g.getLanguageService().getEditsForFileRename(i,s,o,c),h=[];for(let S of d)_.has(S.fileName)||(u.push(S),h.push(S.fileName));for(let S of h)_.add(S)}),n?u.map(g=>this.mapTextChangeToCodeEdit(g)):u}getCodeFixes(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=s.getScriptInfoForNormalizedPath(i),{startPosition:c,endPosition:_}=this.getStartAndEndPosition(t,o),u;try{u=s.getLanguageService().getCodeFixesAtPosition(i,c,_,t.errorCodes,this.getFormatOptions(i),this.getPreferences(i))}catch(g){let d=g instanceof Error?g:new Error(g),h=s.getLanguageService(),S=[...h.getSyntacticDiagnostics(i),...h.getSemanticDiagnostics(i),...h.getSuggestionDiagnostics(i)].filter(k=>YA(c,_-c,k.start,k.length)).map(k=>k.code),T=t.errorCodes.find(k=>!S.includes(k));throw T!==void 0&&(d.message+=`
|
|
436
436
|
Additional information: BADCLIENT: Bad error code, ${T} not found in range ${c}..${_} (found: ${S.join(", ")})`),d}return n?u.map(g=>this.mapCodeFixAction(g)):u}getCombinedCodeFix({scope:t,fixId:n},i){E.assert(t.type==="file");let{file:s,project:o}=this.getFileAndProject(t.args),c=o.getLanguageService().getCombinedCodeFix({type:"file",fileName:s},n,this.getFormatOptions(s),this.getPreferences(s));return i?{changes:this.mapTextChangesToCodeEdits(c.changes),commands:c.commands}:c}applyCodeActionCommand(t){let n=t.command;for(let i of Fx(n)){let{file:s,project:o}=this.getFileAndProject(i);o.getLanguageService().applyCodeActionCommand(i,this.getFormatOptions(s)).then(c=>{},c=>{})}return{}}getStartAndEndPosition(t,n){let i,s;return t.startPosition!==void 0?i=t.startPosition:(i=n.lineOffsetToPosition(t.startLine,t.startOffset),t.startPosition=i),t.endPosition!==void 0?s=t.endPosition:(s=n.lineOffsetToPosition(t.endLine,t.endOffset),t.endPosition=s),{startPosition:i,endPosition:s}}mapCodeAction({description:t,changes:n,commands:i}){return{description:t,changes:this.mapTextChangesToCodeEdits(n),commands:i}}mapCodeFixAction({fixName:t,description:n,changes:i,commands:s,fixId:o,fixAllDescription:c}){return{fixName:t,description:n,changes:this.mapTextChangesToCodeEdits(i),commands:s,fixId:o,fixAllDescription:c}}mapPasteEditsAction({edits:t,fixId:n}){return{edits:this.mapTextChangesToCodeEdits(t),fixId:n}}mapTextChangesToCodeEdits(t){return t.map(n=>this.mapTextChangeToCodeEdit(n))}mapTextChangeToCodeEdit(t){let n=this.projectService.getScriptInfoOrConfig(t.fileName);return!!t.isNewFile==!!n&&(n||this.projectService.logErrorForScriptInfoNotFound(t.fileName),E.fail("Expected isNewFile for (only) new files. "+JSON.stringify({isNewFile:!!t.isNewFile,hasScriptInfo:!!n}))),n?{fileName:t.fileName,textChanges:t.textChanges.map(i=>wnt(i,n))}:Nnt(t)}convertTextChangeToCodeEdit(t,n){return{start:n.positionToLineOffset(t.span.start),end:n.positionToLineOffset(t.span.start+t.span.length),newText:t.newText?t.newText:""}}getBraceMatching(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getPosition(t,o),_=s.getBraceMatchingAtPosition(i,c);return _?n?_.map(u=>Qm(u,o)):_:void 0}getDiagnosticsForProject(t,n,i){if(this.suppressDiagnosticEvents)return;let{fileNames:s,languageServiceDisabled:o}=this.getProjectInfoWorker(i,void 0,!0,void 0,!0);if(o)return;let c=s.filter(D=>!D.includes("lib.d.ts"));if(c.length===0)return;let _=[],u=[],g=[],d=[],h=yo(i),S=this.projectService.ensureDefaultProjectForFile(h);for(let D of c)this.getCanonicalFileName(D)===this.getCanonicalFileName(i)?_.push(D):this.projectService.getScriptInfo(D).isScriptOpen()?u.push(D):Gl(D)?d.push(D):g.push(D);let k=[..._,...u,...g,...d].map(D=>({fileName:D,project:S}));this.updateErrorCheck(t,k,n,!1)}configurePlugin(t){this.projectService.configurePlugin(t)}getSmartSelectionRange(t,n){let{locations:i}=t,{file:s,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),c=E.checkDefined(this.projectService.getScriptInfo(s));return Er(i,_=>{let u=this.getPosition(_,c),g=o.getSmartSelectionRange(s,u);return n?this.mapSelectionRange(g,c):g})}toggleLineComment(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfo(i),c=this.getRange(t,o),_=s.toggleLineComment(i,c);if(n){let u=this.projectService.getScriptInfoForNormalizedPath(i);return _.map(g=>this.convertTextChangeToCodeEdit(g,u))}return _}toggleMultilineComment(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getRange(t,o),_=s.toggleMultilineComment(i,c);if(n){let u=this.projectService.getScriptInfoForNormalizedPath(i);return _.map(g=>this.convertTextChangeToCodeEdit(g,u))}return _}commentSelection(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getRange(t,o),_=s.commentSelection(i,c);if(n){let u=this.projectService.getScriptInfoForNormalizedPath(i);return _.map(g=>this.convertTextChangeToCodeEdit(g,u))}return _}uncommentSelection(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getRange(t,o),_=s.uncommentSelection(i,c);if(n){let u=this.projectService.getScriptInfoForNormalizedPath(i);return _.map(g=>this.convertTextChangeToCodeEdit(g,u))}return _}mapSelectionRange(t,n){let i={textSpan:Qm(t.textSpan,n)};return t.parent&&(i.parent=this.mapSelectionRange(t.parent,n)),i}getScriptInfoFromProjectService(t){let n=yo(t),i=this.projectService.getScriptInfoForNormalizedPath(n);return i||(this.projectService.logErrorForScriptInfoNotFound(n),l0.ThrowNoProject())}toProtocolCallHierarchyItem(t){let n=this.getScriptInfoFromProjectService(t.file);return{name:t.name,kind:t.kind,kindModifiers:t.kindModifiers,file:t.file,containerName:t.containerName,span:Qm(t.span,n),selectionSpan:Qm(t.selectionSpan,n)}}toProtocolCallHierarchyIncomingCall(t){let n=this.getScriptInfoFromProjectService(t.from.file);return{from:this.toProtocolCallHierarchyItem(t.from),fromSpans:t.fromSpans.map(i=>Qm(i,n))}}toProtocolCallHierarchyOutgoingCall(t,n){return{to:this.toProtocolCallHierarchyItem(t.to),fromSpans:t.fromSpans.map(i=>Qm(i,n))}}prepareCallHierarchy(t){let{file:n,project:i}=this.getFileAndProject(t),s=this.projectService.getScriptInfoForNormalizedPath(n);if(s){let o=this.getPosition(t,s),c=i.getLanguageService().prepareCallHierarchy(n,o);return c&&S$(c,_=>this.toProtocolCallHierarchyItem(_))}}provideCallHierarchyIncomingCalls(t){let{file:n,project:i}=this.getFileAndProject(t),s=this.getScriptInfoFromProjectService(n);return i.getLanguageService().provideCallHierarchyIncomingCalls(n,this.getPosition(t,s)).map(c=>this.toProtocolCallHierarchyIncomingCall(c))}provideCallHierarchyOutgoingCalls(t){let{file:n,project:i}=this.getFileAndProject(t),s=this.getScriptInfoFromProjectService(n);return i.getLanguageService().provideCallHierarchyOutgoingCalls(n,this.getPosition(t,s)).map(c=>this.toProtocolCallHierarchyOutgoingCall(c,s))}getCanonicalFileName(t){let n=this.host.useCaseSensitiveFileNames?t:Vy(t);return oa(n)}exit(){}notRequired(t){return t&&this.doOutput(void 0,t.command,t.seq,!0,this.performanceData),{responseRequired:!1,performanceData:this.performanceData}}requiredResponse(t){return{response:t,responseRequired:!0,performanceData:this.performanceData}}addProtocolHandler(t,n){if(this.handlers.has(t))throw new Error(`Protocol handler already exists for command "${t}"`);this.handlers.set(t,n)}setCurrentRequest(t){E.assert(this.currentRequestId===void 0),this.currentRequestId=t,this.cancellationToken.setRequest(t)}resetCurrentRequest(t){E.assert(this.currentRequestId===t),this.currentRequestId=void 0,this.cancellationToken.resetRequest(t)}executeWithRequestId(t,n,i){let s=this.performanceData;try{return this.performanceData=i,this.setCurrentRequest(t),n()}finally{this.resetCurrentRequest(t),this.performanceData=s}}executeCommand(t){let n=this.handlers.get(t.command);if(n){let i=this.executeWithRequestId(t.seq,()=>n(t),void 0);return this.projectService.enableRequestedPlugins(),i}else return this.logger.msg(`Unrecognized JSON command:${Qv(t)}`,"Err"),this.doOutput(void 0,"unknown",t.seq,!1,void 0,`Unrecognized JSON command: ${t.command}`),{responseRequired:!1}}onMessage(t){var n,i,s,o,c,_,u;this.gcTimer.scheduleCollect();let g,d=this.performanceData;this.logger.hasLevel(2)&&(g=this.hrtime(),this.logger.hasLevel(3)&&this.logger.info(`request:${r4(this.toStringMessage(t))}`));let h,S;try{h=this.parseMessage(t),S=h.arguments&&h.arguments.file?h.arguments:void 0,(n=yn)==null||n.instant(yn.Phase.Session,"request",{seq:h.seq,command:h.command}),(i=yn)==null||i.push(yn.Phase.Session,"executeCommand",{seq:h.seq,command:h.command},!0);let{response:T,responseRequired:k,performanceData:D}=this.executeCommand(h);if((s=yn)==null||s.pop(),this.logger.hasLevel(2)){let P=ynt(this.hrtime(g)).toFixed(4);k?this.logger.perftrc(`${h.seq}::${h.command}: elapsed time (in milliseconds) ${P}`):this.logger.perftrc(`${h.seq}::${h.command}: async elapsed time (in milliseconds) ${P}`)}(o=yn)==null||o.instant(yn.Phase.Session,"response",{seq:h.seq,command:h.command,success:!!T}),T?this.doOutput(T,h.command,h.seq,!0,D):k&&this.doOutput(void 0,h.command,h.seq,!1,D,"No content available.")}catch(T){if((c=yn)==null||c.popAll(),T instanceof K6){(_=yn)==null||_.instant(yn.Phase.Session,"commandCanceled",{seq:h?.seq,command:h?.command}),this.doOutput({canceled:!0},h.command,h.seq,!0,this.performanceData);return}this.logErrorWorker(T,this.toStringMessage(t),S),(u=yn)==null||u.instant(yn.Phase.Session,"commandError",{seq:h?.seq,command:h?.command,message:T.message}),this.doOutput(void 0,h?h.command:"unknown",h?h.seq:0,!1,this.performanceData,"Error processing request. "+T.message+`
|
|
437
437
|
`+T.stack)}finally{this.performanceData=d}}parseMessage(t){return JSON.parse(t)}toStringMessage(t){return t}getFormatOptions(t){return this.projectService.getFormatCodeOptions(t)}getPreferences(t){return this.projectService.getPreferences(t)}getHostFormatOptions(){return this.projectService.getHostFormatCodeOptions()}getHostPreferences(){return this.projectService.getHostPreferences()}};function CNe(e){let t=e.diagnosticsDuration&&ys(e.diagnosticsDuration,([n,i])=>({...i,file:n}));return{...e,diagnosticsDuration:t}}function Qm(e,t){return{start:t.positionToLineOffset(e.start),end:t.positionToLineOffset(gc(e))}}function Ope(e,t,n){let i=Qm(e,n),s=t&&Qm(t,n);return s?{...i,contextStart:s.start,contextEnd:s.end}:i}function wnt(e,t){return{start:ENe(t,e.span.start),end:ENe(t,gc(e.span)),newText:e.newText}}function ENe(e,t){return Epe(e)?Ant(e.getLineAndCharacterOfPosition(t)):e.positionToLineOffset(t)}function Pnt(e,t){let n=e.ranges.map(i=>({start:t.positionToLineOffset(i.start),end:t.positionToLineOffset(i.start+i.length)}));return e.wordPattern?{ranges:n,wordPattern:e.wordPattern}:{ranges:n}}function Ant(e){return{line:e.line+1,offset:e.character+1}}function Nnt(e){E.assert(e.textChanges.length===1);let t=ja(e.textChanges);return E.assert(t.span.start===0&&t.span.length===0),{fileName:e.fileName,textChanges:[{start:{line:0,offset:0},end:{line:0,offset:0},newText:t.newText}]}}function Fpe(e,t,n,i){let s=Int(e,t,i),{line:o,character:c}=_E(zx(s),n);return{line:o+1,offset:c+1}}function Int(e,t,n){for(let{fileName:i,textChanges:s}of n)if(i===t)for(let o=s.length-1;o>=0;o--){let{newText:c,span:{start:_,length:u}}=s[o];e=e.slice(0,_)+c+e.slice(_+u)}return e}function DNe(e,{fileName:t,textSpan:n,contextSpan:i,isWriteAccess:s,isDefinition:o},{disableLineTextInReferences:c}){let _=E.checkDefined(e.getScriptInfo(t)),u=Ope(n,i,_),g=c?void 0:Ont(_,u);return{file:t,...u,lineText:g,isWriteAccess:s,isDefinition:o}}function Ont(e,t){let n=e.lineToTextSpan(t.start.line-1);return e.getSnapshot().getText(n.start,gc(n)).replace(/\r|\n/g,"")}function Fnt(e){return e===void 0||e&&typeof e=="object"&&typeof e.exportName=="string"&&(e.fileName===void 0||typeof e.fileName=="string")&&(e.ambientModuleName===void 0||typeof e.ambientModuleName=="string"&&(e.isPackageJsonImport===void 0||typeof e.isPackageJsonImport=="boolean"))}var YD=4,Lpe=(e=>(e[e.PreStart=0]="PreStart",e[e.Start=1]="Start",e[e.Entire=2]="Entire",e[e.Mid=3]="Mid",e[e.End=4]="End",e[e.PostEnd=5]="PostEnd",e))(Lpe||{}),Lnt=class{constructor(){this.goSubtree=!0,this.lineIndex=new B8,this.endBranch=[],this.state=2,this.initialText="",this.trailingText="",this.lineIndex.root=new KD,this.startPath=[this.lineIndex.root],this.stack=[this.lineIndex.root]}get done(){return!1}insertLines(e,t){t&&(this.trailingText=""),e?e=this.initialText+e+this.trailingText:e=this.initialText+this.trailingText;let i=B8.linesFromText(e).lines;i.length>1&&i[i.length-1]===""&&i.pop();let s,o;for(let _=this.endBranch.length-1;_>=0;_--)this.endBranch[_].updateCounts(),this.endBranch[_].charCount()===0&&(o=this.endBranch[_],_>0?s=this.endBranch[_-1]:s=this.branchNode);o&&s.remove(o);let c=this.startPath[this.startPath.length-1];if(i.length>0)if(c.text=i[0],i.length>1){let _=new Array(i.length-1),u=c;for(let h=1;h<i.length;h++)_[h-1]=new GM(i[h]);let g=this.startPath.length-2;for(;g>=0;){let h=this.startPath[g];_=h.insertAt(u,_),g--,u=h}let d=_.length;for(;d>0;){let h=new KD;h.add(this.lineIndex.root),_=h.insertAt(this.lineIndex.root,_),d=_.length,this.lineIndex.root=h}this.lineIndex.root.updateCounts()}else for(let _=this.startPath.length-2;_>=0;_--)this.startPath[_].updateCounts();else{this.startPath[this.startPath.length-2].remove(c);for(let u=this.startPath.length-2;u>=0;u--)this.startPath[u].updateCounts()}return this.lineIndex}post(e,t,n){n===this.lineCollectionAtBranch&&(this.state=4),this.stack.pop()}pre(e,t,n,i,s){let o=this.stack[this.stack.length-1];this.state===2&&s===1&&(this.state=1,this.branchNode=o,this.lineCollectionAtBranch=n);let c;function _(u){return u.isLeaf()?new GM(""):new KD}switch(s){case 0:this.goSubtree=!1,this.state!==4&&o.add(n);break;case 1:this.state===4?this.goSubtree=!1:(c=_(n),o.add(c),this.startPath.push(c));break;case 2:this.state!==4?(c=_(n),o.add(c),this.startPath.push(c)):n.isLeaf()||(c=_(n),o.add(c),this.endBranch.push(c));break;case 3:this.goSubtree=!1;break;case 4:this.state!==4?this.goSubtree=!1:n.isLeaf()||(c=_(n),o.add(c),this.endBranch.push(c));break;case 5:this.goSubtree=!1,this.state!==1&&o.add(n);break}this.goSubtree&&this.stack.push(c)}leaf(e,t,n){this.state===1?this.initialText=n.text.substring(0,e):this.state===2?(this.initialText=n.text.substring(0,e),this.trailingText=n.text.substring(e+t)):this.trailingText=n.text.substring(e+t)}},Mnt=class{constructor(e,t,n){this.pos=e,this.deleteLen=t,this.insertedText=n}getTextChangeRange(){return KA(mu(this.pos,this.deleteLen),this.insertedText?this.insertedText.length:0)}},QH=class Ex{constructor(){this.changes=[],this.versions=new Array(Ex.maxVersions),this.minVersion=0,this.currentVersion=0}versionToIndex(t){if(!(t<this.minVersion||t>this.currentVersion))return t%Ex.maxVersions}currentVersionToIndex(){return this.currentVersion%Ex.maxVersions}edit(t,n,i){this.changes.push(new Mnt(t,n,i)),(this.changes.length>Ex.changeNumberThreshold||n>Ex.changeLengthThreshold||i&&i.length>Ex.changeLengthThreshold)&&this.getSnapshot()}getSnapshot(){return this._getSnapshot()}_getSnapshot(){let t=this.versions[this.currentVersionToIndex()];if(this.changes.length>0){let n=t.index;for(let i of this.changes)n=n.edit(i.pos,i.deleteLen,i.insertedText);t=new wNe(this.currentVersion+1,this,n,this.changes),this.currentVersion=t.version,this.versions[this.currentVersionToIndex()]=t,this.changes=[],this.currentVersion-this.minVersion>=Ex.maxVersions&&(this.minVersion=this.currentVersion-Ex.maxVersions+1)}return t}getSnapshotVersion(){return this._getSnapshot().version}getAbsolutePositionAndLineText(t){return this._getSnapshot().index.lineNumberToInfo(t)}lineOffsetToPosition(t,n){return this._getSnapshot().index.absolutePositionOfStartOfLine(t)+(n-1)}positionToLineOffset(t){return this._getSnapshot().index.positionToLineOffset(t)}lineToTextSpan(t){let n=this._getSnapshot().index,{lineText:i,absolutePosition:s}=n.lineNumberToInfo(t+1),o=i!==void 0?i.length:n.absolutePositionOfStartOfLine(t+2)-s;return mu(s,o)}getTextChangesBetweenVersions(t,n){if(t<n)if(t>=this.minVersion){let i=[];for(let s=t+1;s<=n;s++){let o=this.versions[this.versionToIndex(s)];for(let c of o.changesSincePreviousVersion)i.push(c.getTextChangeRange())}return yZ(i)}else return;else return b5}getLineCount(){return this._getSnapshot().index.getLineCount()}static fromString(t){let n=new Ex,i=new wNe(0,n,new B8);n.versions[n.currentVersion]=i;let s=B8.linesFromText(t);return i.index.load(s.lines),n}};QH.changeNumberThreshold=8,QH.changeLengthThreshold=256,QH.maxVersions=8;var XH=QH,wNe=class D9e{constructor(t,n,i,s=Ll){this.version=t,this.cache=n,this.index=i,this.changesSincePreviousVersion=s}getText(t,n){return this.index.getText(t,n-t)}getLength(){return this.index.getLength()}getChangeRange(t){if(t instanceof D9e&&this.cache===t.cache)return this.version<=t.version?b5:this.cache.getTextChangesBetweenVersions(t.version,this.version)}},B8=class e0e{constructor(){this.checkEdits=!1}absolutePositionOfStartOfLine(t){return this.lineNumberToInfo(t).absolutePosition}positionToLineOffset(t){let{oneBasedLine:n,zeroBasedColumn:i}=this.root.charOffsetToLineInfo(1,t);return{line:n,offset:i+1}}positionToColumnAndLineText(t){return this.root.charOffsetToLineInfo(1,t)}getLineCount(){return this.root.lineCount()}lineNumberToInfo(t){let n=this.getLineCount();if(t<=n){let{position:i,leaf:s}=this.root.lineNumberToInfo(t,0);return{absolutePosition:i,lineText:s&&s.text}}else return{absolutePosition:this.root.charCount(),lineText:void 0}}load(t){if(t.length>0){let n=[];for(let i=0;i<t.length;i++)n[i]=new GM(t[i]);this.root=e0e.buildTreeFromBottom(n)}else this.root=new KD}walk(t,n,i){this.root.walk(t,n,i)}getText(t,n){let i="";return n>0&&t<this.root.charCount()&&this.walk(t,n,{goSubtree:!0,done:!1,leaf:(s,o,c)=>{i=i.concat(c.text.substring(s,s+o))}}),i}getLength(){return this.root.charCount()}every(t,n,i){i||(i=this.root.charCount());let s={goSubtree:!0,done:!1,leaf(o,c,_){t(_,o,c)||(this.done=!0)}};return this.walk(n,i-n,s),!s.done}edit(t,n,i){if(this.root.charCount()===0)return E.assert(n===0),i!==void 0?(this.load(e0e.linesFromText(i).lines),this):void 0;{let s;if(this.checkEdits){let _=this.getText(0,this.root.charCount());s=_.slice(0,t)+i+_.slice(t+n)}let o=new Lnt,c=!1;if(t>=this.root.charCount()){t=this.root.charCount()-1;let _=this.getText(t,1);i?i=_+i:i=_,n=0,c=!0}else if(n>0){let _=t+n,{zeroBasedColumn:u,lineText:g}=this.positionToColumnAndLineText(_);u===0&&(n+=g.length,i=i?i+g:g)}if(this.root.walk(t,n,o),o.insertLines(i,c),this.checkEdits){let _=o.lineIndex.getText(0,o.lineIndex.getLength());E.assert(s===_,"buffer edit mismatch")}return o.lineIndex}}static buildTreeFromBottom(t){if(t.length<YD)return new KD(t);let n=new Array(Math.ceil(t.length/YD)),i=0;for(let s=0;s<n.length;s++){let o=Math.min(i+YD,t.length);n[s]=new KD(t.slice(i,o)),i=o}return this.buildTreeFromBottom(n)}static linesFromText(t){let n=zx(t);if(n.length===0)return{lines:[],lineMap:n};let i=new Array(n.length),s=n.length-1;for(let c=0;c<s;c++)i[c]=t.substring(n[c],n[c+1]);let o=t.substring(n[s]);return o.length>0?i[s]=o:i.pop(),{lines:i,lineMap:n}}},KD=class t0e{constructor(t=[]){this.children=t,this.totalChars=0,this.totalLines=0,t.length&&this.updateCounts()}isLeaf(){return!1}updateCounts(){this.totalChars=0,this.totalLines=0;for(let t of this.children)this.totalChars+=t.charCount(),this.totalLines+=t.lineCount()}execWalk(t,n,i,s,o){return i.pre&&i.pre(t,n,this.children[s],this,o),i.goSubtree?(this.children[s].walk(t,n,i),i.post&&i.post(t,n,this.children[s],this,o)):i.goSubtree=!0,i.done}skipChild(t,n,i,s,o){s.pre&&!s.done&&(s.pre(t,n,this.children[i],this,o),s.goSubtree=!0)}walk(t,n,i){if(this.children.length===0)return;let s=0,o=this.children[s].charCount(),c=t;for(;c>=o;)this.skipChild(c,n,s,i,0),c-=o,s++,o=this.children[s].charCount();if(c+n<=o){if(this.execWalk(c,n,i,s,2))return}else{if(this.execWalk(c,o-c,i,s,1))return;let _=n-(o-c);for(s++,o=this.children[s].charCount();_>o;){if(this.execWalk(0,o,i,s,3))return;_-=o,s++,o=this.children[s].charCount()}if(_>0&&this.execWalk(0,_,i,s,4))return}if(i.pre){let _=this.children.length;if(s<_-1)for(let u=s+1;u<_;u++)this.skipChild(0,0,u,i,5)}}charOffsetToLineInfo(t,n){if(this.children.length===0)return{oneBasedLine:t,zeroBasedColumn:n,lineText:void 0};for(let o of this.children){if(o.charCount()>n)return o.isLeaf()?{oneBasedLine:t,zeroBasedColumn:n,lineText:o.text}:o.charOffsetToLineInfo(t,n);n-=o.charCount(),t+=o.lineCount()}let i=this.lineCount();if(i===0)return{oneBasedLine:1,zeroBasedColumn:0,lineText:void 0};let s=E.checkDefined(this.lineNumberToInfo(i,0).leaf);return{oneBasedLine:i,zeroBasedColumn:s.charCount(),lineText:void 0}}lineNumberToInfo(t,n){for(let i of this.children){let s=i.lineCount();if(s>=t)return i.isLeaf()?{position:n,leaf:i}:i.lineNumberToInfo(t,n);t-=s,n+=i.charCount()}return{position:n,leaf:void 0}}splitAfter(t){let n,i=this.children.length;t++;let s=t;if(t<i){for(n=new t0e;t<i;)n.add(this.children[t]),t++;n.updateCounts()}return this.children.length=s,n}remove(t){let n=this.findChildIndex(t),i=this.children.length;if(n<i-1)for(let s=n;s<i-1;s++)this.children[s]=this.children[s+1];this.children.pop()}findChildIndex(t){let n=this.children.indexOf(t);return E.assert(n!==-1),n}insertAt(t,n){let i=this.findChildIndex(t),s=this.children.length,o=n.length;if(s<YD&&i===s-1&&o===1)return this.add(n[0]),this.updateCounts(),[];{let c=this.splitAfter(i),_=0;for(i++;i<YD&&_<o;)this.children[i]=n[_],i++,_++;let u=[],g=0;if(_<o){g=Math.ceil((o-_)/YD),u=new Array(g);let d=0;for(let S=0;S<g;S++)u[S]=new t0e;let h=u[0];for(;_<o;)h.add(n[_]),_++,h.children.length===YD&&(d++,h=u[d]);for(let S=u.length-1;S>=0;S--)u[S].children.length===0&&u.pop()}c&&u.push(c),this.updateCounts();for(let d=0;d<g;d++)u[d].updateCounts();return u}}add(t){this.children.push(t),E.assert(this.children.length<=YD)}charCount(){return this.totalChars}lineCount(){return this.totalLines}},GM=class{constructor(e){this.text=e}isLeaf(){return!0}walk(e,t,n){n.leaf(e,t,this)}charCount(){return this.text.length}lineCount(){return 1}},PNe=class w9e{constructor(t,n,i,s,o,c){this.telemetryEnabled=t,this.logger=n,this.host=i,this.globalTypingsCacheLocation=s,this.event=o,this.maxActiveRequestCount=c,this.activeRequestCount=0,this.requestQueue=MA(),this.requestMap=new Map,this.requestedRegistry=!1,this.packageInstallId=0}isKnownTypesPackageName(t){var n;return A1.validatePackageName(t)!==A1.NameValidationResult.Ok?!1:(this.requestedRegistry||(this.requestedRegistry=!0,this.installer.send({kind:"typesRegistry"})),!!((n=this.typesRegistryCache)!=null&&n.has(t)))}installPackage(t){this.packageInstallId++;let n={kind:"installPackage",...t,id:this.packageInstallId},i=new Promise((s,o)=>{(this.packageInstalledPromise??(this.packageInstalledPromise=new Map)).set(this.packageInstallId,{resolve:s,reject:o})});return this.installer.send(n),i}attach(t){this.projectService=t,this.installer=this.createInstallerProcess()}onProjectClosed(t){this.installer.send({projectName:t.getProjectName(),kind:"closeProject"})}enqueueInstallTypingsRequest(t,n,i){let s=Wfe(t,n,i);this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling throttled operation:${Qv(s)}`),this.activeRequestCount<this.maxActiveRequestCount?this.scheduleRequest(s):(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Deferring request for: ${s.projectName}`),this.requestQueue.enqueue(s),this.requestMap.set(s.projectName,s))}handleMessage(t){var n,i;switch(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Received response:${Qv(t)}`),t.kind){case bq:this.typesRegistryCache=new Map(Object.entries(t.typesRegistry));break;case fL:{let s=(n=this.packageInstalledPromise)==null?void 0:n.get(t.id);E.assertIsDefined(s,"Should find the promise for package install"),(i=this.packageInstalledPromise)==null||i.delete(t.id),t.success?s.resolve({successMessage:t.message}):s.reject(t.message),this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case Hae:{let s={message:t.message};this.event(s,"typesInstallerInitializationFailed");break}case Sq:{let s={eventId:t.eventId,packages:t.packagesToInstall};this.event(s,"beginInstallTypes");break}case Tq:{if(this.telemetryEnabled){let c={telemetryEventName:"typingsInstalled",payload:{installedPackages:t.packagesToInstall.join(","),installSuccess:t.installSuccess,typingsInstallerVersion:t.typingsInstallerVersion}};this.event(c,"telemetry")}let s={eventId:t.eventId,packages:t.packagesToInstall,success:t.installSuccess};this.event(s,"endInstallTypes");break}case _L:{this.projectService.updateTypingsForProject(t);break}case uL:{for(this.activeRequestCount>0?this.activeRequestCount--:E.fail("TIAdapter:: Received too many responses");!this.requestQueue.isEmpty();){let s=this.requestQueue.dequeue();if(this.requestMap.get(s.projectName)===s){this.requestMap.delete(s.projectName),this.scheduleRequest(s);break}this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Skipping defunct request for: ${s.projectName}`)}this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case F3:this.projectService.watchTypingLocations(t);break;default:}}scheduleRequest(t){this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling request for: ${t.projectName}`),this.activeRequestCount++,this.host.setTimeout(()=>{this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Sending request:${Qv(t)}`),this.installer.send(t)},w9e.requestDelayMillis,`${t.projectName}::${t.kind}`)}};PNe.requestDelayMillis=100;var ANe=PNe,NNe={};Je(NNe,{ActionInvalidate:()=>_L,ActionPackageInstalled:()=>fL,ActionSet:()=>uL,ActionWatchTypingLocations:()=>F3,Arguments:()=>xq,AutoImportProviderProject:()=>lpe,AuxiliaryProject:()=>ope,CharRangeSection:()=>Lpe,CloseFileWatcherEvent:()=>jH,CommandNames:()=>gNe,ConfigFileDiagEvent:()=>OH,ConfiguredProject:()=>upe,ConfiguredProjectLoadKind:()=>gpe,CreateDirectoryWatcherEvent:()=>RH,CreateFileWatcherEvent:()=>MH,Errors:()=>l0,EventBeginInstallTypes:()=>Sq,EventEndInstallTypes:()=>Tq,EventInitializationFailed:()=>Hae,EventTypesRegistry:()=>bq,ExternalProject:()=>DH,GcTimer:()=>Qfe,InferredProject:()=>ape,LargeFileReferencedEvent:()=>IH,LineIndex:()=>B8,LineLeaf:()=>GM,LineNode:()=>KD,LogLevel:()=>Jfe,Msg:()=>zfe,OpenFileInfoTelemetryEvent:()=>_pe,Project:()=>uC,ProjectInfoTelemetryEvent:()=>LH,ProjectKind:()=>N4,ProjectLanguageServiceStateEvent:()=>FH,ProjectLoadingFinishEvent:()=>NH,ProjectLoadingStartEvent:()=>AH,ProjectService:()=>Cpe,ProjectsUpdatedInBackgroundEvent:()=>VM,ScriptInfo:()=>Zfe,ScriptVersionCache:()=>XH,Session:()=>kNe,TextStorage:()=>Kfe,ThrottledOperations:()=>Hfe,TypingsInstallerAdapter:()=>ANe,allFilesAreJsOrDts:()=>npe,allRootFilesAreJsOrDts:()=>rpe,asNormalizedPath:()=>WAe,convertCompilerOptions:()=>qM,convertFormatOptions:()=>QD,convertScriptKindName:()=>JH,convertTypeAcquisition:()=>ppe,convertUserPreferences:()=>dpe,convertWatchOptions:()=>R8,countEachFileTypes:()=>O8,createInstallTypingsRequest:()=>Wfe,createModuleSpecifierCache:()=>wpe,createNormalizedPathMap:()=>UAe,createPackageJsonCache:()=>Ppe,createSortedArray:()=>Gfe,emptyArray:()=>Ll,findArgument:()=>USe,formatDiagnosticToProtocol:()=>j8,formatMessage:()=>Ape,getBaseConfigFileName:()=>EH,getDetailWatchInfo:()=>VH,getLocationInNewDocument:()=>Fpe,hasArgument:()=>WSe,hasNoTypeScriptSource:()=>ipe,indent:()=>r4,isBackgroundProject:()=>L8,isConfigFile:()=>Epe,isConfiguredProject:()=>oy,isDynamicFileName:()=>A4,isExternalProject:()=>F8,isInferredProject:()=>HD,isInferredProjectName:()=>Ufe,isProjectDeferredClose:()=>M8,makeAutoImportProviderProjectName:()=>qfe,makeAuxiliaryProjectName:()=>$fe,makeInferredProjectName:()=>Vfe,maxFileSize:()=>PH,maxProgramSizeForNonTsFiles:()=>wH,normalizedPathToPath:()=>GD,nowString:()=>VSe,nullCancellationToken:()=>pNe,nullTypingsInstaller:()=>$M,protocol:()=>Xfe,scriptInfoIsContainedByBackgroundProject:()=>epe,scriptInfoIsContainedByDeferredClosedProject:()=>tpe,stringifyIndented:()=>Qv,toEvent:()=>Npe,toNormalizedPath:()=>yo,tryConvertScriptKindName:()=>BH,typingsInstaller:()=>Bfe,updateProjectIfDirty:()=>ud}),typeof console<"u"&&(E.loggingHost={log(e,t){switch(e){case 1:return console.error(t);case 2:return console.warn(t);case 3:return console.log(t);case 4:return console.log(t)}}})})({get exports(){return S9e},set exports(ne){S9e=ne,typeof fY<"u"&&fY.exports&&(fY.exports=ne)}})});var X9e={};Pgt(X9e,{FILE_TYPE_MAPPINGS:()=>V0t,GLOBAL_RISK_RULES:()=>q0t,MODULE_IMPACT_CONFIG:()=>U0t,getRiskLevelString:()=>$0t});var U0t,V0t,q0t,$0t,Y9e=wgt(()=>{"use strict";U0t=[{moduleName:"Authentication",description:"Handles user login, registration, and session management.",pathPatterns:["app/api/auth/**","app/(auth)/**","lib/auth.ts"],riskFactors:{authenticationChanges:100,serviceLayerChanges:80},regressionSuggestions:["User Login (Success/Failure)","User Registration","Password Reset Flow","SSO (GitHub/GitLab) Login","Session Expiry/Renewal","Role-based Access Control"],smokeTestSuggestions:["Login","Basic Navigation"],relatedModules:["User Management","System Configuration"]},{moduleName:"Payments",description:"Manages payment processing, transactions, and integrations.",pathPatterns:["app/api/payments/**","lib/payments.ts","components/payments/**"],riskFactors:{paymentChanges:100,serviceLayerChanges:80,apiIntegrationChanges:80},regressionSuggestions:["Partial Payment","Full Payment","Overpayment Handling","Installment Allocation","Refund Processing","Payment Gateway Integration"],smokeTestSuggestions:["Payment Entry","Basic Transaction View"],relatedModules:["Ledger","Installments","Reports"]},{moduleName:"Database Migrations",description:"Changes to the database schema or seed data.",pathPatterns:["prisma/migrations/**","prisma/schema.prisma","prisma/seed.ts","prisma/seed-rules.ts"],riskFactors:{databaseMigration:100},regressionSuggestions:["Database Schema Integrity Check","Data Migration Verification","Application `functionality` after Migration","Rollback Procedures (if applicable)"],smokeTestSuggestions:["Application Startup","Critical Feature `functionality`"],relatedModules:[]},{moduleName:"Dashboard & Analytics",description:"Provides insights and visual data representations.",pathPatterns:["app/dashboard/**","app/api/dashboard/**","components/dashboard/**"],riskFactors:{uiViewChanges:20,apiIntegrationChanges:50},regressionSuggestions:["Data Accuracy Verification","Chart Rendering & Interactivity","Data Filtering & Sorting","Reporting Generation"],smokeTestSuggestions:["Dashboard Load","Basic Chart Display"],relatedModules:["API Integration","Data Processing"]},{moduleName:"Rule Engine",description:"Manages and applies code analysis rules.",pathPatterns:["lib/rule-engine.ts","app/api/rules/**","prisma/seed-rules.ts"],riskFactors:{serviceLayerChanges:80,apiIntegrationChanges:80},regressionSuggestions:["Rule Creation/Update","Rule Application on Code","Violation Reporting Accuracy","Performance under Load"],smokeTestSuggestions:["Review Guard Execution","Basic Rule Violation Detection"],relatedModules:["AI Analysis","System Configuration"]},{moduleName:"Repository Integration (GitHub/GitLab)",description:"Handles integration with Git providers.",pathPatterns:["lib/github.ts","lib/gitlab.ts","app/api/github/**","app/api/gitlab/**"],riskFactors:{apiIntegrationChanges:80,serviceLayerChanges:80},regressionSuggestions:["Repository Connection (GitHub/GitLab)","Webhook Event Processing","Pull Request Status Updates","User Repository Sync"],smokeTestSuggestions:["Repository Listing","Basic Webhook Event"],relatedModules:["API Integration","Authentication"]},{moduleName:"User Management",description:"Manages user profiles and settings.",pathPatterns:["app/api/user/**"],riskFactors:{serviceLayerChanges:50,apiIntegrationChanges:50},regressionSuggestions:["User Profile Update","User Settings Modification","User Deactivation/Deletion"],smokeTestSuggestions:["User Profile View"],relatedModules:["Authentication","Dashboard"]},{moduleName:"Error Handling & Logging",description:"Centralized error reporting and logging.",pathPatterns:["lib/error-service.ts","lib/logger.ts","app/api/error/**"],riskFactors:{serviceLayerChanges:80},regressionSuggestions:["Error Logging (various types)","Error Reporting to Dashboard","Application Behavior on Error"],smokeTestSuggestions:["Application Stability"],relatedModules:["System Core"]},{moduleName:"AI Analysis",description:"AI-powered code analysis and suggestions.",pathPatterns:["lib/ai-service.ts","app/api/ai/**"],riskFactors:{serviceLayerChanges:80},regressionSuggestions:["AI Suggestion Accuracy","AI Performance","Integration with Review Process"],smokeTestSuggestions:["Review Guard AI Analysis"],relatedModules:["Rule Engine"]},{moduleName:"System Core",description:"Fundamental application logic and utilities.",pathPatterns:["lib/prisma.ts","middleware.ts","next.config.ts","app/layout.tsx","app/page.tsx","types/**","lib/gemini.ts"],riskFactors:{serviceLayerChanges:100},regressionSuggestions:["Application Startup","Basic Navigation","Data Access Layer Integrity","Middleware `functionality`"],smokeTestSuggestions:["Application Load","Core `functionality`"],relatedModules:[]}],V0t=[{pattern:"prisma/migrations/**",type:"Database Migration",riskFactor:100},{pattern:"prisma/schema.prisma",type:"Database Schema",riskFactor:100},{pattern:"app/api/**",type:"API Endpoint",riskFactor:70},{pattern:"lib/**/*.ts",type:"Service/Utility",riskFactor:60},{pattern:"components/**/*.tsx",type:"UI Component",riskFactor:30},{pattern:"app/**/*.tsx",type:"Page/Layout",riskFactor:40},{pattern:"hooks/**/*.ts",type:"React Hook",riskFactor:40},{pattern:"types/**/*.ts",type:"Type Definition",riskFactor:20},{pattern:"middleware.ts",type:"Middleware",riskFactor:80},{pattern:"package.json",type:"Dependency Configuration",riskFactor:50},{pattern:"package-lock.json",type:"Dependency Lock",riskFactor:20},{pattern:"**/*.css",type:"Styling",riskFactor:10},{pattern:"**/*.html",type:"Static Content",riskFactor:5}],q0t=[{name:"Critical Configuration Change",pattern:/^(next\.config\.ts|tsconfig\.json|postcss\.config\.mjs|tailwind\.config\.ts|eslint\.config\.mjs)$/i,severity:90,message:"Changes to critical configuration files can have widespread impact."},{name:"Hardcoded Secrets in Diff",pattern:/(api[_-]?key|secret|token|password)\s*[:=]\s*['"`].+['"`]/gi,severity:100,message:"Hardcoded secret detected in staged changes. This is a critical security vulnerability."}],$0t=ne=>ne>=90?"CRITICAL":ne>=70?"HIGH":ne>=40?"MEDIUM":ne>=10?"LOW":"NONE"});var Mj=require("child_process");var khe=(ne,q,se)=>{let ge=ne instanceof RegExp?xFe(ne,se):ne,Ee=q instanceof RegExp?xFe(q,se):q,Je=ge!==null&&Ee!=null&&Ngt(ge,Ee,se);return Je&&{start:Je[0],end:Je[1],pre:se.slice(0,Je[0]),body:se.slice(Je[0]+ge.length,Je[1]),post:se.slice(Je[1]+Ee.length)}},xFe=(ne,q)=>{let se=q.match(ne);return se?se[0]:null},Ngt=(ne,q,se)=>{let ge,Ee,Je,Pt,cr,rr=se.indexOf(ne),Hr=se.indexOf(q,rr+1),Tr=rr;if(rr>=0&&Hr>0){if(ne===q)return[rr,Hr];for(ge=[],Je=se.length;Tr>=0&&!cr;){if(Tr===rr)ge.push(Tr),rr=se.indexOf(ne,Tr+1);else if(ge.length===1){let hn=ge.pop();hn!==void 0&&(cr=[hn,Hr])}else Ee=ge.pop(),Ee!==void 0&&Ee<Je&&(Je=Ee,Pt=Hr),Hr=se.indexOf(q,Tr+1);Tr=rr<Hr&&rr>=0?rr:Hr}ge.length&&Pt!==void 0&&(cr=[Je,Pt])}return cr};var kFe="\0SLASH"+Math.random()+"\0",CFe="\0OPEN"+Math.random()+"\0",Ehe="\0CLOSE"+Math.random()+"\0",EFe="\0COMMA"+Math.random()+"\0",DFe="\0PERIOD"+Math.random()+"\0",Igt=new RegExp(kFe,"g"),Ogt=new RegExp(CFe,"g"),Fgt=new RegExp(Ehe,"g"),Lgt=new RegExp(EFe,"g"),Mgt=new RegExp(DFe,"g"),Rgt=/\\\\/g,jgt=/\\{/g,Bgt=/\\}/g,Jgt=/\\,/g,zgt=/\\\./g,Wgt=1e5;function Che(ne){return isNaN(ne)?ne.charCodeAt(0):parseInt(ne,10)}function Ugt(ne){return ne.replace(Rgt,kFe).replace(jgt,CFe).replace(Bgt,Ehe).replace(Jgt,EFe).replace(zgt,DFe)}function Vgt(ne){return ne.replace(Igt,"\\").replace(Ogt,"{").replace(Fgt,"}").replace(Lgt,",").replace(Mgt,".")}function wFe(ne){if(!ne)return[""];let q=[],se=khe("{","}",ne);if(!se)return ne.split(",");let{pre:ge,body:Ee,post:Je}=se,Pt=ge.split(",");Pt[Pt.length-1]+="{"+Ee+"}";let cr=wFe(Je);return Je.length&&(Pt[Pt.length-1]+=cr.shift(),Pt.push.apply(Pt,cr)),q.push.apply(q,Pt),q}function PFe(ne,q={}){if(!ne)return[];let{max:se=Wgt}=q;return ne.slice(0,2)==="{}"&&(ne="\\{\\}"+ne.slice(2)),kj(Ugt(ne),se,!0).map(Vgt)}function qgt(ne){return"{"+ne+"}"}function $gt(ne){return/^-?0\d/.test(ne)}function Ggt(ne,q){return ne<=q}function Hgt(ne,q){return ne>=q}function kj(ne,q,se){let ge=[];for(;;){let Ee=khe("{","}",ne);if(!Ee)return[ne];let Je=Ee.pre;if(/\$$/.test(Ee.pre)){let Yn=Ee.post.length?kj(Ee.post,q,!1):[""];for(let Ut=0;Ut<Yn.length&&Ut<q;Ut++){let bt=Je+"{"+Ee.body+"}"+Yn[Ut];ge.push(bt)}return ge}let Pt=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(Ee.body),cr=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(Ee.body),rr=Pt||cr,Hr=Ee.body.indexOf(",")>=0;if(!rr&&!Hr){if(Ee.post.match(/,(?!,).*\}/)){ne=Ee.pre+"{"+Ee.body+Ehe+Ee.post,se=!0;continue}return[ne]}let Tr=Ee.post.length?kj(Ee.post,q,!1):[""],hn;if(rr)hn=Ee.body.split(/\.\./);else if(hn=wFe(Ee.body),hn.length===1&&hn[0]!==void 0&&(hn=kj(hn[0],q,!1).map(qgt),hn.length===1))return Tr.map(Yn=>Ee.pre+hn[0]+Yn);let De;if(rr&&hn[0]!==void 0&&hn[1]!==void 0){let Yn=Che(hn[0]),Ut=Che(hn[1]),bt=Math.max(hn[0].length,hn[1].length),Ao=hn.length===3&&hn[2]!==void 0?Math.max(Math.abs(Che(hn[2])),1):1,bs=Ggt;Ut<Yn&&(Ao*=-1,bs=Hgt);let Vl=hn.some($gt);De=[];for(let pu=Yn;bs(pu,Ut)&&De.length<q;pu+=Ao){let cg;if(cr)cg=String.fromCharCode(pu),cg==="\\"&&(cg="");else if(cg=String(pu),Vl){let Fi=bt-cg.length;if(Fi>0){let Cn=new Array(Fi+1).join("0");pu<0?cg="-"+Cn+cg.slice(1):cg=Cn+cg}}De.push(cg)}}else{De=[];for(let Yn=0;Yn<hn.length;Yn++)De.push.apply(De,kj(hn[Yn],q,!1))}for(let Yn=0;Yn<De.length;Yn++)for(let Ut=0;Ut<Tr.length&&ge.length<q;Ut++){let bt=Je+De[Yn]+Tr[Ut];(!se||rr||bt)&&ge.push(bt)}return ge}}var Cj=ne=>{if(typeof ne!="string")throw new TypeError("invalid pattern");if(ne.length>65536)throw new TypeError("pattern is too long")};var Qgt={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Ej=ne=>ne.replace(/[[\]\\-]/g,"\\$&"),Xgt=ne=>ne.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),AFe=ne=>ne.join(""),NFe=(ne,q)=>{let se=q;if(ne.charAt(se)!=="[")throw new Error("not in a brace expression");let ge=[],Ee=[],Je=se+1,Pt=!1,cr=!1,rr=!1,Hr=!1,Tr=se,hn="";e:for(;Je<ne.length;){let bt=ne.charAt(Je);if((bt==="!"||bt==="^")&&Je===se+1){Hr=!0,Je++;continue}if(bt==="]"&&Pt&&!rr){Tr=Je+1;break}if(Pt=!0,bt==="\\"&&!rr){rr=!0,Je++;continue}if(bt==="["&&!rr){for(let[Ao,[bs,mo,Vl]]of Object.entries(Qgt))if(ne.startsWith(Ao,Je)){if(hn)return["$.",!1,ne.length-se,!0];Je+=Ao.length,Vl?Ee.push(bs):ge.push(bs),cr=cr||mo;continue e}}if(rr=!1,hn){bt>hn?ge.push(Ej(hn)+"-"+Ej(bt)):bt===hn&&ge.push(Ej(bt)),hn="",Je++;continue}if(ne.startsWith("-]",Je+1)){ge.push(Ej(bt+"-")),Je+=2;continue}if(ne.startsWith("-",Je+1)){hn=bt,Je+=2;continue}ge.push(Ej(bt)),Je++}if(Tr<Je)return["",!1,0,!1];if(!ge.length&&!Ee.length)return["$.",!1,ne.length-se,!0];if(Ee.length===0&&ge.length===1&&/^\\?.$/.test(ge[0])&&!Hr){let bt=ge[0].length===2?ge[0].slice(-1):ge[0];return[Xgt(bt),!1,Tr-se,!1]}let De="["+(Hr?"^":"")+AFe(ge)+"]",Yn="["+(Hr?"":"^")+AFe(Ee)+"]";return[ge.length&&Ee.length?"("+De+"|"+Yn+")":ge.length?De:Yn,cr,Tr-se,!0]};var M6=(ne,{windowsPathsNoEscape:q=!1,magicalBraces:se=!0}={})=>se?q?ne.replace(/\[([^/\\])\]/g,"$1"):ne.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):q?ne.replace(/\[([^/\\{}])\]/g,"$1"):ne.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var Ry,Ygt=new Set(["!","?","+","*","@"]),Dhe=ne=>Ygt.has(ne),IFe=ne=>Dhe(ne.type),Kgt=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),Zgt=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),eht=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),OFe=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),tht="(?!(?:^|/)\\.\\.?(?:$|/))",iY="(?!\\.)",rht=new Set(["[","."]),nht=new Set(["..","."]),iht=new Set("().*{}+?[]^$\\!"),sht=ne=>ne.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),whe="[^/]",FFe=whe+"*?",LFe=whe+"+?",aht=0,CA=class{type;#r;#n;#i=!1;#e=[];#t;#o;#l;#c=!1;#s;#a;#u=!1;id=++aht;get depth(){return(this.#t?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#r.id,parent:this.#t?.id,depth:this.depth,partsLength:this.#e.length,parts:this.#e}}constructor(q,se,ge={}){this.type=q,q&&(this.#n=!0),this.#t=se,this.#r=this.#t?this.#t.#r:this,this.#s=this.#r===this?ge:this.#r.#s,this.#l=this.#r===this?[]:this.#r.#l,q==="!"&&!this.#r.#c&&this.#l.push(this),this.#o=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#n!==void 0)return this.#n;for(let q of this.#e)if(typeof q!="string"&&(q.type||q.hasMagic))return this.#n=!0;return this.#n}toString(){return this.#a!==void 0?this.#a:this.type?this.#a=this.type+"("+this.#e.map(q=>String(q)).join("|")+")":this.#a=this.#e.map(q=>String(q)).join("")}#h(){if(this!==this.#r)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let q;for(;q=this.#l.pop();){if(q.type!=="!")continue;let se=q,ge=se.#t;for(;ge;){for(let Ee=se.#o+1;!ge.type&&Ee<ge.#e.length;Ee++)for(let Je of q.#e){if(typeof Je=="string")throw new Error("string part in extglob AST??");Je.copyIn(ge.#e[Ee])}se=ge,ge=se.#t}}return this}push(...q){for(let se of q)if(se!==""){if(typeof se!="string"&&!(se instanceof Ry&&se.#t===this))throw new Error("invalid part: "+se);this.#e.push(se)}}toJSON(){let q=this.type===null?this.#e.slice().map(se=>typeof se=="string"?se:se.toJSON()):[this.type,...this.#e.map(se=>se.toJSON())];return this.isStart()&&!this.type&&q.unshift([]),this.isEnd()&&(this===this.#r||this.#r.#c&&this.#t?.type==="!")&&q.push({}),q}isStart(){if(this.#r===this)return!0;if(!this.#t?.isStart())return!1;if(this.#o===0)return!0;let q=this.#t;for(let se=0;se<this.#o;se++){let ge=q.#e[se];if(!(ge instanceof Ry&&ge.type==="!"))return!1}return!0}isEnd(){if(this.#r===this||this.#t?.type==="!")return!0;if(!this.#t?.isEnd())return!1;if(!this.type)return this.#t?.isEnd();let q=this.#t?this.#t.#e.length:0;return this.#o===q-1}copyIn(q){typeof q=="string"?this.push(q):this.push(q.clone(this))}clone(q){let se=new Ry(this.type,q);for(let ge of this.#e)se.copyIn(ge);return se}static#_(q,se,ge,Ee,Je){let Pt=Ee.maxExtglobRecursion??2,cr=!1,rr=!1,Hr=-1,Tr=!1;if(se.type===null){let bt=ge,Ao="";for(;bt<q.length;){let bs=q.charAt(bt++);if(cr||bs==="\\"){cr=!cr,Ao+=bs;continue}if(rr){bt===Hr+1?(bs==="^"||bs==="!")&&(Tr=!0):bs==="]"&&!(bt===Hr+2&&Tr)&&(rr=!1),Ao+=bs;continue}else if(bs==="["){rr=!0,Hr=bt,Tr=!1,Ao+=bs;continue}if(!Ee.noext&&Dhe(bs)&&q.charAt(bt)==="("&&Je<=Pt){se.push(Ao),Ao="";let Vl=new Ry(bs,se);bt=Ry.#_(q,Vl,bt,Ee,Je+1),se.push(Vl);continue}Ao+=bs}return se.push(Ao),bt}let hn=ge+1,De=new Ry(null,se),Yn=[],Ut="";for(;hn<q.length;){let bt=q.charAt(hn++);if(cr||bt==="\\"){cr=!cr,Ut+=bt;continue}if(rr){hn===Hr+1?(bt==="^"||bt==="!")&&(Tr=!0):bt==="]"&&!(hn===Hr+2&&Tr)&&(rr=!1),Ut+=bt;continue}else if(bt==="["){rr=!0,Hr=hn,Tr=!1,Ut+=bt;continue}if(!Ee.noext&&Dhe(bt)&&q.charAt(hn)==="("&&(Je<=Pt||se&&se.#f(bt))){let bs=se&&se.#f(bt)?0:1;De.push(Ut),Ut="";let mo=new Ry(bt,De);De.push(mo),hn=Ry.#_(q,mo,hn,Ee,Je+bs);continue}if(bt==="|"){De.push(Ut),Ut="",Yn.push(De),De=new Ry(null,se);continue}if(bt===")")return Ut===""&&se.#e.length===0&&(se.#u=!0),De.push(Ut),Ut="",se.push(...Yn,De),hn;Ut+=bt}return se.type=null,se.#n=void 0,se.#e=[q.substring(ge-1)],hn}#y(q){return this.#d(q,Zgt)}#d(q,se=Kgt){if(!q||typeof q!="object"||q.type!==null||q.#e.length!==1||this.type===null)return!1;let ge=q.#e[0];return!ge||typeof ge!="object"||ge.type===null?!1:this.#f(ge.type,se)}#f(q,se=eht){return!!se.get(this.type)?.includes(q)}#v(q,se){let ge=q.#e[0],Ee=new Ry(null,ge,this.options);Ee.#e.push(""),ge.push(Ee),this.#m(q,se)}#m(q,se){let ge=q.#e[0];this.#e.splice(se,1,...ge.#e);for(let Ee of ge.#e)typeof Ee=="object"&&(Ee.#t=this);this.#a=void 0}#b(q){return!!OFe.get(this.type)?.has(q)}#S(q){if(!q||typeof q!="object"||q.type!==null||q.#e.length!==1||this.type===null||this.#e.length!==1)return!1;let se=q.#e[0];return!se||typeof se!="object"||se.type===null?!1:this.#b(se.type)}#T(q){let se=OFe.get(this.type),ge=q.#e[0],Ee=se?.get(ge.type);if(!Ee)return!1;this.#e=ge.#e;for(let Je of this.#e)typeof Je=="object"&&(Je.#t=this);this.type=Ee,this.#a=void 0,this.#u=!1}static fromGlob(q,se={}){let ge=new Ry(null,void 0,se);return Ry.#_(q,ge,0,se,0),ge}toMMPattern(){if(this!==this.#r)return this.#r.toMMPattern();let q=this.toString(),[se,ge,Ee,Je]=this.toRegExpSource();if(!(Ee||this.#n||this.#s.nocase&&!this.#s.nocaseMagicOnly&&q.toUpperCase()!==q.toLowerCase()))return ge;let cr=(this.#s.nocase?"i":"")+(Je?"u":"");return Object.assign(new RegExp(`^${se}$`,cr),{_src:se,_glob:q})}get options(){return this.#s}toRegExpSource(q){let se=q??!!this.#s.dot;if(this.#r===this&&(this.#p(),this.#h()),!IFe(this)){let rr=this.isStart()&&this.isEnd()&&!this.#e.some(Yn=>typeof Yn!="string"),Hr=this.#e.map(Yn=>{let[Ut,bt,Ao,bs]=typeof Yn=="string"?Ry.#x(Yn,this.#n,rr):Yn.toRegExpSource(q);return this.#n=this.#n||Ao,this.#i=this.#i||bs,Ut}).join(""),Tr="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&nht.has(this.#e[0]))){let Ut=rht,bt=se&&Ut.has(Hr.charAt(0))||Hr.startsWith("\\.")&&Ut.has(Hr.charAt(2))||Hr.startsWith("\\.\\.")&&Ut.has(Hr.charAt(4)),Ao=!se&&!q&&Ut.has(Hr.charAt(0));Tr=bt?tht:Ao?iY:""}let hn="";return this.isEnd()&&this.#r.#c&&this.#t?.type==="!"&&(hn="(?:$|\\/)"),[Tr+Hr+hn,M6(Hr),this.#n=!!this.#n,this.#i]}let ge=this.type==="*"||this.type==="+",Ee=this.type==="!"?"(?:(?!(?:":"(?:",Je=this.#g(se);if(this.isStart()&&this.isEnd()&&!Je&&this.type!=="!"){let rr=this.toString(),Hr=this;return Hr.#e=[rr],Hr.type=null,Hr.#n=void 0,[rr,M6(this.toString()),!1,!1]}let Pt=!ge||q||se||!iY?"":this.#g(!0);Pt===Je&&(Pt=""),Pt&&(Je=`(?:${Je})(?:${Pt})*?`);let cr="";if(this.type==="!"&&this.#u)cr=(this.isStart()&&!se?iY:"")+LFe;else{let rr=this.type==="!"?"))"+(this.isStart()&&!se&&!q?iY:"")+FFe+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Pt?")":this.type==="*"&&Pt?")?":`)${this.type}`;cr=Ee+Je+rr}return[cr,M6(Je),this.#n=!!this.#n,this.#i]}#p(){if(IFe(this)){let q=0,se=!1;do{se=!0;for(let ge=0;ge<this.#e.length;ge++){let Ee=this.#e[ge];typeof Ee=="object"&&(Ee.#p(),this.#d(Ee)?(se=!1,this.#m(Ee,ge)):this.#y(Ee)?(se=!1,this.#v(Ee,ge)):this.#S(Ee)&&(se=!1,this.#T(Ee)))}}while(!se&&++q<10)}else for(let q of this.#e)typeof q=="object"&&q.#p();this.#a=void 0}#g(q){return this.#e.map(se=>{if(typeof se=="string")throw new Error("string type in extglob ast??");let[ge,Ee,Je,Pt]=se.toRegExpSource(q);return this.#i=this.#i||Pt,ge}).filter(se=>!(this.isStart()&&this.isEnd())||!!se).join("|")}static#x(q,se,ge=!1){let Ee=!1,Je="",Pt=!1,cr=!1;for(let rr=0;rr<q.length;rr++){let Hr=q.charAt(rr);if(Ee){Ee=!1,Je+=(iht.has(Hr)?"\\":"")+Hr;continue}if(Hr==="*"){if(cr)continue;cr=!0,Je+=ge&&/^[*]+$/.test(q)?LFe:FFe,se=!0;continue}else cr=!1;if(Hr==="\\"){rr===q.length-1?Je+="\\\\":Ee=!0;continue}if(Hr==="["){let[Tr,hn,De,Yn]=NFe(q,rr);if(De){Je+=Tr,Pt=Pt||hn,rr+=De-1,se=se||Yn;continue}}if(Hr==="?"){Je+=whe,se=!0;continue}Je+=sht(Hr)}return[Je,M6(q),!!se,Pt]}};Ry=CA;var Phe=(ne,{windowsPathsNoEscape:q=!1,magicalBraces:se=!1}={})=>se?q?ne.replace(/[?*()[\]{}]/g,"[$&]"):ne.replace(/[?*()[\]\\{}]/g,"\\$&"):q?ne.replace(/[?*()[\]]/g,"[$&]"):ne.replace(/[?*()[\]\\]/g,"\\$&");var bm=(ne,q,se={})=>(Cj(q),!se.nocomment&&q.charAt(0)==="#"?!1:new U7(q,se).match(ne)),oht=/^\*+([^+@!?*[(]*)$/,cht=ne=>q=>!q.startsWith(".")&&q.endsWith(ne),lht=ne=>q=>q.endsWith(ne),uht=ne=>(ne=ne.toLowerCase(),q=>!q.startsWith(".")&&q.toLowerCase().endsWith(ne)),_ht=ne=>(ne=ne.toLowerCase(),q=>q.toLowerCase().endsWith(ne)),fht=/^\*+\.\*+$/,pht=ne=>!ne.startsWith(".")&&ne.includes("."),dht=ne=>ne!=="."&&ne!==".."&&ne.includes("."),mht=/^\.\*+$/,ght=ne=>ne!=="."&&ne!==".."&&ne.startsWith("."),hht=/^\*+$/,yht=ne=>ne.length!==0&&!ne.startsWith("."),vht=ne=>ne.length!==0&&ne!=="."&&ne!=="..",bht=/^\?+([^+@!?*[(]*)?$/,Sht=([ne,q=""])=>{let se=jFe([ne]);return q?(q=q.toLowerCase(),ge=>se(ge)&&ge.toLowerCase().endsWith(q)):se},Tht=([ne,q=""])=>{let se=BFe([ne]);return q?(q=q.toLowerCase(),ge=>se(ge)&&ge.toLowerCase().endsWith(q)):se},xht=([ne,q=""])=>{let se=BFe([ne]);return q?ge=>se(ge)&&ge.endsWith(q):se},kht=([ne,q=""])=>{let se=jFe([ne]);return q?ge=>se(ge)&&ge.endsWith(q):se},jFe=([ne])=>{let q=ne.length;return se=>se.length===q&&!se.startsWith(".")},BFe=([ne])=>{let q=ne.length;return se=>se.length===q&&se!=="."&&se!==".."},JFe=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",MFe={win32:{sep:"\\"},posix:{sep:"/"}},Cht=JFe==="win32"?MFe.win32.sep:MFe.posix.sep;bm.sep=Cht;var Lh=Symbol("globstar **");bm.GLOBSTAR=Lh;var Eht="[^/]",Dht=Eht+"*?",wht="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Pht="(?:(?!(?:\\/|^)\\.).)*?",Aht=(ne,q={})=>se=>bm(se,ne,q);bm.filter=Aht;var qb=(ne,q={})=>Object.assign({},ne,q),Nht=ne=>{if(!ne||typeof ne!="object"||!Object.keys(ne).length)return bm;let q=bm;return Object.assign((ge,Ee,Je={})=>q(ge,Ee,qb(ne,Je)),{Minimatch:class extends q.Minimatch{constructor(Ee,Je={}){super(Ee,qb(ne,Je))}static defaults(Ee){return q.defaults(qb(ne,Ee)).Minimatch}},AST:class extends q.AST{constructor(Ee,Je,Pt={}){super(Ee,Je,qb(ne,Pt))}static fromGlob(Ee,Je={}){return q.AST.fromGlob(Ee,qb(ne,Je))}},unescape:(ge,Ee={})=>q.unescape(ge,qb(ne,Ee)),escape:(ge,Ee={})=>q.escape(ge,qb(ne,Ee)),filter:(ge,Ee={})=>q.filter(ge,qb(ne,Ee)),defaults:ge=>q.defaults(qb(ne,ge)),makeRe:(ge,Ee={})=>q.makeRe(ge,qb(ne,Ee)),braceExpand:(ge,Ee={})=>q.braceExpand(ge,qb(ne,Ee)),match:(ge,Ee,Je={})=>q.match(ge,Ee,qb(ne,Je)),sep:q.sep,GLOBSTAR:Lh})};bm.defaults=Nht;var zFe=(ne,q={})=>(Cj(ne),q.nobrace||!/\{(?:(?!\{).)*\}/.test(ne)?[ne]:PFe(ne,{max:q.braceExpandMax}));bm.braceExpand=zFe;var Iht=(ne,q={})=>new U7(ne,q).makeRe();bm.makeRe=Iht;var Oht=(ne,q,se={})=>{let ge=new U7(q,se);return ne=ne.filter(Ee=>ge.match(Ee)),ge.options.nonull&&!ne.length&&ne.push(q),ne};bm.match=Oht;var RFe=/[?*]|[+@!]\(.*?\)|\[|\]/,Fht=ne=>ne.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),U7=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(q,se={}){Cj(q),se=se||{},this.options=se,this.maxGlobstarRecursion=se.maxGlobstarRecursion??200,this.pattern=q,this.platform=se.platform||JFe,this.isWindows=this.platform==="win32";let ge="allowWindowsEscape";this.windowsPathsNoEscape=!!se.windowsPathsNoEscape||se[ge]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!se.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!se.nonegate,this.comment=!1,this.empty=!1,this.partial=!!se.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=se.windowsNoMagicRoot!==void 0?se.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let q of this.set)for(let se of q)if(typeof se!="string")return!0;return!1}debug(...q){}make(){let q=this.pattern,se=this.options;if(!se.nocomment&&q.charAt(0)==="#"){this.comment=!0;return}if(!q){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],se.debug&&(this.debug=(...Je)=>console.error(...Je)),this.debug(this.pattern,this.globSet);let ge=this.globSet.map(Je=>this.slashSplit(Je));this.globParts=this.preprocess(ge),this.debug(this.pattern,this.globParts);let Ee=this.globParts.map((Je,Pt,cr)=>{if(this.isWindows&&this.windowsNoMagicRoot){let rr=Je[0]===""&&Je[1]===""&&(Je[2]==="?"||!RFe.test(Je[2]))&&!RFe.test(Je[3]),Hr=/^[a-z]:/i.test(Je[0]);if(rr)return[...Je.slice(0,4),...Je.slice(4).map(Tr=>this.parse(Tr))];if(Hr)return[Je[0],...Je.slice(1).map(Tr=>this.parse(Tr))]}return Je.map(rr=>this.parse(rr))});if(this.debug(this.pattern,Ee),this.set=Ee.filter(Je=>Je.indexOf(!1)===-1),this.isWindows)for(let Je=0;Je<this.set.length;Je++){let Pt=this.set[Je];Pt[0]===""&&Pt[1]===""&&this.globParts[Je][2]==="?"&&typeof Pt[3]=="string"&&/^[a-z]:$/i.test(Pt[3])&&(Pt[2]="?")}this.debug(this.pattern,this.set)}preprocess(q){if(this.options.noglobstar)for(let ge of q)for(let Ee=0;Ee<ge.length;Ee++)ge[Ee]==="**"&&(ge[Ee]="*");let{optimizationLevel:se=1}=this.options;return se>=2?(q=this.firstPhasePreProcess(q),q=this.secondPhasePreProcess(q)):se>=1?q=this.levelOneOptimize(q):q=this.adjascentGlobstarOptimize(q),q}adjascentGlobstarOptimize(q){return q.map(se=>{let ge=-1;for(;(ge=se.indexOf("**",ge+1))!==-1;){let Ee=ge;for(;se[Ee+1]==="**";)Ee++;Ee!==ge&&se.splice(ge,Ee-ge)}return se})}levelOneOptimize(q){return q.map(se=>(se=se.reduce((ge,Ee)=>{let Je=ge[ge.length-1];return Ee==="**"&&Je==="**"?ge:Ee===".."&&Je&&Je!==".."&&Je!=="."&&Je!=="**"?(ge.pop(),ge):(ge.push(Ee),ge)},[]),se.length===0?[""]:se))}levelTwoFileOptimize(q){Array.isArray(q)||(q=this.slashSplit(q));let se=!1;do{if(se=!1,!this.preserveMultipleSlashes){for(let Ee=1;Ee<q.length-1;Ee++){let Je=q[Ee];Ee===1&&Je===""&&q[0]===""||(Je==="."||Je==="")&&(se=!0,q.splice(Ee,1),Ee--)}q[0]==="."&&q.length===2&&(q[1]==="."||q[1]==="")&&(se=!0,q.pop())}let ge=0;for(;(ge=q.indexOf("..",ge+1))!==-1;){let Ee=q[ge-1];Ee&&Ee!=="."&&Ee!==".."&&Ee!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(Ee))&&(se=!0,q.splice(ge-1,2),ge-=2)}}while(se);return q.length===0?[""]:q}firstPhasePreProcess(q){let se=!1;do{se=!1;for(let ge of q){let Ee=-1;for(;(Ee=ge.indexOf("**",Ee+1))!==-1;){let Pt=Ee;for(;ge[Pt+1]==="**";)Pt++;Pt>Ee&&ge.splice(Ee+1,Pt-Ee);let cr=ge[Ee+1],rr=ge[Ee+2],Hr=ge[Ee+3];if(cr!==".."||!rr||rr==="."||rr===".."||!Hr||Hr==="."||Hr==="..")continue;se=!0,ge.splice(Ee,1);let Tr=ge.slice(0);Tr[Ee]="**",q.push(Tr),Ee--}if(!this.preserveMultipleSlashes){for(let Pt=1;Pt<ge.length-1;Pt++){let cr=ge[Pt];Pt===1&&cr===""&&ge[0]===""||(cr==="."||cr==="")&&(se=!0,ge.splice(Pt,1),Pt--)}ge[0]==="."&&ge.length===2&&(ge[1]==="."||ge[1]==="")&&(se=!0,ge.pop())}let Je=0;for(;(Je=ge.indexOf("..",Je+1))!==-1;){let Pt=ge[Je-1];if(Pt&&Pt!=="."&&Pt!==".."&&Pt!=="**"){se=!0;let rr=Je===1&&ge[Je+1]==="**"?["."]:[];ge.splice(Je-1,2,...rr),ge.length===0&&ge.push(""),Je-=2}}}}while(se);return q}secondPhasePreProcess(q){for(let se=0;se<q.length-1;se++)for(let ge=se+1;ge<q.length;ge++){let Ee=this.partsMatch(q[se],q[ge],!this.preserveMultipleSlashes);if(Ee){q[se]=[],q[ge]=Ee;break}}return q.filter(se=>se.length)}partsMatch(q,se,ge=!1){let Ee=0,Je=0,Pt=[],cr="";for(;Ee<q.length&&Je<se.length;)if(q[Ee]===se[Je])Pt.push(cr==="b"?se[Je]:q[Ee]),Ee++,Je++;else if(ge&&q[Ee]==="**"&&se[Je]===q[Ee+1])Pt.push(q[Ee]),Ee++;else if(ge&&se[Je]==="**"&&q[Ee]===se[Je+1])Pt.push(se[Je]),Je++;else if(q[Ee]==="*"&&se[Je]&&(this.options.dot||!se[Je].startsWith("."))&&se[Je]!=="**"){if(cr==="b")return!1;cr="a",Pt.push(q[Ee]),Ee++,Je++}else if(se[Je]==="*"&&q[Ee]&&(this.options.dot||!q[Ee].startsWith("."))&&q[Ee]!=="**"){if(cr==="a")return!1;cr="b",Pt.push(se[Je]),Ee++,Je++}else return!1;return q.length===se.length&&Pt}parseNegate(){if(this.nonegate)return;let q=this.pattern,se=!1,ge=0;for(let Ee=0;Ee<q.length&&q.charAt(Ee)==="!";Ee++)se=!se,ge++;ge&&(this.pattern=q.slice(ge)),this.negate=se}matchOne(q,se,ge=!1){let Ee=0,Je=0;if(this.isWindows){let cr=typeof q[0]=="string"&&/^[a-z]:$/i.test(q[0]),rr=!cr&&q[0]===""&&q[1]===""&&q[2]==="?"&&/^[a-z]:$/i.test(q[3]),Hr=typeof se[0]=="string"&&/^[a-z]:$/i.test(se[0]),Tr=!Hr&&se[0]===""&&se[1]===""&&se[2]==="?"&&typeof se[3]=="string"&&/^[a-z]:$/i.test(se[3]),hn=rr?3:cr?0:void 0,De=Tr?3:Hr?0:void 0;if(typeof hn=="number"&&typeof De=="number"){let[Yn,Ut]=[q[hn],se[De]];Yn.toLowerCase()===Ut.toLowerCase()&&(se[De]=Yn,Je=De,Ee=hn)}}let{optimizationLevel:Pt=1}=this.options;return Pt>=2&&(q=this.levelTwoFileOptimize(q)),se.includes(Lh)?this.#r(q,se,ge,Ee,Je):this.#i(q,se,ge,Ee,Je)}#r(q,se,ge,Ee,Je){let Pt=se.indexOf(Lh,Je),cr=se.lastIndexOf(Lh),[rr,Hr,Tr]=ge?[se.slice(Je,Pt),se.slice(Pt+1),[]]:[se.slice(Je,Pt),se.slice(Pt+1,cr),se.slice(cr+1)];if(rr.length){let mo=q.slice(Ee,Ee+rr.length);if(!this.#i(mo,rr,ge,0,0))return!1;Ee+=rr.length,Je+=rr.length}let hn=0;if(Tr.length){if(Tr.length+Ee>q.length)return!1;let mo=q.length-Tr.length;if(this.#i(q,Tr,ge,mo,0))hn=Tr.length;else{if(q[q.length-1]!==""||Ee+Tr.length===q.length||(mo--,!this.#i(q,Tr,ge,mo,0)))return!1;hn=Tr.length+1}}if(!Hr.length){let mo=!!hn;for(let Vl=Ee;Vl<q.length-hn;Vl++){let pu=String(q[Vl]);if(mo=!0,pu==="."||pu===".."||!this.options.dot&&pu.startsWith("."))return!1}return ge||mo}let De=[[[],0]],Yn=De[0],Ut=0,bt=[0];for(let mo of Hr)mo===Lh?(bt.push(Ut),Yn=[[],0],De.push(Yn)):(Yn[0].push(mo),Ut++);let Ao=De.length-1,bs=q.length-hn;for(let mo of De)mo[1]=bs-(bt[Ao--]+mo[0].length);return!!this.#n(q,De,Ee,0,ge,0,!!hn)}#n(q,se,ge,Ee,Je,Pt,cr){let rr=se[Ee];if(!rr){for(let hn=ge;hn<q.length;hn++){cr=!0;let De=q[hn];if(De==="."||De===".."||!this.options.dot&&De.startsWith("."))return!1}return cr}let[Hr,Tr]=rr;for(;ge<=Tr;){if(this.#i(q.slice(0,ge+Hr.length),Hr,Je,ge,0)&&Pt<this.maxGlobstarRecursion){let Yn=this.#n(q,se,ge+Hr.length,Ee+1,Je,Pt+1,cr);if(Yn!==!1)return Yn}let De=q[ge];if(De==="."||De===".."||!this.options.dot&&De.startsWith("."))return!1;ge++}return Je||null}#i(q,se,ge,Ee,Je){let Pt,cr,rr,Hr;for(Pt=Ee,cr=Je,Hr=q.length,rr=se.length;Pt<Hr&&cr<rr;Pt++,cr++){this.debug("matchOne loop");let Tr=se[cr],hn=q[Pt];if(this.debug(se,Tr,hn),Tr===!1||Tr===Lh)return!1;let De;if(typeof Tr=="string"?(De=hn===Tr,this.debug("string match",Tr,hn,De)):(De=Tr.test(hn),this.debug("pattern match",Tr,hn,De)),!De)return!1}if(Pt===Hr&&cr===rr)return!0;if(Pt===Hr)return ge;if(cr===rr)return Pt===Hr-1&&q[Pt]==="";throw new Error("wtf?")}braceExpand(){return zFe(this.pattern,this.options)}parse(q){Cj(q);let se=this.options;if(q==="**")return Lh;if(q==="")return"";let ge,Ee=null;(ge=q.match(hht))?Ee=se.dot?vht:yht:(ge=q.match(oht))?Ee=(se.nocase?se.dot?_ht:uht:se.dot?lht:cht)(ge[1]):(ge=q.match(bht))?Ee=(se.nocase?se.dot?Tht:Sht:se.dot?xht:kht)(ge):(ge=q.match(fht))?Ee=se.dot?dht:pht:(ge=q.match(mht))&&(Ee=ght);let Je=CA.fromGlob(q,this.options).toMMPattern();return Ee&&typeof Je=="object"&&Reflect.defineProperty(Je,"test",{value:Ee}),Je}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let q=this.set;if(!q.length)return this.regexp=!1,this.regexp;let se=this.options,ge=se.noglobstar?Dht:se.dot?wht:Pht,Ee=new Set(se.nocase?["i"]:[]),Je=q.map(rr=>{let Hr=rr.map(hn=>{if(hn instanceof RegExp)for(let De of hn.flags.split(""))Ee.add(De);return typeof hn=="string"?Fht(hn):hn===Lh?Lh:hn._src});Hr.forEach((hn,De)=>{let Yn=Hr[De+1],Ut=Hr[De-1];hn!==Lh||Ut===Lh||(Ut===void 0?Yn!==void 0&&Yn!==Lh?Hr[De+1]="(?:\\/|"+ge+"\\/)?"+Yn:Hr[De]=ge:Yn===void 0?Hr[De-1]=Ut+"(?:\\/|\\/"+ge+")?":Yn!==Lh&&(Hr[De-1]=Ut+"(?:\\/|\\/"+ge+"\\/)"+Yn,Hr[De+1]=Lh))});let Tr=Hr.filter(hn=>hn!==Lh);if(this.partial&&Tr.length>=1){let hn=[];for(let De=1;De<=Tr.length;De++)hn.push(Tr.slice(0,De).join("/"));return"(?:"+hn.join("|")+")"}return Tr.join("/")}).join("|"),[Pt,cr]=q.length>1?["(?:",")"]:["",""];Je="^"+Pt+Je+cr+"$",this.partial&&(Je="^(?:\\/|"+Pt+Je.slice(1,-1)+cr+")$"),this.negate&&(Je="^(?!"+Je+").+$");try{this.regexp=new RegExp(Je,[...Ee].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(q){return this.preserveMultipleSlashes?q.split("/"):this.isWindows&&/^\/\/[^/]+/.test(q)?["",...q.split(/\/+/)]:q.split(/\/+/)}match(q,se=this.partial){if(this.debug("match",q,this.pattern),this.comment)return!1;if(this.empty)return q==="";if(q==="/"&&se)return!0;let ge=this.options;this.isWindows&&(q=q.split("\\").join("/"));let Ee=this.slashSplit(q);this.debug(this.pattern,"split",Ee);let Je=this.set;this.debug(this.pattern,"set",Je);let Pt=Ee[Ee.length-1];if(!Pt)for(let cr=Ee.length-2;!Pt&&cr>=0;cr--)Pt=Ee[cr];for(let cr of Je){let rr=Ee;if(ge.matchBase&&cr.length===1&&(rr=[Pt]),this.matchOne(rr,cr,se))return ge.flipNegate?!0:!this.negate}return ge.flipNegate?!1:this.negate}static defaults(q){return bm.defaults(q).Minimatch}};bm.AST=CA;bm.Minimatch=U7;bm.escape=Phe;bm.unescape=M6;var Du=xj(P9e()),jy=xj(require("fs")),iLe=xj(require("path"));var A9e;(function(ne){ne.STRING="string",ne.NUMBER="number",ne.INTEGER="integer",ne.BOOLEAN="boolean",ne.ARRAY="array",ne.OBJECT="object"})(A9e||(A9e={}));var N9e;(function(ne){ne.LANGUAGE_UNSPECIFIED="language_unspecified",ne.PYTHON="python"})(N9e||(N9e={}));var I9e;(function(ne){ne.OUTCOME_UNSPECIFIED="outcome_unspecified",ne.OUTCOME_OK="outcome_ok",ne.OUTCOME_FAILED="outcome_failed",ne.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})(I9e||(I9e={}));var O9e=["user","model","function","system"],F9e;(function(ne){ne.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",ne.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",ne.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",ne.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",ne.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT"})(F9e||(F9e={}));var L9e;(function(ne){ne.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",ne.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",ne.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",ne.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",ne.BLOCK_NONE="BLOCK_NONE"})(L9e||(L9e={}));var M9e;(function(ne){ne.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",ne.NEGLIGIBLE="NEGLIGIBLE",ne.LOW="LOW",ne.MEDIUM="MEDIUM",ne.HIGH="HIGH"})(M9e||(M9e={}));var R9e;(function(ne){ne.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",ne.SAFETY="SAFETY",ne.OTHER="OTHER"})(R9e||(R9e={}));var Ij;(function(ne){ne.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",ne.STOP="STOP",ne.MAX_TOKENS="MAX_TOKENS",ne.SAFETY="SAFETY",ne.RECITATION="RECITATION",ne.LANGUAGE="LANGUAGE",ne.OTHER="OTHER"})(Ij||(Ij={}));var j9e;(function(ne){ne.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",ne.RETRIEVAL_QUERY="RETRIEVAL_QUERY",ne.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",ne.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",ne.CLASSIFICATION="CLASSIFICATION",ne.CLUSTERING="CLUSTERING"})(j9e||(j9e={}));var B9e;(function(ne){ne.MODE_UNSPECIFIED="MODE_UNSPECIFIED",ne.AUTO="AUTO",ne.ANY="ANY",ne.NONE="NONE"})(B9e||(B9e={}));var J9e;(function(ne){ne.MODE_UNSPECIFIED="MODE_UNSPECIFIED",ne.MODE_DYNAMIC="MODE_DYNAMIC"})(J9e||(J9e={}));var Rh=class extends Error{constructor(q){super(`[GoogleGenerativeAI Error]: ${q}`)}},J6=class extends Rh{constructor(q,se){super(q),this.response=se}},dY=class extends Rh{constructor(q,se,ge,Ee){super(q),this.status=se,this.statusText=ge,this.errorDetails=Ee}},Dx=class extends Rh{};var g0t="https://generativelanguage.googleapis.com",h0t="v1beta",y0t="0.21.0",v0t="genai-js",AA;(function(ne){ne.GENERATE_CONTENT="generateContent",ne.STREAM_GENERATE_CONTENT="streamGenerateContent",ne.COUNT_TOKENS="countTokens",ne.EMBED_CONTENT="embedContent",ne.BATCH_EMBED_CONTENTS="batchEmbedContents"})(AA||(AA={}));var r0e=class{constructor(q,se,ge,Ee,Je){this.model=q,this.task=se,this.apiKey=ge,this.stream=Ee,this.requestOptions=Je}toString(){var q,se;let ge=((q=this.requestOptions)===null||q===void 0?void 0:q.apiVersion)||h0t,Je=`${((se=this.requestOptions)===null||se===void 0?void 0:se.baseUrl)||g0t}/${ge}/${this.model}:${this.task}`;return this.stream&&(Je+="?alt=sse"),Je}};function b0t(ne){let q=[];return ne?.apiClient&&q.push(ne.apiClient),q.push(`${v0t}/${y0t}`),q.join(" ")}async function S0t(ne){var q;let se=new Headers;se.append("Content-Type","application/json"),se.append("x-goog-api-client",b0t(ne.requestOptions)),se.append("x-goog-api-key",ne.apiKey);let ge=(q=ne.requestOptions)===null||q===void 0?void 0:q.customHeaders;if(ge){if(!(ge instanceof Headers))try{ge=new Headers(ge)}catch(Ee){throw new Dx(`unable to convert customHeaders value ${JSON.stringify(ge)} to Headers: ${Ee.message}`)}for(let[Ee,Je]of ge.entries()){if(Ee==="x-goog-api-key")throw new Dx(`Cannot set reserved header name ${Ee}`);if(Ee==="x-goog-api-client")throw new Dx(`Header name ${Ee} can only be set using the apiClient field`);se.append(Ee,Je)}}return se}async function T0t(ne,q,se,ge,Ee,Je){let Pt=new r0e(ne,q,se,ge,Je);return{url:Pt.toString(),fetchOptions:Object.assign(Object.assign({},E0t(Je)),{method:"POST",headers:await S0t(Pt),body:Ee})}}async function Lj(ne,q,se,ge,Ee,Je={},Pt=fetch){let{url:cr,fetchOptions:rr}=await T0t(ne,q,se,ge,Ee,Je);return x0t(cr,rr,Pt)}async function x0t(ne,q,se=fetch){let ge;try{ge=await se(ne,q)}catch(Ee){k0t(Ee,ne)}return ge.ok||await C0t(ge,ne),ge}function k0t(ne,q){let se=ne;throw ne instanceof dY||ne instanceof Dx||(se=new Rh(`Error fetching from ${q.toString()}: ${ne.message}`),se.stack=ne.stack),se}async function C0t(ne,q){let se="",ge;try{let Ee=await ne.json();se=Ee.error.message,Ee.error.details&&(se+=` ${JSON.stringify(Ee.error.details)}`,ge=Ee.error.details)}catch{}throw new dY(`Error fetching from ${q.toString()}: [${ne.status} ${ne.statusText}] ${se}`,ne.status,ne.statusText,ge)}function E0t(ne){let q={};if(ne?.signal!==void 0||ne?.timeout>=0){let se=new AbortController;ne?.timeout>=0&&setTimeout(()=>se.abort(),ne.timeout),ne?.signal&&ne.signal.addEventListener("abort",()=>{se.abort()}),q.signal=se.signal}return q}function i0e(ne){return ne.text=()=>{if(ne.candidates&&ne.candidates.length>0){if(ne.candidates.length>1&&console.warn(`This response had ${ne.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),pY(ne.candidates[0]))throw new J6(`${z6(ne)}`,ne);return D0t(ne)}else if(ne.promptFeedback)throw new J6(`Text not available. ${z6(ne)}`,ne);return""},ne.functionCall=()=>{if(ne.candidates&&ne.candidates.length>0){if(ne.candidates.length>1&&console.warn(`This response had ${ne.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),pY(ne.candidates[0]))throw new J6(`${z6(ne)}`,ne);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),z9e(ne)[0]}else if(ne.promptFeedback)throw new J6(`Function call not available. ${z6(ne)}`,ne)},ne.functionCalls=()=>{if(ne.candidates&&ne.candidates.length>0){if(ne.candidates.length>1&&console.warn(`This response had ${ne.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),pY(ne.candidates[0]))throw new J6(`${z6(ne)}`,ne);return z9e(ne)}else if(ne.promptFeedback)throw new J6(`Function call not available. ${z6(ne)}`,ne)},ne}function D0t(ne){var q,se,ge,Ee;let Je=[];if(!((se=(q=ne.candidates)===null||q===void 0?void 0:q[0].content)===null||se===void 0)&&se.parts)for(let Pt of(Ee=(ge=ne.candidates)===null||ge===void 0?void 0:ge[0].content)===null||Ee===void 0?void 0:Ee.parts)Pt.text&&Je.push(Pt.text),Pt.executableCode&&Je.push("\n```"+Pt.executableCode.language+`
|
|
438
|
-
`+Pt.executableCode.code+"\n```\n"),Pt.codeExecutionResult&&Je.push("\n```\n"+Pt.codeExecutionResult.output+"\n```\n");return Je.length>0?Je.join(""):""}function z9e(ne){var q,se,ge,Ee;let Je=[];if(!((se=(q=ne.candidates)===null||q===void 0?void 0:q[0].content)===null||se===void 0)&&se.parts)for(let Pt of(Ee=(ge=ne.candidates)===null||ge===void 0?void 0:ge[0].content)===null||Ee===void 0?void 0:Ee.parts)Pt.functionCall&&Je.push(Pt.functionCall);if(Je.length>0)return Je}var w0t=[Ij.RECITATION,Ij.SAFETY,Ij.LANGUAGE];function pY(ne){return!!ne.finishReason&&w0t.includes(ne.finishReason)}function z6(ne){var q,se,ge;let Ee="";if((!ne.candidates||ne.candidates.length===0)&&ne.promptFeedback)Ee+="Response was blocked",!((q=ne.promptFeedback)===null||q===void 0)&&q.blockReason&&(Ee+=` due to ${ne.promptFeedback.blockReason}`),!((se=ne.promptFeedback)===null||se===void 0)&&se.blockReasonMessage&&(Ee+=`: ${ne.promptFeedback.blockReasonMessage}`);else if(!((ge=ne.candidates)===null||ge===void 0)&&ge[0]){let Je=ne.candidates[0];pY(Je)&&(Ee+=`Candidate was blocked due to ${Je.finishReason}`,Je.finishMessage&&(Ee+=`: ${Je.finishMessage}`))}return Ee}function Oj(ne){return this instanceof Oj?(this.v=ne,this):new Oj(ne)}function P0t(ne,q,se){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var ge=se.apply(ne,q||[]),Ee,Je=[];return Ee={},Pt("next"),Pt("throw"),Pt("return"),Ee[Symbol.asyncIterator]=function(){return this},Ee;function Pt(De){ge[De]&&(Ee[De]=function(Yn){return new Promise(function(Ut,bt){Je.push([De,Yn,Ut,bt])>1||cr(De,Yn)})})}function cr(De,Yn){try{rr(ge[De](Yn))}catch(Ut){hn(Je[0][3],Ut)}}function rr(De){De.value instanceof Oj?Promise.resolve(De.value.v).then(Hr,Tr):hn(Je[0][2],De)}function Hr(De){cr("next",De)}function Tr(De){cr("throw",De)}function hn(De,Yn){De(Yn),Je.shift(),Je.length&&cr(Je[0][0],Je[0][1])}}var W9e=/^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;function A0t(ne){let q=ne.body.pipeThrough(new TextDecoderStream("utf8",{fatal:!0})),se=O0t(q),[ge,Ee]=se.tee();return{stream:I0t(ge),response:N0t(Ee)}}async function N0t(ne){let q=[],se=ne.getReader();for(;;){let{done:ge,value:Ee}=await se.read();if(ge)return i0e(F0t(q));q.push(Ee)}}function I0t(ne){return P0t(this,arguments,function*(){let se=ne.getReader();for(;;){let{value:ge,done:Ee}=yield Oj(se.read());if(Ee)break;yield yield Oj(i0e(ge))}})}function O0t(ne){let q=ne.getReader();return new ReadableStream({start(ge){let Ee="";return Je();function Je(){return q.read().then(({value:Pt,done:cr})=>{if(cr){if(Ee.trim()){ge.error(new Rh("Failed to parse stream"));return}ge.close();return}Ee+=Pt;let rr=Ee.match(W9e),Hr;for(;rr;){try{Hr=JSON.parse(rr[1])}catch{ge.error(new Rh(`Error parsing JSON response: "${rr[1]}"`));return}ge.enqueue(Hr),Ee=Ee.substring(rr[0].length),rr=Ee.match(W9e)}return Je()})}}})}function F0t(ne){let q=ne[ne.length-1],se={promptFeedback:q?.promptFeedback};for(let ge of ne){if(ge.candidates)for(let Ee of ge.candidates){let Je=Ee.index;if(se.candidates||(se.candidates=[]),se.candidates[Je]||(se.candidates[Je]={index:Ee.index}),se.candidates[Je].citationMetadata=Ee.citationMetadata,se.candidates[Je].groundingMetadata=Ee.groundingMetadata,se.candidates[Je].finishReason=Ee.finishReason,se.candidates[Je].finishMessage=Ee.finishMessage,se.candidates[Je].safetyRatings=Ee.safetyRatings,Ee.content&&Ee.content.parts){se.candidates[Je].content||(se.candidates[Je].content={role:Ee.content.role||"user",parts:[]});let Pt={};for(let cr of Ee.content.parts)cr.text&&(Pt.text=cr.text),cr.functionCall&&(Pt.functionCall=cr.functionCall),cr.executableCode&&(Pt.executableCode=cr.executableCode),cr.codeExecutionResult&&(Pt.codeExecutionResult=cr.codeExecutionResult),Object.keys(Pt).length===0&&(Pt.text=""),se.candidates[Je].content.parts.push(Pt)}}ge.usageMetadata&&(se.usageMetadata=ge.usageMetadata)}return se}async function $9e(ne,q,se,ge){let Ee=await Lj(q,AA.STREAM_GENERATE_CONTENT,ne,!0,JSON.stringify(se),ge);return A0t(Ee)}async function G9e(ne,q,se,ge){let Je=await(await Lj(q,AA.GENERATE_CONTENT,ne,!1,JSON.stringify(se),ge)).json();return{response:i0e(Je)}}function H9e(ne){if(ne!=null){if(typeof ne=="string")return{role:"system",parts:[{text:ne}]};if(ne.text)return{role:"system",parts:[ne]};if(ne.parts)return ne.role?ne:{role:"system",parts:ne.parts}}}function Fj(ne){let q=[];if(typeof ne=="string")q=[{text:ne}];else for(let se of ne)typeof se=="string"?q.push({text:se}):q.push(se);return L0t(q)}function L0t(ne){let q={role:"user",parts:[]},se={role:"function",parts:[]},ge=!1,Ee=!1;for(let Je of ne)"functionResponse"in Je?(se.parts.push(Je),Ee=!0):(q.parts.push(Je),ge=!0);if(ge&&Ee)throw new Rh("Within a single message, FunctionResponse cannot be mixed with other type of part in the request for sending chat message.");if(!ge&&!Ee)throw new Rh("No content is provided for sending chat message.");return ge?q:se}function M0t(ne,q){var se;let ge={model:q?.model,generationConfig:q?.generationConfig,safetySettings:q?.safetySettings,tools:q?.tools,toolConfig:q?.toolConfig,systemInstruction:q?.systemInstruction,cachedContent:(se=q?.cachedContent)===null||se===void 0?void 0:se.name,contents:[]},Ee=ne.generateContentRequest!=null;if(ne.contents){if(Ee)throw new Dx("CountTokensRequest must have one of contents or generateContentRequest, not both.");ge.contents=ne.contents}else if(Ee)ge=Object.assign(Object.assign({},ge),ne.generateContentRequest);else{let Je=Fj(ne);ge.contents=[Je]}return{generateContentRequest:ge}}function U9e(ne){let q;return ne.contents?q=ne:q={contents:[Fj(ne)]},ne.systemInstruction&&(q.systemInstruction=H9e(ne.systemInstruction)),q}function R0t(ne){return typeof ne=="string"||Array.isArray(ne)?{content:Fj(ne)}:ne}var V9e=["text","inlineData","functionCall","functionResponse","executableCode","codeExecutionResult"],j0t={user:["text","inlineData"],function:["functionResponse"],model:["text","functionCall","executableCode","codeExecutionResult"],system:["text"]};function B0t(ne){let q=!1;for(let se of ne){let{role:ge,parts:Ee}=se;if(!q&&ge!=="user")throw new Rh(`First content should be with role 'user', got ${ge}`);if(!O9e.includes(ge))throw new Rh(`Each item should include role field. Got ${ge} but valid roles are: ${JSON.stringify(O9e)}`);if(!Array.isArray(Ee))throw new Rh("Content should have 'parts' property with an array of Parts");if(Ee.length===0)throw new Rh("Each Content should have at least one part");let Je={text:0,inlineData:0,functionCall:0,functionResponse:0,fileData:0,executableCode:0,codeExecutionResult:0};for(let cr of Ee)for(let rr of V9e)rr in cr&&(Je[rr]+=1);let Pt=j0t[ge];for(let cr of V9e)if(!Pt.includes(cr)&&Je[cr]>0)throw new Rh(`Content with role '${ge}' can't contain '${cr}' part`);q=!0}}var q9e="SILENT_ERROR",n0e=class{constructor(q,se,ge,Ee={}){this.model=se,this.params=ge,this._requestOptions=Ee,this._history=[],this._sendPromise=Promise.resolve(),this._apiKey=q,ge?.history&&(B0t(ge.history),this._history=ge.history)}async getHistory(){return await this._sendPromise,this._history}async sendMessage(q,se={}){var ge,Ee,Je,Pt,cr,rr;await this._sendPromise;let Hr=Fj(q),Tr={safetySettings:(ge=this.params)===null||ge===void 0?void 0:ge.safetySettings,generationConfig:(Ee=this.params)===null||Ee===void 0?void 0:Ee.generationConfig,tools:(Je=this.params)===null||Je===void 0?void 0:Je.tools,toolConfig:(Pt=this.params)===null||Pt===void 0?void 0:Pt.toolConfig,systemInstruction:(cr=this.params)===null||cr===void 0?void 0:cr.systemInstruction,cachedContent:(rr=this.params)===null||rr===void 0?void 0:rr.cachedContent,contents:[...this._history,Hr]},hn=Object.assign(Object.assign({},this._requestOptions),se),De;return this._sendPromise=this._sendPromise.then(()=>G9e(this._apiKey,this.model,Tr,hn)).then(Yn=>{var Ut;if(Yn.response.candidates&&Yn.response.candidates.length>0){this._history.push(Hr);let bt=Object.assign({parts:[],role:"model"},(Ut=Yn.response.candidates)===null||Ut===void 0?void 0:Ut[0].content);this._history.push(bt)}else{let bt=z6(Yn.response);bt&&console.warn(`sendMessage() was unsuccessful. ${bt}. Inspect response object for details.`)}De=Yn}),await this._sendPromise,De}async sendMessageStream(q,se={}){var ge,Ee,Je,Pt,cr,rr;await this._sendPromise;let Hr=Fj(q),Tr={safetySettings:(ge=this.params)===null||ge===void 0?void 0:ge.safetySettings,generationConfig:(Ee=this.params)===null||Ee===void 0?void 0:Ee.generationConfig,tools:(Je=this.params)===null||Je===void 0?void 0:Je.tools,toolConfig:(Pt=this.params)===null||Pt===void 0?void 0:Pt.toolConfig,systemInstruction:(cr=this.params)===null||cr===void 0?void 0:cr.systemInstruction,cachedContent:(rr=this.params)===null||rr===void 0?void 0:rr.cachedContent,contents:[...this._history,Hr]},hn=Object.assign(Object.assign({},this._requestOptions),se),De=$9e(this._apiKey,this.model,Tr,hn);return this._sendPromise=this._sendPromise.then(()=>De).catch(Yn=>{throw new Error(q9e)}).then(Yn=>Yn.response).then(Yn=>{if(Yn.candidates&&Yn.candidates.length>0){this._history.push(Hr);let Ut=Object.assign({},Yn.candidates[0].content);Ut.role||(Ut.role="model"),this._history.push(Ut)}else{let Ut=z6(Yn);Ut&&console.warn(`sendMessageStream() was unsuccessful. ${Ut}. Inspect response object for details.`)}}).catch(Yn=>{Yn.message!==q9e&&console.error(Yn)}),De}};async function J0t(ne,q,se,ge){return(await Lj(q,AA.COUNT_TOKENS,ne,!1,JSON.stringify(se),ge)).json()}async function z0t(ne,q,se,ge){return(await Lj(q,AA.EMBED_CONTENT,ne,!1,JSON.stringify(se),ge)).json()}async function W0t(ne,q,se,ge){let Ee=se.requests.map(Pt=>Object.assign(Object.assign({},Pt),{model:q}));return(await Lj(q,AA.BATCH_EMBED_CONTENTS,ne,!1,JSON.stringify({requests:Ee}),ge)).json()}var mY=class{constructor(q,se,ge={}){this.apiKey=q,this._requestOptions=ge,se.model.includes("/")?this.model=se.model:this.model=`models/${se.model}`,this.generationConfig=se.generationConfig||{},this.safetySettings=se.safetySettings||[],this.tools=se.tools,this.toolConfig=se.toolConfig,this.systemInstruction=H9e(se.systemInstruction),this.cachedContent=se.cachedContent}async generateContent(q,se={}){var ge;let Ee=U9e(q),Je=Object.assign(Object.assign({},this._requestOptions),se);return G9e(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(ge=this.cachedContent)===null||ge===void 0?void 0:ge.name},Ee),Je)}async generateContentStream(q,se={}){var ge;let Ee=U9e(q),Je=Object.assign(Object.assign({},this._requestOptions),se);return $9e(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(ge=this.cachedContent)===null||ge===void 0?void 0:ge.name},Ee),Je)}startChat(q){var se;return new n0e(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(se=this.cachedContent)===null||se===void 0?void 0:se.name},q),this._requestOptions)}async countTokens(q,se={}){let ge=M0t(q,{model:this.model,generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:this.cachedContent}),Ee=Object.assign(Object.assign({},this._requestOptions),se);return J0t(this.apiKey,this.model,ge,Ee)}async embedContent(q,se={}){let ge=R0t(q),Ee=Object.assign(Object.assign({},this._requestOptions),se);return z0t(this.apiKey,this.model,ge,Ee)}async batchEmbedContents(q,se={}){let ge=Object.assign(Object.assign({},this._requestOptions),se);return W0t(this.apiKey,this.model,q,ge)}};var gY=class{constructor(q){this.apiKey=q}getGenerativeModel(q,se){if(!q.model)throw new Rh("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new mY(this.apiKey,q,se)}getGenerativeModelFromCachedContent(q,se,ge){if(!q.name)throw new Dx("Cached content must contain a `name` field.");if(!q.model)throw new Dx("Cached content must contain a `model` field.");let Ee=["model","systemInstruction"];for(let Pt of Ee)if(se?.[Pt]&&q[Pt]&&se?.[Pt]!==q[Pt]){if(Pt==="model"){let cr=se.model.startsWith("models/")?se.model.replace("models/",""):se.model,rr=q.model.startsWith("models/")?q.model.replace("models/",""):q.model;if(cr===rr)continue}throw new Dx(`Different value for "${Pt}" specified in modelParams (${se[Pt]}) and cachedContent (${q[Pt]})`)}let Je=Object.assign(Object.assign({},se),{model:q.model,tools:q.tools,toolConfig:q.toolConfig,systemInstruction:q.systemInstruction,cachedContent:q});return new mY(this.apiKey,Je,ge)}};var hY=xj(require("fs")),So={reset:"\x1B[0m",bold:"\x1B[1m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",cyan:"\x1B[36m",gray:"\x1B[90m",orange:"\x1B[38;5;208m"};async function Q9e(ne,q){try{if(!ne.trim()||q.length===0)return;let se=process.env.GEMINI_API_KEY;if(!se)return"";let ge=new gY(se),Ee=process.env.GEMINI_MODEL||"gemini-1.5-flash",Je=ge.getGenerativeModel({model:Ee}),Pt=process.cwd(),cr="";try{cr=hY.readdirSync(Pt,{withFileTypes:!0}).filter(bt=>bt.isDirectory()&&!bt.name.startsWith(".")&&bt.name!=="node_modules").map(bt=>bt.name).join(", ")}catch{}let rr=`
|
|
438
|
+
`+Pt.executableCode.code+"\n```\n"),Pt.codeExecutionResult&&Je.push("\n```\n"+Pt.codeExecutionResult.output+"\n```\n");return Je.length>0?Je.join(""):""}function z9e(ne){var q,se,ge,Ee;let Je=[];if(!((se=(q=ne.candidates)===null||q===void 0?void 0:q[0].content)===null||se===void 0)&&se.parts)for(let Pt of(Ee=(ge=ne.candidates)===null||ge===void 0?void 0:ge[0].content)===null||Ee===void 0?void 0:Ee.parts)Pt.functionCall&&Je.push(Pt.functionCall);if(Je.length>0)return Je}var w0t=[Ij.RECITATION,Ij.SAFETY,Ij.LANGUAGE];function pY(ne){return!!ne.finishReason&&w0t.includes(ne.finishReason)}function z6(ne){var q,se,ge;let Ee="";if((!ne.candidates||ne.candidates.length===0)&&ne.promptFeedback)Ee+="Response was blocked",!((q=ne.promptFeedback)===null||q===void 0)&&q.blockReason&&(Ee+=` due to ${ne.promptFeedback.blockReason}`),!((se=ne.promptFeedback)===null||se===void 0)&&se.blockReasonMessage&&(Ee+=`: ${ne.promptFeedback.blockReasonMessage}`);else if(!((ge=ne.candidates)===null||ge===void 0)&&ge[0]){let Je=ne.candidates[0];pY(Je)&&(Ee+=`Candidate was blocked due to ${Je.finishReason}`,Je.finishMessage&&(Ee+=`: ${Je.finishMessage}`))}return Ee}function Oj(ne){return this instanceof Oj?(this.v=ne,this):new Oj(ne)}function P0t(ne,q,se){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var ge=se.apply(ne,q||[]),Ee,Je=[];return Ee={},Pt("next"),Pt("throw"),Pt("return"),Ee[Symbol.asyncIterator]=function(){return this},Ee;function Pt(De){ge[De]&&(Ee[De]=function(Yn){return new Promise(function(Ut,bt){Je.push([De,Yn,Ut,bt])>1||cr(De,Yn)})})}function cr(De,Yn){try{rr(ge[De](Yn))}catch(Ut){hn(Je[0][3],Ut)}}function rr(De){De.value instanceof Oj?Promise.resolve(De.value.v).then(Hr,Tr):hn(Je[0][2],De)}function Hr(De){cr("next",De)}function Tr(De){cr("throw",De)}function hn(De,Yn){De(Yn),Je.shift(),Je.length&&cr(Je[0][0],Je[0][1])}}var W9e=/^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;function A0t(ne){let q=ne.body.pipeThrough(new TextDecoderStream("utf8",{fatal:!0})),se=O0t(q),[ge,Ee]=se.tee();return{stream:I0t(ge),response:N0t(Ee)}}async function N0t(ne){let q=[],se=ne.getReader();for(;;){let{done:ge,value:Ee}=await se.read();if(ge)return i0e(F0t(q));q.push(Ee)}}function I0t(ne){return P0t(this,arguments,function*(){let se=ne.getReader();for(;;){let{value:ge,done:Ee}=yield Oj(se.read());if(Ee)break;yield yield Oj(i0e(ge))}})}function O0t(ne){let q=ne.getReader();return new ReadableStream({start(ge){let Ee="";return Je();function Je(){return q.read().then(({value:Pt,done:cr})=>{if(cr){if(Ee.trim()){ge.error(new Rh("Failed to parse stream"));return}ge.close();return}Ee+=Pt;let rr=Ee.match(W9e),Hr;for(;rr;){try{Hr=JSON.parse(rr[1])}catch{ge.error(new Rh(`Error parsing JSON response: "${rr[1]}"`));return}ge.enqueue(Hr),Ee=Ee.substring(rr[0].length),rr=Ee.match(W9e)}return Je()})}}})}function F0t(ne){let q=ne[ne.length-1],se={promptFeedback:q?.promptFeedback};for(let ge of ne){if(ge.candidates)for(let Ee of ge.candidates){let Je=Ee.index;if(se.candidates||(se.candidates=[]),se.candidates[Je]||(se.candidates[Je]={index:Ee.index}),se.candidates[Je].citationMetadata=Ee.citationMetadata,se.candidates[Je].groundingMetadata=Ee.groundingMetadata,se.candidates[Je].finishReason=Ee.finishReason,se.candidates[Je].finishMessage=Ee.finishMessage,se.candidates[Je].safetyRatings=Ee.safetyRatings,Ee.content&&Ee.content.parts){se.candidates[Je].content||(se.candidates[Je].content={role:Ee.content.role||"user",parts:[]});let Pt={};for(let cr of Ee.content.parts)cr.text&&(Pt.text=cr.text),cr.functionCall&&(Pt.functionCall=cr.functionCall),cr.executableCode&&(Pt.executableCode=cr.executableCode),cr.codeExecutionResult&&(Pt.codeExecutionResult=cr.codeExecutionResult),Object.keys(Pt).length===0&&(Pt.text=""),se.candidates[Je].content.parts.push(Pt)}}ge.usageMetadata&&(se.usageMetadata=ge.usageMetadata)}return se}async function $9e(ne,q,se,ge){let Ee=await Lj(q,AA.STREAM_GENERATE_CONTENT,ne,!0,JSON.stringify(se),ge);return A0t(Ee)}async function G9e(ne,q,se,ge){let Je=await(await Lj(q,AA.GENERATE_CONTENT,ne,!1,JSON.stringify(se),ge)).json();return{response:i0e(Je)}}function H9e(ne){if(ne!=null){if(typeof ne=="string")return{role:"system",parts:[{text:ne}]};if(ne.text)return{role:"system",parts:[ne]};if(ne.parts)return ne.role?ne:{role:"system",parts:ne.parts}}}function Fj(ne){let q=[];if(typeof ne=="string")q=[{text:ne}];else for(let se of ne)typeof se=="string"?q.push({text:se}):q.push(se);return L0t(q)}function L0t(ne){let q={role:"user",parts:[]},se={role:"function",parts:[]},ge=!1,Ee=!1;for(let Je of ne)"functionResponse"in Je?(se.parts.push(Je),Ee=!0):(q.parts.push(Je),ge=!0);if(ge&&Ee)throw new Rh("Within a single message, FunctionResponse cannot be mixed with other type of part in the request for sending chat message.");if(!ge&&!Ee)throw new Rh("No content is provided for sending chat message.");return ge?q:se}function M0t(ne,q){var se;let ge={model:q?.model,generationConfig:q?.generationConfig,safetySettings:q?.safetySettings,tools:q?.tools,toolConfig:q?.toolConfig,systemInstruction:q?.systemInstruction,cachedContent:(se=q?.cachedContent)===null||se===void 0?void 0:se.name,contents:[]},Ee=ne.generateContentRequest!=null;if(ne.contents){if(Ee)throw new Dx("CountTokensRequest must have one of contents or generateContentRequest, not both.");ge.contents=ne.contents}else if(Ee)ge=Object.assign(Object.assign({},ge),ne.generateContentRequest);else{let Je=Fj(ne);ge.contents=[Je]}return{generateContentRequest:ge}}function U9e(ne){let q;return ne.contents?q=ne:q={contents:[Fj(ne)]},ne.systemInstruction&&(q.systemInstruction=H9e(ne.systemInstruction)),q}function R0t(ne){return typeof ne=="string"||Array.isArray(ne)?{content:Fj(ne)}:ne}var V9e=["text","inlineData","functionCall","functionResponse","executableCode","codeExecutionResult"],j0t={user:["text","inlineData"],function:["functionResponse"],model:["text","functionCall","executableCode","codeExecutionResult"],system:["text"]};function B0t(ne){let q=!1;for(let se of ne){let{role:ge,parts:Ee}=se;if(!q&&ge!=="user")throw new Rh(`First content should be with role 'user', got ${ge}`);if(!O9e.includes(ge))throw new Rh(`Each item should include role field. Got ${ge} but valid roles are: ${JSON.stringify(O9e)}`);if(!Array.isArray(Ee))throw new Rh("Content should have 'parts' property with an array of Parts");if(Ee.length===0)throw new Rh("Each Content should have at least one part");let Je={text:0,inlineData:0,functionCall:0,functionResponse:0,fileData:0,executableCode:0,codeExecutionResult:0};for(let cr of Ee)for(let rr of V9e)rr in cr&&(Je[rr]+=1);let Pt=j0t[ge];for(let cr of V9e)if(!Pt.includes(cr)&&Je[cr]>0)throw new Rh(`Content with role '${ge}' can't contain '${cr}' part`);q=!0}}var q9e="SILENT_ERROR",n0e=class{constructor(q,se,ge,Ee={}){this.model=se,this.params=ge,this._requestOptions=Ee,this._history=[],this._sendPromise=Promise.resolve(),this._apiKey=q,ge?.history&&(B0t(ge.history),this._history=ge.history)}async getHistory(){return await this._sendPromise,this._history}async sendMessage(q,se={}){var ge,Ee,Je,Pt,cr,rr;await this._sendPromise;let Hr=Fj(q),Tr={safetySettings:(ge=this.params)===null||ge===void 0?void 0:ge.safetySettings,generationConfig:(Ee=this.params)===null||Ee===void 0?void 0:Ee.generationConfig,tools:(Je=this.params)===null||Je===void 0?void 0:Je.tools,toolConfig:(Pt=this.params)===null||Pt===void 0?void 0:Pt.toolConfig,systemInstruction:(cr=this.params)===null||cr===void 0?void 0:cr.systemInstruction,cachedContent:(rr=this.params)===null||rr===void 0?void 0:rr.cachedContent,contents:[...this._history,Hr]},hn=Object.assign(Object.assign({},this._requestOptions),se),De;return this._sendPromise=this._sendPromise.then(()=>G9e(this._apiKey,this.model,Tr,hn)).then(Yn=>{var Ut;if(Yn.response.candidates&&Yn.response.candidates.length>0){this._history.push(Hr);let bt=Object.assign({parts:[],role:"model"},(Ut=Yn.response.candidates)===null||Ut===void 0?void 0:Ut[0].content);this._history.push(bt)}else{let bt=z6(Yn.response);bt&&console.warn(`sendMessage() was unsuccessful. ${bt}. Inspect response object for details.`)}De=Yn}),await this._sendPromise,De}async sendMessageStream(q,se={}){var ge,Ee,Je,Pt,cr,rr;await this._sendPromise;let Hr=Fj(q),Tr={safetySettings:(ge=this.params)===null||ge===void 0?void 0:ge.safetySettings,generationConfig:(Ee=this.params)===null||Ee===void 0?void 0:Ee.generationConfig,tools:(Je=this.params)===null||Je===void 0?void 0:Je.tools,toolConfig:(Pt=this.params)===null||Pt===void 0?void 0:Pt.toolConfig,systemInstruction:(cr=this.params)===null||cr===void 0?void 0:cr.systemInstruction,cachedContent:(rr=this.params)===null||rr===void 0?void 0:rr.cachedContent,contents:[...this._history,Hr]},hn=Object.assign(Object.assign({},this._requestOptions),se),De=$9e(this._apiKey,this.model,Tr,hn);return this._sendPromise=this._sendPromise.then(()=>De).catch(Yn=>{throw new Error(q9e)}).then(Yn=>Yn.response).then(Yn=>{if(Yn.candidates&&Yn.candidates.length>0){this._history.push(Hr);let Ut=Object.assign({},Yn.candidates[0].content);Ut.role||(Ut.role="model"),this._history.push(Ut)}else{let Ut=z6(Yn);Ut&&console.warn(`sendMessageStream() was unsuccessful. ${Ut}. Inspect response object for details.`)}}).catch(Yn=>{Yn.message!==q9e&&console.error(Yn)}),De}};async function J0t(ne,q,se,ge){return(await Lj(q,AA.COUNT_TOKENS,ne,!1,JSON.stringify(se),ge)).json()}async function z0t(ne,q,se,ge){return(await Lj(q,AA.EMBED_CONTENT,ne,!1,JSON.stringify(se),ge)).json()}async function W0t(ne,q,se,ge){let Ee=se.requests.map(Pt=>Object.assign(Object.assign({},Pt),{model:q}));return(await Lj(q,AA.BATCH_EMBED_CONTENTS,ne,!1,JSON.stringify({requests:Ee}),ge)).json()}var mY=class{constructor(q,se,ge={}){this.apiKey=q,this._requestOptions=ge,se.model.includes("/")?this.model=se.model:this.model=`models/${se.model}`,this.generationConfig=se.generationConfig||{},this.safetySettings=se.safetySettings||[],this.tools=se.tools,this.toolConfig=se.toolConfig,this.systemInstruction=H9e(se.systemInstruction),this.cachedContent=se.cachedContent}async generateContent(q,se={}){var ge;let Ee=U9e(q),Je=Object.assign(Object.assign({},this._requestOptions),se);return G9e(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(ge=this.cachedContent)===null||ge===void 0?void 0:ge.name},Ee),Je)}async generateContentStream(q,se={}){var ge;let Ee=U9e(q),Je=Object.assign(Object.assign({},this._requestOptions),se);return $9e(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(ge=this.cachedContent)===null||ge===void 0?void 0:ge.name},Ee),Je)}startChat(q){var se;return new n0e(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(se=this.cachedContent)===null||se===void 0?void 0:se.name},q),this._requestOptions)}async countTokens(q,se={}){let ge=M0t(q,{model:this.model,generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:this.cachedContent}),Ee=Object.assign(Object.assign({},this._requestOptions),se);return J0t(this.apiKey,this.model,ge,Ee)}async embedContent(q,se={}){let ge=R0t(q),Ee=Object.assign(Object.assign({},this._requestOptions),se);return z0t(this.apiKey,this.model,ge,Ee)}async batchEmbedContents(q,se={}){let ge=Object.assign(Object.assign({},this._requestOptions),se);return W0t(this.apiKey,this.model,q,ge)}};var gY=class{constructor(q){this.apiKey=q}getGenerativeModel(q,se){if(!q.model)throw new Rh("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new mY(this.apiKey,q,se)}getGenerativeModelFromCachedContent(q,se,ge){if(!q.name)throw new Dx("Cached content must contain a `name` field.");if(!q.model)throw new Dx("Cached content must contain a `model` field.");let Ee=["model","systemInstruction"];for(let Pt of Ee)if(se?.[Pt]&&q[Pt]&&se?.[Pt]!==q[Pt]){if(Pt==="model"){let cr=se.model.startsWith("models/")?se.model.replace("models/",""):se.model,rr=q.model.startsWith("models/")?q.model.replace("models/",""):q.model;if(cr===rr)continue}throw new Dx(`Different value for "${Pt}" specified in modelParams (${se[Pt]}) and cachedContent (${q[Pt]})`)}let Je=Object.assign(Object.assign({},se),{model:q.model,tools:q.tools,toolConfig:q.toolConfig,systemInstruction:q.systemInstruction,cachedContent:q});return new mY(this.apiKey,Je,ge)}};var hY=xj(require("fs")),So={reset:"\x1B[0m",bold:"\x1B[1m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",cyan:"\x1B[36m",gray:"\x1B[90m",orange:"\x1B[38;5;208m"};async function Q9e(ne,q){try{if(!ne.trim()||q.length===0)return;let se=process.env.GEMINI_API_KEY;if(!se)return"";let ge=new gY(se),Ee=process.env.GEMINI_MODEL||"gemini-3.6-flash";(Ee==="gemini-2.5-flash"||Ee==="gemini-1.5-flash")&&(Ee="gemini-3.6-flash");let Je=ge.getGenerativeModel({model:Ee}),Pt=process.cwd(),cr="";try{cr=hY.readdirSync(Pt,{withFileTypes:!0}).filter(bt=>bt.isDirectory()&&!bt.name.startsWith(".")&&bt.name!=="node_modules").map(bt=>bt.name).join(", ")}catch{}let rr=`
|
|
439
439
|
You are the Code Impact Analyzer, an expert software developer tool. Analyze the provided git diff and all staged files to determine the exact intent and the overall impact of this commit.
|
|
440
440
|
Project top-level folders: ${cr}
|
|
441
441
|
Staged files: ${q.join(", ")}
|
|
@@ -520,7 +520,8 @@ if [ -z "$GEMINI_API_KEY" ]; then
|
|
|
520
520
|
echo "GEMINI_API_KEY=\\"$NEW_KEY\\"" >> .env
|
|
521
521
|
export GEMINI_API_KEY="$NEW_KEY"
|
|
522
522
|
if ! grep -q "^GEMINI_MODEL=" .env; then
|
|
523
|
-
echo "GEMINI_MODEL
|
|
523
|
+
echo "GEMINI_MODEL="gemini-3.6-flash"" >> .env
|
|
524
|
+
export GEMINI_MODEL="gemini-3.6-flash"
|
|
524
525
|
fi
|
|
525
526
|
echo "\u2705 API key and model saved to .env!"
|
|
526
527
|
echo ""
|