@raycast/api 1.96.3 → 1.97.0
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/api/evals.js +2 -2
- package/dist/commands/develop/index.js +1 -1
- package/dist/commands/lint/index.js +1 -1
- package/dist/commands/logout/index.js +1 -1
- package/dist/commands/publish/index.js +2 -2
- package/dist/commands/token/index.js +4 -4
- package/dist/commands/validate/index.js +1 -1
- package/dist/commands/version/index.js +1 -1
- package/dist/config.js +1 -1
- package/dist/utils/raycast-app-communication.js +1 -1
- package/oclif.manifest.json +19 -19
- package/package.json +1 -1
- package/types/index.d.ts +59 -8
|
@@ -605,7 +605,7 @@ Project '${h.projectName}' (${BM[h.projectKind]}) ${u}
|
|
|
605
605
|
`,u++};this.projectService.externalProjects.forEach(f),this.projectService.configuredProjects.forEach(f),this.projectService.inferredProjects.forEach(f)}}this.logger.msg(o,"Err")}send(t){if(t.type==="event"&&!this.canUseEvents){this.logger.hasLevel(3)&&this.logger.info(`Session does not support events: ignored event: ${rx(t)}`);return}this.writeMessage(t)}writeMessage(t){let n=zwe(t,this.logger,this.byteLength,this.host.newLine);this.host.write(n)}event(t,n){this.send($we(n,t))}doOutput(t,n,a,o,u,f){let h={seq:0,type:"response",command:n,request_seq:a,success:o,performanceData:u&&FZe(u)};if(o){let m;if(zs(t))h.body=t,m=t.metadata,delete t.metadata;else if(typeof t=="object")if(t.metadata){let{metadata:b,...T}=t;h.body=T,m=b}else h.body=t;else h.body=t;m&&(h.metadata=m)}else I.assert(t===void 0);f&&(h.message=f),this.send(h)}semanticCheck(t,n){var a,o;let u=Ho();(a=Rn)==null||a.push(Rn.Phase.Session,"semanticCheck",{file:t,configFilePath:n.canonicalConfigFilePath});let f=CZe(n,t)?Vu:n.getLanguageService().getSemanticDiagnostics(t).filter(h=>!!h.file);this.sendDiagnosticsEvent(t,n,f,"semanticDiag",u),(o=Rn)==null||o.pop()}syntacticCheck(t,n){var a,o;let u=Ho();(a=Rn)==null||a.push(Rn.Phase.Session,"syntacticCheck",{file:t,configFilePath:n.canonicalConfigFilePath}),this.sendDiagnosticsEvent(t,n,n.getLanguageService().getSyntacticDiagnostics(t),"syntaxDiag",u),(o=Rn)==null||o.pop()}suggestionCheck(t,n){var a,o;let u=Ho();(a=Rn)==null||a.push(Rn.Phase.Session,"suggestionCheck",{file:t,configFilePath:n.canonicalConfigFilePath}),this.sendDiagnosticsEvent(t,n,n.getLanguageService().getSuggestionDiagnostics(t),"suggestionDiag",u),(o=Rn)==null||o.pop()}regionSemanticCheck(t,n,a){var o,u,f;let h=Ho();(o=Rn)==null||o.push(Rn.Phase.Session,"regionSemanticCheck",{file:t,configFilePath:n.canonicalConfigFilePath});let m;if(!this.shouldDoRegionCheck(t)||!(m=n.getLanguageService().getRegionSemanticDiagnostics(t,a))){(u=Rn)==null||u.pop();return}this.sendDiagnosticsEvent(t,n,m.diagnostics,"regionSemanticDiag",h,m.spans),(f=Rn)==null||f.pop()}shouldDoRegionCheck(t){var n;let a=(n=this.projectService.getScriptInfoForNormalizedPath(t))==null?void 0:n.textStorage.getLineInfo().getLineCount();return!!(a&&a>=this.regionDiagLineCountThreshold)}sendDiagnosticsEvent(t,n,a,o,u,f){try{let h=I.checkDefined(n.getScriptInfo(t)),m=Ho()-u,b={file:t,diagnostics:a.map(T=>EZe(t,n,T)),spans:f?.map(T=>Ny(T,h))};this.event(b,o),this.addDiagnosticsPerformanceData(t,o,m)}catch(h){this.logError(h,o)}}updateErrorCheck(t,n,a,o=!0){if(n.length===0)return;I.assert(!this.suppressDiagnosticEvents);let u=this.changeSeq,f=Math.min(a,200),h=0,m=()=>{if(h++,n.length>h)return t.delay("checkOne",f,T)},b=(D,A)=>{if(this.semanticCheck(D,A),this.changeSeq===u){if(this.getPreferences(D).disableSuggestions)return m();t.immediate("suggestionCheck",()=>{this.suggestionCheck(D,A),m()})}},T=()=>{if(this.changeSeq!==u)return;let D,A=n[h];if(Ls(A)?A=this.toPendingErrorCheck(A):"ranges"in A&&(D=A.ranges,A=this.toPendingErrorCheck(A.file)),!A)return m();let{fileName:P,project:O}=A;if(Vm(O),!!O.containsFile(P,o)&&(this.syntacticCheck(P,O),this.changeSeq===u)){if(O.projectService.serverMode!==0)return m();if(D)return t.immediate("regionSemanticCheck",()=>{let R=this.projectService.getScriptInfoForNormalizedPath(P);R&&this.regionSemanticCheck(P,O,D.map(M=>this.getRange({file:P,...M},R))),this.changeSeq===u&&t.immediate("semanticCheck",()=>b(P,O))});t.immediate("semanticCheck",()=>b(P,O))}};n.length>h&&this.changeSeq===u&&t.delay("checkOne",a,T)}cleanProjects(t,n){if(n){this.logger.info(`cleaning ${t}`);for(let a of n)a.getLanguageService(!1).cleanupSemanticCache(),a.cleanupProgram()}}cleanup(){this.cleanProjects("inferred projects",this.projectService.inferredProjects),this.cleanProjects("configured projects",Js(this.projectService.configuredProjects.values())),this.cleanProjects("external projects",this.projectService.externalProjects),this.host.gc&&(this.logger.info("host.gc()"),this.host.gc())}getEncodedSyntacticClassifications(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t);return a.getEncodedSyntacticClassifications(n,t)}getEncodedSemanticClassifications(t){let{file:n,project:a}=this.getFileAndProject(t),o=t.format==="2020"?"2020":"original";return a.getLanguageService().getEncodedSemanticClassifications(n,t,o)}getProject(t){return t===void 0?void 0:this.projectService.findProject(t)}getConfigFileAndProject(t){let n=this.getProject(t.projectFileName),a=Jc(t.file);return{configFile:n&&n.hasConfigFile(a)?a:void 0,project:n}}getConfigFileDiagnostics(t,n,a){let o=n.getAllProjectErrors(),u=n.getLanguageService().getCompilerOptionsDiagnostics(),f=_n(Ns(o,u),h=>!!h.file&&h.file.fileName===t);return a?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(f):gr(f,h=>zM(h,!1))}convertToDiagnosticsWithLinePositionFromDiagnosticFile(t){return t.map(n=>({message:wy(n.messageText,this.host.newLine),start:n.start,length:n.length,category:pl(n),code:n.code,source:n.source,startLocation:n.file&&y4(Ua(n.file,n.start)),endLocation:n.file&&y4(Ua(n.file,n.start+n.length)),reportsUnnecessary:n.reportsUnnecessary,reportsDeprecated:n.reportsDeprecated,relatedInformation:gr(n.relatedInformation,Ooe)}))}getCompilerOptionsDiagnostics(t){let n=this.getProject(t.projectFileName);return this.convertToDiagnosticsWithLinePosition(_n(n.getLanguageService().getCompilerOptionsDiagnostics(),a=>!a.file),void 0)}convertToDiagnosticsWithLinePosition(t,n){return t.map(a=>({message:wy(a.messageText,this.host.newLine),start:a.start,length:a.length,category:pl(a),code:a.code,source:a.source,startLocation:n&&n.positionToLineOffset(a.start),endLocation:n&&n.positionToLineOffset(a.start+a.length),reportsUnnecessary:a.reportsUnnecessary,reportsDeprecated:a.reportsDeprecated,relatedInformation:gr(a.relatedInformation,Ooe)}))}getDiagnosticsWorker(t,n,a,o){let{project:u,file:f}=this.getFileAndProject(t);if(n&&CZe(u,f))return Vu;let h=u.getScriptInfoForNormalizedPath(f),m=a(u,f);return o?this.convertToDiagnosticsWithLinePosition(m,h):m.map(b=>EZe(f,u,b))}getDefinition(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=this.getPositionInFile(t,a),f=this.mapDefinitionInfoLocations(o.getLanguageService().getDefinitionAtPosition(a,u)||Vu,o);return n?this.mapDefinitionInfo(f,o):f.map(Qme.mapToOriginalLocation)}mapDefinitionInfoLocations(t,n){return t.map(a=>{let o=PZe(a,n);return o?{...o,containerKind:a.containerKind,containerName:a.containerName,kind:a.kind,name:a.name,failedAliasResolution:a.failedAliasResolution,...a.unverified&&{unverified:a.unverified}}:a})}getDefinitionAndBoundSpan(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=this.getPositionInFile(t,a),f=I.checkDefined(o.getScriptInfo(a)),h=o.getLanguageService().getDefinitionAndBoundSpan(a,u);if(!h||!h.definitions)return{definitions:Vu,textSpan:void 0};let m=this.mapDefinitionInfoLocations(h.definitions,o),{textSpan:b}=h;return n?{definitions:this.mapDefinitionInfo(m,o),textSpan:Ny(b,f)}:{definitions:m.map(Qme.mapToOriginalLocation),textSpan:b}}findSourceDefinition(t){var n;let{file:a,project:o}=this.getFileAndProject(t),u=this.getPositionInFile(t,a),f=o.getLanguageService().getDefinitionAtPosition(a,u),h=this.mapDefinitionInfoLocations(f||Vu,o).slice();if(this.projectService.serverMode===0&&(!Nt(h,P=>Jc(P.fileName)!==a&&!P.isAmbient)||Nt(h,P=>!!P.failedAliasResolution))){let P=pD(U=>U.textSpan.start,Qie(this.host.useCaseSensitiveFileNames));h?.forEach(U=>P.add(U));let O=o.getNoDtsResolutionProject(a),R=O.getLanguageService(),M=(n=R.getDefinitionAtPosition(a,u,!0,!1))==null?void 0:n.filter(U=>Jc(U.fileName)!==a);if(Nt(M))for(let U of M){if(U.unverified){let z=D(U,o.getLanguageService().getProgram(),R.getProgram());if(Nt(z)){for(let W of z)P.add(W);continue}}P.add(U)}else{let U=h.filter(z=>Jc(z.fileName)!==a&&z.isAmbient);for(let z of Nt(U)?U:T()){let W=b(z.fileName,a,O);if(!W)continue;let Q=this.projectService.getOrCreateScriptInfoNotOpenedByClient(W,O.currentDirectory,O.directoryStructureHost,!1);if(!Q)continue;O.containsScriptInfo(Q)||(O.addRoot(Q),O.updateGraph());let Z=R.getProgram(),le=I.checkDefined(Z.getSourceFile(W));for(let ie of A(z.name,le,Z))P.add(ie)}}h=Js(P.values())}return h=h.filter(P=>!P.isAmbient&&!P.failedAliasResolution),this.mapDefinitionInfo(h,o);function b(P,O,R){var M,U,z;let W=DW(P);if(W&&P.lastIndexOf(C1)===W.topLevelNodeModulesIndex){let Q=P.substring(0,W.packageRootIndex),Z=(M=o.getModuleResolutionCache())==null?void 0:M.getPackageJsonInfoCache(),le=o.getCompilationSettings(),ie=Y8($s(Q,o.getCurrentDirectory()),H8(Z,o,le));if(!ie)return;let re=gre(ie,{moduleResolution:2},o,o.getModuleResolutionCache()),Se=P.substring(W.topLevelPackageNameIndex+1,W.packageRootIndex),pe=Q8(fL(Se)),oe=o.toPath(P);if(re&&Nt(re,Ee=>o.toPath(Ee)===oe))return(U=R.resolutionCache.resolveSingleModuleNameWithoutWatching(pe,O).resolvedModule)==null?void 0:U.resolvedFileName;{let Ee=P.substring(W.packageRootIndex+1),ge=`${pe}/${Q_(Ee)}`;return(z=R.resolutionCache.resolveSingleModuleNameWithoutWatching(ge,O).resolvedModule)==null?void 0:z.resolvedFileName}}}function T(){let P=o.getLanguageService(),O=P.getProgram(),R=xp(O.getSourceFile(a),u);return(Qo(R)||Xe(R))&&Sc(R.parent)&&a0e(R,M=>{var U;if(M===R)return;let z=(U=P.getDefinitionAtPosition(a,M.getStart(),!0,!1))==null?void 0:U.filter(W=>Jc(W.fileName)!==a&&W.isAmbient).map(W=>({fileName:W.fileName,name:mh(R)}));if(Nt(z))return z})||Vu}function D(P,O,R){var M;let U=R.getSourceFile(P.fileName);if(!U)return;let z=xp(O.getSourceFile(a),u),W=O.getTypeChecker().getSymbolAtLocation(z),Q=W&&Bc(W,276);if(!Q)return;let Z=((M=Q.propertyName)==null?void 0:M.text)||Q.name.text;return A(Z,U,R)}function A(P,O,R){let M=Dc.Core.getTopMostDeclarationNamesInFile(P,O);return ls(M,U=>{let z=R.getTypeChecker().getSymbolAtLocation(U),W=$F(U);if(z&&W)return _4.createDefinitionInfo(W,R.getTypeChecker(),z,W,!0)})}}getEmitOutput(t){let{file:n,project:a}=this.getFileAndProject(t);if(!a.shouldEmitFile(a.getScriptInfo(n)))return{emitSkipped:!0,outputFiles:[],diagnostics:[]};let o=a.getLanguageService().getEmitOutput(n);return t.richResponse?{...o,diagnostics:t.includeLinePosition?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(o.diagnostics):o.diagnostics.map(u=>zM(u,!0))}:o}mapJSDocTagInfo(t,n,a){return t?t.map(o=>{var u;return{...o,text:a?this.mapDisplayParts(o.text,n):(u=o.text)==null?void 0:u.map(f=>f.text).join("")}}):[]}mapDisplayParts(t,n){return t?t.map(a=>a.kind!=="linkName"?a:{...a,target:this.toFileSpan(a.target.fileName,a.target.textSpan,n)}):[]}mapSignatureHelpItems(t,n,a){return t.map(o=>({...o,documentation:this.mapDisplayParts(o.documentation,n),parameters:o.parameters.map(u=>({...u,documentation:this.mapDisplayParts(u.documentation,n)})),tags:this.mapJSDocTagInfo(o.tags,n,a)}))}mapDefinitionInfo(t,n){return t.map(a=>({...this.toFileSpanWithContext(a.fileName,a.textSpan,a.contextSpan,n),...a.unverified&&{unverified:a.unverified}}))}static mapToOriginalLocation(t){return t.originalFileName?(I.assert(t.originalTextSpan!==void 0,"originalTextSpan should be present if originalFileName is"),{...t,fileName:t.originalFileName,textSpan:t.originalTextSpan,targetFileName:t.fileName,targetTextSpan:t.textSpan,contextSpan:t.originalContextSpan,targetContextSpan:t.contextSpan}):t}toFileSpan(t,n,a){let o=a.getLanguageService(),u=o.toLineColumnOffset(t,n.start),f=o.toLineColumnOffset(t,tl(n));return{file:t,start:{line:u.line+1,offset:u.character+1},end:{line:f.line+1,offset:f.character+1}}}toFileSpanWithContext(t,n,a,o){let u=this.toFileSpan(t,n,o),f=a&&this.toFileSpan(t,a,o);return f?{...u,contextStart:f.start,contextEnd:f.end}:u}getTypeDefinition(t){let{file:n,project:a}=this.getFileAndProject(t),o=this.getPositionInFile(t,n),u=this.mapDefinitionInfoLocations(a.getLanguageService().getTypeDefinitionAtPosition(n,o)||Vu,a);return this.mapDefinitionInfo(u,a)}mapImplementationLocations(t,n){return t.map(a=>{let o=PZe(a,n);return o?{...o,kind:a.kind,displayParts:a.displayParts}:a})}getImplementation(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=this.getPositionInFile(t,a),f=this.mapImplementationLocations(o.getLanguageService().getImplementationAtPosition(a,u)||Vu,o);return n?f.map(({fileName:h,textSpan:m,contextSpan:b})=>this.toFileSpanWithContext(h,m,b,o)):f.map(Qme.mapToOriginalLocation)}getSyntacticDiagnosticsSync(t){let{configFile:n}=this.getConfigFileAndProject(t);return n?Vu:this.getDiagnosticsWorker(t,!1,(a,o)=>a.getLanguageService().getSyntacticDiagnostics(o),!!t.includeLinePosition)}getSemanticDiagnosticsSync(t){let{configFile:n,project:a}=this.getConfigFileAndProject(t);return n?this.getConfigFileDiagnostics(n,a,!!t.includeLinePosition):this.getDiagnosticsWorker(t,!0,(o,u)=>o.getLanguageService().getSemanticDiagnostics(u).filter(f=>!!f.file),!!t.includeLinePosition)}getSuggestionDiagnosticsSync(t){let{configFile:n}=this.getConfigFileAndProject(t);return n?Vu:this.getDiagnosticsWorker(t,!0,(a,o)=>a.getLanguageService().getSuggestionDiagnostics(o),!!t.includeLinePosition)}getJsxClosingTag(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.getPositionInFile(t,n),u=a.getJsxClosingTagAtPosition(n,o);return u===void 0?void 0:{newText:u.newText,caretOffset:0}}getLinkedEditingRange(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.getPositionInFile(t,n),u=a.getLinkedEditingRangeAtPosition(n,o),f=this.projectService.getScriptInfoForNormalizedPath(n);if(!(f===void 0||u===void 0))return J$t(u,f)}getDocumentHighlights(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=this.getPositionInFile(t,a),f=o.getLanguageService().getDocumentHighlights(a,u,t.filesToSearch);return f?n?f.map(({fileName:h,highlightSpans:m})=>{let b=o.getScriptInfo(h);return{file:h,highlightSpans:m.map(({textSpan:T,kind:D,contextSpan:A})=>({...Gwe(T,A,b),kind:D}))}}):f:Vu}provideInlayHints(t){let{file:n,project:a}=this.getFileAndProject(t),o=this.projectService.getScriptInfoForNormalizedPath(n);return a.getLanguageService().provideInlayHints(n,t,this.getPreferences(n)).map(f=>{let{position:h,displayParts:m}=f;return{...f,position:o.positionToLineOffset(h),displayParts:m?.map(({text:b,span:T,file:D})=>{if(T){I.assertIsDefined(D,"Target file should be defined together with its span.");let A=this.projectService.getScriptInfo(D);return{text:b,span:{start:A.positionToLineOffset(T.start),end:A.positionToLineOffset(T.start+T.length),file:D}}}else return{text:b}})}})}mapCode(t){var n;let a=this.getHostFormatOptions(),o=this.getHostPreferences(),{file:u,languageService:f}=this.getFileAndLanguageServiceForSyntacticOperation(t),h=this.projectService.getScriptInfoForNormalizedPath(u),m=(n=t.mapping.focusLocations)==null?void 0:n.map(T=>T.map(D=>{let A=h.lineOffsetToPosition(D.start.line,D.start.offset),P=h.lineOffsetToPosition(D.end.line,D.end.offset);return{start:A,length:P-A}})),b=f.mapCode(u,t.mapping.contents,m,a,o);return this.mapTextChangesToCodeEdits(b)}setCompilerOptionsForInferredProjects(t){this.projectService.setCompilerOptionsForInferredProjects(t.options,t.projectRootPath)}getProjectInfo(t){return this.getProjectInfoWorker(t.file,t.projectFileName,t.needFileNameList,!1)}getProjectInfoWorker(t,n,a,o){let{project:u}=this.getFileAndProjectWorker(t,n);return Vm(u),{configFileName:u.getProjectName(),languageServiceDisabled:!u.languageServiceEnabled,fileNames:a?u.getFileNames(!1,o):void 0}}getRenameInfo(t){let{file:n,project:a}=this.getFileAndProject(t),o=this.getPositionInFile(t,n),u=this.getPreferences(n);return a.getLanguageService().getRenameInfo(n,o,u)}getProjects(t,n,a){let o,u;if(t.projectFileName){let f=this.getProject(t.projectFileName);f&&(o=[f])}else{let f=n?this.projectService.getScriptInfoEnsuringProjectsUptoDate(t.file):this.projectService.getScriptInfo(t.file);if(f)n||this.projectService.ensureDefaultProjectForFile(f);else return a?Vu:(this.projectService.logErrorForScriptInfoNotFound(t.file),Rv.ThrowNoProject());o=f.containingProjects,u=this.projectService.getSymlinkedProjects(f)}return o=_n(o,f=>f.languageServiceEnabled&&!f.isOrphan()),!a&&(!o||!o.length)&&!u?(this.projectService.logErrorForScriptInfoNotFound(t.file??t.projectFileName),Rv.ThrowNoProject()):u?{projects:o,symLinkedProjects:u}:o}getDefaultProject(t){if(t.projectFileName){let a=this.getProject(t.projectFileName);if(a)return a;if(!t.file)return Rv.ThrowNoProject()}return this.projectService.getScriptInfo(t.file).getDefaultProject()}getRenameLocations(t,n){let a=Jc(t.file),o=this.getPositionInFile(t,a),u=this.getProjects(t),f=this.getDefaultProject(t),h=this.getPreferences(a),m=this.mapRenameInfo(f.getLanguageService().getRenameInfo(a,o,h),I.checkDefined(this.projectService.getScriptInfo(a)));if(!m.canRename)return n?{info:m,locs:[]}:[];let b=F$t(u,f,{fileName:t.file,pos:o},!!t.findInStrings,!!t.findInComments,h,this.host.useCaseSensitiveFileNames);return n?{info:m,locs:this.toSpanGroups(b)}:b}mapRenameInfo(t,n){if(t.canRename){let{canRename:a,fileToRename:o,displayName:u,fullDisplayName:f,kind:h,kindModifiers:m,triggerSpan:b}=t;return{canRename:a,fileToRename:o,displayName:u,fullDisplayName:f,kind:h,kindModifiers:m,triggerSpan:Ny(b,n)}}else return t}toSpanGroups(t){let n=new Map;for(let{fileName:a,textSpan:o,contextSpan:u,originalContextSpan:f,originalTextSpan:h,originalFileName:m,...b}of t){let T=n.get(a);T||n.set(a,T={file:a,locs:[]});let D=I.checkDefined(this.projectService.getScriptInfo(a));T.locs.push({...Gwe(o,u,D),...b})}return Js(n.values())}getReferences(t,n){let a=Jc(t.file),o=this.getProjects(t),u=this.getPositionInFile(t,a),f=R$t(o,this.getDefaultProject(t),{fileName:t.file,pos:u},this.host.useCaseSensitiveFileNames,this.logger);if(!n)return f;let h=this.getPreferences(a),m=this.getDefaultProject(t),b=m.getScriptInfoForNormalizedPath(a),T=m.getLanguageService().getQuickInfoAtPosition(a,u),D=T?dM(T.displayParts):"",A=T&&T.textSpan,P=A?b.positionToLineOffset(A.start).offset:0,O=A?b.getSnapshot().getText(A.start,tl(A)):"";return{refs:Pa(f,M=>M.references.map(U=>RZe(this.projectService,U,h))),symbolName:O,symbolStartOffset:P,symbolDisplayString:D}}getFileReferences(t,n){let a=this.getProjects(t),o=t.file,u=this.getPreferences(Jc(o)),f=[],h=Roe(this.host.useCaseSensitiveFileNames);return Vwe(a,void 0,b=>{if(b.getCancellationToken().isCancellationRequested())return;let T=b.getLanguageService().getFileReferences(o);if(T)for(let D of T)h.has(D)||(f.push(D),h.add(D))}),n?{refs:f.map(b=>RZe(this.projectService,b,u)),symbolName:`"${t.file}"`}:f}openClientFile(t,n,a,o){this.projectService.openClientFileWithNormalizedPath(t,n,a,!1,o)}getPosition(t,n){return t.position!==void 0?t.position:n.lineOffsetToPosition(t.line,t.offset)}getPositionInFile(t,n){let a=this.projectService.getScriptInfoForNormalizedPath(n);return this.getPosition(t,a)}getFileAndProject(t){return this.getFileAndProjectWorker(t.file,t.projectFileName)}getFileAndLanguageServiceForSyntacticOperation(t){let{file:n,project:a}=this.getFileAndProject(t);return{file:n,languageService:a.getLanguageService(!1)}}getFileAndProjectWorker(t,n){let a=Jc(t),o=this.getProject(n)||this.projectService.ensureDefaultProjectForFile(a);return{file:a,project:o}}getOutliningSpans(t,n){let{file:a,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),u=o.getOutliningSpans(a);if(n){let f=this.projectService.getScriptInfoForNormalizedPath(a);return u.map(h=>({textSpan:Ny(h.textSpan,f),hintSpan:Ny(h.hintSpan,f),bannerText:h.bannerText,autoCollapse:h.autoCollapse,kind:h.kind}))}else return u}getTodoComments(t){let{file:n,project:a}=this.getFileAndProject(t);return a.getLanguageService().getTodoComments(n,t.descriptors)}getDocCommentTemplate(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.getPositionInFile(t,n);return a.getDocCommentTemplateAtPosition(n,o,this.getPreferences(n),this.getFormatOptions(n))}getSpanOfEnclosingComment(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=t.onlyMultiLine,u=this.getPositionInFile(t,n);return a.getSpanOfEnclosingComment(n,u,o)}getIndentation(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.getPositionInFile(t,n),u=t.options?g4(t.options):this.getFormatOptions(n),f=a.getIndentationAtPosition(n,o,u);return{position:o,indentation:f}}getBreakpointStatement(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.getPositionInFile(t,n);return a.getBreakpointStatementAtPosition(n,o)}getNameOrDottedNameSpan(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.getPositionInFile(t,n);return a.getNameOrDottedNameSpan(n,o,o)}isValidBraceCompletion(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.getPositionInFile(t,n);return a.isValidBraceCompletionAtPosition(n,o,t.openingBrace.charCodeAt(0))}getQuickInfoWorker(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=this.projectService.getScriptInfoForNormalizedPath(a),f=o.getLanguageService().getQuickInfoAtPosition(a,this.getPosition(t,u));if(!f)return;let h=!!this.getPreferences(a).displayPartsForJSDoc;if(n){let m=dM(f.displayParts);return{kind:f.kind,kindModifiers:f.kindModifiers,start:u.positionToLineOffset(f.textSpan.start),end:u.positionToLineOffset(tl(f.textSpan)),displayString:m,documentation:h?this.mapDisplayParts(f.documentation,o):dM(f.documentation),tags:this.mapJSDocTagInfo(f.tags,o,h)}}else return h?f:{...f,tags:this.mapJSDocTagInfo(f.tags,o,!1)}}getFormattingEditsForRange(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(n),u=o.lineOffsetToPosition(t.line,t.offset),f=o.lineOffsetToPosition(t.endLine,t.endOffset),h=a.getFormattingEditsForRange(n,u,f,this.getFormatOptions(n));if(h)return h.map(m=>this.convertTextChangeToCodeEdit(m,o))}getFormattingEditsForRangeFull(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=t.options?g4(t.options):this.getFormatOptions(n);return a.getFormattingEditsForRange(n,t.position,t.endPosition,o)}getFormattingEditsForDocumentFull(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=t.options?g4(t.options):this.getFormatOptions(n);return a.getFormattingEditsForDocument(n,o)}getFormattingEditsAfterKeystrokeFull(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=t.options?g4(t.options):this.getFormatOptions(n);return a.getFormattingEditsAfterKeystroke(n,t.position,t.key,o)}getFormattingEditsAfterKeystroke(t){let{file:n,languageService:a}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(n),u=o.lineOffsetToPosition(t.line,t.offset),f=this.getFormatOptions(n),h=a.getFormattingEditsAfterKeystroke(n,u,t.key,f);if(t.key===`
|
|
606
606
|
`&&(!h||h.length===0||P$t(h,u))){let{lineText:m,absolutePosition:b}=o.textStorage.getAbsolutePositionAndLineText(t.line);if(m&&m.search("\\S")<0){let T=a.getIndentationAtPosition(n,u,f),D=0,A,P;for(A=0,P=m.length;A<P;A++)if(m.charAt(A)===" ")D++;else if(m.charAt(A)===" ")D+=f.tabSize;else break;if(T!==D){let O=b+A;h.push({span:Pl(b,O),newText:hu.getIndentationString(T,f)})}}}if(h)return h.map(m=>({start:o.positionToLineOffset(m.span.start),end:o.positionToLineOffset(tl(m.span)),newText:m.newText?m.newText:""}))}getCompletions(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=this.projectService.getScriptInfoForNormalizedPath(a),f=this.getPosition(t,u),h=o.getLanguageService().getCompletionsAtPosition(a,f,{...Pwe(this.getPreferences(a)),triggerCharacter:t.triggerCharacter,triggerKind:t.triggerKind,includeExternalModuleExports:t.includeExternalModuleExports,includeInsertTextCompletions:t.includeInsertTextCompletions},o.projectService.getFormatCodeOptions(a));if(h===void 0)return;if(n==="completions-full")return h;let m=t.prefix||"",b=ls(h.entries,D=>{if(h.isMemberCompletion||Ss(D.name.toLowerCase(),m.toLowerCase())){let A=D.replacementSpan?Ny(D.replacementSpan,u):void 0;return{...D,replacementSpan:A,hasAction:D.hasAction||void 0,symbol:void 0}}});return n==="completions"?(h.metadata&&(b.metadata=h.metadata),b):{...h,optionalReplacementSpan:h.optionalReplacementSpan&&Ny(h.optionalReplacementSpan,u),entries:b}}getCompletionEntryDetails(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=this.projectService.getScriptInfoForNormalizedPath(a),f=this.getPosition(t,u),h=o.projectService.getFormatCodeOptions(a),m=!!this.getPreferences(a).displayPartsForJSDoc,b=ls(t.entryNames,T=>{let{name:D,source:A,data:P}=typeof T=="string"?{name:T,source:void 0,data:void 0}:T;return o.getLanguageService().getCompletionEntryDetails(a,f,D,h,A,this.getPreferences(a),P?va(P,V$t):void 0)});return n?m?b:b.map(T=>({...T,tags:this.mapJSDocTagInfo(T.tags,o,!1)})):b.map(T=>({...T,codeActions:gr(T.codeActions,D=>this.mapCodeAction(D)),documentation:this.mapDisplayParts(T.documentation,o),tags:this.mapJSDocTagInfo(T.tags,o,m)}))}getCompileOnSaveAffectedFileList(t){let n=this.getProjects(t,!0,!0),a=this.projectService.getScriptInfo(t.file);return a?I$t(a,o=>this.projectService.getScriptInfoForPath(o),n,(o,u)=>{if(!o.compileOnSaveEnabled||!o.languageServiceEnabled||o.isOrphan())return;let f=o.getCompilationSettings();if(!(f.noEmit||pf(u.fileName)&&!A$t(f)))return{projectFileName:o.getProjectName(),fileNames:o.getCompileOnSaveAffectedFileList(u),projectUsesOutFile:!!f.outFile}}):Vu}emitFile(t){let{file:n,project:a}=this.getFileAndProject(t);if(a||Rv.ThrowNoProject(),!a.languageServiceEnabled)return t.richResponse?{emitSkipped:!0,diagnostics:[]}:!1;let o=a.getScriptInfo(n),{emitSkipped:u,diagnostics:f}=a.emitFile(o,(h,m,b)=>this.host.writeFile(h,m,b));return t.richResponse?{emitSkipped:u,diagnostics:t.includeLinePosition?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(f):f.map(h=>zM(h,!0))}:!u}getSignatureHelpItems(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=this.projectService.getScriptInfoForNormalizedPath(a),f=this.getPosition(t,u),h=o.getLanguageService().getSignatureHelpItems(a,f,t),m=!!this.getPreferences(a).displayPartsForJSDoc;if(h&&n){let b=h.applicableSpan;return{...h,applicableSpan:{start:u.positionToLineOffset(b.start),end:u.positionToLineOffset(b.start+b.length)},items:this.mapSignatureHelpItems(h.items,o,m)}}else return m||!h?h:{...h,items:h.items.map(b=>({...b,tags:this.mapJSDocTagInfo(b.tags,o,!1)}))}}toPendingErrorCheck(t){let n=Jc(t),a=this.projectService.tryGetDefaultProjectForFile(n);return a&&{fileName:n,project:a}}getDiagnostics(t,n,a){this.suppressDiagnosticEvents||a.length>0&&this.updateErrorCheck(t,a,n)}change(t){let n=this.projectService.getScriptInfo(t.file);I.assert(!!n),n.textStorage.switchToScriptVersionCache();let a=n.lineOffsetToPosition(t.line,t.offset),o=n.lineOffsetToPosition(t.endLine,t.endOffset);a>=0&&(this.changeSeq++,this.projectService.applyChangesToFile(n,rT({span:{start:a,length:o-a},newText:t.insertString})))}reload(t){let n=Jc(t.file),a=t.tmpfile===void 0?void 0:Jc(t.tmpfile),o=this.projectService.getScriptInfoForNormalizedPath(n);o&&(this.changeSeq++,o.reloadFromFile(a))}saveToTmp(t,n){let a=this.projectService.getScriptInfo(t);a&&a.saveTo(n)}closeClientFile(t){if(!t)return;let n=Ca(t);this.projectService.closeClientFile(n)}mapLocationNavigationBarItems(t,n){return gr(t,a=>({text:a.text,kind:a.kind,kindModifiers:a.kindModifiers,spans:a.spans.map(o=>Ny(o,n)),childItems:this.mapLocationNavigationBarItems(a.childItems,n),indent:a.indent}))}getNavigationBarItems(t,n){let{file:a,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),u=o.getNavigationBarItems(a);return u?n?this.mapLocationNavigationBarItems(u,this.projectService.getScriptInfoForNormalizedPath(a)):u:void 0}toLocationNavigationTree(t,n){return{text:t.text,kind:t.kind,kindModifiers:t.kindModifiers,spans:t.spans.map(a=>Ny(a,n)),nameSpan:t.nameSpan&&Ny(t.nameSpan,n),childItems:gr(t.childItems,a=>this.toLocationNavigationTree(a,n))}}getNavigationTree(t,n){let{file:a,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),u=o.getNavigationTree(a);return u?n?this.toLocationNavigationTree(u,this.projectService.getScriptInfoForNormalizedPath(a)):u:void 0}getNavigateToItems(t,n){let a=this.getFullNavigateToItems(t);return n?Pa(a,({project:o,navigateToItems:u})=>u.map(f=>{let h=o.getScriptInfo(f.fileName),m={name:f.name,kind:f.kind,kindModifiers:f.kindModifiers,isCaseSensitive:f.isCaseSensitive,matchKind:f.matchKind,file:f.fileName,start:h.positionToLineOffset(f.textSpan.start),end:h.positionToLineOffset(tl(f.textSpan))};return f.kindModifiers&&f.kindModifiers!==""&&(m.kindModifiers=f.kindModifiers),f.containerName&&f.containerName.length>0&&(m.containerName=f.containerName),f.containerKind&&f.containerKind.length>0&&(m.containerKind=f.containerKind),m})):Pa(a,({navigateToItems:o})=>o)}getFullNavigateToItems(t){let{currentFileOnly:n,searchValue:a,maxResultCount:o,projectFileName:u}=t;if(n){I.assertIsDefined(t.file);let{file:A,project:P}=this.getFileAndProject(t);return[{project:P,navigateToItems:P.getLanguageService().getNavigateToItems(a,o,A)}]}let f=this.getHostPreferences(),h=[],m=new Map;if(!t.file&&!u)this.projectService.loadAncestorProjectTree(),this.projectService.forEachEnabledProject(A=>b(A));else{let A=this.getProjects(t);Vwe(A,void 0,P=>b(P))}return h;function b(A){let P=A.getLanguageService().getNavigateToItems(a,o,void 0,A.isNonTsProject(),f.excludeLibrarySymbolsInNavTo),O=_n(P,R=>T(R)&&!Loe(BO(R),A));O.length&&h.push({project:A,navigateToItems:O})}function T(A){let P=A.name;if(!m.has(P))return m.set(P,[A]),!0;let O=m.get(P);for(let R of O)if(D(R,A))return!1;return O.push(A),!0}function D(A,P){return A===P?!0:!A||!P?!1:A.containerKind===P.containerKind&&A.containerName===P.containerName&&A.fileName===P.fileName&&A.isCaseSensitive===P.isCaseSensitive&&A.kind===P.kind&&A.kindModifiers===P.kindModifiers&&A.matchKind===P.matchKind&&A.name===P.name&&A.textSpan.start===P.textSpan.start&&A.textSpan.length===P.textSpan.length}}getSupportedCodeFixes(t){if(!t)return rae();if(t.file){let{file:a,project:o}=this.getFileAndProject(t);return o.getLanguageService().getSupportedCodeFixes(a)}let n=this.getProject(t.projectFileName);return n||Rv.ThrowNoProject(),n.getLanguageService().getSupportedCodeFixes()}isLocation(t){return t.line!==void 0}extractPositionOrRange(t,n){let a,o;return this.isLocation(t)?a=u(t):o=this.getRange(t,n),I.checkDefined(a===void 0?o:a);function u(f){return f.position!==void 0?f.position:n.lineOffsetToPosition(f.line,f.offset)}}getRange(t,n){let{startPosition:a,endPosition:o}=this.getStartAndEndPosition(t,n);return{pos:a,end:o}}getApplicableRefactors(t){let{file:n,project:a}=this.getFileAndProject(t),o=a.getScriptInfoForNormalizedPath(n);return a.getLanguageService().getApplicableRefactors(n,this.extractPositionOrRange(t,o),this.getPreferences(n),t.triggerReason,t.kind,t.includeInteractiveActions).map(f=>({...f,actions:f.actions.map(h=>({...h,range:h.range?{start:y4({line:h.range.start.line,character:h.range.start.offset}),end:y4({line:h.range.end.line,character:h.range.end.offset})}:void 0}))}))}getEditsForRefactor(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=o.getScriptInfoForNormalizedPath(a),f=o.getLanguageService().getEditsForRefactor(a,this.getFormatOptions(a),this.extractPositionOrRange(t,u),t.refactor,t.action,this.getPreferences(a),t.interactiveRefactorArguments);if(f===void 0)return{edits:[]};if(n){let{renameFilename:h,renameLocation:m,edits:b}=f,T;if(h!==void 0&&m!==void 0){let D=o.getScriptInfoForNormalizedPath(Jc(h));T=Hwe(N6(D.getSnapshot()),h,m,b)}return{renameLocation:T,renameFilename:h,edits:this.mapTextChangesToCodeEdits(b),notApplicableReason:f.notApplicableReason}}return f}getMoveToRefactoringFileSuggestions(t){let{file:n,project:a}=this.getFileAndProject(t),o=a.getScriptInfoForNormalizedPath(n);return a.getLanguageService().getMoveToRefactoringFileSuggestions(n,this.extractPositionOrRange(t,o),this.getPreferences(n))}getPasteEdits(t){let{file:n,project:a}=this.getFileAndProject(t),o=t.copiedFrom?{file:t.copiedFrom.file,range:t.copiedFrom.spans.map(f=>this.getRange({file:t.copiedFrom.file,startLine:f.start.line,startOffset:f.start.offset,endLine:f.end.line,endOffset:f.end.offset},a.getScriptInfoForNormalizedPath(Jc(t.copiedFrom.file))))}:void 0,u=a.getLanguageService().getPasteEdits({targetFile:n,pastedText:t.pastedText,pasteLocations:t.pasteLocations.map(f=>this.getRange({file:n,startLine:f.start.line,startOffset:f.start.offset,endLine:f.end.line,endOffset:f.end.offset},a.getScriptInfoForNormalizedPath(n))),copiedFrom:o,preferences:this.getPreferences(n)},this.getFormatOptions(n));return u&&this.mapPasteEditsAction(u)}organizeImports(t,n){I.assert(t.scope.type==="file");let{file:a,project:o}=this.getFileAndProject(t.scope.args),u=o.getLanguageService().organizeImports({fileName:a,mode:t.mode??(t.skipDestructiveCodeActions?"SortAndCombine":void 0),type:"file"},this.getFormatOptions(a),this.getPreferences(a));return n?this.mapTextChangesToCodeEdits(u):u}getEditsForFileRename(t,n){let a=Jc(t.oldFilePath),o=Jc(t.newFilePath),u=this.getHostFormatOptions(),f=this.getHostPreferences(),h=new Set,m=[];return this.projectService.loadAncestorProjectTree(),this.projectService.forEachEnabledProject(b=>{let T=b.getLanguageService().getEditsForFileRename(a,o,u,f),D=[];for(let A of T)h.has(A.fileName)||(m.push(A),D.push(A.fileName));for(let A of D)h.add(A)}),n?m.map(b=>this.mapTextChangeToCodeEdit(b)):m}getCodeFixes(t,n){let{file:a,project:o}=this.getFileAndProject(t),u=o.getScriptInfoForNormalizedPath(a),{startPosition:f,endPosition:h}=this.getStartAndEndPosition(t,u),m;try{m=o.getLanguageService().getCodeFixesAtPosition(a,f,h,t.errorCodes,this.getFormatOptions(a),this.getPreferences(a))}catch(b){let T=o.getLanguageService(),D=[...T.getSyntacticDiagnostics(a),...T.getSemanticDiagnostics(a),...T.getSuggestionDiagnostics(a)].map(P=>aR(f,h-f,P.start,P.length)&&P.code),A=t.errorCodes.find(P=>!D.includes(P));throw A!==void 0&&(b.message=`BADCLIENT: Bad error code, ${A} not found in range ${f}..${h} (found: ${D.join(", ")}); could have caused this error:
|
|
607
607
|
${b.message}`),b}return n?m.map(b=>this.mapCodeFixAction(b)):m}getCombinedCodeFix({scope:t,fixId:n},a){I.assert(t.type==="file");let{file:o,project:u}=this.getFileAndProject(t.args),f=u.getLanguageService().getCombinedCodeFix({type:"file",fileName:o},n,this.getFormatOptions(o),this.getPreferences(o));return a?{changes:this.mapTextChangesToCodeEdits(f.changes),commands:f.commands}:f}applyCodeActionCommand(t){let n=t.command;for(let a of n1(n)){let{file:o,project:u}=this.getFileAndProject(a);u.getLanguageService().applyCodeActionCommand(a,this.getFormatOptions(o)).then(f=>{},f=>{})}return{}}getStartAndEndPosition(t,n){let a,o;return t.startPosition!==void 0?a=t.startPosition:(a=n.lineOffsetToPosition(t.startLine,t.startOffset),t.startPosition=a),t.endPosition!==void 0?o=t.endPosition:(o=n.lineOffsetToPosition(t.endLine,t.endOffset),t.endPosition=o),{startPosition:a,endPosition:o}}mapCodeAction({description:t,changes:n,commands:a}){return{description:t,changes:this.mapTextChangesToCodeEdits(n),commands:a}}mapCodeFixAction({fixName:t,description:n,changes:a,commands:o,fixId:u,fixAllDescription:f}){return{fixName:t,description:n,changes:this.mapTextChangesToCodeEdits(a),commands:o,fixId:u,fixAllDescription:f}}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),I.fail("Expected isNewFile for (only) new files. "+JSON.stringify({isNewFile:!!t.isNewFile,hasScriptInfo:!!n}))),n?{fileName:t.fileName,textChanges:t.textChanges.map(a=>q$t(a,n))}:W$t(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:a,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),u=this.projectService.getScriptInfoForNormalizedPath(a),f=this.getPosition(t,u),h=o.getBraceMatchingAtPosition(a,f);return h?n?h.map(m=>Ny(m,u)):h:void 0}getDiagnosticsForProject(t,n,a){if(this.suppressDiagnosticEvents)return;let{fileNames:o,languageServiceDisabled:u}=this.getProjectInfoWorker(a,void 0,!0,!0);if(u)return;let f=o.filter(R=>!R.includes("lib.d.ts"));if(f.length===0)return;let h=[],m=[],b=[],T=[],D=Jc(a),A=this.projectService.ensureDefaultProjectForFile(D);for(let R of f)this.getCanonicalFileName(R)===this.getCanonicalFileName(a)?h.push(R):this.projectService.getScriptInfo(R).isScriptOpen()?m.push(R):pf(R)?T.push(R):b.push(R);let O=[...h,...m,...b,...T].map(R=>({fileName:R,project:A}));this.updateErrorCheck(t,O,n,!1)}configurePlugin(t){this.projectService.configurePlugin(t)}getSmartSelectionRange(t,n){let{locations:a}=t,{file:o,languageService:u}=this.getFileAndLanguageServiceForSyntacticOperation(t),f=I.checkDefined(this.projectService.getScriptInfo(o));return gr(a,h=>{let m=this.getPosition(h,f),b=u.getSmartSelectionRange(o,m);return n?this.mapSelectionRange(b,f):b})}toggleLineComment(t,n){let{file:a,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),u=this.projectService.getScriptInfo(a),f=this.getRange(t,u),h=o.toggleLineComment(a,f);if(n){let m=this.projectService.getScriptInfoForNormalizedPath(a);return h.map(b=>this.convertTextChangeToCodeEdit(b,m))}return h}toggleMultilineComment(t,n){let{file:a,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),u=this.projectService.getScriptInfoForNormalizedPath(a),f=this.getRange(t,u),h=o.toggleMultilineComment(a,f);if(n){let m=this.projectService.getScriptInfoForNormalizedPath(a);return h.map(b=>this.convertTextChangeToCodeEdit(b,m))}return h}commentSelection(t,n){let{file:a,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),u=this.projectService.getScriptInfoForNormalizedPath(a),f=this.getRange(t,u),h=o.commentSelection(a,f);if(n){let m=this.projectService.getScriptInfoForNormalizedPath(a);return h.map(b=>this.convertTextChangeToCodeEdit(b,m))}return h}uncommentSelection(t,n){let{file:a,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),u=this.projectService.getScriptInfoForNormalizedPath(a),f=this.getRange(t,u),h=o.uncommentSelection(a,f);if(n){let m=this.projectService.getScriptInfoForNormalizedPath(a);return h.map(b=>this.convertTextChangeToCodeEdit(b,m))}return h}mapSelectionRange(t,n){let a={textSpan:Ny(t.textSpan,n)};return t.parent&&(a.parent=this.mapSelectionRange(t.parent,n)),a}getScriptInfoFromProjectService(t){let n=Jc(t),a=this.projectService.getScriptInfoForNormalizedPath(n);return a||(this.projectService.logErrorForScriptInfoNotFound(n),Rv.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:Ny(t.span,n),selectionSpan:Ny(t.selectionSpan,n)}}toProtocolCallHierarchyIncomingCall(t){let n=this.getScriptInfoFromProjectService(t.from.file);return{from:this.toProtocolCallHierarchyItem(t.from),fromSpans:t.fromSpans.map(a=>Ny(a,n))}}toProtocolCallHierarchyOutgoingCall(t,n){return{to:this.toProtocolCallHierarchyItem(t.to),fromSpans:t.fromSpans.map(a=>Ny(a,n))}}prepareCallHierarchy(t){let{file:n,project:a}=this.getFileAndProject(t),o=this.projectService.getScriptInfoForNormalizedPath(n);if(o){let u=this.getPosition(t,o),f=a.getLanguageService().prepareCallHierarchy(n,u);return f&&pse(f,h=>this.toProtocolCallHierarchyItem(h))}}provideCallHierarchyIncomingCalls(t){let{file:n,project:a}=this.getFileAndProject(t),o=this.getScriptInfoFromProjectService(n);return a.getLanguageService().provideCallHierarchyIncomingCalls(n,this.getPosition(t,o)).map(f=>this.toProtocolCallHierarchyIncomingCall(f))}provideCallHierarchyOutgoingCalls(t){let{file:n,project:a}=this.getFileAndProject(t),o=this.getScriptInfoFromProjectService(n);return a.getLanguageService().provideCallHierarchyOutgoingCalls(n,this.getPosition(t,o)).map(f=>this.toProtocolCallHierarchyOutgoingCall(f,o))}getCanonicalFileName(t){let n=this.host.useCaseSensitiveFileNames?t:Nm(t);return Ca(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){I.assert(this.currentRequestId===void 0),this.currentRequestId=t,this.cancellationToken.setRequest(t)}resetCurrentRequest(t){I.assert(this.currentRequestId===t),this.currentRequestId=void 0,this.cancellationToken.resetRequest(t)}executeWithRequestId(t,n,a){let o=this.performanceData;try{return this.performanceData=a,this.setCurrentRequest(t),n()}finally{this.resetCurrentRequest(t),this.performanceData=o}}executeCommand(t){let n=this.handlers.get(t.command);if(n){let a=this.executeWithRequestId(t.seq,()=>n(t),void 0);return this.projectService.enableRequestedPlugins(),a}else return this.logger.msg(`Unrecognized JSON command:${rx(t)}`,"Err"),this.doOutput(void 0,"unknown",t.seq,!1,void 0,`Unrecognized JSON command: ${t.command}`),{responseRequired:!1}}onMessage(t){var n,a,o,u,f,h,m;this.gcTimer.scheduleCollect();let b,T=this.performanceData;this.logger.hasLevel(2)&&(b=this.hrtime(),this.logger.hasLevel(3)&&this.logger.info(`request:${_O(this.toStringMessage(t))}`));let D,A;try{D=this.parseMessage(t),A=D.arguments&&D.arguments.file?D.arguments:void 0,(n=Rn)==null||n.instant(Rn.Phase.Session,"request",{seq:D.seq,command:D.command}),(a=Rn)==null||a.push(Rn.Phase.Session,"executeCommand",{seq:D.seq,command:D.command},!0);let{response:P,responseRequired:O,performanceData:R}=this.executeCommand(D);if((o=Rn)==null||o.pop(),this.logger.hasLevel(2)){let M=k$t(this.hrtime(b)).toFixed(4);O?this.logger.perftrc(`${D.seq}::${D.command}: elapsed time (in milliseconds) ${M}`):this.logger.perftrc(`${D.seq}::${D.command}: async elapsed time (in milliseconds) ${M}`)}(u=Rn)==null||u.instant(Rn.Phase.Session,"response",{seq:D.seq,command:D.command,success:!!P}),P?this.doOutput(P,D.command,D.seq,!0,R):O&&this.doOutput(void 0,D.command,D.seq,!1,R,"No content available.")}catch(P){if((f=Rn)==null||f.popAll(),P instanceof FE){(h=Rn)==null||h.instant(Rn.Phase.Session,"commandCanceled",{seq:D?.seq,command:D?.command}),this.doOutput({canceled:!0},D.command,D.seq,!0,this.performanceData);return}this.logErrorWorker(P,this.toStringMessage(t),A),(m=Rn)==null||m.instant(Rn.Phase.Session,"commandError",{seq:D?.seq,command:D?.command,message:P.message}),this.doOutput(void 0,D?D.command:"unknown",D?D.seq:0,!1,this.performanceData,"Error processing request. "+P.message+`
|
|
608
|
-
`+P.stack)}finally{this.performanceData=T}}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 FZe(e){let t=e.diagnosticsDuration&&Js(e.diagnosticsDuration,([n,a])=>({...a,file:n}));return{...e,diagnosticsDuration:t}}function Ny(e,t){return{start:t.positionToLineOffset(e.start),end:t.positionToLineOffset(tl(e))}}function Gwe(e,t,n){let a=Ny(e,n),o=t&&Ny(t,n);return o?{...a,contextStart:o.start,contextEnd:o.end}:a}function q$t(e,t){return{start:OZe(t,e.span.start),end:OZe(t,tl(e.span)),newText:e.newText}}function OZe(e,t){return qwe(e)?U$t(e.getLineAndCharacterOfPosition(t)):e.positionToLineOffset(t)}function J$t(e,t){let n=e.ranges.map(a=>({start:t.positionToLineOffset(a.start),end:t.positionToLineOffset(a.start+a.length)}));return e.wordPattern?{ranges:n,wordPattern:e.wordPattern}:{ranges:n}}function U$t(e){return{line:e.line+1,offset:e.character+1}}function W$t(e){I.assert(e.textChanges.length===1);let t=La(e.textChanges);return I.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 Hwe(e,t,n,a){let o=z$t(e,t,a),{line:u,character:f}=ON(vA(o),n);return{line:u+1,offset:f+1}}function z$t(e,t,n){for(let{fileName:a,textChanges:o}of n)if(a===t)for(let u=o.length-1;u>=0;u--){let{newText:f,span:{start:h,length:m}}=o[u];e=e.slice(0,h)+f+e.slice(h+m)}return e}function RZe(e,{fileName:t,textSpan:n,contextSpan:a,isWriteAccess:o,isDefinition:u},{disableLineTextInReferences:f}){let h=I.checkDefined(e.getScriptInfo(t)),m=Gwe(n,a,h),b=f?void 0:$$t(h,m);return{file:t,...m,lineText:b,isWriteAccess:o,isDefinition:u}}function $$t(e,t){let n=e.lineToTextSpan(t.start.line-1);return e.getSnapshot().getText(n.start,tl(n)).replace(/\r|\n/g,"")}function V$t(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 v4=4,Ywe=(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))(Ywe||{}),G$t=class{constructor(){this.goSubtree=!0,this.lineIndex=new $M,this.endBranch=[],this.state=2,this.initialText="",this.trailingText="",this.lineIndex.root=new b4,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 a=$M.linesFromText(e).lines;a.length>1&&a[a.length-1]===""&&a.pop();let o,u;for(let h=this.endBranch.length-1;h>=0;h--)this.endBranch[h].updateCounts(),this.endBranch[h].charCount()===0&&(u=this.endBranch[h],h>0?o=this.endBranch[h-1]:o=this.branchNode);u&&o.remove(u);let f=this.startPath[this.startPath.length-1];if(a.length>0)if(f.text=a[0],a.length>1){let h=new Array(a.length-1),m=f;for(let D=1;D<a.length;D++)h[D-1]=new pG(a[D]);let b=this.startPath.length-2;for(;b>=0;){let D=this.startPath[b];h=D.insertAt(m,h),b--,m=D}let T=h.length;for(;T>0;){let D=new b4;D.add(this.lineIndex.root),h=D.insertAt(this.lineIndex.root,h),T=h.length,this.lineIndex.root=D}this.lineIndex.root.updateCounts()}else for(let h=this.startPath.length-2;h>=0;h--)this.startPath[h].updateCounts();else{this.startPath[this.startPath.length-2].remove(f);for(let m=this.startPath.length-2;m>=0;m--)this.startPath[m].updateCounts()}return this.lineIndex}post(e,t,n){n===this.lineCollectionAtBranch&&(this.state=4),this.stack.pop()}pre(e,t,n,a,o){let u=this.stack[this.stack.length-1];this.state===2&&o===1&&(this.state=1,this.branchNode=u,this.lineCollectionAtBranch=n);let f;function h(m){return m.isLeaf()?new pG(""):new b4}switch(o){case 0:this.goSubtree=!1,this.state!==4&&u.add(n);break;case 1:this.state===4?this.goSubtree=!1:(f=h(n),u.add(f),this.startPath.push(f));break;case 2:this.state!==4?(f=h(n),u.add(f),this.startPath.push(f)):n.isLeaf()||(f=h(n),u.add(f),this.endBranch.push(f));break;case 3:this.goSubtree=!1;break;case 4:this.state!==4?this.goSubtree=!1:n.isLeaf()||(f=h(n),u.add(f),this.endBranch.push(f));break;case 5:this.goSubtree=!1,this.state!==1&&u.add(n);break}this.goSubtree&&this.stack.push(f)}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)}},H$t=class{constructor(e,t,n){this.pos=e,this.deleteLen=t,this.insertedText=n}getTextChangeRange(){return oR(Ff(this.pos,this.deleteLen),this.insertedText?this.insertedText.length:0)}},Moe=class Xk{constructor(){this.changes=[],this.versions=new Array(Xk.maxVersions),this.minVersion=0,this.currentVersion=0}versionToIndex(t){if(!(t<this.minVersion||t>this.currentVersion))return t%Xk.maxVersions}currentVersionToIndex(){return this.currentVersion%Xk.maxVersions}edit(t,n,a){this.changes.push(new H$t(t,n,a)),(this.changes.length>Xk.changeNumberThreshold||n>Xk.changeLengthThreshold||a&&a.length>Xk.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 a of this.changes)n=n.edit(a.pos,a.deleteLen,a.insertedText);t=new LZe(this.currentVersion+1,this,n,this.changes),this.currentVersion=t.version,this.versions[this.currentVersionToIndex()]=t,this.changes=[],this.currentVersion-this.minVersion>=Xk.maxVersions&&(this.minVersion=this.currentVersion-Xk.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:a,absolutePosition:o}=n.lineNumberToInfo(t+1),u=a!==void 0?a.length:n.absolutePositionOfStartOfLine(t+2)-o;return Ff(o,u)}getTextChangesBetweenVersions(t,n){if(t<n)if(t>=this.minVersion){let a=[];for(let o=t+1;o<=n;o++){let u=this.versions[this.versionToIndex(o)];for(let f of u.changesSincePreviousVersion)a.push(f.getTextChangeRange())}return Uhe(a)}else return;else return wJ}getLineCount(){return this._getSnapshot().index.getLineCount()}static fromString(t){let n=new Xk,a=new LZe(0,n,new $M);n.versions[n.currentVersion]=a;let o=$M.linesFromText(t);return a.index.load(o.lines),n}};Moe.changeNumberThreshold=8,Moe.changeLengthThreshold=256,Moe.maxVersions=8;var joe=Moe,LZe=class S6t{constructor(t,n,a,o=Vu){this.version=t,this.cache=n,this.index=a,this.changesSincePreviousVersion=o}getText(t,n){return this.index.getText(t,n-t)}getLength(){return this.index.getLength()}getChangeRange(t){if(t instanceof S6t&&this.cache===t.cache)return this.version<=t.version?wJ:this.cache.getTextChangesBetweenVersions(t.version,this.version)}},$M=class m9e{constructor(){this.checkEdits=!1}absolutePositionOfStartOfLine(t){return this.lineNumberToInfo(t).absolutePosition}positionToLineOffset(t){let{oneBasedLine:n,zeroBasedColumn:a}=this.root.charOffsetToLineInfo(1,t);return{line:n,offset:a+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:a,leaf:o}=this.root.lineNumberToInfo(t,0);return{absolutePosition:a,lineText:o&&o.text}}else return{absolutePosition:this.root.charCount(),lineText:void 0}}load(t){if(t.length>0){let n=[];for(let a=0;a<t.length;a++)n[a]=new pG(t[a]);this.root=m9e.buildTreeFromBottom(n)}else this.root=new b4}walk(t,n,a){this.root.walk(t,n,a)}getText(t,n){let a="";return n>0&&t<this.root.charCount()&&this.walk(t,n,{goSubtree:!0,done:!1,leaf:(o,u,f)=>{a=a.concat(f.text.substring(o,o+u))}}),a}getLength(){return this.root.charCount()}every(t,n,a){a||(a=this.root.charCount());let o={goSubtree:!0,done:!1,leaf(u,f,h){t(h,u,f)||(this.done=!0)}};return this.walk(n,a-n,o),!o.done}edit(t,n,a){if(this.root.charCount()===0)return I.assert(n===0),a!==void 0?(this.load(m9e.linesFromText(a).lines),this):void 0;{let o;if(this.checkEdits){let h=this.getText(0,this.root.charCount());o=h.slice(0,t)+a+h.slice(t+n)}let u=new G$t,f=!1;if(t>=this.root.charCount()){t=this.root.charCount()-1;let h=this.getText(t,1);a?a=h+a:a=h,n=0,f=!0}else if(n>0){let h=t+n,{zeroBasedColumn:m,lineText:b}=this.positionToColumnAndLineText(h);m===0&&(n+=b.length,a=a?a+b:b)}if(this.root.walk(t,n,u),u.insertLines(a,f),this.checkEdits){let h=u.lineIndex.getText(0,u.lineIndex.getLength());I.assert(o===h,"buffer edit mismatch")}return u.lineIndex}}static buildTreeFromBottom(t){if(t.length<v4)return new b4(t);let n=new Array(Math.ceil(t.length/v4)),a=0;for(let o=0;o<n.length;o++){let u=Math.min(a+v4,t.length);n[o]=new b4(t.slice(a,u)),a=u}return this.buildTreeFromBottom(n)}static linesFromText(t){let n=vA(t);if(n.length===0)return{lines:[],lineMap:n};let a=new Array(n.length),o=n.length-1;for(let f=0;f<o;f++)a[f]=t.substring(n[f],n[f+1]);let u=t.substring(n[o]);return u.length>0?a[o]=u:a.pop(),{lines:a,lineMap:n}}},b4=class h9e{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,a,o,u){return a.pre&&a.pre(t,n,this.children[o],this,u),a.goSubtree?(this.children[o].walk(t,n,a),a.post&&a.post(t,n,this.children[o],this,u)):a.goSubtree=!0,a.done}skipChild(t,n,a,o,u){o.pre&&!o.done&&(o.pre(t,n,this.children[a],this,u),o.goSubtree=!0)}walk(t,n,a){let o=0,u=this.children[o].charCount(),f=t;for(;f>=u;)this.skipChild(f,n,o,a,0),f-=u,o++,u=this.children[o].charCount();if(f+n<=u){if(this.execWalk(f,n,a,o,2))return}else{if(this.execWalk(f,u-f,a,o,1))return;let h=n-(u-f);for(o++,u=this.children[o].charCount();h>u;){if(this.execWalk(0,u,a,o,3))return;h-=u,o++,u=this.children[o].charCount()}if(h>0&&this.execWalk(0,h,a,o,4))return}if(a.pre){let h=this.children.length;if(o<h-1)for(let m=o+1;m<h;m++)this.skipChild(0,0,m,a,5)}}charOffsetToLineInfo(t,n){if(this.children.length===0)return{oneBasedLine:t,zeroBasedColumn:n,lineText:void 0};for(let u of this.children){if(u.charCount()>n)return u.isLeaf()?{oneBasedLine:t,zeroBasedColumn:n,lineText:u.text}:u.charOffsetToLineInfo(t,n);n-=u.charCount(),t+=u.lineCount()}let a=this.lineCount();if(a===0)return{oneBasedLine:1,zeroBasedColumn:0,lineText:void 0};let o=I.checkDefined(this.lineNumberToInfo(a,0).leaf);return{oneBasedLine:a,zeroBasedColumn:o.charCount(),lineText:void 0}}lineNumberToInfo(t,n){for(let a of this.children){let o=a.lineCount();if(o>=t)return a.isLeaf()?{position:n,leaf:a}:a.lineNumberToInfo(t,n);t-=o,n+=a.charCount()}return{position:n,leaf:void 0}}splitAfter(t){let n,a=this.children.length;t++;let o=t;if(t<a){for(n=new h9e;t<a;)n.add(this.children[t]),t++;n.updateCounts()}return this.children.length=o,n}remove(t){let n=this.findChildIndex(t),a=this.children.length;if(n<a-1)for(let o=n;o<a-1;o++)this.children[o]=this.children[o+1];this.children.pop()}findChildIndex(t){let n=this.children.indexOf(t);return I.assert(n!==-1),n}insertAt(t,n){let a=this.findChildIndex(t),o=this.children.length,u=n.length;if(o<v4&&a===o-1&&u===1)return this.add(n[0]),this.updateCounts(),[];{let f=this.splitAfter(a),h=0;for(a++;a<v4&&h<u;)this.children[a]=n[h],a++,h++;let m=[],b=0;if(h<u){b=Math.ceil((u-h)/v4),m=new Array(b);let T=0;for(let A=0;A<b;A++)m[A]=new h9e;let D=m[0];for(;h<u;)D.add(n[h]),h++,D.children.length===v4&&(T++,D=m[T]);for(let A=m.length-1;A>=0;A--)m[A].children.length===0&&m.pop()}f&&m.push(f),this.updateCounts();for(let T=0;T<b;T++)m[T].updateCounts();return m}}add(t){this.children.push(t),I.assert(this.children.length<=v4)}charCount(){return this.totalChars}lineCount(){return this.totalLines}},pG=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}},MZe=class T6t{constructor(t,n,a,o,u,f){this.telemetryEnabled=t,this.logger=n,this.host=a,this.globalTypingsCacheLocation=o,this.event=u,this.maxActiveRequestCount=f,this.activeRequestCount=0,this.requestQueue=_D(),this.requestMap=new Map,this.requestedRegistry=!1,this.packageInstallId=0}isKnownTypesPackageName(t){var n;return ky.validatePackageName(t)!==ky.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},a=new Promise((o,u)=>{(this.packageInstalledPromise??(this.packageInstalledPromise=new Map)).set(this.packageInstallId,{resolve:o,reject:u})});return this.installer.send(n),a}attach(t){this.projectService=t,this.installer=this.createInstallerProcess()}onProjectClosed(t){this.installer.send({projectName:t.getProjectName(),kind:"closeProject"})}enqueueInstallTypingsRequest(t,n,a){let o=awe(t,n,a);this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling throttled operation:${rx(o)}`),this.activeRequestCount<this.maxActiveRequestCount?this.scheduleRequest(o):(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Deferring request for: ${o.projectName}`),this.requestQueue.enqueue(o),this.requestMap.set(o.projectName,o))}handleMessage(t){var n,a;switch(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Received response:${rx(t)}`),t.kind){case lie:this.typesRegistryCache=new Map(Object.entries(t.typesRegistry));break;case A$:{let o=(n=this.packageInstalledPromise)==null?void 0:n.get(t.id);I.assertIsDefined(o,"Should find the promise for package install"),(a=this.packageInstalledPromise)==null||a.delete(t.id),t.success?o.resolve({successMessage:t.message}):o.reject(t.message),this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case m2e:{let o={message:t.message};this.event(o,"typesInstallerInitializationFailed");break}case uie:{let o={eventId:t.eventId,packages:t.packagesToInstall};this.event(o,"beginInstallTypes");break}case fie:{if(this.telemetryEnabled){let f={telemetryEventName:"typingsInstalled",payload:{installedPackages:t.packagesToInstall.join(","),installSuccess:t.installSuccess,typingsInstallerVersion:t.typingsInstallerVersion}};this.event(f,"telemetry")}let o={eventId:t.eventId,packages:t.packagesToInstall,success:t.installSuccess};this.event(o,"endInstallTypes");break}case k$:{this.projectService.updateTypingsForProject(t);break}case w$:{for(this.activeRequestCount>0?this.activeRequestCount--:I.fail("TIAdapter:: Received too many responses");!this.requestQueue.isEmpty();){let o=this.requestQueue.dequeue();if(this.requestMap.get(o.projectName)===o){this.requestMap.delete(o.projectName),this.scheduleRequest(o);break}this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Skipping defunct request for: ${o.projectName}`)}this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case LL: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:${rx(t)}`),this.installer.send(t)},T6t.requestDelayMillis,`${t.projectName}::${t.kind}`)}};MZe.requestDelayMillis=100;var jZe=MZe,BZe={};x(BZe,{ActionInvalidate:()=>k$,ActionPackageInstalled:()=>A$,ActionSet:()=>w$,ActionWatchTypingLocations:()=>LL,Arguments:()=>_ie,AutoImportProviderProject:()=>Cwe,AuxiliaryProject:()=>xwe,CharRangeSection:()=>Ywe,CloseFileWatcherEvent:()=>woe,CommandNames:()=>wZe,ConfigFileDiagEvent:()=>Toe,ConfiguredProject:()=>Ewe,ConfiguredProjectLoadKind:()=>Iwe,CreateDirectoryWatcherEvent:()=>Eoe,CreateFileWatcherEvent:()=>Coe,Errors:()=>Rv,EventBeginInstallTypes:()=>uie,EventEndInstallTypes:()=>fie,EventInitializationFailed:()=>m2e,EventTypesRegistry:()=>lie,ExternalProject:()=>hoe,GcTimer:()=>pwe,InferredProject:()=>Twe,LargeFileReferencedEvent:()=>Soe,LineIndex:()=>$M,LineLeaf:()=>pG,LineNode:()=>b4,LogLevel:()=>iwe,Msg:()=>swe,OpenFileInfoTelemetryEvent:()=>wwe,Project:()=>$6,ProjectInfoTelemetryEvent:()=>Doe,ProjectKind:()=>BM,ProjectLanguageServiceStateEvent:()=>xoe,ProjectLoadingFinishEvent:()=>boe,ProjectLoadingStartEvent:()=>voe,ProjectService:()=>Bwe,ProjectsUpdatedInBackgroundEvent:()=>uG,ScriptInfo:()=>gwe,ScriptVersionCache:()=>joe,Session:()=>IZe,TextStorage:()=>hwe,ThrottledOperations:()=>_we,TypingsInstallerAdapter:()=>jZe,allFilesAreJsOrDts:()=>vwe,allRootFilesAreJsOrDts:()=>ywe,asNormalizedPath:()=>eZe,convertCompilerOptions:()=>fG,convertFormatOptions:()=>g4,convertScriptKindName:()=>Aoe,convertTypeAcquisition:()=>Awe,convertUserPreferences:()=>Pwe,convertWatchOptions:()=>WM,countEachFileTypes:()=>qM,createInstallTypingsRequest:()=>awe,createModuleSpecifierCache:()=>Uwe,createNormalizedPathMap:()=>tZe,createPackageJsonCache:()=>Wwe,createSortedArray:()=>fwe,emptyArray:()=>Vu,findArgument:()=>ZJe,formatDiagnosticToProtocol:()=>zM,formatMessage:()=>zwe,getBaseConfigFileName:()=>moe,getLocationInNewDocument:()=>Hwe,hasArgument:()=>XJe,hasNoTypeScriptSource:()=>bwe,indent:()=>_O,isBackgroundProject:()=>UM,isConfigFile:()=>qwe,isConfiguredProject:()=>$b,isDynamicFileName:()=>jM,isExternalProject:()=>JM,isInferredProject:()=>h4,isInferredProjectName:()=>owe,isProjectDeferredClose:()=>lG,makeAutoImportProviderProjectName:()=>lwe,makeAuxiliaryProjectName:()=>uwe,makeInferredProjectName:()=>cwe,maxFileSize:()=>yoe,maxProgramSizeForNonTsFiles:()=>goe,normalizedPathToPath:()=>m4,nowString:()=>eUe,nullCancellationToken:()=>DZe,nullTypingsInstaller:()=>_G,protocol:()=>dwe,stringifyIndented:()=>rx,toEvent:()=>$we,toNormalizedPath:()=>Jc,tryConvertScriptKindName:()=>koe,typingsInstaller:()=>nwe,updateProjectIfDirty:()=>Vm}),typeof console<"u"&&(I.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 m6t},set exports(i){m6t=i,typeof Kme<"u"&&Kme.exports&&(Kme.exports=i)}})});var O7r={};Nir(O7r,{default:()=>ahe});module.exports=Iir(O7r);var she=require("@oclif/core"),uPt=xa(Jct());var s3=require("@oclif/core");var aB=xa(require("node:fs")),sY=xa(require("node:path")),$ct=xa(require("node:os"));var Uct=xa(require("node:path")),Wct=xa(require("node:fs"));function Dk(){let i;try{i=Uct.resolve("package.json")}catch(c){throw new Error(`cannot resolve package manifest path: ${c}`)}let s;try{s=JSON.parse(Wct.readFileSync(i,"utf8"))}catch(c){throw new Error(`cannot read package manifest: ${c}`)}return s.name=s.name.replace(/^@workaround/g,""),s}function zct(i){return!!i.owner&&i.access!=="public"}var Ux={production:{url:"https://www.raycast.com",clientID:"KqAdcGhNfBKiUpfjD3nU3VNgh1t0iMPoX2hYEkN9d4I"},staging:{url:"https://www.rayca.st",clientID:"KqAdcGhNfBKiUpfjD3nU3VNgh1t0iMPoX2hYEkN9d4I"},development:{url:"http://localhost:3000",clientID:"rOCD_LhnXFObSLu9v7788qOGu25FZDqEzGjet4Q45ZY"}}[process.env.API_ENV||"production"],kar="e69bae0ec90f5e838555",jh={},gue;function w7(){let i=Dk();if(!i.name)throw new Error("extension name in manifest cannot be empty");return sY.join(oY(),"extensions",i.name)}function Vct(){let i=yue(gue);return i?.startsWith("x")?i==="x"?"com.raycast-x.macos":`com.raycast-x.macos.${i.replace("x-","")}`:i?`com.raycast.macos.${i}`:"com.raycast.macos"}function Gct(){return`raycast${yue(gue)}`}function Hct(i){gue=i;try{jh=JSON.parse(aB.readFileSync(sY.join(oY(),"config.json"),"utf8"))}catch(s){if(s instanceof Error&&s.code==="ENOENT")return;throw new Error(`Failed to read config file: ${s}`)}}function $_(i){switch(i){case"raycastApiURL":return process.env.RAY_APIURL||jh.APIURL||Ux.url;case"raycastAccessToken":return process.env.RAY_TOKEN||jh.Token||jh.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||jh.ClientID||Ux.clientID;case"githubClientId":return process.env.RAY_GithubClientID||jh.GithubClientID||kar;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||jh.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof jh.Target>"u"?yue("release"):jh.Target)}}function aY(i,s){switch(i){case"raycastApiURL":s===void 0?delete jh.APIURL:jh.APIURL=s;break;case"raycastAccessToken":s===void 0?delete jh.Token:jh.Token=s,delete jh.AccessToken;break;case"raycastClientId":s===void 0?delete jh.ClientID:jh.ClientID=s;break;case"githubAccessToken":s===void 0?delete jh.GithubAccessToken:jh.GithubAccessToken=s;break;case"flavorName":s===void 0?delete jh.Target:jh.Target=s;break}let c=oY();aB.writeFileSync(sY.join(c,"config.json"),JSON.stringify(jh,null," "),"utf8")}function yue(i){switch(i){case"debug":return"debug";case"internal":return"internal";case"release":return"";case"x":return"x";case"x-internal":return"x-internal";case"x-debug":return"x-debug";case void 0:return $_("flavorName")}}function Aar(){let i=yue(gue);return i==""?"raycast":`raycast-${i}`}function oY(){let i=sY.join($ct.default.homedir(),".config",Aar());return aB.mkdirSync(i,{recursive:!0}),i}var xd=xa(cY());var gY=xa(require("node:process"),1);var Qct=(i=0)=>s=>`\x1B[${s+i}m`,Kct=(i=0)=>s=>`\x1B[${38+i};5;${s}m`,Xct=(i=0)=>(s,c,p)=>`\x1B[${38+i};2;${s};${c};${p}m`,Qd={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},C5r=Object.keys(Qd.modifier),Iar=Object.keys(Qd.color),Far=Object.keys(Qd.bgColor),E5r=[...Iar,...Far];function Oar(){let i=new Map;for(let[s,c]of Object.entries(Qd)){for(let[p,y]of Object.entries(c))Qd[p]={open:`\x1B[${y[0]}m`,close:`\x1B[${y[1]}m`},c[p]=Qd[p],i.set(y[0],y[1]);Object.defineProperty(Qd,s,{value:c,enumerable:!1})}return Object.defineProperty(Qd,"codes",{value:i,enumerable:!1}),Qd.color.close="\x1B[39m",Qd.bgColor.close="\x1B[49m",Qd.color.ansi=Qct(),Qd.color.ansi256=Kct(),Qd.color.ansi16m=Xct(),Qd.bgColor.ansi=Qct(10),Qd.bgColor.ansi256=Kct(10),Qd.bgColor.ansi16m=Xct(10),Object.defineProperties(Qd,{rgbToAnsi256:{value(s,c,p){return s===c&&c===p?s<8?16:s>248?231:Math.round((s-8)/247*24)+232:16+36*Math.round(s/255*5)+6*Math.round(c/255*5)+Math.round(p/255*5)},enumerable:!1},hexToRgb:{value(s){let c=/[a-f\d]{6}|[a-f\d]{3}/i.exec(s.toString(16));if(!c)return[0,0,0];let[p]=c;p.length===3&&(p=[...p].map(x=>x+x).join(""));let y=Number.parseInt(p,16);return[y>>16&255,y>>8&255,y&255]},enumerable:!1},hexToAnsi256:{value:s=>Qd.rgbToAnsi256(...Qd.hexToRgb(s)),enumerable:!1},ansi256ToAnsi:{value(s){if(s<8)return 30+s;if(s<16)return 90+(s-8);let c,p,y;if(s>=232)c=((s-232)*10+8)/255,p=c,y=c;else{s-=16;let L=s%36;c=Math.floor(s/36)/5,p=Math.floor(L/6)/5,y=L%6/5}let x=Math.max(c,p,y)*2;if(x===0)return 30;let w=30+(Math.round(y)<<2|Math.round(p)<<1|Math.round(c));return x===2&&(w+=60),w},enumerable:!1},rgbToAnsi:{value:(s,c,p)=>Qd.ansi256ToAnsi(Qd.rgbToAnsi256(s,c,p)),enumerable:!1},hexToAnsi:{value:s=>Qd.ansi256ToAnsi(Qd.hexToAnsi256(s)),enumerable:!1}}),Qd}var Rar=Oar(),KC=Rar;var bue=xa(require("node:process"),1),elt=xa(require("node:os"),1),yNe=xa(require("node:tty"),1);function Wx(i,s=globalThis.Deno?globalThis.Deno.args:bue.default.argv){let c=i.startsWith("-")?"":i.length===1?"-":"--",p=s.indexOf(c+i),y=s.indexOf("--");return p!==-1&&(y===-1||p<y)}var{env:Dm}=bue.default,vue;Wx("no-color")||Wx("no-colors")||Wx("color=false")||Wx("color=never")?vue=0:(Wx("color")||Wx("colors")||Wx("color=true")||Wx("color=always"))&&(vue=1);function Lar(){if("FORCE_COLOR"in Dm)return Dm.FORCE_COLOR==="true"?1:Dm.FORCE_COLOR==="false"?0:Dm.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Dm.FORCE_COLOR,10),3)}function Mar(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function jar(i,{streamIsTTY:s,sniffFlags:c=!0}={}){let p=Lar();p!==void 0&&(vue=p);let y=c?vue:p;if(y===0)return 0;if(c){if(Wx("color=16m")||Wx("color=full")||Wx("color=truecolor"))return 3;if(Wx("color=256"))return 2}if("TF_BUILD"in Dm&&"AGENT_NAME"in Dm)return 1;if(i&&!s&&y===void 0)return 0;let x=y||0;if(Dm.TERM==="dumb")return x;if(bue.default.platform==="win32"){let w=elt.default.release().split(".");return Number(w[0])>=10&&Number(w[2])>=10586?Number(w[2])>=14931?3:2:1}if("CI"in Dm)return"GITHUB_ACTIONS"in Dm||"GITEA_ACTIONS"in Dm?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(w=>w in Dm)||Dm.CI_NAME==="codeship"?1:x;if("TEAMCITY_VERSION"in Dm)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Dm.TEAMCITY_VERSION)?1:0;if(Dm.COLORTERM==="truecolor"||Dm.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in Dm){let w=Number.parseInt((Dm.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Dm.TERM_PROGRAM){case"iTerm.app":return w>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Dm.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Dm.TERM)||"COLORTERM"in Dm?1:x}function Zct(i,s={}){let c=jar(i,{streamIsTTY:i&&i.isTTY,...s});return Mar(c)}var Bar={stdout:Zct({isTTY:yNe.default.isatty(1)}),stderr:Zct({isTTY:yNe.default.isatty(2)})},tlt=Bar;function rlt(i,s,c){let p=i.indexOf(s);if(p===-1)return i;let y=s.length,x=0,w="";do w+=i.slice(x,p)+s+c,x=p+y,p=i.indexOf(s,x);while(p!==-1);return w+=i.slice(x),w}function nlt(i,s,c,p){let y=0,x="";do{let w=i[p-1]==="\r";x+=i.slice(y,w?p-1:p)+s+(w?`\r
|
|
608
|
+
`+P.stack)}finally{this.performanceData=T}}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 FZe(e){let t=e.diagnosticsDuration&&Js(e.diagnosticsDuration,([n,a])=>({...a,file:n}));return{...e,diagnosticsDuration:t}}function Ny(e,t){return{start:t.positionToLineOffset(e.start),end:t.positionToLineOffset(tl(e))}}function Gwe(e,t,n){let a=Ny(e,n),o=t&&Ny(t,n);return o?{...a,contextStart:o.start,contextEnd:o.end}:a}function q$t(e,t){return{start:OZe(t,e.span.start),end:OZe(t,tl(e.span)),newText:e.newText}}function OZe(e,t){return qwe(e)?U$t(e.getLineAndCharacterOfPosition(t)):e.positionToLineOffset(t)}function J$t(e,t){let n=e.ranges.map(a=>({start:t.positionToLineOffset(a.start),end:t.positionToLineOffset(a.start+a.length)}));return e.wordPattern?{ranges:n,wordPattern:e.wordPattern}:{ranges:n}}function U$t(e){return{line:e.line+1,offset:e.character+1}}function W$t(e){I.assert(e.textChanges.length===1);let t=La(e.textChanges);return I.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 Hwe(e,t,n,a){let o=z$t(e,t,a),{line:u,character:f}=ON(vA(o),n);return{line:u+1,offset:f+1}}function z$t(e,t,n){for(let{fileName:a,textChanges:o}of n)if(a===t)for(let u=o.length-1;u>=0;u--){let{newText:f,span:{start:h,length:m}}=o[u];e=e.slice(0,h)+f+e.slice(h+m)}return e}function RZe(e,{fileName:t,textSpan:n,contextSpan:a,isWriteAccess:o,isDefinition:u},{disableLineTextInReferences:f}){let h=I.checkDefined(e.getScriptInfo(t)),m=Gwe(n,a,h),b=f?void 0:$$t(h,m);return{file:t,...m,lineText:b,isWriteAccess:o,isDefinition:u}}function $$t(e,t){let n=e.lineToTextSpan(t.start.line-1);return e.getSnapshot().getText(n.start,tl(n)).replace(/\r|\n/g,"")}function V$t(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 v4=4,Ywe=(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))(Ywe||{}),G$t=class{constructor(){this.goSubtree=!0,this.lineIndex=new $M,this.endBranch=[],this.state=2,this.initialText="",this.trailingText="",this.lineIndex.root=new b4,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 a=$M.linesFromText(e).lines;a.length>1&&a[a.length-1]===""&&a.pop();let o,u;for(let h=this.endBranch.length-1;h>=0;h--)this.endBranch[h].updateCounts(),this.endBranch[h].charCount()===0&&(u=this.endBranch[h],h>0?o=this.endBranch[h-1]:o=this.branchNode);u&&o.remove(u);let f=this.startPath[this.startPath.length-1];if(a.length>0)if(f.text=a[0],a.length>1){let h=new Array(a.length-1),m=f;for(let D=1;D<a.length;D++)h[D-1]=new pG(a[D]);let b=this.startPath.length-2;for(;b>=0;){let D=this.startPath[b];h=D.insertAt(m,h),b--,m=D}let T=h.length;for(;T>0;){let D=new b4;D.add(this.lineIndex.root),h=D.insertAt(this.lineIndex.root,h),T=h.length,this.lineIndex.root=D}this.lineIndex.root.updateCounts()}else for(let h=this.startPath.length-2;h>=0;h--)this.startPath[h].updateCounts();else{this.startPath[this.startPath.length-2].remove(f);for(let m=this.startPath.length-2;m>=0;m--)this.startPath[m].updateCounts()}return this.lineIndex}post(e,t,n){n===this.lineCollectionAtBranch&&(this.state=4),this.stack.pop()}pre(e,t,n,a,o){let u=this.stack[this.stack.length-1];this.state===2&&o===1&&(this.state=1,this.branchNode=u,this.lineCollectionAtBranch=n);let f;function h(m){return m.isLeaf()?new pG(""):new b4}switch(o){case 0:this.goSubtree=!1,this.state!==4&&u.add(n);break;case 1:this.state===4?this.goSubtree=!1:(f=h(n),u.add(f),this.startPath.push(f));break;case 2:this.state!==4?(f=h(n),u.add(f),this.startPath.push(f)):n.isLeaf()||(f=h(n),u.add(f),this.endBranch.push(f));break;case 3:this.goSubtree=!1;break;case 4:this.state!==4?this.goSubtree=!1:n.isLeaf()||(f=h(n),u.add(f),this.endBranch.push(f));break;case 5:this.goSubtree=!1,this.state!==1&&u.add(n);break}this.goSubtree&&this.stack.push(f)}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)}},H$t=class{constructor(e,t,n){this.pos=e,this.deleteLen=t,this.insertedText=n}getTextChangeRange(){return oR(Ff(this.pos,this.deleteLen),this.insertedText?this.insertedText.length:0)}},Moe=class Xk{constructor(){this.changes=[],this.versions=new Array(Xk.maxVersions),this.minVersion=0,this.currentVersion=0}versionToIndex(t){if(!(t<this.minVersion||t>this.currentVersion))return t%Xk.maxVersions}currentVersionToIndex(){return this.currentVersion%Xk.maxVersions}edit(t,n,a){this.changes.push(new H$t(t,n,a)),(this.changes.length>Xk.changeNumberThreshold||n>Xk.changeLengthThreshold||a&&a.length>Xk.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 a of this.changes)n=n.edit(a.pos,a.deleteLen,a.insertedText);t=new LZe(this.currentVersion+1,this,n,this.changes),this.currentVersion=t.version,this.versions[this.currentVersionToIndex()]=t,this.changes=[],this.currentVersion-this.minVersion>=Xk.maxVersions&&(this.minVersion=this.currentVersion-Xk.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:a,absolutePosition:o}=n.lineNumberToInfo(t+1),u=a!==void 0?a.length:n.absolutePositionOfStartOfLine(t+2)-o;return Ff(o,u)}getTextChangesBetweenVersions(t,n){if(t<n)if(t>=this.minVersion){let a=[];for(let o=t+1;o<=n;o++){let u=this.versions[this.versionToIndex(o)];for(let f of u.changesSincePreviousVersion)a.push(f.getTextChangeRange())}return Uhe(a)}else return;else return wJ}getLineCount(){return this._getSnapshot().index.getLineCount()}static fromString(t){let n=new Xk,a=new LZe(0,n,new $M);n.versions[n.currentVersion]=a;let o=$M.linesFromText(t);return a.index.load(o.lines),n}};Moe.changeNumberThreshold=8,Moe.changeLengthThreshold=256,Moe.maxVersions=8;var joe=Moe,LZe=class S6t{constructor(t,n,a,o=Vu){this.version=t,this.cache=n,this.index=a,this.changesSincePreviousVersion=o}getText(t,n){return this.index.getText(t,n-t)}getLength(){return this.index.getLength()}getChangeRange(t){if(t instanceof S6t&&this.cache===t.cache)return this.version<=t.version?wJ:this.cache.getTextChangesBetweenVersions(t.version,this.version)}},$M=class m9e{constructor(){this.checkEdits=!1}absolutePositionOfStartOfLine(t){return this.lineNumberToInfo(t).absolutePosition}positionToLineOffset(t){let{oneBasedLine:n,zeroBasedColumn:a}=this.root.charOffsetToLineInfo(1,t);return{line:n,offset:a+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:a,leaf:o}=this.root.lineNumberToInfo(t,0);return{absolutePosition:a,lineText:o&&o.text}}else return{absolutePosition:this.root.charCount(),lineText:void 0}}load(t){if(t.length>0){let n=[];for(let a=0;a<t.length;a++)n[a]=new pG(t[a]);this.root=m9e.buildTreeFromBottom(n)}else this.root=new b4}walk(t,n,a){this.root.walk(t,n,a)}getText(t,n){let a="";return n>0&&t<this.root.charCount()&&this.walk(t,n,{goSubtree:!0,done:!1,leaf:(o,u,f)=>{a=a.concat(f.text.substring(o,o+u))}}),a}getLength(){return this.root.charCount()}every(t,n,a){a||(a=this.root.charCount());let o={goSubtree:!0,done:!1,leaf(u,f,h){t(h,u,f)||(this.done=!0)}};return this.walk(n,a-n,o),!o.done}edit(t,n,a){if(this.root.charCount()===0)return I.assert(n===0),a!==void 0?(this.load(m9e.linesFromText(a).lines),this):void 0;{let o;if(this.checkEdits){let h=this.getText(0,this.root.charCount());o=h.slice(0,t)+a+h.slice(t+n)}let u=new G$t,f=!1;if(t>=this.root.charCount()){t=this.root.charCount()-1;let h=this.getText(t,1);a?a=h+a:a=h,n=0,f=!0}else if(n>0){let h=t+n,{zeroBasedColumn:m,lineText:b}=this.positionToColumnAndLineText(h);m===0&&(n+=b.length,a=a?a+b:b)}if(this.root.walk(t,n,u),u.insertLines(a,f),this.checkEdits){let h=u.lineIndex.getText(0,u.lineIndex.getLength());I.assert(o===h,"buffer edit mismatch")}return u.lineIndex}}static buildTreeFromBottom(t){if(t.length<v4)return new b4(t);let n=new Array(Math.ceil(t.length/v4)),a=0;for(let o=0;o<n.length;o++){let u=Math.min(a+v4,t.length);n[o]=new b4(t.slice(a,u)),a=u}return this.buildTreeFromBottom(n)}static linesFromText(t){let n=vA(t);if(n.length===0)return{lines:[],lineMap:n};let a=new Array(n.length),o=n.length-1;for(let f=0;f<o;f++)a[f]=t.substring(n[f],n[f+1]);let u=t.substring(n[o]);return u.length>0?a[o]=u:a.pop(),{lines:a,lineMap:n}}},b4=class h9e{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,a,o,u){return a.pre&&a.pre(t,n,this.children[o],this,u),a.goSubtree?(this.children[o].walk(t,n,a),a.post&&a.post(t,n,this.children[o],this,u)):a.goSubtree=!0,a.done}skipChild(t,n,a,o,u){o.pre&&!o.done&&(o.pre(t,n,this.children[a],this,u),o.goSubtree=!0)}walk(t,n,a){let o=0,u=this.children[o].charCount(),f=t;for(;f>=u;)this.skipChild(f,n,o,a,0),f-=u,o++,u=this.children[o].charCount();if(f+n<=u){if(this.execWalk(f,n,a,o,2))return}else{if(this.execWalk(f,u-f,a,o,1))return;let h=n-(u-f);for(o++,u=this.children[o].charCount();h>u;){if(this.execWalk(0,u,a,o,3))return;h-=u,o++,u=this.children[o].charCount()}if(h>0&&this.execWalk(0,h,a,o,4))return}if(a.pre){let h=this.children.length;if(o<h-1)for(let m=o+1;m<h;m++)this.skipChild(0,0,m,a,5)}}charOffsetToLineInfo(t,n){if(this.children.length===0)return{oneBasedLine:t,zeroBasedColumn:n,lineText:void 0};for(let u of this.children){if(u.charCount()>n)return u.isLeaf()?{oneBasedLine:t,zeroBasedColumn:n,lineText:u.text}:u.charOffsetToLineInfo(t,n);n-=u.charCount(),t+=u.lineCount()}let a=this.lineCount();if(a===0)return{oneBasedLine:1,zeroBasedColumn:0,lineText:void 0};let o=I.checkDefined(this.lineNumberToInfo(a,0).leaf);return{oneBasedLine:a,zeroBasedColumn:o.charCount(),lineText:void 0}}lineNumberToInfo(t,n){for(let a of this.children){let o=a.lineCount();if(o>=t)return a.isLeaf()?{position:n,leaf:a}:a.lineNumberToInfo(t,n);t-=o,n+=a.charCount()}return{position:n,leaf:void 0}}splitAfter(t){let n,a=this.children.length;t++;let o=t;if(t<a){for(n=new h9e;t<a;)n.add(this.children[t]),t++;n.updateCounts()}return this.children.length=o,n}remove(t){let n=this.findChildIndex(t),a=this.children.length;if(n<a-1)for(let o=n;o<a-1;o++)this.children[o]=this.children[o+1];this.children.pop()}findChildIndex(t){let n=this.children.indexOf(t);return I.assert(n!==-1),n}insertAt(t,n){let a=this.findChildIndex(t),o=this.children.length,u=n.length;if(o<v4&&a===o-1&&u===1)return this.add(n[0]),this.updateCounts(),[];{let f=this.splitAfter(a),h=0;for(a++;a<v4&&h<u;)this.children[a]=n[h],a++,h++;let m=[],b=0;if(h<u){b=Math.ceil((u-h)/v4),m=new Array(b);let T=0;for(let A=0;A<b;A++)m[A]=new h9e;let D=m[0];for(;h<u;)D.add(n[h]),h++,D.children.length===v4&&(T++,D=m[T]);for(let A=m.length-1;A>=0;A--)m[A].children.length===0&&m.pop()}f&&m.push(f),this.updateCounts();for(let T=0;T<b;T++)m[T].updateCounts();return m}}add(t){this.children.push(t),I.assert(this.children.length<=v4)}charCount(){return this.totalChars}lineCount(){return this.totalLines}},pG=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}},MZe=class T6t{constructor(t,n,a,o,u,f){this.telemetryEnabled=t,this.logger=n,this.host=a,this.globalTypingsCacheLocation=o,this.event=u,this.maxActiveRequestCount=f,this.activeRequestCount=0,this.requestQueue=_D(),this.requestMap=new Map,this.requestedRegistry=!1,this.packageInstallId=0}isKnownTypesPackageName(t){var n;return ky.validatePackageName(t)!==ky.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},a=new Promise((o,u)=>{(this.packageInstalledPromise??(this.packageInstalledPromise=new Map)).set(this.packageInstallId,{resolve:o,reject:u})});return this.installer.send(n),a}attach(t){this.projectService=t,this.installer=this.createInstallerProcess()}onProjectClosed(t){this.installer.send({projectName:t.getProjectName(),kind:"closeProject"})}enqueueInstallTypingsRequest(t,n,a){let o=awe(t,n,a);this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling throttled operation:${rx(o)}`),this.activeRequestCount<this.maxActiveRequestCount?this.scheduleRequest(o):(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Deferring request for: ${o.projectName}`),this.requestQueue.enqueue(o),this.requestMap.set(o.projectName,o))}handleMessage(t){var n,a;switch(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Received response:${rx(t)}`),t.kind){case lie:this.typesRegistryCache=new Map(Object.entries(t.typesRegistry));break;case A$:{let o=(n=this.packageInstalledPromise)==null?void 0:n.get(t.id);I.assertIsDefined(o,"Should find the promise for package install"),(a=this.packageInstalledPromise)==null||a.delete(t.id),t.success?o.resolve({successMessage:t.message}):o.reject(t.message),this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case m2e:{let o={message:t.message};this.event(o,"typesInstallerInitializationFailed");break}case uie:{let o={eventId:t.eventId,packages:t.packagesToInstall};this.event(o,"beginInstallTypes");break}case fie:{if(this.telemetryEnabled){let f={telemetryEventName:"typingsInstalled",payload:{installedPackages:t.packagesToInstall.join(","),installSuccess:t.installSuccess,typingsInstallerVersion:t.typingsInstallerVersion}};this.event(f,"telemetry")}let o={eventId:t.eventId,packages:t.packagesToInstall,success:t.installSuccess};this.event(o,"endInstallTypes");break}case k$:{this.projectService.updateTypingsForProject(t);break}case w$:{for(this.activeRequestCount>0?this.activeRequestCount--:I.fail("TIAdapter:: Received too many responses");!this.requestQueue.isEmpty();){let o=this.requestQueue.dequeue();if(this.requestMap.get(o.projectName)===o){this.requestMap.delete(o.projectName),this.scheduleRequest(o);break}this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Skipping defunct request for: ${o.projectName}`)}this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case LL: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:${rx(t)}`),this.installer.send(t)},T6t.requestDelayMillis,`${t.projectName}::${t.kind}`)}};MZe.requestDelayMillis=100;var jZe=MZe,BZe={};x(BZe,{ActionInvalidate:()=>k$,ActionPackageInstalled:()=>A$,ActionSet:()=>w$,ActionWatchTypingLocations:()=>LL,Arguments:()=>_ie,AutoImportProviderProject:()=>Cwe,AuxiliaryProject:()=>xwe,CharRangeSection:()=>Ywe,CloseFileWatcherEvent:()=>woe,CommandNames:()=>wZe,ConfigFileDiagEvent:()=>Toe,ConfiguredProject:()=>Ewe,ConfiguredProjectLoadKind:()=>Iwe,CreateDirectoryWatcherEvent:()=>Eoe,CreateFileWatcherEvent:()=>Coe,Errors:()=>Rv,EventBeginInstallTypes:()=>uie,EventEndInstallTypes:()=>fie,EventInitializationFailed:()=>m2e,EventTypesRegistry:()=>lie,ExternalProject:()=>hoe,GcTimer:()=>pwe,InferredProject:()=>Twe,LargeFileReferencedEvent:()=>Soe,LineIndex:()=>$M,LineLeaf:()=>pG,LineNode:()=>b4,LogLevel:()=>iwe,Msg:()=>swe,OpenFileInfoTelemetryEvent:()=>wwe,Project:()=>$6,ProjectInfoTelemetryEvent:()=>Doe,ProjectKind:()=>BM,ProjectLanguageServiceStateEvent:()=>xoe,ProjectLoadingFinishEvent:()=>boe,ProjectLoadingStartEvent:()=>voe,ProjectService:()=>Bwe,ProjectsUpdatedInBackgroundEvent:()=>uG,ScriptInfo:()=>gwe,ScriptVersionCache:()=>joe,Session:()=>IZe,TextStorage:()=>hwe,ThrottledOperations:()=>_we,TypingsInstallerAdapter:()=>jZe,allFilesAreJsOrDts:()=>vwe,allRootFilesAreJsOrDts:()=>ywe,asNormalizedPath:()=>eZe,convertCompilerOptions:()=>fG,convertFormatOptions:()=>g4,convertScriptKindName:()=>Aoe,convertTypeAcquisition:()=>Awe,convertUserPreferences:()=>Pwe,convertWatchOptions:()=>WM,countEachFileTypes:()=>qM,createInstallTypingsRequest:()=>awe,createModuleSpecifierCache:()=>Uwe,createNormalizedPathMap:()=>tZe,createPackageJsonCache:()=>Wwe,createSortedArray:()=>fwe,emptyArray:()=>Vu,findArgument:()=>ZJe,formatDiagnosticToProtocol:()=>zM,formatMessage:()=>zwe,getBaseConfigFileName:()=>moe,getLocationInNewDocument:()=>Hwe,hasArgument:()=>XJe,hasNoTypeScriptSource:()=>bwe,indent:()=>_O,isBackgroundProject:()=>UM,isConfigFile:()=>qwe,isConfiguredProject:()=>$b,isDynamicFileName:()=>jM,isExternalProject:()=>JM,isInferredProject:()=>h4,isInferredProjectName:()=>owe,isProjectDeferredClose:()=>lG,makeAutoImportProviderProjectName:()=>lwe,makeAuxiliaryProjectName:()=>uwe,makeInferredProjectName:()=>cwe,maxFileSize:()=>yoe,maxProgramSizeForNonTsFiles:()=>goe,normalizedPathToPath:()=>m4,nowString:()=>eUe,nullCancellationToken:()=>DZe,nullTypingsInstaller:()=>_G,protocol:()=>dwe,stringifyIndented:()=>rx,toEvent:()=>$we,toNormalizedPath:()=>Jc,tryConvertScriptKindName:()=>koe,typingsInstaller:()=>nwe,updateProjectIfDirty:()=>Vm}),typeof console<"u"&&(I.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 m6t},set exports(i){m6t=i,typeof Kme<"u"&&Kme.exports&&(Kme.exports=i)}})});var O7r={};Nir(O7r,{default:()=>ahe});module.exports=Iir(O7r);var she=require("@oclif/core"),uPt=xa(Jct());var s3=require("@oclif/core");var aB=xa(require("node:fs")),sY=xa(require("node:path")),$ct=xa(require("node:os"));var Uct=xa(require("node:path")),Wct=xa(require("node:fs"));function Dk(){let i;try{i=Uct.resolve("package.json")}catch(c){throw new Error(`cannot resolve package manifest path: ${c}`)}let s;try{s=JSON.parse(Wct.readFileSync(i,"utf8"))}catch(c){throw new Error(`cannot read package manifest: ${c}`)}return s.name=s.name.replace(/^@workaround/g,""),s}function zct(i){return!!i.owner&&i.access!=="public"}var Ux={production:{url:"https://www.raycast.com",clientID:"KqAdcGhNfBKiUpfjD3nU3VNgh1t0iMPoX2hYEkN9d4I"},staging:{url:"https://www.rayca.st",clientID:"KqAdcGhNfBKiUpfjD3nU3VNgh1t0iMPoX2hYEkN9d4I"},development:{url:"http://localhost:3000",clientID:"rOCD_LhnXFObSLu9v7788qOGu25FZDqEzGjet4Q45ZY"}}[process.env.API_ENV||"production"],kar="e69bae0ec90f5e838555",jh={},gue;function w7(){let i=Dk();if(!i.name)throw new Error("extension name in manifest cannot be empty");return sY.join(oY(),"extensions",i.name)}function Vct(){let i=yue(gue);return i?.startsWith("x")?i==="x"?"com.raycast-x.macos":`com.raycast-x.macos.${i.replace("x-","")}`:i?`com.raycast.macos.${i}`:"com.raycast.macos"}function Gct(){let i=yue(gue);return i?.startsWith("x")?i==="x"?"com.raycast-x":`com.raycast-x.${i.replace("x-","")}`:`raycast${i}`}function Hct(i){gue=i;try{jh=JSON.parse(aB.readFileSync(sY.join(oY(),"config.json"),"utf8"))}catch(s){if(s instanceof Error&&s.code==="ENOENT")return;throw new Error(`Failed to read config file: ${s}`)}}function $_(i){switch(i){case"raycastApiURL":return process.env.RAY_APIURL||jh.APIURL||Ux.url;case"raycastAccessToken":return process.env.RAY_TOKEN||jh.Token||jh.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||jh.ClientID||Ux.clientID;case"githubClientId":return process.env.RAY_GithubClientID||jh.GithubClientID||kar;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||jh.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof jh.Target>"u"?yue("release"):jh.Target)}}function aY(i,s){switch(i){case"raycastApiURL":s===void 0?delete jh.APIURL:jh.APIURL=s;break;case"raycastAccessToken":s===void 0?delete jh.Token:jh.Token=s,delete jh.AccessToken;break;case"raycastClientId":s===void 0?delete jh.ClientID:jh.ClientID=s;break;case"githubAccessToken":s===void 0?delete jh.GithubAccessToken:jh.GithubAccessToken=s;break;case"flavorName":s===void 0?delete jh.Target:jh.Target=s;break}let c=oY();aB.writeFileSync(sY.join(c,"config.json"),JSON.stringify(jh,null," "),"utf8")}function yue(i){switch(i){case"debug":return"debug";case"internal":return"internal";case"release":return"";case"x":return"x";case"x-internal":return"x-internal";case"x-debug":return"x-debug";case void 0:return $_("flavorName")}}function Aar(){let i=yue(gue);return i==""?"raycast":`raycast-${i}`}function oY(){let i=sY.join($ct.default.homedir(),".config",Aar());return aB.mkdirSync(i,{recursive:!0}),i}var xd=xa(cY());var gY=xa(require("node:process"),1);var Qct=(i=0)=>s=>`\x1B[${s+i}m`,Kct=(i=0)=>s=>`\x1B[${38+i};5;${s}m`,Xct=(i=0)=>(s,c,p)=>`\x1B[${38+i};2;${s};${c};${p}m`,Qd={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},C5r=Object.keys(Qd.modifier),Iar=Object.keys(Qd.color),Far=Object.keys(Qd.bgColor),E5r=[...Iar,...Far];function Oar(){let i=new Map;for(let[s,c]of Object.entries(Qd)){for(let[p,y]of Object.entries(c))Qd[p]={open:`\x1B[${y[0]}m`,close:`\x1B[${y[1]}m`},c[p]=Qd[p],i.set(y[0],y[1]);Object.defineProperty(Qd,s,{value:c,enumerable:!1})}return Object.defineProperty(Qd,"codes",{value:i,enumerable:!1}),Qd.color.close="\x1B[39m",Qd.bgColor.close="\x1B[49m",Qd.color.ansi=Qct(),Qd.color.ansi256=Kct(),Qd.color.ansi16m=Xct(),Qd.bgColor.ansi=Qct(10),Qd.bgColor.ansi256=Kct(10),Qd.bgColor.ansi16m=Xct(10),Object.defineProperties(Qd,{rgbToAnsi256:{value(s,c,p){return s===c&&c===p?s<8?16:s>248?231:Math.round((s-8)/247*24)+232:16+36*Math.round(s/255*5)+6*Math.round(c/255*5)+Math.round(p/255*5)},enumerable:!1},hexToRgb:{value(s){let c=/[a-f\d]{6}|[a-f\d]{3}/i.exec(s.toString(16));if(!c)return[0,0,0];let[p]=c;p.length===3&&(p=[...p].map(x=>x+x).join(""));let y=Number.parseInt(p,16);return[y>>16&255,y>>8&255,y&255]},enumerable:!1},hexToAnsi256:{value:s=>Qd.rgbToAnsi256(...Qd.hexToRgb(s)),enumerable:!1},ansi256ToAnsi:{value(s){if(s<8)return 30+s;if(s<16)return 90+(s-8);let c,p,y;if(s>=232)c=((s-232)*10+8)/255,p=c,y=c;else{s-=16;let L=s%36;c=Math.floor(s/36)/5,p=Math.floor(L/6)/5,y=L%6/5}let x=Math.max(c,p,y)*2;if(x===0)return 30;let w=30+(Math.round(y)<<2|Math.round(p)<<1|Math.round(c));return x===2&&(w+=60),w},enumerable:!1},rgbToAnsi:{value:(s,c,p)=>Qd.ansi256ToAnsi(Qd.rgbToAnsi256(s,c,p)),enumerable:!1},hexToAnsi:{value:s=>Qd.ansi256ToAnsi(Qd.hexToAnsi256(s)),enumerable:!1}}),Qd}var Rar=Oar(),KC=Rar;var bue=xa(require("node:process"),1),elt=xa(require("node:os"),1),yNe=xa(require("node:tty"),1);function Wx(i,s=globalThis.Deno?globalThis.Deno.args:bue.default.argv){let c=i.startsWith("-")?"":i.length===1?"-":"--",p=s.indexOf(c+i),y=s.indexOf("--");return p!==-1&&(y===-1||p<y)}var{env:Dm}=bue.default,vue;Wx("no-color")||Wx("no-colors")||Wx("color=false")||Wx("color=never")?vue=0:(Wx("color")||Wx("colors")||Wx("color=true")||Wx("color=always"))&&(vue=1);function Lar(){if("FORCE_COLOR"in Dm)return Dm.FORCE_COLOR==="true"?1:Dm.FORCE_COLOR==="false"?0:Dm.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Dm.FORCE_COLOR,10),3)}function Mar(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function jar(i,{streamIsTTY:s,sniffFlags:c=!0}={}){let p=Lar();p!==void 0&&(vue=p);let y=c?vue:p;if(y===0)return 0;if(c){if(Wx("color=16m")||Wx("color=full")||Wx("color=truecolor"))return 3;if(Wx("color=256"))return 2}if("TF_BUILD"in Dm&&"AGENT_NAME"in Dm)return 1;if(i&&!s&&y===void 0)return 0;let x=y||0;if(Dm.TERM==="dumb")return x;if(bue.default.platform==="win32"){let w=elt.default.release().split(".");return Number(w[0])>=10&&Number(w[2])>=10586?Number(w[2])>=14931?3:2:1}if("CI"in Dm)return"GITHUB_ACTIONS"in Dm||"GITEA_ACTIONS"in Dm?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(w=>w in Dm)||Dm.CI_NAME==="codeship"?1:x;if("TEAMCITY_VERSION"in Dm)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Dm.TEAMCITY_VERSION)?1:0;if(Dm.COLORTERM==="truecolor"||Dm.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in Dm){let w=Number.parseInt((Dm.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Dm.TERM_PROGRAM){case"iTerm.app":return w>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Dm.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Dm.TERM)||"COLORTERM"in Dm?1:x}function Zct(i,s={}){let c=jar(i,{streamIsTTY:i&&i.isTTY,...s});return Mar(c)}var Bar={stdout:Zct({isTTY:yNe.default.isatty(1)}),stderr:Zct({isTTY:yNe.default.isatty(2)})},tlt=Bar;function rlt(i,s,c){let p=i.indexOf(s);if(p===-1)return i;let y=s.length,x=0,w="";do w+=i.slice(x,p)+s+c,x=p+y,p=i.indexOf(s,x);while(p!==-1);return w+=i.slice(x),w}function nlt(i,s,c,p){let y=0,x="";do{let w=i[p-1]==="\r";x+=i.slice(y,w?p-1:p)+s+(w?`\r
|
|
609
609
|
`:`
|
|
610
610
|
`)+c,y=p+1,p=i.indexOf(`
|
|
611
611
|
`,y)}while(p!==-1);return x+=i.slice(y),x}var{stdout:ilt,stderr:slt}=tlt,vNe=Symbol("GENERATOR"),oB=Symbol("STYLER"),lY=Symbol("IS_EMPTY"),alt=["ansi","ansi","ansi256","ansi16m"],cB=Object.create(null),qar=(i,s={})=>{if(s.level&&!(Number.isInteger(s.level)&&s.level>=0&&s.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let c=ilt?ilt.level:0;i.level=s.level===void 0?c:s.level};var Jar=i=>{let s=(...c)=>c.join(" ");return qar(s,i),Object.setPrototypeOf(s,uY.prototype),s};function uY(i){return Jar(i)}Object.setPrototypeOf(uY.prototype,Function.prototype);for(let[i,s]of Object.entries(KC))cB[i]={get(){let c=Sue(this,SNe(s.open,s.close,this[oB]),this[lY]);return Object.defineProperty(this,i,{value:c}),c}};cB.visible={get(){let i=Sue(this,this[oB],!0);return Object.defineProperty(this,"visible",{value:i}),i}};var bNe=(i,s,c,...p)=>i==="rgb"?s==="ansi16m"?KC[c].ansi16m(...p):s==="ansi256"?KC[c].ansi256(KC.rgbToAnsi256(...p)):KC[c].ansi(KC.rgbToAnsi(...p)):i==="hex"?bNe("rgb",s,c,...KC.hexToRgb(...p)):KC[c][i](...p),Uar=["rgb","hex","ansi256"];for(let i of Uar){cB[i]={get(){let{level:c}=this;return function(...p){let y=SNe(bNe(i,alt[c],"color",...p),KC.color.close,this[oB]);return Sue(this,y,this[lY])}}};let s="bg"+i[0].toUpperCase()+i.slice(1);cB[s]={get(){let{level:c}=this;return function(...p){let y=SNe(bNe(i,alt[c],"bgColor",...p),KC.bgColor.close,this[oB]);return Sue(this,y,this[lY])}}}}var War=Object.defineProperties(()=>{},{...cB,level:{enumerable:!0,get(){return this[vNe].level},set(i){this[vNe].level=i}}}),SNe=(i,s,c)=>{let p,y;return c===void 0?(p=i,y=s):(p=c.openAll+i,y=s+c.closeAll),{open:i,close:s,openAll:p,closeAll:y,parent:c}},Sue=(i,s,c)=>{let p=(...y)=>zar(p,y.length===1?""+y[0]:y.join(" "));return Object.setPrototypeOf(p,War),p[vNe]=i,p[oB]=s,p[lY]=c,p},zar=(i,s)=>{if(i.level<=0||!s)return i[lY]?"":s;let c=i[oB];if(c===void 0)return s;let{openAll:p,closeAll:y}=c;if(s.includes("\x1B"))for(;c!==void 0;)s=rlt(s,c.close,c.open),c=c.parent;let x=s.indexOf(`
|
|
@@ -658,7 +658,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
|
|
|
658
658
|
`,LF:`
|
|
659
659
|
`,concatBytes:WIe},kfr=(i,s)=>{let c=new Uint8Array(i.length+s.length);return c.set(i,0),c.set(s,i.length),c},Afr={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:kfr};var Fpt=require("node:buffer");var Opt=(i,s)=>i?void 0:Pfr.bind(void 0,s),Pfr=function*(i,s){if(typeof s!="string"&&!Hg(s)&&!Fpt.Buffer.isBuffer(s))throw new TypeError(`The \`${i}\` option's transform must use "objectMode: true" to receive as input: ${typeof s}.`);yield s},Rpt=(i,s)=>i?Nfr.bind(void 0,s):Ifr.bind(void 0,s),Nfr=function*(i,s){Lpt(i,s),yield s},Ifr=function*(i,s){if(Lpt(i,s),typeof s!="string"&&!Hg(s))throw new TypeError(`The \`${i}\` option's function must yield a string or an Uint8Array, not ${typeof s}.`);yield s},Lpt=(i,s)=>{if(s==null)throw new TypeError(`The \`${i}\` option's function must not call \`yield ${s}\`.
|
|
660
660
|
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
661
|
-
if (condition) { yield value; }`)};var Mpt=require("node:buffer"),jpt=require("node:string_decoder");var wfe=(i,s,c)=>{if(c)return;if(i)return{transform:Ffr.bind(void 0,new TextEncoder)};let p=new jpt.StringDecoder(s);return{transform:Ofr.bind(void 0,p),final:Rfr.bind(void 0,p)}},Ffr=function*(i,s){Mpt.Buffer.isBuffer(s)?yield RP(s):typeof s=="string"?yield i.encode(s):yield s},Ofr=function*(i,s){yield Hg(s)?i.write(s):s},Rfr=function*(i){let s=i.end();s!==""&&(yield s)};var $Ie=require("node:util"),VIe=(0,$Ie.callbackify)(async(i,s,c,p)=>{s.currentIterable=i(...c);try{for await(let y of s.currentIterable)p.push(y)}finally{delete s.currentIterable}}),kfe=async function*(i,s,c){if(c===s.length){yield i;return}let{transform:p=Mfr}=s[c];for await(let y of p(i))yield*kfe(y,s,c+1)},Bpt=async function*(i){for(let[s,{final:c}]of Object.entries(i))yield*Lfr(c,Number(s),i)},Lfr=async function*(i,s,c){if(i!==void 0)for await(let p of i())yield*kfe(p,c,s+1)},qpt=(0,$Ie.callbackify)(async({currentIterable:i},s)=>{if(i!==void 0){await(s?i.throw(s):i.return());return}if(s)throw s}),Mfr=function*(i){yield i};var GIe=(i,s,c,p)=>{try{for(let y of i(...s))c.push(y);p()}catch(y){p(y)}},Jpt=(i,s)=>[...s.flatMap(c=>[...F7(c,i,0)]),...PY(i)],F7=function*(i,s,c){if(c===s.length){yield i;return}let{transform:p=Bfr}=s[c];for(let y of p(i))yield*F7(y,s,c+1)},PY=function*(i){for(let[s,{final:c}]of Object.entries(i))yield*jfr(c,Number(s),i)},jfr=function*(i,s,c){if(i!==void 0)for(let p of i())yield*F7(p,c,s+1)},Bfr=function*(i){yield i};var HIe=({value:i,value:{transform:s,final:c,writableObjectMode:p,readableObjectMode:y},optionName:x},{encoding:w})=>{let L={},$=Upt(i,w,x),ne=I7(s),_e=I7(c),Ce=ne?VIe.bind(void 0,kfe,L):GIe.bind(void 0,F7),X=ne||_e?VIe.bind(void 0,Bpt,L):GIe.bind(void 0,PY),Je=ne||_e?qpt.bind(void 0,L):void 0;return{stream:new NY.Transform({writableObjectMode:p,writableHighWaterMark:(0,NY.getDefaultHighWaterMark)(p),readableObjectMode:y,readableHighWaterMark:(0,NY.getDefaultHighWaterMark)(y),transform(he,ct,Ze){Ce([he,$,0],this,Ze)},flush(he){X([$],this,he)},destroy:Je})}},Afe=(i,s,c,p)=>{let y=s.filter(({type:w})=>w==="generator"),x=p?y.reverse():y;for(let{value:w,optionName:L}of x){let $=Upt(w,c,L);i=Jpt($,i)}return i},Upt=({transform:i,final:s,binary:c,writableObjectMode:p,readableObjectMode:y,preserveNewlines:x},w,L)=>{let $={};return[{transform:Opt(p,L)},wfe(c,w,p),Efe(c,x,p,$),{transform:i,final:s},{transform:Rpt(y,L)},Ipt({binary:c,preserveNewlines:x,readableObjectMode:y,state:$})].filter(Boolean)};var Wpt=(i,s)=>{for(let c of qfr(i))Jfr(i,c,s)},qfr=i=>new Set(Object.entries(i).filter(([,{direction:s}])=>s==="input").map(([s])=>Number(s))),Jfr=(i,s,c)=>{let{stdioItems:p}=i[s],y=p.filter(({contents:L})=>L!==void 0);if(y.length===0)return;if(s!==0){let[{type:L,optionName:$}]=y;throw new TypeError(`Only the \`stdin\` option, not \`${$}\`, can be ${f3[L]} with synchronous methods.`)}let w=y.map(({contents:L})=>L).map(L=>Ufr(L,p));c.input=bY(w)},Ufr=(i,s)=>{let c=Afe(i,s,"utf8",!0);return Wfr(c),bY(c)},Wfr=i=>{let s=i.find(c=>typeof c!="string"&&!Hg(c));if(s!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${s}.`)};var Nfe=require("node:fs");var Pfe=({stdioItems:i,encoding:s,verboseInfo:c,fdNumber:p})=>p!=="all"&&hB(c,p)&&!G2.has(s)&&zfr(p)&&(i.some(({type:y,value:x})=>y==="native"&&$fr.has(x))||i.every(({type:y})=>Hx.has(y))),zfr=i=>i===1||i===2,$fr=new Set(["pipe","overlapped"]),zpt=async(i,s,c,p)=>{for await(let y of i)Vfr(s)||Vpt(y,c,p)},$pt=(i,s,c)=>{for(let p of i)Vpt(p,s,c)},Vfr=i=>i._readableState.pipes.length>0,Vpt=(i,s,c)=>{let p=Wue(i);Ck({type:"output",verboseMessage:p,fdNumber:s,verboseInfo:c})};var Gpt=({fileDescriptors:i,syncResult:{output:s},options:c,isMaxBuffer:p,verboseInfo:y})=>{if(s===null)return{output:Array.from({length:3})};let x={},w=new Set([]);return{output:s.map(($,ne)=>Gfr({result:$,fileDescriptors:i,fdNumber:ne,state:x,outputFiles:w,isMaxBuffer:p,verboseInfo:y},c)),...x}},Gfr=({result:i,fileDescriptors:s,fdNumber:c,state:p,outputFiles:y,isMaxBuffer:x,verboseInfo:w},{buffer:L,encoding:$,lines:ne,stripFinalNewline:_e,maxBuffer:Ce})=>{if(i===null)return;let X=$_t(i,x,Ce),Je=RP(X),{stdioItems:Ae,objectMode:he}=s[c],ct=Hfr([Je],Ae,$,p),{serializedResult:Ze,finalResult:dr=Ze}=Yfr({chunks:ct,objectMode:he,encoding:$,lines:ne,stripFinalNewline:_e,fdNumber:c});Qfr({serializedResult:Ze,fdNumber:c,state:p,verboseInfo:w,encoding:$,stdioItems:Ae,objectMode:he});let Rr=L[c]?dr:void 0;try{return p.error===void 0&&Kfr(Ze,Ae,y),Rr}catch(wr){return p.error=wr,Rr}},Hfr=(i,s,c,p)=>{try{return Afe(i,s,c,!1)}catch(y){return p.error=y,i}},Yfr=({chunks:i,objectMode:s,encoding:c,lines:p,stripFinalNewline:y,fdNumber:x})=>{if(s)return{serializedResult:i};if(c==="buffer")return{serializedResult:bY(i)};let w=Ylt(i,c);return p[x]?{serializedResult:w,finalResult:zIe(w,!y[x],s)}:{serializedResult:w}},Qfr=({serializedResult:i,fdNumber:s,state:c,verboseInfo:p,encoding:y,stdioItems:x,objectMode:w})=>{if(!Pfe({stdioItems:x,encoding:y,verboseInfo:p,fdNumber:s}))return;let L=zIe(i,!1,w);try{$pt(L,s,p)}catch($){c.error??=$}},Kfr=(i,s,c)=>{for(let{path:p,append:y}of s.filter(({type:x})=>xfe.has(x))){let x=typeof p=="string"?p:p.toString();y||c.has(x)?(0,Nfe.appendFileSync)(p,i):(c.add(x),(0,Nfe.writeFileSync)(p,i))}};var Hpt=([,i,s],c)=>{if(c.all)return i===void 0?s:s===void 0?i:Array.isArray(i)?Array.isArray(s)?[...i,...s]:[...i,jP(s,c,"all")]:Array.isArray(s)?[jP(i,c,"all"),...s]:Hg(i)&&Hg(s)?KNe([i,s]):`${i}${s}`};var Ife=require("node:events");var Ypt=async(i,s)=>{let[c,p]=await Xfr(i);return s.isForcefullyTerminated??=!1,[c,p]},Xfr=async i=>{let[s,c]=await Promise.allSettled([(0,Ife.once)(i,"spawn"),(0,Ife.once)(i,"exit")]);return s.status==="rejected"?[]:c.status==="rejected"?Qpt(i):c.value},Qpt=async i=>{try{return await(0,Ife.once)(i,"exit")}catch{return Qpt(i)}},Kpt=async i=>{let[s,c]=await i;if(!Zfr(s,c)&&YIe(s,c))throw new tE;return[s,c]},Zfr=(i,s)=>i===void 0&&s===void 0,YIe=(i,s)=>i!==0||s!==null;var Xpt=({error:i,status:s,signal:c,output:p},{maxBuffer:y})=>{let x=e_r(i,s,c),w=x?.code==="ETIMEDOUT",L=z_t(x,p,y);return{resultError:x,exitCode:s,signal:c,timedOut:w,isMaxBuffer:L}},e_r=(i,s,c)=>i!==void 0?i:YIe(s,c)?new tE:void 0;var edt=(i,s,c)=>{let{file:p,commandArguments:y,command:x,escapedCommand:w,startTime:L,verboseInfo:$,options:ne,fileDescriptors:_e}=t_r(i,s,c),Ce=i_r({file:p,commandArguments:y,options:ne,command:x,escapedCommand:w,verboseInfo:$,fileDescriptors:_e,startTime:L});return EB(Ce,$,ne)},t_r=(i,s,c)=>{let{command:p,escapedCommand:y,startTime:x,verboseInfo:w}=$ue(i,s,c),L=r_r(c),{file:$,commandArguments:ne,options:_e}=ffe(i,s,L);n_r(_e);let Ce=kpt(_e,w);return{file:$,commandArguments:ne,command:p,escapedCommand:y,startTime:x,verboseInfo:w,options:_e,fileDescriptors:Ce}},r_r=i=>i.node&&!i.ipc?{...i,ipc:!1}:i,n_r=({ipc:i,ipcInput:s,detached:c,cancelSignal:p})=>{s&&Ffe("ipcInput"),i&&Ffe("ipc: true"),c&&Ffe("detached: true"),p&&Ffe("cancelSignal")},Ffe=i=>{throw new TypeError(`The "${i}" option cannot be used with synchronous methods.`)},i_r=({file:i,commandArguments:s,options:c,command:p,escapedCommand:y,verboseInfo:x,fileDescriptors:w,startTime:L})=>{let $=s_r({file:i,commandArguments:s,options:c,command:p,escapedCommand:y,fileDescriptors:w,startTime:L});if($.failed)return $;let{resultError:ne,exitCode:_e,signal:Ce,timedOut:X,isMaxBuffer:Je}=Xpt($,c),{output:Ae,error:he=ne}=Gpt({fileDescriptors:w,syncResult:$,options:c,isMaxBuffer:Je,verboseInfo:x}),ct=Ae.map((dr,Rr)=>jP(dr,c,Rr)),Ze=jP(Hpt(Ae,c),c,"all");return o_r({error:he,exitCode:_e,signal:Ce,timedOut:X,isMaxBuffer:Je,stdio:ct,all:Ze,options:c,command:p,escapedCommand:y,startTime:L})},s_r=({file:i,commandArguments:s,options:c,command:p,escapedCommand:y,fileDescriptors:x,startTime:w})=>{try{Wpt(x,c);let L=a_r(c);return(0,Zpt.spawnSync)(i,s,L)}catch(L){return CB({error:L,command:p,escapedCommand:y,fileDescriptors:x,options:c,startTime:w,isSync:!0})}},a_r=({encoding:i,maxBuffer:s,...c})=>({...c,encoding:"buffer",maxBuffer:vfe(s)}),o_r=({error:i,exitCode:s,signal:c,timedOut:p,isMaxBuffer:y,stdio:x,all:w,options:L,command:$,escapedCommand:ne,startTime:_e})=>i===void 0?bfe({command:$,escapedCommand:ne,stdio:x,all:w,ipcOutput:[],options:L,startTime:_e}):AY({error:i,command:$,escapedCommand:ne,timedOut:p,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:y,isForcefullyTerminated:!1,exitCode:s,signal:c,stdio:x,all:w,ipcOutput:[],options:L,startTime:_e,isSync:!0});var omt=require("node:events"),cmt=require("node:child_process");var KIe=xa(require("node:process"),1);var kB=require("node:events");var tdt=({anyProcess:i,channel:s,isSubprocess:c,ipc:p},{reference:y=!0,filter:x}={})=>(bB({methodName:"getOneMessage",isSubprocess:c,ipc:p,isConnected:ife(i)}),c_r({anyProcess:i,channel:s,isSubprocess:c,filter:x,reference:y})),c_r=async({anyProcess:i,channel:s,isSubprocess:c,filter:p,reference:y})=>{efe(s,y);let x=u3(i,s,c),w=new AbortController;try{return await Promise.race([l_r(x,p,w),u_r(x,c,w),f_r(x,c,w)])}catch(L){throw SB(i),L}finally{w.abort(),tfe(s,y)}},l_r=async(i,s,{signal:c})=>{if(s===void 0){let[p]=await(0,kB.once)(i,"message",{signal:c});return p}for await(let[p]of(0,kB.on)(i,"message",{signal:c}))if(s(p))return p},u_r=async(i,s,{signal:c})=>{await(0,kB.once)(i,"disconnect",{signal:c}),Dft(s)},f_r=async(i,s,{signal:c})=>{let[p]=await(0,kB.once)(i,"strict:error",{signal:c});throw Kue(p,s)};var IY=require("node:events");var ndt=({anyProcess:i,channel:s,isSubprocess:c,ipc:p},{reference:y=!0}={})=>QIe({anyProcess:i,channel:s,isSubprocess:c,ipc:p,shouldAwait:!c,reference:y}),QIe=({anyProcess:i,channel:s,isSubprocess:c,ipc:p,shouldAwait:y,reference:x})=>{bB({methodName:"getEachMessage",isSubprocess:c,ipc:p,isConnected:ife(i)}),efe(s,x);let w=u3(i,s,c),L=new AbortController,$={};return __r(i,w,L),p_r({ipcEmitter:w,isSubprocess:c,controller:L,state:$}),d_r({anyProcess:i,channel:s,ipcEmitter:w,isSubprocess:c,shouldAwait:y,controller:L,state:$,reference:x})},__r=async(i,s,c)=>{try{await(0,IY.once)(s,"disconnect",{signal:c.signal}),c.abort()}catch{}},p_r=async({ipcEmitter:i,isSubprocess:s,controller:c,state:p})=>{try{let[y]=await(0,IY.once)(i,"strict:error",{signal:c.signal});p.error=Kue(y,s),c.abort()}catch{}},d_r=async function*({anyProcess:i,channel:s,ipcEmitter:c,isSubprocess:p,shouldAwait:y,controller:x,state:w,reference:L}){try{for await(let[$]of(0,IY.on)(c,"message",{signal:x.signal}))rdt(w),yield $}catch{rdt(w)}finally{x.abort(),tfe(s,L),p||SB(i),y&&await i}},rdt=({error:i})=>{if(i)throw i};var idt=(i,{ipc:s})=>{Object.assign(i,adt(i,!1,s))},sdt=()=>{let i=KIe.default,s=!0,c=KIe.default.channel!==void 0;return{...adt(i,s,c),getCancelSignal:i_t.bind(void 0,{anyProcess:i,channel:i.channel,isSubprocess:s,ipc:c})}},adt=(i,s,c)=>({sendMessage:cfe.bind(void 0,{anyProcess:i,channel:i.channel,isSubprocess:s,ipc:c}),getOneMessage:tdt.bind(void 0,{anyProcess:i,channel:i.channel,isSubprocess:s,ipc:c}),getEachMessage:ndt.bind(void 0,{anyProcess:i,channel:i.channel,isSubprocess:s,ipc:c})});var odt=require("node:child_process"),_3=require("node:stream");var cdt=({error:i,command:s,escapedCommand:c,fileDescriptors:p,options:y,startTime:x,verboseInfo:w})=>{qIe(p);let L=new odt.ChildProcess;m_r(L,p),Object.assign(L,{readable:h_r,writable:g_r,duplex:y_r});let $=CB({error:i,command:s,escapedCommand:c,fileDescriptors:p,options:y,startTime:x,isSync:!1}),ne=v_r($,w,y);return{subprocess:L,promise:ne}},m_r=(i,s)=>{let c=FY(),p=FY(),y=FY(),x=Array.from({length:s.length-3},FY),w=FY(),L=[c,p,y,...x];Object.assign(i,{stdin:c,stdout:p,stderr:y,all:w,stdio:L})},FY=()=>{let i=new _3.PassThrough;return i.end(),i},h_r=()=>new _3.Readable({read(){}}),g_r=()=>new _3.Writable({write(){}}),y_r=()=>new _3.Duplex({read(){},write(){}}),v_r=async(i,s,c)=>EB(i,s,c);var AB=require("node:fs"),udt=require("node:buffer"),Pk=require("node:stream");var fdt=(i,s)=>Cfe(b_r,i,s,!1),OY=({type:i,optionName:s})=>{throw new TypeError(`The \`${s}\` option cannot be ${f3[i]}.`)},ldt={fileNumber:OY,generator:HIe,asyncGenerator:HIe,nodeStream:({value:i})=>({stream:i}),webTransform({value:{transform:i,writableObjectMode:s,readableObjectMode:c}}){let p=s||c;return{stream:Pk.Duplex.fromWeb(i,{objectMode:p})}},duplex:({value:{transform:i}})=>({stream:i}),native(){}},b_r={input:{...ldt,fileUrl:({value:i})=>({stream:(0,AB.createReadStream)(i)}),filePath:({value:{file:i}})=>({stream:(0,AB.createReadStream)(i)}),webStream:({value:i})=>({stream:Pk.Readable.fromWeb(i)}),iterable:({value:i})=>({stream:Pk.Readable.from(i)}),asyncIterable:({value:i})=>({stream:Pk.Readable.from(i)}),string:({value:i})=>({stream:Pk.Readable.from(i)}),uint8Array:({value:i})=>({stream:Pk.Readable.from(udt.Buffer.from(i))})},output:{...ldt,fileUrl:({value:i})=>({stream:(0,AB.createWriteStream)(i)}),filePath:({value:{file:i,append:s}})=>({stream:(0,AB.createWriteStream)(i,s?{flags:"a"}:{})}),webStream:({value:i})=>({stream:Pk.Writable.fromWeb(i)}),iterable:OY,asyncIterable:OY,string:OY,uint8Array:OY}};var RY=require("node:events"),Rfe=require("node:stream"),e4e=require("node:stream/promises");function O7(i){if(!Array.isArray(i))throw new TypeError(`Expected an array, got \`${typeof i}\`.`);for(let y of i)ZIe(y);let s=i.some(({readableObjectMode:y})=>y),c=S_r(i,s),p=new XIe({objectMode:s,writableHighWaterMark:c,readableHighWaterMark:c});for(let y of i)p.add(y);return p}var S_r=(i,s)=>{if(i.length===0)return(0,Rfe.getDefaultHighWaterMark)(s);let c=i.filter(({readableObjectMode:p})=>p===s).map(({readableHighWaterMark:p})=>p);return Math.max(...c)},XIe=class extends Rfe.PassThrough{#e=new Set([]);#t=new Set([]);#r=new Set([]);#n;#a=Symbol("unpipe");#c=new WeakMap;add(s){if(ZIe(s),this.#e.has(s))return;this.#e.add(s),this.#n??=T_r(this,this.#e,this.#a);let c=C_r({passThroughStream:this,stream:s,streams:this.#e,ended:this.#t,aborted:this.#r,onFinished:this.#n,unpipeEvent:this.#a});this.#c.set(s,c),s.pipe(this,{end:!1})}async remove(s){if(ZIe(s),!this.#e.has(s))return!1;let c=this.#c.get(s);return c===void 0?!1:(this.#c.delete(s),s.unpipe(this),await c,!0)}},T_r=async(i,s,c)=>{Ofe(i,_dt);let p=new AbortController;try{await Promise.race([x_r(i,p),D_r(i,s,c,p)])}finally{p.abort(),Ofe(i,-_dt)}},x_r=async(i,{signal:s})=>{try{await(0,e4e.finished)(i,{signal:s,cleanup:!0})}catch(c){throw ddt(i,c),c}},D_r=async(i,s,c,{signal:p})=>{for await(let[y]of(0,RY.on)(i,"unpipe",{signal:p}))s.has(y)&&y.emit(c)},ZIe=i=>{if(typeof i?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof i}\`.`)},C_r=async({passThroughStream:i,stream:s,streams:c,ended:p,aborted:y,onFinished:x,unpipeEvent:w})=>{Ofe(i,pdt);let L=new AbortController;try{await Promise.race([E_r(x,s,L),w_r({passThroughStream:i,stream:s,streams:c,ended:p,aborted:y,controller:L}),k_r({stream:s,streams:c,ended:p,aborted:y,unpipeEvent:w,controller:L})])}finally{L.abort(),Ofe(i,-pdt)}c.size>0&&c.size===p.size+y.size&&(p.size===0&&y.size>0?t4e(i):A_r(i))},E_r=async(i,s,{signal:c})=>{try{await i,c.aborted||t4e(s)}catch(p){c.aborted||ddt(s,p)}},w_r=async({passThroughStream:i,stream:s,streams:c,ended:p,aborted:y,controller:{signal:x}})=>{try{await(0,e4e.finished)(s,{signal:x,cleanup:!0,readable:!0,writable:!1}),c.has(s)&&p.add(s)}catch(w){if(x.aborted||!c.has(s))return;mdt(w)?y.add(s):hdt(i,w)}},k_r=async({stream:i,streams:s,ended:c,aborted:p,unpipeEvent:y,controller:{signal:x}})=>{if(await(0,RY.once)(i,y,{signal:x}),!i.readable)return(0,RY.once)(x,"abort",{signal:x});s.delete(i),c.delete(i),p.delete(i)},A_r=i=>{i.writable&&i.end()},ddt=(i,s)=>{mdt(s)?t4e(i):hdt(i,s)},mdt=i=>i?.code==="ERR_STREAM_PREMATURE_CLOSE",t4e=i=>{(i.readable||i.writable)&&i.destroy()},hdt=(i,s)=>{i.destroyed||(i.once("error",P_r),i.destroy(s))},P_r=()=>{},Ofe=(i,s)=>{let c=i.getMaxListeners();c!==0&&c!==Number.POSITIVE_INFINITY&&i.setMaxListeners(c+s)},_dt=2,pdt=1;var r4e=require("node:stream/promises");var PB=(i,s)=>{i.pipe(s),N_r(i,s),I_r(i,s)},N_r=async(i,s)=>{if(!(eE(i)||eE(s))){try{await(0,r4e.finished)(i,{cleanup:!0,readable:!0,writable:!1})}catch{}n4e(s)}},n4e=i=>{i.writable&&i.end()},I_r=async(i,s)=>{if(!(eE(i)||eE(s))){try{await(0,r4e.finished)(s,{cleanup:!0,readable:!1,writable:!0})}catch{}i4e(i)}},i4e=i=>{i.readable&&i.destroy()};var gdt=(i,s,c)=>{let p=new Map;for(let[y,{stdioItems:x,direction:w}]of Object.entries(s)){for(let{stream:L}of x.filter(({type:$})=>Hx.has($)))F_r(i,L,w,y);for(let{stream:L}of x.filter(({type:$})=>!Hx.has($)))R_r({subprocess:i,stream:L,direction:w,fdNumber:y,pipeGroups:p,controller:c})}for(let[y,x]of p.entries()){let w=x.length===1?x[0]:O7(x);PB(w,y)}},F_r=(i,s,c,p)=>{c==="output"?PB(i.stdio[p],s):PB(s,i.stdio[p]);let y=O_r[p];y!==void 0&&(i[y]=s),i.stdio[p]=s},O_r=["stdin","stdout","stderr"],R_r=({subprocess:i,stream:s,direction:c,fdNumber:p,pipeGroups:y,controller:x})=>{if(s===void 0)return;L_r(s,x);let[w,L]=c==="output"?[s,i.stdio[p]]:[i.stdio[p],s],$=y.get(w)??[];y.set(w,[...$,L])},L_r=(i,{signal:s})=>{eE(i)&&P7(i,M_r,s)},M_r=2;var ydt=require("node:events");var vdt=(i,{cleanup:s,detached:c},{signal:p})=>{if(!s||c)return;let y=Cue(()=>{i.kill()});(0,ydt.addAbortListener)(p,()=>{y()})};var Sdt=({source:i,sourcePromise:s,boundOptions:c,createNested:p},...y)=>{let x=zue(),{destination:w,destinationStream:L,destinationError:$,from:ne,unpipeSignal:_e}=j_r(c,p,y),{sourceStream:Ce,sourceError:X}=q_r(i,ne),{options:Je,fileDescriptors:Ae}=wk.get(i);return{sourcePromise:s,sourceStream:Ce,sourceOptions:Je,sourceError:X,destination:w,destinationStream:L,destinationError:$,unpipeSignal:_e,fileDescriptors:Ae,startTime:x}},j_r=(i,s,c)=>{try{let{destination:p,pipeOptions:{from:y,to:x,unpipeSignal:w}={}}=B_r(i,s,...c),L=Zue(p,x);return{destination:p,destinationStream:L,from:y,unpipeSignal:w}}catch(p){return{destinationError:p}}},B_r=(i,s,c,...p)=>{if(Array.isArray(c))return{destination:s(bdt,i)(c,...p),pipeOptions:i};if(typeof c=="string"||c instanceof URL||YNe(c)){if(Object.keys(i).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[y,x,w]=Fue(c,...p);return{destination:s(bdt)(y,x,w),pipeOptions:w}}if(wk.has(c)){if(Object.keys(i).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:c,pipeOptions:p[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${c}`)},bdt=({options:i})=>({options:{...i,stdin:"pipe",piped:!0}}),q_r=(i,s)=>{try{return{sourceStream:TB(i,s)}}catch(c){return{sourceError:c}}};var xdt=({sourceStream:i,sourceError:s,destinationStream:c,destinationError:p,fileDescriptors:y,sourceOptions:x,startTime:w})=>{let L=J_r({sourceStream:i,sourceError:s,destinationStream:c,destinationError:p});if(L!==void 0)throw s4e({error:L,fileDescriptors:y,sourceOptions:x,startTime:w})},J_r=({sourceStream:i,sourceError:s,destinationStream:c,destinationError:p})=>{if(s!==void 0&&p!==void 0)return p;if(p!==void 0)return i4e(i),p;if(s!==void 0)return n4e(c),s},s4e=({error:i,fileDescriptors:s,sourceOptions:c,startTime:p})=>CB({error:i,command:Tdt,escapedCommand:Tdt,fileDescriptors:s,options:c,startTime:p,isSync:!1}),Tdt="source.pipe(destination)";var Ddt=async i=>{let[{status:s,reason:c,value:p=c},{status:y,reason:x,value:w=x}]=await i;if(w.pipedFrom.includes(p)||w.pipedFrom.push(p),y==="rejected")throw w;if(s==="rejected")throw p;return w};var Cdt=require("node:stream/promises");var Edt=(i,s,c)=>{let p=Lfe.has(s)?W_r(i,s):U_r(i,s);return P7(i,$_r,c.signal),P7(s,V_r,c.signal),z_r(s),p},U_r=(i,s)=>{let c=O7([i]);return PB(c,s),Lfe.set(s,c),c},W_r=(i,s)=>{let c=Lfe.get(s);return c.add(i),c},z_r=async i=>{try{await(0,Cdt.finished)(i,{cleanup:!0,readable:!1,writable:!0})}catch{}Lfe.delete(i)},Lfe=new WeakMap,$_r=2,V_r=1;var wdt=require("node:util");var kdt=(i,s)=>i===void 0?[]:[G_r(i,s)],G_r=async(i,{sourceStream:s,mergedStream:c,fileDescriptors:p,sourceOptions:y,startTime:x})=>{await(0,wdt.aborted)(i,s),await c.remove(s);let w=new Error("Pipe canceled by `unpipeSignal` option.");throw s4e({error:w,fileDescriptors:p,sourceOptions:y,startTime:x})};var Mfe=(i,...s)=>{if(Bh(s[0]))return Mfe.bind(void 0,{...i,boundOptions:{...i.boundOptions,...s[0]}});let{destination:c,...p}=Sdt(i,...s),y=H_r({...p,destination:c});return y.pipe=Mfe.bind(void 0,{...i,source:c,sourcePromise:y,boundOptions:{}}),y},H_r=async({sourcePromise:i,sourceStream:s,sourceOptions:c,sourceError:p,destination:y,destinationStream:x,destinationError:w,unpipeSignal:L,fileDescriptors:$,startTime:ne})=>{let _e=Y_r(i,y);xdt({sourceStream:s,sourceError:p,destinationStream:x,destinationError:w,fileDescriptors:$,sourceOptions:c,startTime:ne});let Ce=new AbortController;try{let X=Edt(s,x,Ce);return await Promise.race([Ddt(_e),...kdt(L,{sourceStream:s,mergedStream:X,sourceOptions:c,fileDescriptors:$,startTime:ne})])}finally{Ce.abort()}},Y_r=(i,s)=>Promise.allSettled([i,s]);var Fdt=require("node:timers/promises");var Pdt=require("node:events"),Ndt=require("node:stream");var jfe=({subprocessStdout:i,subprocess:s,binary:c,shouldEncode:p,encoding:y,preserveNewlines:x})=>{let w=new AbortController;return Q_r(s,w),Idt({stream:i,controller:w,binary:c,shouldEncode:!i.readableObjectMode&&p,encoding:y,shouldSplit:!i.readableObjectMode,preserveNewlines:x})},Q_r=async(i,s)=>{try{await i}catch{}finally{s.abort()}},a4e=({stream:i,onStreamEnd:s,lines:c,encoding:p,stripFinalNewline:y,allMixed:x})=>{let w=new AbortController;K_r(s,w,i);let L=i.readableObjectMode&&!x;return Idt({stream:i,controller:w,binary:p==="buffer",shouldEncode:!L,encoding:p,shouldSplit:!L&&c,preserveNewlines:!y})},K_r=async(i,s,c)=>{try{await i}catch{c.destroy()}finally{s.abort()}},Idt=({stream:i,controller:s,binary:c,shouldEncode:p,encoding:y,shouldSplit:x,preserveNewlines:w})=>{let L=(0,Pdt.on)(i,"data",{signal:s.signal,highWaterMark:Adt,highWatermark:Adt});return X_r({onStdoutChunk:L,controller:s,binary:c,shouldEncode:p,encoding:y,shouldSplit:x,preserveNewlines:w})},o4e=(0,Ndt.getDefaultHighWaterMark)(!0),Adt=o4e,X_r=async function*({onStdoutChunk:i,controller:s,binary:c,shouldEncode:p,encoding:y,shouldSplit:x,preserveNewlines:w}){let L=Z_r({binary:c,shouldEncode:p,encoding:y,shouldSplit:x,preserveNewlines:w});try{for await(let[$]of i)yield*F7($,L,0)}catch($){if(!s.signal.aborted)throw $}finally{yield*PY(L)}},Z_r=({binary:i,shouldEncode:s,encoding:c,shouldSplit:p,preserveNewlines:y})=>[wfe(i,c,!s),Efe(i,y,!p,{})].filter(Boolean);var Odt=async({stream:i,onStreamEnd:s,fdNumber:c,encoding:p,buffer:y,maxBuffer:x,lines:w,allMixed:L,stripFinalNewline:$,verboseInfo:ne,streamInfo:_e})=>{let Ce=epr({stream:i,onStreamEnd:s,fdNumber:c,encoding:p,allMixed:L,verboseInfo:ne,streamInfo:_e});if(!y){await Promise.all([tpr(i),Ce]);return}let X=UIe($,c),Je=a4e({stream:i,onStreamEnd:s,lines:w,encoding:p,stripFinalNewline:X,allMixed:L}),[Ae]=await Promise.all([rpr({stream:i,iterable:Je,fdNumber:c,encoding:p,maxBuffer:x,lines:w}),Ce]);return Ae},epr=async({stream:i,onStreamEnd:s,fdNumber:c,encoding:p,allMixed:y,verboseInfo:x,streamInfo:{fileDescriptors:w}})=>{if(!Pfe({stdioItems:w[c]?.stdioItems,encoding:p,verboseInfo:x,fdNumber:c}))return;let L=a4e({stream:i,onStreamEnd:s,lines:!0,encoding:p,stripFinalNewline:!0,allMixed:y});await zpt(L,i,c,x)},tpr=async i=>{await(0,Fdt.setImmediate)(),i.readableFlowing===null&&i.resume()},rpr=async({stream:i,stream:{readableObjectMode:s},iterable:c,fdNumber:p,encoding:y,maxBuffer:x,lines:w})=>{try{return s||w?await mfe(c,{maxBuffer:x}):y==="buffer"?new Uint8Array(await hfe(c,{maxBuffer:x})):await yfe(c,{maxBuffer:x})}catch(L){return Rdt(J_t({error:L,stream:i,readableObjectMode:s,lines:w,encoding:y,fdNumber:p}))}},c4e=async i=>{try{return await i}catch(s){return Rdt(s)}},Rdt=({bufferedData:i})=>Glt(i)?new Uint8Array(i):i;var Mdt=require("node:stream/promises"),LY=async(i,s,c,{isSameDirection:p,stopOnExit:y=!1}={})=>{let x=npr(i,c),w=new AbortController;try{await Promise.race([...y?[c.exitPromise]:[],(0,Mdt.finished)(i,{cleanup:!0,signal:w.signal})])}catch(L){x.stdinCleanedUp||apr(L,s,c,p)}finally{w.abort()}},npr=(i,{originalStreams:[s],subprocess:c})=>{let p={stdinCleanedUp:!1};return i===s&&ipr(i,c,p),p},ipr=(i,s,c)=>{let{_destroy:p}=i;i._destroy=(...y)=>{spr(s,c),p.call(i,...y)}},spr=({exitCode:i,signalCode:s},c)=>{(i!==null||s!==null)&&(c.stdinCleanedUp=!0)},apr=(i,s,c,p)=>{if(!opr(i,s,c,p))throw i},opr=(i,s,c,p=!0)=>c.propagating?Ldt(i)||Bfe(i):(c.propagating=!0,l4e(c,s)===p?Ldt(i):Bfe(i)),l4e=({fileDescriptors:i},s)=>s!=="all"&&i[s].direction==="input",Bfe=i=>i?.code==="ERR_STREAM_PREMATURE_CLOSE",Ldt=i=>i?.code==="EPIPE";var jdt=({subprocess:i,encoding:s,buffer:c,maxBuffer:p,lines:y,stripFinalNewline:x,verboseInfo:w,streamInfo:L})=>i.stdio.map(($,ne)=>u4e({stream:$,fdNumber:ne,encoding:s,buffer:c[ne],maxBuffer:p[ne],lines:y[ne],allMixed:!1,stripFinalNewline:x,verboseInfo:w,streamInfo:L})),u4e=async({stream:i,fdNumber:s,encoding:c,buffer:p,maxBuffer:y,lines:x,allMixed:w,stripFinalNewline:L,verboseInfo:$,streamInfo:ne})=>{if(!i)return;let _e=LY(i,s,ne);if(l4e(ne,s)){await _e;return}let[Ce]=await Promise.all([Odt({stream:i,onStreamEnd:_e,fdNumber:s,encoding:c,buffer:p,maxBuffer:y,lines:x,allMixed:w,stripFinalNewline:L,verboseInfo:$,streamInfo:ne}),_e]);return Ce};var Bdt=({stdout:i,stderr:s},{all:c})=>c&&(i||s)?O7([i,s].filter(Boolean)):void 0,qdt=({subprocess:i,encoding:s,buffer:c,maxBuffer:p,lines:y,stripFinalNewline:x,verboseInfo:w,streamInfo:L})=>u4e({...cpr(i,c),fdNumber:"all",encoding:s,maxBuffer:p[1]+p[2],lines:y[1]||y[2],allMixed:lpr(i),stripFinalNewline:x,verboseInfo:w,streamInfo:L}),cpr=({stdout:i,stderr:s,all:c},[,p,y])=>{let x=p||y;return x?p?y?{stream:c,buffer:x}:{stream:i,buffer:x}:{stream:s,buffer:x}:{stream:c,buffer:x}},lpr=({all:i,stdout:s,stderr:c})=>i&&s&&c&&s.readableObjectMode!==c.readableObjectMode;var $dt=require("node:events");var Jdt=i=>hB(i,"ipc"),Udt=(i,s)=>{let c=Wue(i);Ck({type:"ipc",verboseMessage:c,fdNumber:"ipc",verboseInfo:s})};var Wdt=async({subprocess:i,buffer:s,maxBuffer:c,ipc:p,ipcOutput:y,verboseInfo:x})=>{if(!p)return y;let w=Jdt(x),L=LP(s,"ipc"),$=LP(c,"ipc");for await(let ne of QIe({anyProcess:i,channel:i.channel,isSubprocess:!1,ipc:p,shouldAwait:!1,reference:!0}))L&&(U_t(i,y,$),y.push(ne)),w&&Udt(ne,x);return y},zdt=async(i,s)=>(await Promise.allSettled([i]),s);var Vdt=async({subprocess:i,options:{encoding:s,buffer:c,maxBuffer:p,lines:y,timeoutDuration:x,cancelSignal:w,gracefulCancel:L,forceKillAfterDelay:$,stripFinalNewline:ne,ipc:_e,ipcInput:Ce},context:X,verboseInfo:Je,fileDescriptors:Ae,originalStreams:he,onInternalError:ct,controller:Ze})=>{let dr=Ypt(i,X),Rr={originalStreams:he,fileDescriptors:Ae,subprocess:i,exitPromise:dr,propagating:!1},wr=jdt({subprocess:i,encoding:s,buffer:c,maxBuffer:p,lines:y,stripFinalNewline:ne,verboseInfo:Je,streamInfo:Rr}),Dr=qdt({subprocess:i,encoding:s,buffer:c,maxBuffer:p,lines:y,stripFinalNewline:ne,verboseInfo:Je,streamInfo:Rr}),ir=[],Ft=Wdt({subprocess:i,buffer:c,maxBuffer:p,ipc:_e,ipcOutput:ir,verboseInfo:Je}),Tn=upr(he,i,Rr),rr=fpr(Ae,Rr);try{return await Promise.race([Promise.all([{},Kpt(dr),Promise.all(wr),Dr,Ft,m_t(i,Ce),...Tn,...rr]),ct,_pr(i,Ze),...u_t(i,x,X,Ze),...xft({subprocess:i,cancelSignal:w,gracefulCancel:L,context:X,controller:Ze}),...o_t({subprocess:i,cancelSignal:w,gracefulCancel:L,forceKillAfterDelay:$,context:X,controller:Ze})])}catch(Vn){return X.terminationReason??="other",Promise.all([{error:Vn},dr,Promise.all(wr.map(Nr=>c4e(Nr))),c4e(Dr),zdt(Ft,ir),Promise.allSettled(Tn),Promise.allSettled(rr)])}},upr=(i,s,c)=>i.map((p,y)=>p===s.stdio[y]?void 0:LY(p,y,c)),fpr=(i,s)=>i.flatMap(({stdioItems:c},p)=>c.filter(({value:y,stream:x=y})=>nE(x,{checkOpen:!1})&&!eE(x)).map(({type:y,value:x,stream:w=x})=>LY(w,p,s,{isSameDirection:Hx.has(y),stopOnExit:y==="native"}))),_pr=async(i,{signal:s})=>{let[c]=await(0,$dt.once)(i,"error",{signal:s});throw c};var Gdt=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),MY=(i,s,c)=>{let p=i[c];p.has(s)||p.set(s,[]);let y=p.get(s),x=Ek();return y.push(x),{resolve:x.resolve.bind(x),promises:y}},NB=async({resolve:i,promises:s},c)=>{i();let[p]=await Promise.race([Promise.allSettled([!0,c]),Promise.all([!1,...s])]);return!p};var Ydt=require("node:stream"),Qdt=require("node:util");var f4e=require("node:stream/promises");var _4e=async i=>{if(i!==void 0)try{await p4e(i)}catch{}},Hdt=async i=>{if(i!==void 0)try{await d4e(i)}catch{}},p4e=async i=>{await(0,f4e.finished)(i,{cleanup:!0,readable:!1,writable:!0})},d4e=async i=>{await(0,f4e.finished)(i,{cleanup:!0,readable:!0,writable:!1})},qfe=async(i,s)=>{if(await i,s)throw s},Jfe=(i,s,c)=>{c&&!Bfe(c)?i.destroy(c):s&&i.destroy()};var Kdt=({subprocess:i,concurrentStreams:s,encoding:c},{from:p,binary:y=!0,preserveNewlines:x=!0}={})=>{let w=y||G2.has(c),{subprocessStdout:L,waitReadableDestroy:$}=m4e(i,p,s),{readableEncoding:ne,readableObjectMode:_e,readableHighWaterMark:Ce}=h4e(L,w),{read:X,onStdoutDataDone:Je}=g4e({subprocessStdout:L,subprocess:i,binary:w,encoding:c,preserveNewlines:x}),Ae=new Ydt.Readable({read:X,destroy:(0,Qdt.callbackify)(v4e.bind(void 0,{subprocessStdout:L,subprocess:i,waitReadableDestroy:$})),highWaterMark:Ce,objectMode:_e,encoding:ne});return y4e({subprocessStdout:L,onStdoutDataDone:Je,readable:Ae,subprocess:i}),Ae},m4e=(i,s,c)=>{let p=TB(i,s),y=MY(c,p,"readableDestroy");return{subprocessStdout:p,waitReadableDestroy:y}},h4e=({readableEncoding:i,readableObjectMode:s,readableHighWaterMark:c},p)=>p?{readableEncoding:i,readableObjectMode:s,readableHighWaterMark:c}:{readableEncoding:i,readableObjectMode:!0,readableHighWaterMark:o4e},g4e=({subprocessStdout:i,subprocess:s,binary:c,encoding:p,preserveNewlines:y})=>{let x=Ek(),w=jfe({subprocessStdout:i,subprocess:s,binary:c,shouldEncode:!c,encoding:p,preserveNewlines:y});return{read(){ppr(this,w,x)},onStdoutDataDone:x}},ppr=async(i,s,c)=>{try{let{value:p,done:y}=await s.next();y?c.resolve():i.push(p)}catch{}},y4e=async({subprocessStdout:i,onStdoutDataDone:s,readable:c,subprocess:p,subprocessStdin:y})=>{try{await d4e(i),await p,await _4e(y),await s,c.readable&&c.push(null)}catch(x){await _4e(y),Xdt(c,x)}},v4e=async({subprocessStdout:i,subprocess:s,waitReadableDestroy:c},p)=>{await NB(c,s)&&(Xdt(i,p),await qfe(s,p))},Xdt=(i,s)=>{Jfe(i,i.readable,s)};var Zdt=require("node:stream"),b4e=require("node:util");var emt=({subprocess:i,concurrentStreams:s},{to:c}={})=>{let{subprocessStdin:p,waitWritableFinal:y,waitWritableDestroy:x}=S4e(i,c,s),w=new Zdt.Writable({...T4e(p,i,y),destroy:(0,b4e.callbackify)(D4e.bind(void 0,{subprocessStdin:p,subprocess:i,waitWritableFinal:y,waitWritableDestroy:x})),highWaterMark:p.writableHighWaterMark,objectMode:p.writableObjectMode});return x4e(p,w),w},S4e=(i,s,c)=>{let p=Zue(i,s),y=MY(c,p,"writableFinal"),x=MY(c,p,"writableDestroy");return{subprocessStdin:p,waitWritableFinal:y,waitWritableDestroy:x}},T4e=(i,s,c)=>({write:dpr.bind(void 0,i),final:(0,b4e.callbackify)(mpr.bind(void 0,i,s,c))}),dpr=(i,s,c,p)=>{i.write(s,c)?p():i.once("drain",p)},mpr=async(i,s,c)=>{await NB(c,s)&&(i.writable&&i.end(),await s)},x4e=async(i,s,c)=>{try{await p4e(i),s.writable&&s.end()}catch(p){await Hdt(c),tmt(s,p)}},D4e=async({subprocessStdin:i,subprocess:s,waitWritableFinal:c,waitWritableDestroy:p},y)=>{await NB(c,s),await NB(p,s)&&(tmt(i,y),await qfe(s,y))},tmt=(i,s)=>{Jfe(i,i.writable,s)};var rmt=require("node:stream"),nmt=require("node:util");var imt=({subprocess:i,concurrentStreams:s,encoding:c},{from:p,to:y,binary:x=!0,preserveNewlines:w=!0}={})=>{let L=x||G2.has(c),{subprocessStdout:$,waitReadableDestroy:ne}=m4e(i,p,s),{subprocessStdin:_e,waitWritableFinal:Ce,waitWritableDestroy:X}=S4e(i,y,s),{readableEncoding:Je,readableObjectMode:Ae,readableHighWaterMark:he}=h4e($,L),{read:ct,onStdoutDataDone:Ze}=g4e({subprocessStdout:$,subprocess:i,binary:L,encoding:c,preserveNewlines:w}),dr=new rmt.Duplex({read:ct,...T4e(_e,i,Ce),destroy:(0,nmt.callbackify)(hpr.bind(void 0,{subprocessStdout:$,subprocessStdin:_e,subprocess:i,waitReadableDestroy:ne,waitWritableFinal:Ce,waitWritableDestroy:X})),readableHighWaterMark:he,writableHighWaterMark:_e.writableHighWaterMark,readableObjectMode:Ae,writableObjectMode:_e.writableObjectMode,encoding:Je});return y4e({subprocessStdout:$,onStdoutDataDone:Ze,readable:dr,subprocess:i,subprocessStdin:_e}),x4e(_e,dr,$),dr},hpr=async({subprocessStdout:i,subprocessStdin:s,subprocess:c,waitReadableDestroy:p,waitWritableFinal:y,waitWritableDestroy:x},w)=>{await Promise.all([v4e({subprocessStdout:i,subprocess:c,waitReadableDestroy:p},w),D4e({subprocessStdin:s,subprocess:c,waitWritableFinal:y,waitWritableDestroy:x},w)])};var C4e=(i,s,{from:c,binary:p=!1,preserveNewlines:y=!1}={})=>{let x=p||G2.has(s),w=TB(i,c),L=jfe({subprocessStdout:w,subprocess:i,binary:x,shouldEncode:!0,encoding:s,preserveNewlines:y});return gpr(L,w,i)},gpr=async function*(i,s,c){try{yield*i}finally{s.readable&&s.destroy(),await c}};var smt=(i,{encoding:s})=>{let c=Gdt();i.readable=Kdt.bind(void 0,{subprocess:i,concurrentStreams:c,encoding:s}),i.writable=emt.bind(void 0,{subprocess:i,concurrentStreams:c}),i.duplex=imt.bind(void 0,{subprocess:i,concurrentStreams:c,encoding:s}),i.iterable=C4e.bind(void 0,i,s),i[Symbol.asyncIterator]=C4e.bind(void 0,i,s,{})};var amt=(i,s)=>{for(let[c,p]of vpr){let y=p.value.bind(s);Reflect.defineProperty(i,c,{...p,value:y})}},ypr=(async()=>{})().constructor.prototype,vpr=["then","catch","finally"].map(i=>[i,Reflect.getOwnPropertyDescriptor(ypr,i)]);var lmt=(i,s,c,p)=>{let{file:y,commandArguments:x,command:w,escapedCommand:L,startTime:$,verboseInfo:ne,options:_e,fileDescriptors:Ce}=bpr(i,s,c),{subprocess:X,promise:Je}=Tpr({file:y,commandArguments:x,options:_e,startTime:$,verboseInfo:ne,command:w,escapedCommand:L,fileDescriptors:Ce});return X.pipe=Mfe.bind(void 0,{source:X,sourcePromise:Je,boundOptions:{},createNested:p}),amt(X,Je),wk.set(X,{options:_e,fileDescriptors:Ce}),X},bpr=(i,s,c)=>{let{command:p,escapedCommand:y,startTime:x,verboseInfo:w}=$ue(i,s,c),{file:L,commandArguments:$,options:ne}=ffe(i,s,c),_e=Spr(ne),Ce=fdt(_e,w);return{file:L,commandArguments:$,command:p,escapedCommand:y,startTime:x,verboseInfo:w,options:_e,fileDescriptors:Ce}},Spr=({timeout:i,signal:s,...c})=>{if(s!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...c,timeoutDuration:i}},Tpr=({file:i,commandArguments:s,options:c,startTime:p,verboseInfo:y,command:x,escapedCommand:w,fileDescriptors:L})=>{let $;try{$=(0,cmt.spawn)(i,s,c)}catch(Ae){return cdt({error:Ae,command:x,escapedCommand:w,fileDescriptors:L,options:c,startTime:p,verboseInfo:y})}let ne=new AbortController;(0,omt.setMaxListeners)(Number.POSITIVE_INFINITY,ne.signal);let _e=[...$.stdio];gdt($,L,ne),vdt($,c,ne);let Ce={},X=Ek();$.kill=bft.bind(void 0,{kill:$.kill.bind($),options:c,onInternalError:X,context:Ce,controller:ne}),$.all=Bdt($,c),smt($,c),idt($,c);let Je=xpr({subprocess:$,options:c,startTime:p,verboseInfo:y,fileDescriptors:L,originalStreams:_e,command:x,escapedCommand:w,context:Ce,onInternalError:X,controller:ne});return{subprocess:$,promise:Je}},xpr=async({subprocess:i,options:s,startTime:c,verboseInfo:p,fileDescriptors:y,originalStreams:x,command:w,escapedCommand:L,context:$,onInternalError:ne,controller:_e})=>{let[Ce,[X,Je],Ae,he,ct]=await Vdt({subprocess:i,options:s,context:$,verboseInfo:p,fileDescriptors:y,originalStreams:x,onInternalError:ne,controller:_e});_e.abort(),ne.resolve();let Ze=Ae.map((wr,Dr)=>jP(wr,s,Dr)),dr=jP(he,s,"all"),Rr=Dpr({errorInfo:Ce,exitCode:X,signal:Je,stdio:Ze,all:dr,ipcOutput:ct,context:$,options:s,command:w,escapedCommand:L,startTime:c});return EB(Rr,p,s)},Dpr=({errorInfo:i,exitCode:s,signal:c,stdio:p,all:y,ipcOutput:x,context:w,options:L,command:$,escapedCommand:ne,startTime:_e})=>"error"in i?AY({error:i.error,command:$,escapedCommand:ne,timedOut:w.terminationReason==="timeout",isCanceled:w.terminationReason==="cancel"||w.terminationReason==="gracefulCancel",isGracefullyCanceled:w.terminationReason==="gracefulCancel",isMaxBuffer:i.error instanceof kk,isForcefullyTerminated:w.isForcefullyTerminated,exitCode:s,signal:c,stdio:p,all:y,ipcOutput:x,options:L,startTime:_e,isSync:!1}):bfe({command:$,escapedCommand:ne,stdio:p,all:y,ipcOutput:x,options:L,startTime:_e});var Ufe=(i,s)=>{let c=Object.fromEntries(Object.entries(s).map(([p,y])=>[p,Cpr(p,i[p],y)]));return{...i,...c}},Cpr=(i,s,c)=>Epr.has(i)&&Bh(s)&&Bh(c)?{...s,...c}:c,Epr=new Set(["env",...eIe]);var p3=(i,s,c,p)=>{let y=(w,L,$)=>p3(w,L,c,$),x=(...w)=>wpr({mapArguments:i,deepOptions:c,boundOptions:s,setBoundExeca:p,createNested:y},...w);return p!==void 0&&p(x,y,s),x},wpr=({mapArguments:i,deepOptions:s={},boundOptions:c={},setBoundExeca:p,createNested:y},x,...w)=>{if(Bh(x))return y(i,Ufe(c,x),p);let{file:L,commandArguments:$,options:ne,isSync:_e}=kpr({mapArguments:i,firstArgument:x,nextArguments:w,deepOptions:s,boundOptions:c});return _e?edt(L,$,ne):lmt(L,$,ne,y)},kpr=({mapArguments:i,firstArgument:s,nextArguments:c,deepOptions:p,boundOptions:y})=>{let x=eut(s)?tut(s,c):[s,...c],[w,L,$]=Fue(...x),ne=Ufe(Ufe(p,y),$),{file:_e=w,commandArguments:Ce=L,options:X=ne,isSync:Je=!1}=i({file:w,commandArguments:L,options:ne});return{file:_e,commandArguments:Ce,options:X,isSync:Je}};var umt=({file:i,commandArguments:s})=>_mt(i,s),fmt=({file:i,commandArguments:s})=>({..._mt(i,s),isSync:!0}),_mt=(i,s)=>{if(s.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${i} ${s}.`);let[c,...p]=Apr(i);return{file:c,commandArguments:p}},Apr=i=>{if(typeof i!="string")throw new TypeError(`The command must be a string: ${String(i)}.`);let s=i.trim();if(s==="")return[];let c=[];for(let p of s.split(Ppr)){let y=c.at(-1);y&&y.endsWith("\\")?c[c.length-1]=`${y.slice(0,-1)} ${p}`:c.push(p)}return c},Ppr=/ +/g;var pmt=(i,s,c)=>{i.sync=s(Npr,c),i.s=i.sync},dmt=({options:i})=>mmt(i),Npr=({options:i})=>({...mmt(i),isSync:!0}),mmt=i=>({options:{...Ipr(i),...i}}),Ipr=({input:i,inputFile:s,stdio:c})=>i===void 0&&s===void 0&&c===void 0?{stdin:"inherit"}:{},hmt={preferLocal:!0};var d3=p3(()=>({})),QWr=p3(()=>({isSync:!0})),KWr=p3(umt),XWr=p3(fmt),ZWr=p3(f_t),ezr=p3(dmt,{},hmt,pmt),{sendMessage:tzr,getOneMessage:rzr,getEachMessage:nzr,getCancelSignal:izr}=sdt();var ng=xa(require("node:path")),eD=xa(require("node:fs")),Kyt=xa(ymt()),z_e=xa(cY()),Xyt=xa(r_e()),Zyt=xa(wyt()),$7=xa(Pyt());var IFe=xa(require("crypto")),Uyt=xa(require("path")),SQ=xa(require("fs")),Wyt=xa(r_e()),zyt=require("@oclif/core");var Byt=require("@oclif/core"),qyt=xa(r_e()),Jyt=xa(PFe());async function Yg(i,s){let c;try{c=await(0,qyt.default)(i,{method:s.method||"GET",headers:{"Content-Type":"application/json",Accept:"application/json",...s.token?{Authorization:`Bearer ${s.token}`}:void 0},body:s.body})}catch(p){throw new Error(`HTTP request: ${p.message}`)}if(!c.ok){switch(c.status){case 401:throw new Mk(c,"not authorized - please log in first using `npx ray login`");case 403:throw new Mk(c,"forbidden - you don't have permissions to perform the request");case 402:throw new Mk(c,"the limit of free commands has been reached")}let p=await c.text(),y;try{y=JSON.parse(p)}catch{throw new Mk(c,`HTTP error: ${c.status} - ${p}`)}throw Array.isArray(y.errors)&&y.errors.length>0?new Mk(c,`error: ${y.errors[0].status} - ${y.errors[0].title}`):new Mk(c,`HTTP error: ${c.status} - ${p}`)}return await c.json()}var Mk=class extends Error{constructor(s,c){let p=s.headers.get("X-Request-Id");p?super(`${c} (${s.url} RequestID: ${p})`):super(c),this.name="HTTPError"}};function NFe(i){(0,Jyt.default)(i).catch(s=>{Byt.ux.error(new Error(`failed opening browser to URL ${i}: ${s.message}`),{exit:1})})}var U$r=`${Ux.url}/sessions/success`,W$r=`${Ux.url}/sessions/failure`;function $yt(){$_("raycastAccessToken")===""&&zyt.ux.error("please first log in first using `npx ray login`",{exit:1})}function FFe(){let i=$_("raycastApiURL"),s=$_("raycastAccessToken");return Yg(`${i}/api/v1/me`,{token:s})}function U_e(i){let s=$_("raycastApiURL"),c=$_("raycastAccessToken");return Yg(`${s}/api/v1/users/${i}`,{token:c})}function Vyt(){let i=$_("raycastApiURL"),s=$_("raycastAccessToken");return Yg(`${i}/api/v1/me/organizations`,{token:s})}function Gyt(i){let s=$_("raycastApiURL"),c=$_("raycastAccessToken");return Yg(`${s}/api/v1/organizations/${i}`,{token:c})}function Hyt(i){return Promise.all(i.map(async s=>{try{return await OFe(s,"image/png")}catch(c){throw new Error(`upload: ${c.message}`)}}))}async function OFe(i,s){let c=$_("raycastApiURL"),p=$_("raycastAccessToken"),y=SQ.statSync(i),x=await Yg(`${c}/api/v1/direct_uploads`,{token:p,method:"POST",body:JSON.stringify({blob:{content_type:s,filename:Uyt.basename(i),byte_size:y.size,checksum:IFe.createHash("md5").update(SQ.readFileSync(i)).digest("base64")}})}),w=SQ.readFileSync(i),L=await(0,Wyt.default)(x.direct_upload.url,{method:"PUT",body:w,headers:x.direct_upload.headers});if(!L.ok)throw new Mk(L,L.statusText);return x.signed_id}function Yyt(i){let s=$_("raycastApiURL"),c=$_("raycastAccessToken");return Yg(`${s}/api/v1/versions`,{token:c,method:"POST",body:JSON.stringify(i)})}function Qyt(i){let s=$_("raycastApiURL"),c=$_("raycastAccessToken");return Yg(`${s}/api/v1/organizations/%${i}/billing/checkouts`,{token:c,method:"POST"}).then(p=>p.key).catch(()=>{})}var RFe=class i extends a3{static description="Validate the extension manifest and metadata, and lint its source code";static flags={fix:W_e.Flags.boolean({char:"f",default:!1,description:"Attempt to fix linting issues"}),relaxed:W_e.Flags.boolean({char:"r",description:"Use relaxed linting mode to skip validation of: package.json schema, icons and metadata.",default:!1}),schema:W_e.Flags.string({char:"s",description:"Path to JSON schema for package.json validation "+i3,default:`${Ux.url}/schemas/extension.json`,hidden:!0})};async run(){let{flags:s}=await this.parse(i);await LFe({skipOwner:!1,fix:s.fix,relaxed:s.relaxed,skipLockFiles:process.env.CI?.toLowerCase()!=="true",schema:s.schema})||this.error("linting issues found (tip: try re-running with '--fix')")}};async function LFe(i){let s=!0;try{let c=Dk();s=await a1r(c,i),s=await o1r(c,i)&&s,s=await c1r(c,i)&&s,s=await l1r(c,i)&&s}catch(c){console.error("error reading manifest:",c),s=!1}return s=await u1r(i)&&s,s=await f1r(i)&&s,s}async function a1r(i,s){return await Gg("validate package.json file",async()=>{let p=[],y=[];try{await U_e(i.author)}catch(x){x.message.includes("Couldn't find User")?p.push({pointer:"/author",message:`Invalid author "${i.author}". Use the Raycast username`,level:"error"}):p.push({pointer:"/author",message:`Invalid author "${i.author}". ${x.message}`,level:"error"})}if(await Promise.all((i.contributors||[]).map(async(x,w)=>{try{await U_e(x)}catch(L){L.message.includes("Couldn't find User")?p.push({pointer:"/contributors/"+w,message:`Invalid contributor "${i.author}". Use the Raycast username`,level:"error"}):p.push({pointer:"/contributors/"+w,message:`Invalid contributor "${i.author}". ${L.message}`,level:"error"})}x===i.author&&p.push({pointer:"/contributors/"+w,message:`Author "${i.author}" should not be added as a contributor`,level:"error"})})),await Promise.all((i.pastContributors||[]).map(async(x,w)=>{try{await U_e(x)}catch(L){L.message.includes("Couldn't find User")?p.push({pointer:"/pastContributors/"+w,message:`Invalid contributor "${i.author}". Use the Raycast username`,level:"error"}):p.push({pointer:"/pastContributors/"+w,message:`Invalid contributor "${i.author}". ${L.message}`,level:"error"})}})),i.owner&&!s.skipOwner)try{await Gyt(i.owner)}catch(x){x.message.includes("Couldn't find Organization")?p.push({pointer:"/owner",message:`Invalid owner "${i.owner}". Use the Raycast organization handle`,level:"error"}):p.push({pointer:"/owner",message:`Invalid owner "${i.author}". ${x.message}`,level:"error"})}if(!s.relaxed){let x=new Zyt.default({allErrors:!0});try{let w=await(await(0,Xyt.default)(s.schema)).json();delete w.$schema;let L=x.compile(w);L(i)||p.push(...(L.errors||[]).map($=>({pointer:$.instancePath,message:$.message||"",level:"error"})))}catch(w){p.push({message:`Failed compiling JSON schema: ${w.message}`,level:"error"})}i.name.startsWith("@workaround/")&&y.push({pointer:"/name",message:`"@workaround/" is a reserved prefix for internal extensions in companies that have a policy regarding namespaced package.json names. This isn't valid for public extensions`,level:"warning"}),(0,$7.titleCase)(i.title)!==i.title&&y.push({pointer:"/title",message:`Extension's title has to be Title Cased. Expected "${(0,$7.titleCase)(i.title)}"`,level:"warning"}),eq(i.title)||y.push({pointer:"/title",message:'Raycast is spelled "Raycast"',level:"warning"}),eq(i.description)||y.push({pointer:"/description",message:'Raycast is spelled "Raycast"',level:"warning"}),i.commands.forEach((w,L)=>{(0,$7.titleCase)(w.title)!==w.title&&y.push({pointer:`/commands/${L}/title`,message:`Command's title has to be Title Cased. Expected "${(0,$7.titleCase)(w.title)}"`,level:"warning"}),eq(w.title)||y.push({pointer:`/commands/${L}/title`,message:'Raycast is spelled "Raycast"',level:"warning"}),eq(w.description)||y.push({pointer:`/commands/${L}/description`,message:'Raycast is spelled "Raycast"',level:"warning"})}),i.tools?.forEach((w,L)=>{(0,$7.titleCase)(w.title)!==w.title&&y.push({pointer:`/tools/${L}/title`,message:`Tool's title has to be Title Cased. Expected "${(0,$7.titleCase)(w.title)}"`,level:"warning"}),eq(w.title)||y.push({pointer:`/tools/${L}/title`,message:'Raycast is spelled "Raycast"',level:"warning"}),eq(w.description)||y.push({pointer:`/tools/${L}/description`,message:'Raycast is spelled "Raycast"',level:"warning"})})}if(p.length>0)throw new Error(`${ng.resolve("package.json")}
|
|
661
|
+
if (condition) { yield value; }`)};var Mpt=require("node:buffer"),jpt=require("node:string_decoder");var wfe=(i,s,c)=>{if(c)return;if(i)return{transform:Ffr.bind(void 0,new TextEncoder)};let p=new jpt.StringDecoder(s);return{transform:Ofr.bind(void 0,p),final:Rfr.bind(void 0,p)}},Ffr=function*(i,s){Mpt.Buffer.isBuffer(s)?yield RP(s):typeof s=="string"?yield i.encode(s):yield s},Ofr=function*(i,s){yield Hg(s)?i.write(s):s},Rfr=function*(i){let s=i.end();s!==""&&(yield s)};var $Ie=require("node:util"),VIe=(0,$Ie.callbackify)(async(i,s,c,p)=>{s.currentIterable=i(...c);try{for await(let y of s.currentIterable)p.push(y)}finally{delete s.currentIterable}}),kfe=async function*(i,s,c){if(c===s.length){yield i;return}let{transform:p=Mfr}=s[c];for await(let y of p(i))yield*kfe(y,s,c+1)},Bpt=async function*(i){for(let[s,{final:c}]of Object.entries(i))yield*Lfr(c,Number(s),i)},Lfr=async function*(i,s,c){if(i!==void 0)for await(let p of i())yield*kfe(p,c,s+1)},qpt=(0,$Ie.callbackify)(async({currentIterable:i},s)=>{if(i!==void 0){await(s?i.throw(s):i.return());return}if(s)throw s}),Mfr=function*(i){yield i};var GIe=(i,s,c,p)=>{try{for(let y of i(...s))c.push(y);p()}catch(y){p(y)}},Jpt=(i,s)=>[...s.flatMap(c=>[...F7(c,i,0)]),...PY(i)],F7=function*(i,s,c){if(c===s.length){yield i;return}let{transform:p=Bfr}=s[c];for(let y of p(i))yield*F7(y,s,c+1)},PY=function*(i){for(let[s,{final:c}]of Object.entries(i))yield*jfr(c,Number(s),i)},jfr=function*(i,s,c){if(i!==void 0)for(let p of i())yield*F7(p,c,s+1)},Bfr=function*(i){yield i};var HIe=({value:i,value:{transform:s,final:c,writableObjectMode:p,readableObjectMode:y},optionName:x},{encoding:w})=>{let L={},$=Upt(i,w,x),ne=I7(s),_e=I7(c),Ce=ne?VIe.bind(void 0,kfe,L):GIe.bind(void 0,F7),X=ne||_e?VIe.bind(void 0,Bpt,L):GIe.bind(void 0,PY),Je=ne||_e?qpt.bind(void 0,L):void 0;return{stream:new NY.Transform({writableObjectMode:p,writableHighWaterMark:(0,NY.getDefaultHighWaterMark)(p),readableObjectMode:y,readableHighWaterMark:(0,NY.getDefaultHighWaterMark)(y),transform(he,ct,Ze){Ce([he,$,0],this,Ze)},flush(he){X([$],this,he)},destroy:Je})}},Afe=(i,s,c,p)=>{let y=s.filter(({type:w})=>w==="generator"),x=p?y.reverse():y;for(let{value:w,optionName:L}of x){let $=Upt(w,c,L);i=Jpt($,i)}return i},Upt=({transform:i,final:s,binary:c,writableObjectMode:p,readableObjectMode:y,preserveNewlines:x},w,L)=>{let $={};return[{transform:Opt(p,L)},wfe(c,w,p),Efe(c,x,p,$),{transform:i,final:s},{transform:Rpt(y,L)},Ipt({binary:c,preserveNewlines:x,readableObjectMode:y,state:$})].filter(Boolean)};var Wpt=(i,s)=>{for(let c of qfr(i))Jfr(i,c,s)},qfr=i=>new Set(Object.entries(i).filter(([,{direction:s}])=>s==="input").map(([s])=>Number(s))),Jfr=(i,s,c)=>{let{stdioItems:p}=i[s],y=p.filter(({contents:L})=>L!==void 0);if(y.length===0)return;if(s!==0){let[{type:L,optionName:$}]=y;throw new TypeError(`Only the \`stdin\` option, not \`${$}\`, can be ${f3[L]} with synchronous methods.`)}let w=y.map(({contents:L})=>L).map(L=>Ufr(L,p));c.input=bY(w)},Ufr=(i,s)=>{let c=Afe(i,s,"utf8",!0);return Wfr(c),bY(c)},Wfr=i=>{let s=i.find(c=>typeof c!="string"&&!Hg(c));if(s!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${s}.`)};var Nfe=require("node:fs");var Pfe=({stdioItems:i,encoding:s,verboseInfo:c,fdNumber:p})=>p!=="all"&&hB(c,p)&&!G2.has(s)&&zfr(p)&&(i.some(({type:y,value:x})=>y==="native"&&$fr.has(x))||i.every(({type:y})=>Hx.has(y))),zfr=i=>i===1||i===2,$fr=new Set(["pipe","overlapped"]),zpt=async(i,s,c,p)=>{for await(let y of i)Vfr(s)||Vpt(y,c,p)},$pt=(i,s,c)=>{for(let p of i)Vpt(p,s,c)},Vfr=i=>i._readableState.pipes.length>0,Vpt=(i,s,c)=>{let p=Wue(i);Ck({type:"output",verboseMessage:p,fdNumber:s,verboseInfo:c})};var Gpt=({fileDescriptors:i,syncResult:{output:s},options:c,isMaxBuffer:p,verboseInfo:y})=>{if(s===null)return{output:Array.from({length:3})};let x={},w=new Set([]);return{output:s.map(($,ne)=>Gfr({result:$,fileDescriptors:i,fdNumber:ne,state:x,outputFiles:w,isMaxBuffer:p,verboseInfo:y},c)),...x}},Gfr=({result:i,fileDescriptors:s,fdNumber:c,state:p,outputFiles:y,isMaxBuffer:x,verboseInfo:w},{buffer:L,encoding:$,lines:ne,stripFinalNewline:_e,maxBuffer:Ce})=>{if(i===null)return;let X=$_t(i,x,Ce),Je=RP(X),{stdioItems:Ae,objectMode:he}=s[c],ct=Hfr([Je],Ae,$,p),{serializedResult:Ze,finalResult:dr=Ze}=Yfr({chunks:ct,objectMode:he,encoding:$,lines:ne,stripFinalNewline:_e,fdNumber:c});Qfr({serializedResult:Ze,fdNumber:c,state:p,verboseInfo:w,encoding:$,stdioItems:Ae,objectMode:he});let Rr=L[c]?dr:void 0;try{return p.error===void 0&&Kfr(Ze,Ae,y),Rr}catch(wr){return p.error=wr,Rr}},Hfr=(i,s,c,p)=>{try{return Afe(i,s,c,!1)}catch(y){return p.error=y,i}},Yfr=({chunks:i,objectMode:s,encoding:c,lines:p,stripFinalNewline:y,fdNumber:x})=>{if(s)return{serializedResult:i};if(c==="buffer")return{serializedResult:bY(i)};let w=Ylt(i,c);return p[x]?{serializedResult:w,finalResult:zIe(w,!y[x],s)}:{serializedResult:w}},Qfr=({serializedResult:i,fdNumber:s,state:c,verboseInfo:p,encoding:y,stdioItems:x,objectMode:w})=>{if(!Pfe({stdioItems:x,encoding:y,verboseInfo:p,fdNumber:s}))return;let L=zIe(i,!1,w);try{$pt(L,s,p)}catch($){c.error??=$}},Kfr=(i,s,c)=>{for(let{path:p,append:y}of s.filter(({type:x})=>xfe.has(x))){let x=typeof p=="string"?p:p.toString();y||c.has(x)?(0,Nfe.appendFileSync)(p,i):(c.add(x),(0,Nfe.writeFileSync)(p,i))}};var Hpt=([,i,s],c)=>{if(c.all)return i===void 0?s:s===void 0?i:Array.isArray(i)?Array.isArray(s)?[...i,...s]:[...i,jP(s,c,"all")]:Array.isArray(s)?[jP(i,c,"all"),...s]:Hg(i)&&Hg(s)?KNe([i,s]):`${i}${s}`};var Ife=require("node:events");var Ypt=async(i,s)=>{let[c,p]=await Xfr(i);return s.isForcefullyTerminated??=!1,[c,p]},Xfr=async i=>{let[s,c]=await Promise.allSettled([(0,Ife.once)(i,"spawn"),(0,Ife.once)(i,"exit")]);return s.status==="rejected"?[]:c.status==="rejected"?Qpt(i):c.value},Qpt=async i=>{try{return await(0,Ife.once)(i,"exit")}catch{return Qpt(i)}},Kpt=async i=>{let[s,c]=await i;if(!Zfr(s,c)&&YIe(s,c))throw new tE;return[s,c]},Zfr=(i,s)=>i===void 0&&s===void 0,YIe=(i,s)=>i!==0||s!==null;var Xpt=({error:i,status:s,signal:c,output:p},{maxBuffer:y})=>{let x=e_r(i,s,c),w=x?.code==="ETIMEDOUT",L=z_t(x,p,y);return{resultError:x,exitCode:s,signal:c,timedOut:w,isMaxBuffer:L}},e_r=(i,s,c)=>i!==void 0?i:YIe(s,c)?new tE:void 0;var edt=(i,s,c)=>{let{file:p,commandArguments:y,command:x,escapedCommand:w,startTime:L,verboseInfo:$,options:ne,fileDescriptors:_e}=t_r(i,s,c),Ce=i_r({file:p,commandArguments:y,options:ne,command:x,escapedCommand:w,verboseInfo:$,fileDescriptors:_e,startTime:L});return EB(Ce,$,ne)},t_r=(i,s,c)=>{let{command:p,escapedCommand:y,startTime:x,verboseInfo:w}=$ue(i,s,c),L=r_r(c),{file:$,commandArguments:ne,options:_e}=ffe(i,s,L);n_r(_e);let Ce=kpt(_e,w);return{file:$,commandArguments:ne,command:p,escapedCommand:y,startTime:x,verboseInfo:w,options:_e,fileDescriptors:Ce}},r_r=i=>i.node&&!i.ipc?{...i,ipc:!1}:i,n_r=({ipc:i,ipcInput:s,detached:c,cancelSignal:p})=>{s&&Ffe("ipcInput"),i&&Ffe("ipc: true"),c&&Ffe("detached: true"),p&&Ffe("cancelSignal")},Ffe=i=>{throw new TypeError(`The "${i}" option cannot be used with synchronous methods.`)},i_r=({file:i,commandArguments:s,options:c,command:p,escapedCommand:y,verboseInfo:x,fileDescriptors:w,startTime:L})=>{let $=s_r({file:i,commandArguments:s,options:c,command:p,escapedCommand:y,fileDescriptors:w,startTime:L});if($.failed)return $;let{resultError:ne,exitCode:_e,signal:Ce,timedOut:X,isMaxBuffer:Je}=Xpt($,c),{output:Ae,error:he=ne}=Gpt({fileDescriptors:w,syncResult:$,options:c,isMaxBuffer:Je,verboseInfo:x}),ct=Ae.map((dr,Rr)=>jP(dr,c,Rr)),Ze=jP(Hpt(Ae,c),c,"all");return o_r({error:he,exitCode:_e,signal:Ce,timedOut:X,isMaxBuffer:Je,stdio:ct,all:Ze,options:c,command:p,escapedCommand:y,startTime:L})},s_r=({file:i,commandArguments:s,options:c,command:p,escapedCommand:y,fileDescriptors:x,startTime:w})=>{try{Wpt(x,c);let L=a_r(c);return(0,Zpt.spawnSync)(i,s,L)}catch(L){return CB({error:L,command:p,escapedCommand:y,fileDescriptors:x,options:c,startTime:w,isSync:!0})}},a_r=({encoding:i,maxBuffer:s,...c})=>({...c,encoding:"buffer",maxBuffer:vfe(s)}),o_r=({error:i,exitCode:s,signal:c,timedOut:p,isMaxBuffer:y,stdio:x,all:w,options:L,command:$,escapedCommand:ne,startTime:_e})=>i===void 0?bfe({command:$,escapedCommand:ne,stdio:x,all:w,ipcOutput:[],options:L,startTime:_e}):AY({error:i,command:$,escapedCommand:ne,timedOut:p,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:y,isForcefullyTerminated:!1,exitCode:s,signal:c,stdio:x,all:w,ipcOutput:[],options:L,startTime:_e,isSync:!0});var omt=require("node:events"),cmt=require("node:child_process");var KIe=xa(require("node:process"),1);var kB=require("node:events");var tdt=({anyProcess:i,channel:s,isSubprocess:c,ipc:p},{reference:y=!0,filter:x}={})=>(bB({methodName:"getOneMessage",isSubprocess:c,ipc:p,isConnected:ife(i)}),c_r({anyProcess:i,channel:s,isSubprocess:c,filter:x,reference:y})),c_r=async({anyProcess:i,channel:s,isSubprocess:c,filter:p,reference:y})=>{efe(s,y);let x=u3(i,s,c),w=new AbortController;try{return await Promise.race([l_r(x,p,w),u_r(x,c,w),f_r(x,c,w)])}catch(L){throw SB(i),L}finally{w.abort(),tfe(s,y)}},l_r=async(i,s,{signal:c})=>{if(s===void 0){let[p]=await(0,kB.once)(i,"message",{signal:c});return p}for await(let[p]of(0,kB.on)(i,"message",{signal:c}))if(s(p))return p},u_r=async(i,s,{signal:c})=>{await(0,kB.once)(i,"disconnect",{signal:c}),Dft(s)},f_r=async(i,s,{signal:c})=>{let[p]=await(0,kB.once)(i,"strict:error",{signal:c});throw Kue(p,s)};var IY=require("node:events");var ndt=({anyProcess:i,channel:s,isSubprocess:c,ipc:p},{reference:y=!0}={})=>QIe({anyProcess:i,channel:s,isSubprocess:c,ipc:p,shouldAwait:!c,reference:y}),QIe=({anyProcess:i,channel:s,isSubprocess:c,ipc:p,shouldAwait:y,reference:x})=>{bB({methodName:"getEachMessage",isSubprocess:c,ipc:p,isConnected:ife(i)}),efe(s,x);let w=u3(i,s,c),L=new AbortController,$={};return __r(i,w,L),p_r({ipcEmitter:w,isSubprocess:c,controller:L,state:$}),d_r({anyProcess:i,channel:s,ipcEmitter:w,isSubprocess:c,shouldAwait:y,controller:L,state:$,reference:x})},__r=async(i,s,c)=>{try{await(0,IY.once)(s,"disconnect",{signal:c.signal}),c.abort()}catch{}},p_r=async({ipcEmitter:i,isSubprocess:s,controller:c,state:p})=>{try{let[y]=await(0,IY.once)(i,"strict:error",{signal:c.signal});p.error=Kue(y,s),c.abort()}catch{}},d_r=async function*({anyProcess:i,channel:s,ipcEmitter:c,isSubprocess:p,shouldAwait:y,controller:x,state:w,reference:L}){try{for await(let[$]of(0,IY.on)(c,"message",{signal:x.signal}))rdt(w),yield $}catch{rdt(w)}finally{x.abort(),tfe(s,L),p||SB(i),y&&await i}},rdt=({error:i})=>{if(i)throw i};var idt=(i,{ipc:s})=>{Object.assign(i,adt(i,!1,s))},sdt=()=>{let i=KIe.default,s=!0,c=KIe.default.channel!==void 0;return{...adt(i,s,c),getCancelSignal:i_t.bind(void 0,{anyProcess:i,channel:i.channel,isSubprocess:s,ipc:c})}},adt=(i,s,c)=>({sendMessage:cfe.bind(void 0,{anyProcess:i,channel:i.channel,isSubprocess:s,ipc:c}),getOneMessage:tdt.bind(void 0,{anyProcess:i,channel:i.channel,isSubprocess:s,ipc:c}),getEachMessage:ndt.bind(void 0,{anyProcess:i,channel:i.channel,isSubprocess:s,ipc:c})});var odt=require("node:child_process"),_3=require("node:stream");var cdt=({error:i,command:s,escapedCommand:c,fileDescriptors:p,options:y,startTime:x,verboseInfo:w})=>{qIe(p);let L=new odt.ChildProcess;m_r(L,p),Object.assign(L,{readable:h_r,writable:g_r,duplex:y_r});let $=CB({error:i,command:s,escapedCommand:c,fileDescriptors:p,options:y,startTime:x,isSync:!1}),ne=v_r($,w,y);return{subprocess:L,promise:ne}},m_r=(i,s)=>{let c=FY(),p=FY(),y=FY(),x=Array.from({length:s.length-3},FY),w=FY(),L=[c,p,y,...x];Object.assign(i,{stdin:c,stdout:p,stderr:y,all:w,stdio:L})},FY=()=>{let i=new _3.PassThrough;return i.end(),i},h_r=()=>new _3.Readable({read(){}}),g_r=()=>new _3.Writable({write(){}}),y_r=()=>new _3.Duplex({read(){},write(){}}),v_r=async(i,s,c)=>EB(i,s,c);var AB=require("node:fs"),udt=require("node:buffer"),Pk=require("node:stream");var fdt=(i,s)=>Cfe(b_r,i,s,!1),OY=({type:i,optionName:s})=>{throw new TypeError(`The \`${s}\` option cannot be ${f3[i]}.`)},ldt={fileNumber:OY,generator:HIe,asyncGenerator:HIe,nodeStream:({value:i})=>({stream:i}),webTransform({value:{transform:i,writableObjectMode:s,readableObjectMode:c}}){let p=s||c;return{stream:Pk.Duplex.fromWeb(i,{objectMode:p})}},duplex:({value:{transform:i}})=>({stream:i}),native(){}},b_r={input:{...ldt,fileUrl:({value:i})=>({stream:(0,AB.createReadStream)(i)}),filePath:({value:{file:i}})=>({stream:(0,AB.createReadStream)(i)}),webStream:({value:i})=>({stream:Pk.Readable.fromWeb(i)}),iterable:({value:i})=>({stream:Pk.Readable.from(i)}),asyncIterable:({value:i})=>({stream:Pk.Readable.from(i)}),string:({value:i})=>({stream:Pk.Readable.from(i)}),uint8Array:({value:i})=>({stream:Pk.Readable.from(udt.Buffer.from(i))})},output:{...ldt,fileUrl:({value:i})=>({stream:(0,AB.createWriteStream)(i)}),filePath:({value:{file:i,append:s}})=>({stream:(0,AB.createWriteStream)(i,s?{flags:"a"}:{})}),webStream:({value:i})=>({stream:Pk.Writable.fromWeb(i)}),iterable:OY,asyncIterable:OY,string:OY,uint8Array:OY}};var RY=require("node:events"),Rfe=require("node:stream"),e4e=require("node:stream/promises");function O7(i){if(!Array.isArray(i))throw new TypeError(`Expected an array, got \`${typeof i}\`.`);for(let y of i)ZIe(y);let s=i.some(({readableObjectMode:y})=>y),c=S_r(i,s),p=new XIe({objectMode:s,writableHighWaterMark:c,readableHighWaterMark:c});for(let y of i)p.add(y);return p}var S_r=(i,s)=>{if(i.length===0)return(0,Rfe.getDefaultHighWaterMark)(s);let c=i.filter(({readableObjectMode:p})=>p===s).map(({readableHighWaterMark:p})=>p);return Math.max(...c)},XIe=class extends Rfe.PassThrough{#e=new Set([]);#t=new Set([]);#r=new Set([]);#n;#a=Symbol("unpipe");#c=new WeakMap;add(s){if(ZIe(s),this.#e.has(s))return;this.#e.add(s),this.#n??=T_r(this,this.#e,this.#a);let c=C_r({passThroughStream:this,stream:s,streams:this.#e,ended:this.#t,aborted:this.#r,onFinished:this.#n,unpipeEvent:this.#a});this.#c.set(s,c),s.pipe(this,{end:!1})}async remove(s){if(ZIe(s),!this.#e.has(s))return!1;let c=this.#c.get(s);return c===void 0?!1:(this.#c.delete(s),s.unpipe(this),await c,!0)}},T_r=async(i,s,c)=>{Ofe(i,_dt);let p=new AbortController;try{await Promise.race([x_r(i,p),D_r(i,s,c,p)])}finally{p.abort(),Ofe(i,-_dt)}},x_r=async(i,{signal:s})=>{try{await(0,e4e.finished)(i,{signal:s,cleanup:!0})}catch(c){throw ddt(i,c),c}},D_r=async(i,s,c,{signal:p})=>{for await(let[y]of(0,RY.on)(i,"unpipe",{signal:p}))s.has(y)&&y.emit(c)},ZIe=i=>{if(typeof i?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof i}\`.`)},C_r=async({passThroughStream:i,stream:s,streams:c,ended:p,aborted:y,onFinished:x,unpipeEvent:w})=>{Ofe(i,pdt);let L=new AbortController;try{await Promise.race([E_r(x,s,L),w_r({passThroughStream:i,stream:s,streams:c,ended:p,aborted:y,controller:L}),k_r({stream:s,streams:c,ended:p,aborted:y,unpipeEvent:w,controller:L})])}finally{L.abort(),Ofe(i,-pdt)}c.size>0&&c.size===p.size+y.size&&(p.size===0&&y.size>0?t4e(i):A_r(i))},E_r=async(i,s,{signal:c})=>{try{await i,c.aborted||t4e(s)}catch(p){c.aborted||ddt(s,p)}},w_r=async({passThroughStream:i,stream:s,streams:c,ended:p,aborted:y,controller:{signal:x}})=>{try{await(0,e4e.finished)(s,{signal:x,cleanup:!0,readable:!0,writable:!1}),c.has(s)&&p.add(s)}catch(w){if(x.aborted||!c.has(s))return;mdt(w)?y.add(s):hdt(i,w)}},k_r=async({stream:i,streams:s,ended:c,aborted:p,unpipeEvent:y,controller:{signal:x}})=>{if(await(0,RY.once)(i,y,{signal:x}),!i.readable)return(0,RY.once)(x,"abort",{signal:x});s.delete(i),c.delete(i),p.delete(i)},A_r=i=>{i.writable&&i.end()},ddt=(i,s)=>{mdt(s)?t4e(i):hdt(i,s)},mdt=i=>i?.code==="ERR_STREAM_PREMATURE_CLOSE",t4e=i=>{(i.readable||i.writable)&&i.destroy()},hdt=(i,s)=>{i.destroyed||(i.once("error",P_r),i.destroy(s))},P_r=()=>{},Ofe=(i,s)=>{let c=i.getMaxListeners();c!==0&&c!==Number.POSITIVE_INFINITY&&i.setMaxListeners(c+s)},_dt=2,pdt=1;var r4e=require("node:stream/promises");var PB=(i,s)=>{i.pipe(s),N_r(i,s),I_r(i,s)},N_r=async(i,s)=>{if(!(eE(i)||eE(s))){try{await(0,r4e.finished)(i,{cleanup:!0,readable:!0,writable:!1})}catch{}n4e(s)}},n4e=i=>{i.writable&&i.end()},I_r=async(i,s)=>{if(!(eE(i)||eE(s))){try{await(0,r4e.finished)(s,{cleanup:!0,readable:!1,writable:!0})}catch{}i4e(i)}},i4e=i=>{i.readable&&i.destroy()};var gdt=(i,s,c)=>{let p=new Map;for(let[y,{stdioItems:x,direction:w}]of Object.entries(s)){for(let{stream:L}of x.filter(({type:$})=>Hx.has($)))F_r(i,L,w,y);for(let{stream:L}of x.filter(({type:$})=>!Hx.has($)))R_r({subprocess:i,stream:L,direction:w,fdNumber:y,pipeGroups:p,controller:c})}for(let[y,x]of p.entries()){let w=x.length===1?x[0]:O7(x);PB(w,y)}},F_r=(i,s,c,p)=>{c==="output"?PB(i.stdio[p],s):PB(s,i.stdio[p]);let y=O_r[p];y!==void 0&&(i[y]=s),i.stdio[p]=s},O_r=["stdin","stdout","stderr"],R_r=({subprocess:i,stream:s,direction:c,fdNumber:p,pipeGroups:y,controller:x})=>{if(s===void 0)return;L_r(s,x);let[w,L]=c==="output"?[s,i.stdio[p]]:[i.stdio[p],s],$=y.get(w)??[];y.set(w,[...$,L])},L_r=(i,{signal:s})=>{eE(i)&&P7(i,M_r,s)},M_r=2;var ydt=require("node:events");var vdt=(i,{cleanup:s,detached:c},{signal:p})=>{if(!s||c)return;let y=Cue(()=>{i.kill()});(0,ydt.addAbortListener)(p,()=>{y()})};var Sdt=({source:i,sourcePromise:s,boundOptions:c,createNested:p},...y)=>{let x=zue(),{destination:w,destinationStream:L,destinationError:$,from:ne,unpipeSignal:_e}=j_r(c,p,y),{sourceStream:Ce,sourceError:X}=q_r(i,ne),{options:Je,fileDescriptors:Ae}=wk.get(i);return{sourcePromise:s,sourceStream:Ce,sourceOptions:Je,sourceError:X,destination:w,destinationStream:L,destinationError:$,unpipeSignal:_e,fileDescriptors:Ae,startTime:x}},j_r=(i,s,c)=>{try{let{destination:p,pipeOptions:{from:y,to:x,unpipeSignal:w}={}}=B_r(i,s,...c),L=Zue(p,x);return{destination:p,destinationStream:L,from:y,unpipeSignal:w}}catch(p){return{destinationError:p}}},B_r=(i,s,c,...p)=>{if(Array.isArray(c))return{destination:s(bdt,i)(c,...p),pipeOptions:i};if(typeof c=="string"||c instanceof URL||YNe(c)){if(Object.keys(i).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[y,x,w]=Fue(c,...p);return{destination:s(bdt)(y,x,w),pipeOptions:w}}if(wk.has(c)){if(Object.keys(i).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:c,pipeOptions:p[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${c}`)},bdt=({options:i})=>({options:{...i,stdin:"pipe",piped:!0}}),q_r=(i,s)=>{try{return{sourceStream:TB(i,s)}}catch(c){return{sourceError:c}}};var xdt=({sourceStream:i,sourceError:s,destinationStream:c,destinationError:p,fileDescriptors:y,sourceOptions:x,startTime:w})=>{let L=J_r({sourceStream:i,sourceError:s,destinationStream:c,destinationError:p});if(L!==void 0)throw s4e({error:L,fileDescriptors:y,sourceOptions:x,startTime:w})},J_r=({sourceStream:i,sourceError:s,destinationStream:c,destinationError:p})=>{if(s!==void 0&&p!==void 0)return p;if(p!==void 0)return i4e(i),p;if(s!==void 0)return n4e(c),s},s4e=({error:i,fileDescriptors:s,sourceOptions:c,startTime:p})=>CB({error:i,command:Tdt,escapedCommand:Tdt,fileDescriptors:s,options:c,startTime:p,isSync:!1}),Tdt="source.pipe(destination)";var Ddt=async i=>{let[{status:s,reason:c,value:p=c},{status:y,reason:x,value:w=x}]=await i;if(w.pipedFrom.includes(p)||w.pipedFrom.push(p),y==="rejected")throw w;if(s==="rejected")throw p;return w};var Cdt=require("node:stream/promises");var Edt=(i,s,c)=>{let p=Lfe.has(s)?W_r(i,s):U_r(i,s);return P7(i,$_r,c.signal),P7(s,V_r,c.signal),z_r(s),p},U_r=(i,s)=>{let c=O7([i]);return PB(c,s),Lfe.set(s,c),c},W_r=(i,s)=>{let c=Lfe.get(s);return c.add(i),c},z_r=async i=>{try{await(0,Cdt.finished)(i,{cleanup:!0,readable:!1,writable:!0})}catch{}Lfe.delete(i)},Lfe=new WeakMap,$_r=2,V_r=1;var wdt=require("node:util");var kdt=(i,s)=>i===void 0?[]:[G_r(i,s)],G_r=async(i,{sourceStream:s,mergedStream:c,fileDescriptors:p,sourceOptions:y,startTime:x})=>{await(0,wdt.aborted)(i,s),await c.remove(s);let w=new Error("Pipe canceled by `unpipeSignal` option.");throw s4e({error:w,fileDescriptors:p,sourceOptions:y,startTime:x})};var Mfe=(i,...s)=>{if(Bh(s[0]))return Mfe.bind(void 0,{...i,boundOptions:{...i.boundOptions,...s[0]}});let{destination:c,...p}=Sdt(i,...s),y=H_r({...p,destination:c});return y.pipe=Mfe.bind(void 0,{...i,source:c,sourcePromise:y,boundOptions:{}}),y},H_r=async({sourcePromise:i,sourceStream:s,sourceOptions:c,sourceError:p,destination:y,destinationStream:x,destinationError:w,unpipeSignal:L,fileDescriptors:$,startTime:ne})=>{let _e=Y_r(i,y);xdt({sourceStream:s,sourceError:p,destinationStream:x,destinationError:w,fileDescriptors:$,sourceOptions:c,startTime:ne});let Ce=new AbortController;try{let X=Edt(s,x,Ce);return await Promise.race([Ddt(_e),...kdt(L,{sourceStream:s,mergedStream:X,sourceOptions:c,fileDescriptors:$,startTime:ne})])}finally{Ce.abort()}},Y_r=(i,s)=>Promise.allSettled([i,s]);var Fdt=require("node:timers/promises");var Pdt=require("node:events"),Ndt=require("node:stream");var jfe=({subprocessStdout:i,subprocess:s,binary:c,shouldEncode:p,encoding:y,preserveNewlines:x})=>{let w=new AbortController;return Q_r(s,w),Idt({stream:i,controller:w,binary:c,shouldEncode:!i.readableObjectMode&&p,encoding:y,shouldSplit:!i.readableObjectMode,preserveNewlines:x})},Q_r=async(i,s)=>{try{await i}catch{}finally{s.abort()}},a4e=({stream:i,onStreamEnd:s,lines:c,encoding:p,stripFinalNewline:y,allMixed:x})=>{let w=new AbortController;K_r(s,w,i);let L=i.readableObjectMode&&!x;return Idt({stream:i,controller:w,binary:p==="buffer",shouldEncode:!L,encoding:p,shouldSplit:!L&&c,preserveNewlines:!y})},K_r=async(i,s,c)=>{try{await i}catch{c.destroy()}finally{s.abort()}},Idt=({stream:i,controller:s,binary:c,shouldEncode:p,encoding:y,shouldSplit:x,preserveNewlines:w})=>{let L=(0,Pdt.on)(i,"data",{signal:s.signal,highWaterMark:Adt,highWatermark:Adt});return X_r({onStdoutChunk:L,controller:s,binary:c,shouldEncode:p,encoding:y,shouldSplit:x,preserveNewlines:w})},o4e=(0,Ndt.getDefaultHighWaterMark)(!0),Adt=o4e,X_r=async function*({onStdoutChunk:i,controller:s,binary:c,shouldEncode:p,encoding:y,shouldSplit:x,preserveNewlines:w}){let L=Z_r({binary:c,shouldEncode:p,encoding:y,shouldSplit:x,preserveNewlines:w});try{for await(let[$]of i)yield*F7($,L,0)}catch($){if(!s.signal.aborted)throw $}finally{yield*PY(L)}},Z_r=({binary:i,shouldEncode:s,encoding:c,shouldSplit:p,preserveNewlines:y})=>[wfe(i,c,!s),Efe(i,y,!p,{})].filter(Boolean);var Odt=async({stream:i,onStreamEnd:s,fdNumber:c,encoding:p,buffer:y,maxBuffer:x,lines:w,allMixed:L,stripFinalNewline:$,verboseInfo:ne,streamInfo:_e})=>{let Ce=epr({stream:i,onStreamEnd:s,fdNumber:c,encoding:p,allMixed:L,verboseInfo:ne,streamInfo:_e});if(!y){await Promise.all([tpr(i),Ce]);return}let X=UIe($,c),Je=a4e({stream:i,onStreamEnd:s,lines:w,encoding:p,stripFinalNewline:X,allMixed:L}),[Ae]=await Promise.all([rpr({stream:i,iterable:Je,fdNumber:c,encoding:p,maxBuffer:x,lines:w}),Ce]);return Ae},epr=async({stream:i,onStreamEnd:s,fdNumber:c,encoding:p,allMixed:y,verboseInfo:x,streamInfo:{fileDescriptors:w}})=>{if(!Pfe({stdioItems:w[c]?.stdioItems,encoding:p,verboseInfo:x,fdNumber:c}))return;let L=a4e({stream:i,onStreamEnd:s,lines:!0,encoding:p,stripFinalNewline:!0,allMixed:y});await zpt(L,i,c,x)},tpr=async i=>{await(0,Fdt.setImmediate)(),i.readableFlowing===null&&i.resume()},rpr=async({stream:i,stream:{readableObjectMode:s},iterable:c,fdNumber:p,encoding:y,maxBuffer:x,lines:w})=>{try{return s||w?await mfe(c,{maxBuffer:x}):y==="buffer"?new Uint8Array(await hfe(c,{maxBuffer:x})):await yfe(c,{maxBuffer:x})}catch(L){return Rdt(J_t({error:L,stream:i,readableObjectMode:s,lines:w,encoding:y,fdNumber:p}))}},c4e=async i=>{try{return await i}catch(s){return Rdt(s)}},Rdt=({bufferedData:i})=>Glt(i)?new Uint8Array(i):i;var Mdt=require("node:stream/promises"),LY=async(i,s,c,{isSameDirection:p,stopOnExit:y=!1}={})=>{let x=npr(i,c),w=new AbortController;try{await Promise.race([...y?[c.exitPromise]:[],(0,Mdt.finished)(i,{cleanup:!0,signal:w.signal})])}catch(L){x.stdinCleanedUp||apr(L,s,c,p)}finally{w.abort()}},npr=(i,{originalStreams:[s],subprocess:c})=>{let p={stdinCleanedUp:!1};return i===s&&ipr(i,c,p),p},ipr=(i,s,c)=>{let{_destroy:p}=i;i._destroy=(...y)=>{spr(s,c),p.call(i,...y)}},spr=({exitCode:i,signalCode:s},c)=>{(i!==null||s!==null)&&(c.stdinCleanedUp=!0)},apr=(i,s,c,p)=>{if(!opr(i,s,c,p))throw i},opr=(i,s,c,p=!0)=>c.propagating?Ldt(i)||Bfe(i):(c.propagating=!0,l4e(c,s)===p?Ldt(i):Bfe(i)),l4e=({fileDescriptors:i},s)=>s!=="all"&&i[s].direction==="input",Bfe=i=>i?.code==="ERR_STREAM_PREMATURE_CLOSE",Ldt=i=>i?.code==="EPIPE";var jdt=({subprocess:i,encoding:s,buffer:c,maxBuffer:p,lines:y,stripFinalNewline:x,verboseInfo:w,streamInfo:L})=>i.stdio.map(($,ne)=>u4e({stream:$,fdNumber:ne,encoding:s,buffer:c[ne],maxBuffer:p[ne],lines:y[ne],allMixed:!1,stripFinalNewline:x,verboseInfo:w,streamInfo:L})),u4e=async({stream:i,fdNumber:s,encoding:c,buffer:p,maxBuffer:y,lines:x,allMixed:w,stripFinalNewline:L,verboseInfo:$,streamInfo:ne})=>{if(!i)return;let _e=LY(i,s,ne);if(l4e(ne,s)){await _e;return}let[Ce]=await Promise.all([Odt({stream:i,onStreamEnd:_e,fdNumber:s,encoding:c,buffer:p,maxBuffer:y,lines:x,allMixed:w,stripFinalNewline:L,verboseInfo:$,streamInfo:ne}),_e]);return Ce};var Bdt=({stdout:i,stderr:s},{all:c})=>c&&(i||s)?O7([i,s].filter(Boolean)):void 0,qdt=({subprocess:i,encoding:s,buffer:c,maxBuffer:p,lines:y,stripFinalNewline:x,verboseInfo:w,streamInfo:L})=>u4e({...cpr(i,c),fdNumber:"all",encoding:s,maxBuffer:p[1]+p[2],lines:y[1]||y[2],allMixed:lpr(i),stripFinalNewline:x,verboseInfo:w,streamInfo:L}),cpr=({stdout:i,stderr:s,all:c},[,p,y])=>{let x=p||y;return x?p?y?{stream:c,buffer:x}:{stream:i,buffer:x}:{stream:s,buffer:x}:{stream:c,buffer:x}},lpr=({all:i,stdout:s,stderr:c})=>i&&s&&c&&s.readableObjectMode!==c.readableObjectMode;var $dt=require("node:events");var Jdt=i=>hB(i,"ipc"),Udt=(i,s)=>{let c=Wue(i);Ck({type:"ipc",verboseMessage:c,fdNumber:"ipc",verboseInfo:s})};var Wdt=async({subprocess:i,buffer:s,maxBuffer:c,ipc:p,ipcOutput:y,verboseInfo:x})=>{if(!p)return y;let w=Jdt(x),L=LP(s,"ipc"),$=LP(c,"ipc");for await(let ne of QIe({anyProcess:i,channel:i.channel,isSubprocess:!1,ipc:p,shouldAwait:!1,reference:!0}))L&&(U_t(i,y,$),y.push(ne)),w&&Udt(ne,x);return y},zdt=async(i,s)=>(await Promise.allSettled([i]),s);var Vdt=async({subprocess:i,options:{encoding:s,buffer:c,maxBuffer:p,lines:y,timeoutDuration:x,cancelSignal:w,gracefulCancel:L,forceKillAfterDelay:$,stripFinalNewline:ne,ipc:_e,ipcInput:Ce},context:X,verboseInfo:Je,fileDescriptors:Ae,originalStreams:he,onInternalError:ct,controller:Ze})=>{let dr=Ypt(i,X),Rr={originalStreams:he,fileDescriptors:Ae,subprocess:i,exitPromise:dr,propagating:!1},wr=jdt({subprocess:i,encoding:s,buffer:c,maxBuffer:p,lines:y,stripFinalNewline:ne,verboseInfo:Je,streamInfo:Rr}),Dr=qdt({subprocess:i,encoding:s,buffer:c,maxBuffer:p,lines:y,stripFinalNewline:ne,verboseInfo:Je,streamInfo:Rr}),ir=[],Ft=Wdt({subprocess:i,buffer:c,maxBuffer:p,ipc:_e,ipcOutput:ir,verboseInfo:Je}),Tn=upr(he,i,Rr),rr=fpr(Ae,Rr);try{return await Promise.race([Promise.all([{},Kpt(dr),Promise.all(wr),Dr,Ft,m_t(i,Ce),...Tn,...rr]),ct,_pr(i,Ze),...u_t(i,x,X,Ze),...xft({subprocess:i,cancelSignal:w,gracefulCancel:L,context:X,controller:Ze}),...o_t({subprocess:i,cancelSignal:w,gracefulCancel:L,forceKillAfterDelay:$,context:X,controller:Ze})])}catch(Vn){return X.terminationReason??="other",Promise.all([{error:Vn},dr,Promise.all(wr.map(Nr=>c4e(Nr))),c4e(Dr),zdt(Ft,ir),Promise.allSettled(Tn),Promise.allSettled(rr)])}},upr=(i,s,c)=>i.map((p,y)=>p===s.stdio[y]?void 0:LY(p,y,c)),fpr=(i,s)=>i.flatMap(({stdioItems:c},p)=>c.filter(({value:y,stream:x=y})=>nE(x,{checkOpen:!1})&&!eE(x)).map(({type:y,value:x,stream:w=x})=>LY(w,p,s,{isSameDirection:Hx.has(y),stopOnExit:y==="native"}))),_pr=async(i,{signal:s})=>{let[c]=await(0,$dt.once)(i,"error",{signal:s});throw c};var Gdt=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),MY=(i,s,c)=>{let p=i[c];p.has(s)||p.set(s,[]);let y=p.get(s),x=Ek();return y.push(x),{resolve:x.resolve.bind(x),promises:y}},NB=async({resolve:i,promises:s},c)=>{i();let[p]=await Promise.race([Promise.allSettled([!0,c]),Promise.all([!1,...s])]);return!p};var Ydt=require("node:stream"),Qdt=require("node:util");var f4e=require("node:stream/promises");var _4e=async i=>{if(i!==void 0)try{await p4e(i)}catch{}},Hdt=async i=>{if(i!==void 0)try{await d4e(i)}catch{}},p4e=async i=>{await(0,f4e.finished)(i,{cleanup:!0,readable:!1,writable:!0})},d4e=async i=>{await(0,f4e.finished)(i,{cleanup:!0,readable:!0,writable:!1})},qfe=async(i,s)=>{if(await i,s)throw s},Jfe=(i,s,c)=>{c&&!Bfe(c)?i.destroy(c):s&&i.destroy()};var Kdt=({subprocess:i,concurrentStreams:s,encoding:c},{from:p,binary:y=!0,preserveNewlines:x=!0}={})=>{let w=y||G2.has(c),{subprocessStdout:L,waitReadableDestroy:$}=m4e(i,p,s),{readableEncoding:ne,readableObjectMode:_e,readableHighWaterMark:Ce}=h4e(L,w),{read:X,onStdoutDataDone:Je}=g4e({subprocessStdout:L,subprocess:i,binary:w,encoding:c,preserveNewlines:x}),Ae=new Ydt.Readable({read:X,destroy:(0,Qdt.callbackify)(v4e.bind(void 0,{subprocessStdout:L,subprocess:i,waitReadableDestroy:$})),highWaterMark:Ce,objectMode:_e,encoding:ne});return y4e({subprocessStdout:L,onStdoutDataDone:Je,readable:Ae,subprocess:i}),Ae},m4e=(i,s,c)=>{let p=TB(i,s),y=MY(c,p,"readableDestroy");return{subprocessStdout:p,waitReadableDestroy:y}},h4e=({readableEncoding:i,readableObjectMode:s,readableHighWaterMark:c},p)=>p?{readableEncoding:i,readableObjectMode:s,readableHighWaterMark:c}:{readableEncoding:i,readableObjectMode:!0,readableHighWaterMark:o4e},g4e=({subprocessStdout:i,subprocess:s,binary:c,encoding:p,preserveNewlines:y})=>{let x=Ek(),w=jfe({subprocessStdout:i,subprocess:s,binary:c,shouldEncode:!c,encoding:p,preserveNewlines:y});return{read(){ppr(this,w,x)},onStdoutDataDone:x}},ppr=async(i,s,c)=>{try{let{value:p,done:y}=await s.next();y?c.resolve():i.push(p)}catch{}},y4e=async({subprocessStdout:i,onStdoutDataDone:s,readable:c,subprocess:p,subprocessStdin:y})=>{try{await d4e(i),await p,await _4e(y),await s,c.readable&&c.push(null)}catch(x){await _4e(y),Xdt(c,x)}},v4e=async({subprocessStdout:i,subprocess:s,waitReadableDestroy:c},p)=>{await NB(c,s)&&(Xdt(i,p),await qfe(s,p))},Xdt=(i,s)=>{Jfe(i,i.readable,s)};var Zdt=require("node:stream"),b4e=require("node:util");var emt=({subprocess:i,concurrentStreams:s},{to:c}={})=>{let{subprocessStdin:p,waitWritableFinal:y,waitWritableDestroy:x}=S4e(i,c,s),w=new Zdt.Writable({...T4e(p,i,y),destroy:(0,b4e.callbackify)(D4e.bind(void 0,{subprocessStdin:p,subprocess:i,waitWritableFinal:y,waitWritableDestroy:x})),highWaterMark:p.writableHighWaterMark,objectMode:p.writableObjectMode});return x4e(p,w),w},S4e=(i,s,c)=>{let p=Zue(i,s),y=MY(c,p,"writableFinal"),x=MY(c,p,"writableDestroy");return{subprocessStdin:p,waitWritableFinal:y,waitWritableDestroy:x}},T4e=(i,s,c)=>({write:dpr.bind(void 0,i),final:(0,b4e.callbackify)(mpr.bind(void 0,i,s,c))}),dpr=(i,s,c,p)=>{i.write(s,c)?p():i.once("drain",p)},mpr=async(i,s,c)=>{await NB(c,s)&&(i.writable&&i.end(),await s)},x4e=async(i,s,c)=>{try{await p4e(i),s.writable&&s.end()}catch(p){await Hdt(c),tmt(s,p)}},D4e=async({subprocessStdin:i,subprocess:s,waitWritableFinal:c,waitWritableDestroy:p},y)=>{await NB(c,s),await NB(p,s)&&(tmt(i,y),await qfe(s,y))},tmt=(i,s)=>{Jfe(i,i.writable,s)};var rmt=require("node:stream"),nmt=require("node:util");var imt=({subprocess:i,concurrentStreams:s,encoding:c},{from:p,to:y,binary:x=!0,preserveNewlines:w=!0}={})=>{let L=x||G2.has(c),{subprocessStdout:$,waitReadableDestroy:ne}=m4e(i,p,s),{subprocessStdin:_e,waitWritableFinal:Ce,waitWritableDestroy:X}=S4e(i,y,s),{readableEncoding:Je,readableObjectMode:Ae,readableHighWaterMark:he}=h4e($,L),{read:ct,onStdoutDataDone:Ze}=g4e({subprocessStdout:$,subprocess:i,binary:L,encoding:c,preserveNewlines:w}),dr=new rmt.Duplex({read:ct,...T4e(_e,i,Ce),destroy:(0,nmt.callbackify)(hpr.bind(void 0,{subprocessStdout:$,subprocessStdin:_e,subprocess:i,waitReadableDestroy:ne,waitWritableFinal:Ce,waitWritableDestroy:X})),readableHighWaterMark:he,writableHighWaterMark:_e.writableHighWaterMark,readableObjectMode:Ae,writableObjectMode:_e.writableObjectMode,encoding:Je});return y4e({subprocessStdout:$,onStdoutDataDone:Ze,readable:dr,subprocess:i,subprocessStdin:_e}),x4e(_e,dr,$),dr},hpr=async({subprocessStdout:i,subprocessStdin:s,subprocess:c,waitReadableDestroy:p,waitWritableFinal:y,waitWritableDestroy:x},w)=>{await Promise.all([v4e({subprocessStdout:i,subprocess:c,waitReadableDestroy:p},w),D4e({subprocessStdin:s,subprocess:c,waitWritableFinal:y,waitWritableDestroy:x},w)])};var C4e=(i,s,{from:c,binary:p=!1,preserveNewlines:y=!1}={})=>{let x=p||G2.has(s),w=TB(i,c),L=jfe({subprocessStdout:w,subprocess:i,binary:x,shouldEncode:!0,encoding:s,preserveNewlines:y});return gpr(L,w,i)},gpr=async function*(i,s,c){try{yield*i}finally{s.readable&&s.destroy(),await c}};var smt=(i,{encoding:s})=>{let c=Gdt();i.readable=Kdt.bind(void 0,{subprocess:i,concurrentStreams:c,encoding:s}),i.writable=emt.bind(void 0,{subprocess:i,concurrentStreams:c}),i.duplex=imt.bind(void 0,{subprocess:i,concurrentStreams:c,encoding:s}),i.iterable=C4e.bind(void 0,i,s),i[Symbol.asyncIterator]=C4e.bind(void 0,i,s,{})};var amt=(i,s)=>{for(let[c,p]of vpr){let y=p.value.bind(s);Reflect.defineProperty(i,c,{...p,value:y})}},ypr=(async()=>{})().constructor.prototype,vpr=["then","catch","finally"].map(i=>[i,Reflect.getOwnPropertyDescriptor(ypr,i)]);var lmt=(i,s,c,p)=>{let{file:y,commandArguments:x,command:w,escapedCommand:L,startTime:$,verboseInfo:ne,options:_e,fileDescriptors:Ce}=bpr(i,s,c),{subprocess:X,promise:Je}=Tpr({file:y,commandArguments:x,options:_e,startTime:$,verboseInfo:ne,command:w,escapedCommand:L,fileDescriptors:Ce});return X.pipe=Mfe.bind(void 0,{source:X,sourcePromise:Je,boundOptions:{},createNested:p}),amt(X,Je),wk.set(X,{options:_e,fileDescriptors:Ce}),X},bpr=(i,s,c)=>{let{command:p,escapedCommand:y,startTime:x,verboseInfo:w}=$ue(i,s,c),{file:L,commandArguments:$,options:ne}=ffe(i,s,c),_e=Spr(ne),Ce=fdt(_e,w);return{file:L,commandArguments:$,command:p,escapedCommand:y,startTime:x,verboseInfo:w,options:_e,fileDescriptors:Ce}},Spr=({timeout:i,signal:s,...c})=>{if(s!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...c,timeoutDuration:i}},Tpr=({file:i,commandArguments:s,options:c,startTime:p,verboseInfo:y,command:x,escapedCommand:w,fileDescriptors:L})=>{let $;try{$=(0,cmt.spawn)(i,s,c)}catch(Ae){return cdt({error:Ae,command:x,escapedCommand:w,fileDescriptors:L,options:c,startTime:p,verboseInfo:y})}let ne=new AbortController;(0,omt.setMaxListeners)(Number.POSITIVE_INFINITY,ne.signal);let _e=[...$.stdio];gdt($,L,ne),vdt($,c,ne);let Ce={},X=Ek();$.kill=bft.bind(void 0,{kill:$.kill.bind($),options:c,onInternalError:X,context:Ce,controller:ne}),$.all=Bdt($,c),smt($,c),idt($,c);let Je=xpr({subprocess:$,options:c,startTime:p,verboseInfo:y,fileDescriptors:L,originalStreams:_e,command:x,escapedCommand:w,context:Ce,onInternalError:X,controller:ne});return{subprocess:$,promise:Je}},xpr=async({subprocess:i,options:s,startTime:c,verboseInfo:p,fileDescriptors:y,originalStreams:x,command:w,escapedCommand:L,context:$,onInternalError:ne,controller:_e})=>{let[Ce,[X,Je],Ae,he,ct]=await Vdt({subprocess:i,options:s,context:$,verboseInfo:p,fileDescriptors:y,originalStreams:x,onInternalError:ne,controller:_e});_e.abort(),ne.resolve();let Ze=Ae.map((wr,Dr)=>jP(wr,s,Dr)),dr=jP(he,s,"all"),Rr=Dpr({errorInfo:Ce,exitCode:X,signal:Je,stdio:Ze,all:dr,ipcOutput:ct,context:$,options:s,command:w,escapedCommand:L,startTime:c});return EB(Rr,p,s)},Dpr=({errorInfo:i,exitCode:s,signal:c,stdio:p,all:y,ipcOutput:x,context:w,options:L,command:$,escapedCommand:ne,startTime:_e})=>"error"in i?AY({error:i.error,command:$,escapedCommand:ne,timedOut:w.terminationReason==="timeout",isCanceled:w.terminationReason==="cancel"||w.terminationReason==="gracefulCancel",isGracefullyCanceled:w.terminationReason==="gracefulCancel",isMaxBuffer:i.error instanceof kk,isForcefullyTerminated:w.isForcefullyTerminated,exitCode:s,signal:c,stdio:p,all:y,ipcOutput:x,options:L,startTime:_e,isSync:!1}):bfe({command:$,escapedCommand:ne,stdio:p,all:y,ipcOutput:x,options:L,startTime:_e});var Ufe=(i,s)=>{let c=Object.fromEntries(Object.entries(s).map(([p,y])=>[p,Cpr(p,i[p],y)]));return{...i,...c}},Cpr=(i,s,c)=>Epr.has(i)&&Bh(s)&&Bh(c)?{...s,...c}:c,Epr=new Set(["env",...eIe]);var p3=(i,s,c,p)=>{let y=(w,L,$)=>p3(w,L,c,$),x=(...w)=>wpr({mapArguments:i,deepOptions:c,boundOptions:s,setBoundExeca:p,createNested:y},...w);return p!==void 0&&p(x,y,s),x},wpr=({mapArguments:i,deepOptions:s={},boundOptions:c={},setBoundExeca:p,createNested:y},x,...w)=>{if(Bh(x))return y(i,Ufe(c,x),p);let{file:L,commandArguments:$,options:ne,isSync:_e}=kpr({mapArguments:i,firstArgument:x,nextArguments:w,deepOptions:s,boundOptions:c});return _e?edt(L,$,ne):lmt(L,$,ne,y)},kpr=({mapArguments:i,firstArgument:s,nextArguments:c,deepOptions:p,boundOptions:y})=>{let x=eut(s)?tut(s,c):[s,...c],[w,L,$]=Fue(...x),ne=Ufe(Ufe(p,y),$),{file:_e=w,commandArguments:Ce=L,options:X=ne,isSync:Je=!1}=i({file:w,commandArguments:L,options:ne});return{file:_e,commandArguments:Ce,options:X,isSync:Je}};var umt=({file:i,commandArguments:s})=>_mt(i,s),fmt=({file:i,commandArguments:s})=>({..._mt(i,s),isSync:!0}),_mt=(i,s)=>{if(s.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${i} ${s}.`);let[c,...p]=Apr(i);return{file:c,commandArguments:p}},Apr=i=>{if(typeof i!="string")throw new TypeError(`The command must be a string: ${String(i)}.`);let s=i.trim();if(s==="")return[];let c=[];for(let p of s.split(Ppr)){let y=c.at(-1);y&&y.endsWith("\\")?c[c.length-1]=`${y.slice(0,-1)} ${p}`:c.push(p)}return c},Ppr=/ +/g;var pmt=(i,s,c)=>{i.sync=s(Npr,c),i.s=i.sync},dmt=({options:i})=>mmt(i),Npr=({options:i})=>({...mmt(i),isSync:!0}),mmt=i=>({options:{...Ipr(i),...i}}),Ipr=({input:i,inputFile:s,stdio:c})=>i===void 0&&s===void 0&&c===void 0?{stdin:"inherit"}:{},hmt={preferLocal:!0};var d3=p3(()=>({})),QWr=p3(()=>({isSync:!0})),KWr=p3(umt),XWr=p3(fmt),ZWr=p3(f_t),ezr=p3(dmt,{},hmt,pmt),{sendMessage:tzr,getOneMessage:rzr,getEachMessage:nzr,getCancelSignal:izr}=sdt();var ng=xa(require("node:path")),eD=xa(require("node:fs")),Kyt=xa(ymt()),z_e=xa(cY()),Xyt=xa(r_e()),Zyt=xa(wyt()),$7=xa(Pyt());var IFe=xa(require("crypto")),Uyt=xa(require("path")),SQ=xa(require("fs")),Wyt=xa(r_e()),zyt=require("@oclif/core");var Byt=require("@oclif/core"),qyt=xa(r_e()),Jyt=xa(PFe());async function Yg(i,s){let c;try{c=await(0,qyt.default)(i,{method:s.method||"GET",headers:{"Content-Type":"application/json",Accept:"application/json",...s.token?{Authorization:`Bearer ${s.token}`}:void 0},body:s.body})}catch(p){throw new Error(`HTTP request: ${p.message}`)}if(!c.ok){switch(c.status){case 401:throw new Mk(c,"not authorized - please log in first using `npx ray login`");case 403:throw new Mk(c,"forbidden - you don't have permissions to perform the request");case 402:throw new Mk(c,"the limit of free commands has been reached")}let p=await c.text(),y;try{y=JSON.parse(p)}catch{throw new Mk(c,`HTTP error: ${c.status} - ${p}`)}throw Array.isArray(y.errors)&&y.errors.length>0?new Mk(c,`error: ${y.errors[0].status} - ${y.errors[0].title}`):new Mk(c,`HTTP error: ${c.status} - ${p}`)}return await c.json()}var Mk=class extends Error{constructor(s,c){let p=s.headers.get("X-Request-Id");p?super(`${c} (${s.url} RequestID: ${p})`):super(c),this.name="HTTPError"}};function NFe(i){(0,Jyt.default)(i).catch(s=>{Byt.ux.error(new Error(`failed opening browser to URL ${i}: ${s.message}`),{exit:1})})}var U$r=`${Ux.url}/sessions/success`,W$r=`${Ux.url}/sessions/failure`;function $yt(){$_("raycastAccessToken")===""&&zyt.ux.error("please first log in first using `npx ray login`",{exit:1})}function FFe(){let i=$_("raycastApiURL"),s=$_("raycastAccessToken");return Yg(`${i}/api/v1/me`,{token:s})}function U_e(i){let s=$_("raycastApiURL"),c=$_("raycastAccessToken");return Yg(`${s}/api/v1/users/${i}`,{token:c})}function Vyt(){let i=$_("raycastApiURL"),s=$_("raycastAccessToken");return Yg(`${i}/api/v1/me/organizations`,{token:s})}function Gyt(i){let s=$_("raycastApiURL"),c=$_("raycastAccessToken");return Yg(`${s}/api/v1/organizations/${i}`,{token:c})}function Hyt(i){return Promise.all(i.map(async s=>{try{return await OFe(s,"image/png")}catch(c){throw new Error(`upload: ${c.message}`)}}))}async function OFe(i,s){let c=$_("raycastApiURL"),p=$_("raycastAccessToken"),y=SQ.statSync(i),x=await Yg(`${c}/api/v1/direct_uploads`,{token:p,method:"POST",body:JSON.stringify({blob:{content_type:s,filename:Uyt.basename(i),byte_size:y.size,checksum:IFe.createHash("md5").update(SQ.readFileSync(i)).digest("base64")}})}),w=SQ.readFileSync(i),L=await(0,Wyt.default)(x.direct_upload.url,{method:"PUT",body:w,headers:x.direct_upload.headers});if(!L.ok)throw new Mk(L,L.statusText);return x.signed_id}function Yyt(i){let s=$_("raycastApiURL"),c=$_("raycastAccessToken");return Yg(`${s}/api/v1/versions`,{token:c,method:"POST",body:JSON.stringify(i)})}function Qyt(i){let s=$_("raycastApiURL"),c=$_("raycastAccessToken");return Yg(`${s}/api/v1/organizations/%${i}/billing/checkouts`,{token:c,method:"POST"}).then(p=>p.key).catch(()=>{})}var RFe=class i extends a3{static description="Validate the extension manifest and metadata, and lint its source code";static flags={fix:W_e.Flags.boolean({char:"f",default:!1,description:"Attempt to fix linting issues"}),relaxed:W_e.Flags.boolean({char:"r",description:"Use relaxed linting mode to skip validation of: package.json schema, icons and metadata.",default:!1}),schema:W_e.Flags.string({char:"s",description:"Path to JSON schema for package.json validation "+i3,default:`${Ux.url}/schemas/extension.json`,hidden:!0})};async run(){let{flags:s}=await this.parse(i);await LFe({skipOwner:!1,fix:s.fix,relaxed:s.relaxed,skipLockFiles:process.env.CI?.toLowerCase()!=="true",schema:s.schema})||this.error("linting issues found (tip: try re-running with '--fix')")}};async function LFe(i){let s=!0;try{let c=Dk();s=await a1r(c,i),s=await o1r(c,i)&&s,s=await c1r(c,i)&&s,s=await l1r(c,i)&&s}catch(c){console.error("error reading manifest:",c),s=!1}return s=await u1r(i)&&s,s=await f1r(i)&&s,s}async function a1r(i,s){return await Gg("validate package.json file",async()=>{let p=[],y=[];try{await U_e(i.author)}catch(x){x.message.includes("Couldn't find User")?p.push({pointer:"/author",message:`Invalid author "${i.author}". Use the Raycast username`,level:"error"}):p.push({pointer:"/author",message:`Invalid author "${i.author}". ${x.message}`,level:"error"})}if(await Promise.all((i.contributors||[]).map(async(x,w)=>{try{await U_e(x)}catch(L){L.message.includes("Couldn't find User")?p.push({pointer:"/contributors/"+w,message:`Invalid contributor "${x}". Use the Raycast username`,level:"error"}):p.push({pointer:"/contributors/"+w,message:`Invalid contributor "${x}". ${L.message}`,level:"error"})}x===i.author&&p.push({pointer:"/contributors/"+w,message:`Author "${x}" should not be added as a contributor`,level:"error"})})),await Promise.all((i.pastContributors||[]).map(async(x,w)=>{try{await U_e(x)}catch(L){L.message.includes("Couldn't find User")?p.push({pointer:"/pastContributors/"+w,message:`Invalid contributor "${x}". Use the Raycast username`,level:"error"}):p.push({pointer:"/pastContributors/"+w,message:`Invalid contributor "${x}". ${L.message}`,level:"error"})}})),i.owner&&!s.skipOwner)try{await Gyt(i.owner)}catch(x){x.message.includes("Couldn't find Organization")?p.push({pointer:"/owner",message:`Invalid owner "${i.owner}". Use the Raycast organization handle`,level:"error"}):p.push({pointer:"/owner",message:`Invalid owner "${i.owner}". ${x.message}`,level:"error"})}if(!s.relaxed){let x=new Zyt.default({allErrors:!0});try{let w=await(await(0,Xyt.default)(s.schema)).json();delete w.$schema;let L=x.compile(w);L(i)||p.push(...(L.errors||[]).map($=>({pointer:$.instancePath,message:$.message||"",level:"error"})))}catch(w){p.push({message:`Failed compiling JSON schema: ${w.message}`,level:"error"})}i.name.startsWith("@workaround/")&&y.push({pointer:"/name",message:`"@workaround/" is a reserved prefix for internal extensions in companies that have a policy regarding namespaced package.json names. This isn't valid for public extensions`,level:"warning"}),(0,$7.titleCase)(i.title)!==i.title&&y.push({pointer:"/title",message:`Extension's title has to be Title Cased. Expected "${(0,$7.titleCase)(i.title)}"`,level:"warning"}),eq(i.title)||y.push({pointer:"/title",message:'Raycast is spelled "Raycast"',level:"warning"}),eq(i.description)||y.push({pointer:"/description",message:'Raycast is spelled "Raycast"',level:"warning"}),i.commands.forEach((w,L)=>{(0,$7.titleCase)(w.title)!==w.title&&y.push({pointer:`/commands/${L}/title`,message:`Command's title has to be Title Cased. Expected "${(0,$7.titleCase)(w.title)}"`,level:"warning"}),eq(w.title)||y.push({pointer:`/commands/${L}/title`,message:'Raycast is spelled "Raycast"',level:"warning"}),eq(w.description)||y.push({pointer:`/commands/${L}/description`,message:'Raycast is spelled "Raycast"',level:"warning"})}),i.tools?.forEach((w,L)=>{(0,$7.titleCase)(w.title)!==w.title&&y.push({pointer:`/tools/${L}/title`,message:`Tool's title has to be Title Cased. Expected "${(0,$7.titleCase)(w.title)}"`,level:"warning"}),eq(w.title)||y.push({pointer:`/tools/${L}/title`,message:'Raycast is spelled "Raycast"',level:"warning"}),eq(w.description)||y.push({pointer:`/tools/${L}/description`,message:'Raycast is spelled "Raycast"',level:"warning"})})}if(p.length>0)throw new Error(`${ng.resolve("package.json")}
|
|
662
662
|
${VP(p.concat(y))}`);y.length>0&&console.log((0,z_e.yellow)(`${ng.resolve("package.json")}
|
|
663
663
|
${VP(p.concat(y))}`))})===void 0}async function o1r(i,s){if(s.relaxed||s.skipLockFiles)return!0;let c=await Gg("validate package-lock.json",async()=>{let p=ng.resolve("package-lock.json"),y;try{y=require(p)}catch{throw new Error("missing package-lock.json. Run 'npm install' to generate the file")}if(y.lockfileVersion===1)throw new Error(`${p}
|
|
664
664
|
4:20 error Wrong 'lockfileVersion'. Version '${y.lockfileVersion}' is unsupported. Update to npm v7 or higher`)});return c?!1:(c=await Gg("validate other lock files",async()=>{if(eD.existsSync("yarn.lock"))throw new Error("yarn is not supported. Remove the `yarn.lock` file and run `npm install` instead");if(eD.existsSync("pnpm-lock.yaml"))throw new Error("pnpm is not supported. Remove the `pnpm-lock.yaml` file and run `npm install` instead");if(eD.existsSync("shrinkwrap.json"))throw new Error("shrinkwrap is not supported. Remove the `shrinkwrap.json` file and run `npm install` instead");if(eD.existsSync("npm-shrinkwrap.json"))throw new Error("shrinkwrap is not supported. Remove the `npm-shrinkwrap.json` file and run `npm install` instead")}),c===void 0)}async function c1r(i,s){return s.relaxed?!0:await Gg("validate extension icons",async()=>{let p=[],y=ng.resolve(ng.join("assets",i.icon)),x=V7(y,{type:"icon"});if(x&&p.push(`${y}
|