@raycast/api 1.96.3 → 1.97.1

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 CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var l=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var i in t)l(e,i,{get:t[i],enumerable:!0})},b=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!A.call(e,s)&&s!==i&&l(e,s,{get:()=>t[s],enumerable:!(o=x(t,s))||o.enumerable});return e};var k=e=>b(l({},"__esModule",{value:!0}),e);var R={};T(R,{runEvalsRemotely:()=>I});module.exports=k(R);var f={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"],N="e69bae0ec90f5e838555",r={};function p(e){switch(e){case"raycastApiURL":return process.env.RAY_APIURL||r.APIURL||f.url;case"raycastAccessToken":return process.env.RAY_TOKEN||r.Token||r.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||r.ClientID||f.clientID;case"githubClientId":return process.env.RAY_GithubClientID||r.GithubClientID||N;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||r.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof r.Target>"u"?C("release"):r.Target)}}function C(e){switch(e){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 p("flavorName")}}async function I(e,{apiEndpoint:t,...i},o){let s=p("raycastAccessToken"),a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({packageJson:e,options:i})});if(!a.ok||a.body===null)throw await a.text();let u=a.body.getReader(),m=new TextDecoder("utf-8"),{done:g,value:d}=await u.read(),n="";for(;!g;){for(n+=m.decode(d,{stream:!0});n.includes(`
1
+ "use strict";var l=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var T=(e,t)=>{for(var i in t)l(e,i,{get:t[i],enumerable:!0})},b=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!A.call(e,s)&&s!==i&&l(e,s,{get:()=>t[s],enumerable:!(o=x(t,s))||o.enumerable});return e};var k=e=>b(l({},"__esModule",{value:!0}),e);var R={};T(R,{runEvalsRemotely:()=>I});module.exports=k(R);var f={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"],N="e69bae0ec90f5e838555",r={};function u(e){switch(e){case"raycastApiURL":return process.env.RAY_APIURL||r.APIURL||f.url;case"raycastAccessToken":return process.env.RAY_TOKEN||r.Token||r.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||r.ClientID||f.clientID;case"githubClientId":return process.env.RAY_GithubClientID||r.GithubClientID||N;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||r.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof r.Target>"u"?C("release"):r.Target)}}function C(e){switch(e){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 u("flavorName")}}async function I(e,{apiEndpoint:t,...i},o){let s=u("raycastAccessToken"),a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({packageJson:e,options:i})});if(!a.ok||a.body===null)throw await a.text();let p=a.body.getReader(),m=new TextDecoder("utf-8"),{done:g,value:d}=await p.read(),n="";for(;!g;){for(n+=m.decode(d,{stream:!0});n.includes(`
2
2
 
3
3
  `);){let c=n.indexOf(`
4
4
 
5
- `)+2,y=n.substring(0,c);n=n.substring(c),o(JSON.parse(y))}({done:g,value:d}=await u.read())}n&&(o(JSON.parse(n)),n="")}0&&(module.exports={runEvalsRemotely});
5
+ `)+2,y=n.substring(0,c);n=n.substring(c),o(JSON.parse(y))}({done:g,value:d}=await p.read())}n&&(o(JSON.parse(n)),n="")}0&&(module.exports={runEvalsRemotely});
@@ -563,7 +563,7 @@ Project '${f.projectName}' (${wF[f.projectKind]}) ${o}
563
563
  `,o++};this.projectService.externalProjects.forEach(c),this.projectService.configuredProjects.forEach(c),this.projectService.inferredProjects.forEach(c)}}this.logger.msg(s,"Err")}send(t){if(t.type==="event"&&!this.canUseEvents){this.logger.hasLevel(3)&&this.logger.info(`Session does not support events: ignored event: ${Tb(t)}`);return}this.writeMessage(t)}writeMessage(t){let n=k0e(t,this.logger,this.byteLength,this.host.newLine);this.host.write(n)}event(t,n){this.send(E0e(n,t))}doOutput(t,n,i,s,o,c){let f={seq:0,type:"response",command:n,request_seq:i,success:s,performanceData:o&&tLe(o)};if(s){let _;if(Ns(t))f.body=t,_=t.metadata,delete t.metadata;else if(typeof t=="object")if(t.metadata){let{metadata:g,...y}=t;f.body=y,_=g}else f.body=t;else f.body=t;_&&(f.metadata=_)}else P.assert(t===void 0);c&&(f.message=c),this.send(f)}semanticCheck(t,n){var i,s;let o=No();(i=yn)==null||i.push(yn.Phase.Session,"semanticCheck",{file:t,configFilePath:n.canonicalConfigFilePath});let c=G9e(n,t)?Ul:n.getLanguageService().getSemanticDiagnostics(t).filter(f=>!!f.file);this.sendDiagnosticsEvent(t,n,c,"semanticDiag",o),(s=yn)==null||s.pop()}syntacticCheck(t,n){var i,s;let o=No();(i=yn)==null||i.push(yn.Phase.Session,"syntacticCheck",{file:t,configFilePath:n.canonicalConfigFilePath}),this.sendDiagnosticsEvent(t,n,n.getLanguageService().getSyntacticDiagnostics(t),"syntaxDiag",o),(s=yn)==null||s.pop()}suggestionCheck(t,n){var i,s;let o=No();(i=yn)==null||i.push(yn.Phase.Session,"suggestionCheck",{file:t,configFilePath:n.canonicalConfigFilePath}),this.sendDiagnosticsEvent(t,n,n.getLanguageService().getSuggestionDiagnostics(t),"suggestionDiag",o),(s=yn)==null||s.pop()}regionSemanticCheck(t,n,i){var s,o,c;let f=No();(s=yn)==null||s.push(yn.Phase.Session,"regionSemanticCheck",{file:t,configFilePath:n.canonicalConfigFilePath});let _;if(!this.shouldDoRegionCheck(t)||!(_=n.getLanguageService().getRegionSemanticDiagnostics(t,i))){(o=yn)==null||o.pop();return}this.sendDiagnosticsEvent(t,n,_.diagnostics,"regionSemanticDiag",f,_.spans),(c=yn)==null||c.pop()}shouldDoRegionCheck(t){var n;let i=(n=this.projectService.getScriptInfoForNormalizedPath(t))==null?void 0:n.textStorage.getLineInfo().getLineCount();return!!(i&&i>=this.regionDiagLineCountThreshold)}sendDiagnosticsEvent(t,n,i,s,o,c){try{let f=P.checkDefined(n.getScriptInfo(t)),_=No()-o,g={file:t,diagnostics:i.map(y=>H9e(t,n,y)),spans:c?.map(y=>Sg(y,f))};this.event(g,s),this.addDiagnosticsPerformanceData(t,s,_)}catch(f){this.logError(f,s)}}updateErrorCheck(t,n,i,s=!0){if(n.length===0)return;P.assert(!this.suppressDiagnosticEvents);let o=this.changeSeq,c=Math.min(i,200),f=0,_=()=>{if(f++,n.length>f)return t.delay("checkOne",c,y)},g=(b,D)=>{if(this.semanticCheck(b,D),this.changeSeq===o){if(this.getPreferences(b).disableSuggestions)return _();t.immediate("suggestionCheck",()=>{this.suggestionCheck(b,D),_()})}},y=()=>{if(this.changeSeq!==o)return;let b,D=n[f];if(Is(D)?D=this.toPendingErrorCheck(D):"ranges"in D&&(b=D.ranges,D=this.toPendingErrorCheck(D.file)),!D)return _();let{fileName:k,project:A}=D;if(Zp(A),!!A.containsFile(k,s)&&(this.syntacticCheck(k,A),this.changeSeq===o)){if(A.projectService.serverMode!==0)return _();if(b)return t.immediate("regionSemanticCheck",()=>{let N=this.projectService.getScriptInfoForNormalizedPath(k);N&&this.regionSemanticCheck(k,A,b.map(F=>this.getRange({file:k,...F},N))),this.changeSeq===o&&t.immediate("semanticCheck",()=>g(k,A))});t.immediate("semanticCheck",()=>g(k,A))}};n.length>f&&this.changeSeq===o&&t.delay("checkOne",i,y)}cleanProjects(t,n){if(n){this.logger.info(`cleaning ${t}`);for(let i of n)i.getLanguageService(!1).cleanupSemanticCache(),i.cleanupProgram()}}cleanup(){this.cleanProjects("inferred projects",this.projectService.inferredProjects),this.cleanProjects("configured projects",Cs(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:i}=this.getFileAndLanguageServiceForSyntacticOperation(t);return i.getEncodedSyntacticClassifications(n,t)}getEncodedSemanticClassifications(t){let{file:n,project:i}=this.getFileAndProject(t),s=t.format==="2020"?"2020":"original";return i.getLanguageService().getEncodedSemanticClassifications(n,t,s)}getProject(t){return t===void 0?void 0:this.projectService.findProject(t)}getConfigFileAndProject(t){let n=this.getProject(t.projectFileName),i=lc(t.file);return{configFile:n&&n.hasConfigFile(i)?i:void 0,project:n}}getConfigFileDiagnostics(t,n,i){let s=n.getAllProjectErrors(),o=n.getLanguageService().getCompilerOptionsDiagnostics(),c=Qn(ms(s,o),f=>!!f.file&&f.file.fileName===t);return i?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(c):Tr(c,f=>FF(f,!1))}convertToDiagnosticsWithLinePositionFromDiagnosticFile(t){return t.map(n=>({message:hg(n.messageText,this.host.newLine),start:n.start,length:n.length,category:aT(n),code:n.code,source:n.source,startLocation:n.file&&I6(ya(n.file,n.start)),endLocation:n.file&&I6(ya(n.file,n.start+n.length)),reportsUnnecessary:n.reportsUnnecessary,reportsDeprecated:n.reportsDeprecated,relatedInformation:Tr(n.relatedInformation,SX)}))}getCompilerOptionsDiagnostics(t){let n=this.getProject(t.projectFileName);return this.convertToDiagnosticsWithLinePosition(Qn(n.getLanguageService().getCompilerOptionsDiagnostics(),i=>!i.file),void 0)}convertToDiagnosticsWithLinePosition(t,n){return t.map(i=>({message:hg(i.messageText,this.host.newLine),start:i.start,length:i.length,category:aT(i),code:i.code,source:i.source,startLocation:n&&n.positionToLineOffset(i.start),endLocation:n&&n.positionToLineOffset(i.start+i.length),reportsUnnecessary:i.reportsUnnecessary,reportsDeprecated:i.reportsDeprecated,relatedInformation:Tr(i.relatedInformation,SX)}))}getDiagnosticsWorker(t,n,i,s){let{project:o,file:c}=this.getFileAndProject(t);if(n&&G9e(o,c))return Ul;let f=o.getScriptInfoForNormalizedPath(c),_=i(o,c);return s?this.convertToDiagnosticsWithLinePosition(_,f):_.map(g=>H9e(c,o,g))}getDefinition(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.getPositionInFile(t,i),c=this.mapDefinitionInfoLocations(s.getLanguageService().getDefinitionAtPosition(i,o)||Ul,s);return n?this.mapDefinitionInfo(c,s):c.map(vre.mapToOriginalLocation)}mapDefinitionInfoLocations(t,n){return t.map(i=>{let s=K9e(i,n);return s?{...s,containerKind:i.containerKind,containerName:i.containerName,kind:i.kind,name:i.name,failedAliasResolution:i.failedAliasResolution,...i.unverified&&{unverified:i.unverified}}:i})}getDefinitionAndBoundSpan(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.getPositionInFile(t,i),c=P.checkDefined(s.getScriptInfo(i)),f=s.getLanguageService().getDefinitionAndBoundSpan(i,o);if(!f||!f.definitions)return{definitions:Ul,textSpan:void 0};let _=this.mapDefinitionInfoLocations(f.definitions,s),{textSpan:g}=f;return n?{definitions:this.mapDefinitionInfo(_,s),textSpan:Sg(g,c)}:{definitions:_.map(vre.mapToOriginalLocation),textSpan:g}}findSourceDefinition(t){var n;let{file:i,project:s}=this.getFileAndProject(t),o=this.getPositionInFile(t,i),c=s.getLanguageService().getDefinitionAtPosition(i,o),f=this.mapDefinitionInfoLocations(c||Ul,s).slice();if(this.projectService.serverMode===0&&(!Tt(f,k=>lc(k.fileName)!==i&&!k.isAmbient)||Tt(f,k=>!!k.failedAliasResolution))){let k=Mz(B=>B.textSpan.start,RH(this.host.useCaseSensitiveFileNames));f?.forEach(B=>k.add(B));let A=s.getNoDtsResolutionProject(i),N=A.getLanguageService(),F=(n=N.getDefinitionAtPosition(i,o,!0,!1))==null?void 0:n.filter(B=>lc(B.fileName)!==i);if(Tt(F))for(let B of F){if(B.unverified){let z=b(B,s.getLanguageService().getProgram(),N.getProgram());if(Tt(z)){for(let J of z)k.add(J);continue}}k.add(B)}else{let B=f.filter(z=>lc(z.fileName)!==i&&z.isAmbient);for(let z of Tt(B)?B:y()){let J=g(z.fileName,i,A);if(!J)continue;let $=this.projectService.getOrCreateScriptInfoNotOpenedByClient(J,A.currentDirectory,A.directoryStructureHost,!1);if(!$)continue;A.containsScriptInfo($)||(A.addRoot($),A.updateGraph());let H=N.getProgram(),ne=P.checkDefined(H.getSourceFile(J));for(let K of D(z.name,ne,H))k.add(K)}}f=Cs(k.values())}return f=f.filter(k=>!k.isAmbient&&!k.failedAliasResolution),this.mapDefinitionInfo(f,s);function g(k,A,N){var F,B,z;let J=W9(k);if(J&&k.lastIndexOf(Uh)===J.topLevelNodeModulesIndex){let $=k.substring(0,J.packageRootIndex),H=(F=s.getModuleResolutionCache())==null?void 0:F.getPackageJsonInfoCache(),ne=s.getCompilationSettings(),K=OP(bs($,s.getCurrentDirectory()),FP(H,s,ne));if(!K)return;let X=i$(K,{moduleResolution:2},s,s.getModuleResolutionCache()),pe=k.substring(J.topLevelPackageNameIndex+1,J.packageRootIndex),ae=LP(e8(pe)),ee=s.toPath(k);if(X&&Tt(X,ye=>s.toPath(ye)===ee))return(B=N.resolutionCache.resolveSingleModuleNameWithoutWatching(ae,A).resolvedModule)==null?void 0:B.resolvedFileName;{let ye=k.substring(J.packageRootIndex+1),le=`${ae}/${T_(ye)}`;return(z=N.resolutionCache.resolveSingleModuleNameWithoutWatching(le,A).resolvedModule)==null?void 0:z.resolvedFileName}}}function y(){let k=s.getLanguageService(),A=k.getProgram(),N=$_(A.getSourceFile(i),o);return(ho(N)||Ue(N))&&Vo(N.parent)&&Wae(N,F=>{var B;if(F===N)return;let z=(B=k.getDefinitionAtPosition(i,F.getStart(),!0,!1))==null?void 0:B.filter(J=>lc(J.fileName)!==i&&J.isAmbient).map(J=>({fileName:J.fileName,name:xd(N)}));if(Tt(z))return z})||Ul}function b(k,A,N){var F;let B=N.getSourceFile(k.fileName);if(!B)return;let z=$_(A.getSourceFile(i),o),J=A.getTypeChecker().getSymbolAtLocation(z),$=J&&oc(J,276);if(!$)return;let H=((F=$.propertyName)==null?void 0:F.text)||$.name.text;return D(H,B,N)}function D(k,A,N){let F=Go.Core.getTopMostDeclarationNamesInFile(k,A);return Yi(F,B=>{let z=N.getTypeChecker().getSymbolAtLocation(B),J=PA(B);if(z&&J)return k6.createDefinitionInfo(J,N.getTypeChecker(),z,J,!0)})}}getEmitOutput(t){let{file:n,project:i}=this.getFileAndProject(t);if(!i.shouldEmitFile(i.getScriptInfo(n)))return{emitSkipped:!0,outputFiles:[],diagnostics:[]};let s=i.getLanguageService().getEmitOutput(n);return t.richResponse?{...s,diagnostics:t.includeLinePosition?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(s.diagnostics):s.diagnostics.map(o=>FF(o,!0))}:s}mapJSDocTagInfo(t,n,i){return t?t.map(s=>{var o;return{...s,text:i?this.mapDisplayParts(s.text,n):(o=s.text)==null?void 0:o.map(c=>c.text).join("")}}):[]}mapDisplayParts(t,n){return t?t.map(i=>i.kind!=="linkName"?i:{...i,target:this.toFileSpan(i.target.fileName,i.target.textSpan,n)}):[]}mapSignatureHelpItems(t,n,i){return t.map(s=>({...s,documentation:this.mapDisplayParts(s.documentation,n),parameters:s.parameters.map(o=>({...o,documentation:this.mapDisplayParts(o.documentation,n)})),tags:this.mapJSDocTagInfo(s.tags,n,i)}))}mapDefinitionInfo(t,n){return t.map(i=>({...this.toFileSpanWithContext(i.fileName,i.textSpan,i.contextSpan,n),...i.unverified&&{unverified:i.unverified}}))}static mapToOriginalLocation(t){return t.originalFileName?(P.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,i){let s=i.getLanguageService(),o=s.toLineColumnOffset(t,n.start),c=s.toLineColumnOffset(t,Sc(n));return{file:t,start:{line:o.line+1,offset:o.character+1},end:{line:c.line+1,offset:c.character+1}}}toFileSpanWithContext(t,n,i,s){let o=this.toFileSpan(t,n,s),c=i&&this.toFileSpan(t,i,s);return c?{...o,contextStart:c.start,contextEnd:c.end}:o}getTypeDefinition(t){let{file:n,project:i}=this.getFileAndProject(t),s=this.getPositionInFile(t,n),o=this.mapDefinitionInfoLocations(i.getLanguageService().getTypeDefinitionAtPosition(n,s)||Ul,i);return this.mapDefinitionInfo(o,i)}mapImplementationLocations(t,n){return t.map(i=>{let s=K9e(i,n);return s?{...s,kind:i.kind,displayParts:i.displayParts}:i})}getImplementation(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.getPositionInFile(t,i),c=this.mapImplementationLocations(s.getLanguageService().getImplementationAtPosition(i,o)||Ul,s);return n?c.map(({fileName:f,textSpan:_,contextSpan:g})=>this.toFileSpanWithContext(f,_,g,s)):c.map(vre.mapToOriginalLocation)}getSyntacticDiagnosticsSync(t){let{configFile:n}=this.getConfigFileAndProject(t);return n?Ul:this.getDiagnosticsWorker(t,!1,(i,s)=>i.getLanguageService().getSyntacticDiagnostics(s),!!t.includeLinePosition)}getSemanticDiagnosticsSync(t){let{configFile:n,project:i}=this.getConfigFileAndProject(t);return n?this.getConfigFileDiagnostics(n,i,!!t.includeLinePosition):this.getDiagnosticsWorker(t,!0,(s,o)=>s.getLanguageService().getSemanticDiagnostics(o).filter(c=>!!c.file),!!t.includeLinePosition)}getSuggestionDiagnosticsSync(t){let{configFile:n}=this.getConfigFileAndProject(t);return n?Ul:this.getDiagnosticsWorker(t,!0,(i,s)=>i.getLanguageService().getSuggestionDiagnostics(s),!!t.includeLinePosition)}getJsxClosingTag(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=this.getPositionInFile(t,n),o=i.getJsxClosingTagAtPosition(n,s);return o===void 0?void 0:{newText:o.newText,caretOffset:0}}getLinkedEditingRange(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=this.getPositionInFile(t,n),o=i.getLinkedEditingRangeAtPosition(n,s),c=this.projectService.getScriptInfoForNormalizedPath(n);if(!(c===void 0||o===void 0))return U1t(o,c)}getDocumentHighlights(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.getPositionInFile(t,i),c=s.getLanguageService().getDocumentHighlights(i,o,t.filesToSearch);return c?n?c.map(({fileName:f,highlightSpans:_})=>{let g=s.getScriptInfo(f);return{file:f,highlightSpans:_.map(({textSpan:y,kind:b,contextSpan:D})=>({...A0e(y,D,g),kind:b}))}}):c:Ul}provideInlayHints(t){let{file:n,project:i}=this.getFileAndProject(t),s=this.projectService.getScriptInfoForNormalizedPath(n);return i.getLanguageService().provideInlayHints(n,t,this.getPreferences(n)).map(c=>{let{position:f,displayParts:_}=c;return{...c,position:s.positionToLineOffset(f),displayParts:_?.map(({text:g,span:y,file:b})=>{if(y){P.assertIsDefined(b,"Target file should be defined together with its span.");let D=this.projectService.getScriptInfo(b);return{text:g,span:{start:D.positionToLineOffset(y.start),end:D.positionToLineOffset(y.start+y.length),file:b}}}else return{text:g}})}})}mapCode(t){var n;let i=this.getHostFormatOptions(),s=this.getHostPreferences(),{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(t),f=this.projectService.getScriptInfoForNormalizedPath(o),_=(n=t.mapping.focusLocations)==null?void 0:n.map(y=>y.map(b=>{let D=f.lineOffsetToPosition(b.start.line,b.start.offset),k=f.lineOffsetToPosition(b.end.line,b.end.offset);return{start:D,length:k-D}})),g=c.mapCode(o,t.mapping.contents,_,i,s);return this.mapTextChangesToCodeEdits(g)}setCompilerOptionsForInferredProjects(t){this.projectService.setCompilerOptionsForInferredProjects(t.options,t.projectRootPath)}getProjectInfo(t){return this.getProjectInfoWorker(t.file,t.projectFileName,t.needFileNameList,!1)}getProjectInfoWorker(t,n,i,s){let{project:o}=this.getFileAndProjectWorker(t,n);return Zp(o),{configFileName:o.getProjectName(),languageServiceDisabled:!o.languageServiceEnabled,fileNames:i?o.getFileNames(!1,s):void 0}}getRenameInfo(t){let{file:n,project:i}=this.getFileAndProject(t),s=this.getPositionInFile(t,n),o=this.getPreferences(n);return i.getLanguageService().getRenameInfo(n,s,o)}getProjects(t,n,i){let s,o;if(t.projectFileName){let c=this.getProject(t.projectFileName);c&&(s=[c])}else{let c=n?this.projectService.getScriptInfoEnsuringProjectsUptoDate(t.file):this.projectService.getScriptInfo(t.file);if(c)n||this.projectService.ensureDefaultProjectForFile(c);else return i?Ul:(this.projectService.logErrorForScriptInfoNotFound(t.file),M0.ThrowNoProject());s=c.containingProjects,o=this.projectService.getSymlinkedProjects(c)}return s=Qn(s,c=>c.languageServiceEnabled&&!c.isOrphan()),!i&&(!s||!s.length)&&!o?(this.projectService.logErrorForScriptInfoNotFound(t.file??t.projectFileName),M0.ThrowNoProject()):o?{projects:s,symLinkedProjects:o}:s}getDefaultProject(t){if(t.projectFileName){let i=this.getProject(t.projectFileName);if(i)return i;if(!t.file)return M0.ThrowNoProject()}return this.projectService.getScriptInfo(t.file).getDefaultProject()}getRenameLocations(t,n){let i=lc(t.file),s=this.getPositionInFile(t,i),o=this.getProjects(t),c=this.getDefaultProject(t),f=this.getPreferences(i),_=this.mapRenameInfo(c.getLanguageService().getRenameInfo(i,s,f),P.checkDefined(this.projectService.getScriptInfo(i)));if(!_.canRename)return n?{info:_,locs:[]}:[];let g=L1t(o,c,{fileName:t.file,pos:s},!!t.findInStrings,!!t.findInComments,f,this.host.useCaseSensitiveFileNames);return n?{info:_,locs:this.toSpanGroups(g)}:g}mapRenameInfo(t,n){if(t.canRename){let{canRename:i,fileToRename:s,displayName:o,fullDisplayName:c,kind:f,kindModifiers:_,triggerSpan:g}=t;return{canRename:i,fileToRename:s,displayName:o,fullDisplayName:c,kind:f,kindModifiers:_,triggerSpan:Sg(g,n)}}else return t}toSpanGroups(t){let n=new Map;for(let{fileName:i,textSpan:s,contextSpan:o,originalContextSpan:c,originalTextSpan:f,originalFileName:_,...g}of t){let y=n.get(i);y||n.set(i,y={file:i,locs:[]});let b=P.checkDefined(this.projectService.getScriptInfo(i));y.locs.push({...A0e(s,o,b),...g})}return Cs(n.values())}getReferences(t,n){let i=lc(t.file),s=this.getProjects(t),o=this.getPositionInFile(t,i),c=R1t(s,this.getDefaultProject(t),{fileName:t.file,pos:o},this.host.useCaseSensitiveFileNames,this.logger);if(!n)return c;let f=this.getPreferences(i),_=this.getDefaultProject(t),g=_.getScriptInfoForNormalizedPath(i),y=_.getLanguageService().getQuickInfoAtPosition(i,o),b=y?nF(y.displayParts):"",D=y&&y.textSpan,k=D?g.positionToLineOffset(D.start).offset:0,A=D?g.getSnapshot().getText(D.start,Sc(D)):"";return{refs:xa(c,F=>F.references.map(B=>nLe(this.projectService,B,f))),symbolName:A,symbolStartOffset:k,symbolDisplayString:b}}getFileReferences(t,n){let i=this.getProjects(t),s=t.file,o=this.getPreferences(lc(s)),c=[],f=TX(this.host.useCaseSensitiveFileNames);return w0e(i,void 0,g=>{if(g.getCancellationToken().isCancellationRequested())return;let y=g.getLanguageService().getFileReferences(s);if(y)for(let b of y)f.has(b)||(c.push(b),f.add(b))}),n?{refs:c.map(g=>nLe(this.projectService,g,o)),symbolName:`"${t.file}"`}:c}openClientFile(t,n,i,s){this.projectService.openClientFileWithNormalizedPath(t,n,i,!1,s)}getPosition(t,n){return t.position!==void 0?t.position:n.lineOffsetToPosition(t.line,t.offset)}getPositionInFile(t,n){let i=this.projectService.getScriptInfoForNormalizedPath(n);return this.getPosition(t,i)}getFileAndProject(t){return this.getFileAndProjectWorker(t.file,t.projectFileName)}getFileAndLanguageServiceForSyntacticOperation(t){let{file:n,project:i}=this.getFileAndProject(t);return{file:n,languageService:i.getLanguageService(!1)}}getFileAndProjectWorker(t,n){let i=lc(t),s=this.getProject(n)||this.projectService.ensureDefaultProjectForFile(i);return{file:i,project:s}}getOutliningSpans(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=s.getOutliningSpans(i);if(n){let c=this.projectService.getScriptInfoForNormalizedPath(i);return o.map(f=>({textSpan:Sg(f.textSpan,c),hintSpan:Sg(f.hintSpan,c),bannerText:f.bannerText,autoCollapse:f.autoCollapse,kind:f.kind}))}else return o}getTodoComments(t){let{file:n,project:i}=this.getFileAndProject(t);return i.getLanguageService().getTodoComments(n,t.descriptors)}getDocCommentTemplate(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=this.getPositionInFile(t,n);return i.getDocCommentTemplateAtPosition(n,s,this.getPreferences(n),this.getFormatOptions(n))}getSpanOfEnclosingComment(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=t.onlyMultiLine,o=this.getPositionInFile(t,n);return i.getSpanOfEnclosingComment(n,o,s)}getIndentation(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=this.getPositionInFile(t,n),o=t.options?N6(t.options):this.getFormatOptions(n),c=i.getIndentationAtPosition(n,s,o);return{position:s,indentation:c}}getBreakpointStatement(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=this.getPositionInFile(t,n);return i.getBreakpointStatementAtPosition(n,s)}getNameOrDottedNameSpan(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=this.getPositionInFile(t,n);return i.getNameOrDottedNameSpan(n,s,s)}isValidBraceCompletion(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=this.getPositionInFile(t,n);return i.isValidBraceCompletionAtPosition(n,s,t.openingBrace.charCodeAt(0))}getQuickInfoWorker(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=s.getLanguageService().getQuickInfoAtPosition(i,this.getPosition(t,o));if(!c)return;let f=!!this.getPreferences(i).displayPartsForJSDoc;if(n){let _=nF(c.displayParts);return{kind:c.kind,kindModifiers:c.kindModifiers,start:o.positionToLineOffset(c.textSpan.start),end:o.positionToLineOffset(Sc(c.textSpan)),displayString:_,documentation:f?this.mapDisplayParts(c.documentation,s):nF(c.documentation),tags:this.mapJSDocTagInfo(c.tags,s,f)}}else return f?c:{...c,tags:this.mapJSDocTagInfo(c.tags,s,!1)}}getFormattingEditsForRange(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=this.projectService.getScriptInfoForNormalizedPath(n),o=s.lineOffsetToPosition(t.line,t.offset),c=s.lineOffsetToPosition(t.endLine,t.endOffset),f=i.getFormattingEditsForRange(n,o,c,this.getFormatOptions(n));if(f)return f.map(_=>this.convertTextChangeToCodeEdit(_,s))}getFormattingEditsForRangeFull(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=t.options?N6(t.options):this.getFormatOptions(n);return i.getFormattingEditsForRange(n,t.position,t.endPosition,s)}getFormattingEditsForDocumentFull(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=t.options?N6(t.options):this.getFormatOptions(n);return i.getFormattingEditsForDocument(n,s)}getFormattingEditsAfterKeystrokeFull(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=t.options?N6(t.options):this.getFormatOptions(n);return i.getFormattingEditsAfterKeystroke(n,t.position,t.key,s)}getFormattingEditsAfterKeystroke(t){let{file:n,languageService:i}=this.getFileAndLanguageServiceForSyntacticOperation(t),s=this.projectService.getScriptInfoForNormalizedPath(n),o=s.lineOffsetToPosition(t.line,t.offset),c=this.getFormatOptions(n),f=i.getFormattingEditsAfterKeystroke(n,o,t.key,c);if(t.key===`
564
564
  `&&(!f||f.length===0||I1t(f,o))){let{lineText:_,absolutePosition:g}=s.textStorage.getAbsolutePositionAndLineText(t.line);if(_&&_.search("\\S")<0){let y=i.getIndentationAtPosition(n,o,c),b=0,D,k;for(D=0,k=_.length;D<k;D++)if(_.charAt(D)===" ")b++;else if(_.charAt(D)===" ")b+=c.tabSize;else break;if(y!==b){let A=g+D;f.push({span:Vc(g,A),newText:Sl.getIndentationString(y,c)})}}}if(f)return f.map(_=>({start:s.positionToLineOffset(_.span.start),end:s.positionToLineOffset(Sc(_.span)),newText:_.newText?_.newText:""}))}getCompletions(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getPosition(t,o),f=s.getLanguageService().getCompletionsAtPosition(i,c,{...f0e(this.getPreferences(i)),triggerCharacter:t.triggerCharacter,triggerKind:t.triggerKind,includeExternalModuleExports:t.includeExternalModuleExports,includeInsertTextCompletions:t.includeInsertTextCompletions},s.projectService.getFormatCodeOptions(i));if(f===void 0)return;if(n==="completions-full")return f;let _=t.prefix||"",g=Yi(f.entries,b=>{if(f.isMemberCompletion||os(b.name.toLowerCase(),_.toLowerCase())){let D=b.replacementSpan?Sg(b.replacementSpan,o):void 0;return{...b,replacementSpan:D,hasAction:b.hasAction||void 0,symbol:void 0}}});return n==="completions"?(f.metadata&&(g.metadata=f.metadata),g):{...f,optionalReplacementSpan:f.optionalReplacementSpan&&Sg(f.optionalReplacementSpan,o),entries:g}}getCompletionEntryDetails(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getPosition(t,o),f=s.projectService.getFormatCodeOptions(i),_=!!this.getPreferences(i).displayPartsForJSDoc,g=Yi(t.entryNames,y=>{let{name:b,source:D,data:k}=typeof y=="string"?{name:y,source:void 0,data:void 0}:y;return s.getLanguageService().getCompletionEntryDetails(i,c,b,f,D,this.getPreferences(i),k?oa(k,H1t):void 0)});return n?_?g:g.map(y=>({...y,tags:this.mapJSDocTagInfo(y.tags,s,!1)})):g.map(y=>({...y,codeActions:Tr(y.codeActions,b=>this.mapCodeAction(b)),documentation:this.mapDisplayParts(y.documentation,s),tags:this.mapJSDocTagInfo(y.tags,s,_)}))}getCompileOnSaveAffectedFileList(t){let n=this.getProjects(t,!0,!0),i=this.projectService.getScriptInfo(t.file);return i?O1t(i,s=>this.projectService.getScriptInfoForPath(s),n,(s,o)=>{if(!s.compileOnSaveEnabled||!s.languageServiceEnabled||s.isOrphan())return;let c=s.getCompilationSettings();if(!(c.noEmit||ru(o.fileName)&&!N1t(c)))return{projectFileName:s.getProjectName(),fileNames:s.getCompileOnSaveAffectedFileList(o),projectUsesOutFile:!!c.outFile}}):Ul}emitFile(t){let{file:n,project:i}=this.getFileAndProject(t);if(i||M0.ThrowNoProject(),!i.languageServiceEnabled)return t.richResponse?{emitSkipped:!0,diagnostics:[]}:!1;let s=i.getScriptInfo(n),{emitSkipped:o,diagnostics:c}=i.emitFile(s,(f,_,g)=>this.host.writeFile(f,_,g));return t.richResponse?{emitSkipped:o,diagnostics:t.includeLinePosition?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(c):c.map(f=>FF(f,!0))}:!o}getSignatureHelpItems(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getPosition(t,o),f=s.getLanguageService().getSignatureHelpItems(i,c,t),_=!!this.getPreferences(i).displayPartsForJSDoc;if(f&&n){let g=f.applicableSpan;return{...f,applicableSpan:{start:o.positionToLineOffset(g.start),end:o.positionToLineOffset(g.start+g.length)},items:this.mapSignatureHelpItems(f.items,s,_)}}else return _||!f?f:{...f,items:f.items.map(g=>({...g,tags:this.mapJSDocTagInfo(g.tags,s,!1)}))}}toPendingErrorCheck(t){let n=lc(t),i=this.projectService.tryGetDefaultProjectForFile(n);return i&&{fileName:n,project:i}}getDiagnostics(t,n,i){this.suppressDiagnosticEvents||i.length>0&&this.updateErrorCheck(t,i,n)}change(t){let n=this.projectService.getScriptInfo(t.file);P.assert(!!n),n.textStorage.switchToScriptVersionCache();let i=n.lineOffsetToPosition(t.line,t.offset),s=n.lineOffsetToPosition(t.endLine,t.endOffset);i>=0&&(this.changeSeq++,this.projectService.applyChangesToFile(n,Dre({span:{start:i,length:s-i},newText:t.insertString})))}reload(t){let n=lc(t.file),i=t.tmpfile===void 0?void 0:lc(t.tmpfile),s=this.projectService.getScriptInfoForNormalizedPath(n);s&&(this.changeSeq++,s.reloadFromFile(i))}saveToTmp(t,n){let i=this.projectService.getScriptInfo(t);i&&i.saveTo(n)}closeClientFile(t){if(!t)return;let n=ta(t);this.projectService.closeClientFile(n)}mapLocationNavigationBarItems(t,n){return Tr(t,i=>({text:i.text,kind:i.kind,kindModifiers:i.kindModifiers,spans:i.spans.map(s=>Sg(s,n)),childItems:this.mapLocationNavigationBarItems(i.childItems,n),indent:i.indent}))}getNavigationBarItems(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=s.getNavigationBarItems(i);return o?n?this.mapLocationNavigationBarItems(o,this.projectService.getScriptInfoForNormalizedPath(i)):o:void 0}toLocationNavigationTree(t,n){return{text:t.text,kind:t.kind,kindModifiers:t.kindModifiers,spans:t.spans.map(i=>Sg(i,n)),nameSpan:t.nameSpan&&Sg(t.nameSpan,n),childItems:Tr(t.childItems,i=>this.toLocationNavigationTree(i,n))}}getNavigationTree(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=s.getNavigationTree(i);return o?n?this.toLocationNavigationTree(o,this.projectService.getScriptInfoForNormalizedPath(i)):o:void 0}getNavigateToItems(t,n){let i=this.getFullNavigateToItems(t);return n?xa(i,({project:s,navigateToItems:o})=>o.map(c=>{let f=s.getScriptInfo(c.fileName),_={name:c.name,kind:c.kind,kindModifiers:c.kindModifiers,isCaseSensitive:c.isCaseSensitive,matchKind:c.matchKind,file:c.fileName,start:f.positionToLineOffset(c.textSpan.start),end:f.positionToLineOffset(Sc(c.textSpan))};return c.kindModifiers&&c.kindModifiers!==""&&(_.kindModifiers=c.kindModifiers),c.containerName&&c.containerName.length>0&&(_.containerName=c.containerName),c.containerKind&&c.containerKind.length>0&&(_.containerKind=c.containerKind),_})):xa(i,({navigateToItems:s})=>s)}getFullNavigateToItems(t){let{currentFileOnly:n,searchValue:i,maxResultCount:s,projectFileName:o}=t;if(n){P.assertIsDefined(t.file);let{file:D,project:k}=this.getFileAndProject(t);return[{project:k,navigateToItems:k.getLanguageService().getNavigateToItems(i,s,D)}]}let c=this.getHostPreferences(),f=[],_=new Map;if(!t.file&&!o)this.projectService.loadAncestorProjectTree(),this.projectService.forEachEnabledProject(D=>g(D));else{let D=this.getProjects(t);w0e(D,void 0,k=>g(k))}return f;function g(D){let k=D.getLanguageService().getNavigateToItems(i,s,void 0,D.isNonTsProject(),c.excludeLibrarySymbolsInNavTo),A=Qn(k,N=>y(N)&&!xX(D4(N),D));A.length&&f.push({project:D,navigateToItems:A})}function y(D){let k=D.name;if(!_.has(k))return _.set(k,[D]),!0;let A=_.get(k);for(let N of A)if(b(N,D))return!1;return A.push(D),!0}function b(D,k){return D===k?!0:!D||!k?!1:D.containerKind===k.containerKind&&D.containerName===k.containerName&&D.fileName===k.fileName&&D.isCaseSensitive===k.isCaseSensitive&&D.kind===k.kind&&D.kindModifiers===k.kindModifiers&&D.matchKind===k.matchKind&&D.name===k.name&&D.textSpan.start===k.textSpan.start&&D.textSpan.length===k.textSpan.length}}getSupportedCodeFixes(t){if(!t)return UY();if(t.file){let{file:i,project:s}=this.getFileAndProject(t);return s.getLanguageService().getSupportedCodeFixes(i)}let n=this.getProject(t.projectFileName);return n||M0.ThrowNoProject(),n.getLanguageService().getSupportedCodeFixes()}isLocation(t){return t.line!==void 0}extractPositionOrRange(t,n){let i,s;return this.isLocation(t)?i=o(t):s=this.getRange(t,n),P.checkDefined(i===void 0?s:i);function o(c){return c.position!==void 0?c.position:n.lineOffsetToPosition(c.line,c.offset)}}getRange(t,n){let{startPosition:i,endPosition:s}=this.getStartAndEndPosition(t,n);return{pos:i,end:s}}getApplicableRefactors(t){let{file:n,project:i}=this.getFileAndProject(t),s=i.getScriptInfoForNormalizedPath(n);return i.getLanguageService().getApplicableRefactors(n,this.extractPositionOrRange(t,s),this.getPreferences(n),t.triggerReason,t.kind,t.includeInteractiveActions).map(c=>({...c,actions:c.actions.map(f=>({...f,range:f.range?{start:I6({line:f.range.start.line,character:f.range.start.offset}),end:I6({line:f.range.end.line,character:f.range.end.offset})}:void 0}))}))}getEditsForRefactor(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=s.getScriptInfoForNormalizedPath(i),c=s.getLanguageService().getEditsForRefactor(i,this.getFormatOptions(i),this.extractPositionOrRange(t,o),t.refactor,t.action,this.getPreferences(i),t.interactiveRefactorArguments);if(c===void 0)return{edits:[]};if(n){let{renameFilename:f,renameLocation:_,edits:g}=c,y;if(f!==void 0&&_!==void 0){let b=s.getScriptInfoForNormalizedPath(lc(f));y=P0e(DC(b.getSnapshot()),f,_,g)}return{renameLocation:y,renameFilename:f,edits:this.mapTextChangesToCodeEdits(g),notApplicableReason:c.notApplicableReason}}return c}getMoveToRefactoringFileSuggestions(t){let{file:n,project:i}=this.getFileAndProject(t),s=i.getScriptInfoForNormalizedPath(n);return i.getLanguageService().getMoveToRefactoringFileSuggestions(n,this.extractPositionOrRange(t,s),this.getPreferences(n))}getPasteEdits(t){let{file:n,project:i}=this.getFileAndProject(t),s=t.copiedFrom?{file:t.copiedFrom.file,range:t.copiedFrom.spans.map(c=>this.getRange({file:t.copiedFrom.file,startLine:c.start.line,startOffset:c.start.offset,endLine:c.end.line,endOffset:c.end.offset},i.getScriptInfoForNormalizedPath(lc(t.copiedFrom.file))))}:void 0,o=i.getLanguageService().getPasteEdits({targetFile:n,pastedText:t.pastedText,pasteLocations:t.pasteLocations.map(c=>this.getRange({file:n,startLine:c.start.line,startOffset:c.start.offset,endLine:c.end.line,endOffset:c.end.offset},i.getScriptInfoForNormalizedPath(n))),copiedFrom:s,preferences:this.getPreferences(n)},this.getFormatOptions(n));return o&&this.mapPasteEditsAction(o)}organizeImports(t,n){P.assert(t.scope.type==="file");let{file:i,project:s}=this.getFileAndProject(t.scope.args),o=s.getLanguageService().organizeImports({fileName:i,mode:t.mode??(t.skipDestructiveCodeActions?"SortAndCombine":void 0),type:"file"},this.getFormatOptions(i),this.getPreferences(i));return n?this.mapTextChangesToCodeEdits(o):o}getEditsForFileRename(t,n){let i=lc(t.oldFilePath),s=lc(t.newFilePath),o=this.getHostFormatOptions(),c=this.getHostPreferences(),f=new Set,_=[];return this.projectService.loadAncestorProjectTree(),this.projectService.forEachEnabledProject(g=>{let y=g.getLanguageService().getEditsForFileRename(i,s,o,c),b=[];for(let D of y)f.has(D.fileName)||(_.push(D),b.push(D.fileName));for(let D of b)f.add(D)}),n?_.map(g=>this.mapTextChangeToCodeEdit(g)):_}getCodeFixes(t,n){let{file:i,project:s}=this.getFileAndProject(t),o=s.getScriptInfoForNormalizedPath(i),{startPosition:c,endPosition:f}=this.getStartAndEndPosition(t,o),_;try{_=s.getLanguageService().getCodeFixesAtPosition(i,c,f,t.errorCodes,this.getFormatOptions(i),this.getPreferences(i))}catch(g){let y=s.getLanguageService(),b=[...y.getSyntacticDiagnostics(i),...y.getSemanticDiagnostics(i),...y.getSuggestionDiagnostics(i)].map(k=>Y3(c,f-c,k.start,k.length)&&k.code),D=t.errorCodes.find(k=>!b.includes(k));throw D!==void 0&&(g.message=`BADCLIENT: Bad error code, ${D} not found in range ${c}..${f} (found: ${b.join(", ")}); could have caused this error:
565
565
  ${g.message}`),g}return n?_.map(g=>this.mapCodeFixAction(g)):_}getCombinedCodeFix({scope:t,fixId:n},i){P.assert(t.type==="file");let{file:s,project:o}=this.getFileAndProject(t.args),c=o.getLanguageService().getCombinedCodeFix({type:"file",fileName:s},n,this.getFormatOptions(s),this.getPreferences(s));return i?{changes:this.mapTextChangesToCodeEdits(c.changes),commands:c.commands}:c}applyCodeActionCommand(t){let n=t.command;for(let i of oD(n)){let{file:s,project:o}=this.getFileAndProject(i);o.getLanguageService().applyCodeActionCommand(i,this.getFormatOptions(s)).then(c=>{},c=>{})}return{}}getStartAndEndPosition(t,n){let i,s;return t.startPosition!==void 0?i=t.startPosition:(i=n.lineOffsetToPosition(t.startLine,t.startOffset),t.startPosition=i),t.endPosition!==void 0?s=t.endPosition:(s=n.lineOffsetToPosition(t.endLine,t.endOffset),t.endPosition=s),{startPosition:i,endPosition:s}}mapCodeAction({description:t,changes:n,commands:i}){return{description:t,changes:this.mapTextChangesToCodeEdits(n),commands:i}}mapCodeFixAction({fixName:t,description:n,changes:i,commands:s,fixId:o,fixAllDescription:c}){return{fixName:t,description:n,changes:this.mapTextChangesToCodeEdits(i),commands:s,fixId:o,fixAllDescription:c}}mapPasteEditsAction({edits:t,fixId:n}){return{edits:this.mapTextChangesToCodeEdits(t),fixId:n}}mapTextChangesToCodeEdits(t){return t.map(n=>this.mapTextChangeToCodeEdit(n))}mapTextChangeToCodeEdit(t){let n=this.projectService.getScriptInfoOrConfig(t.fileName);return!!t.isNewFile==!!n&&(n||this.projectService.logErrorForScriptInfoNotFound(t.fileName),P.fail("Expected isNewFile for (only) new files. "+JSON.stringify({isNewFile:!!t.isNewFile,hasScriptInfo:!!n}))),n?{fileName:t.fileName,textChanges:t.textChanges.map(i=>W1t(i,n))}:q1t(t)}convertTextChangeToCodeEdit(t,n){return{start:n.positionToLineOffset(t.span.start),end:n.positionToLineOffset(t.span.start+t.span.length),newText:t.newText?t.newText:""}}getBraceMatching(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getPosition(t,o),f=s.getBraceMatchingAtPosition(i,c);return f?n?f.map(_=>Sg(_,o)):f:void 0}getDiagnosticsForProject(t,n,i){if(this.suppressDiagnosticEvents)return;let{fileNames:s,languageServiceDisabled:o}=this.getProjectInfoWorker(i,void 0,!0,!0);if(o)return;let c=s.filter(N=>!N.includes("lib.d.ts"));if(c.length===0)return;let f=[],_=[],g=[],y=[],b=lc(i),D=this.projectService.ensureDefaultProjectForFile(b);for(let N of c)this.getCanonicalFileName(N)===this.getCanonicalFileName(i)?f.push(N):this.projectService.getScriptInfo(N).isScriptOpen()?_.push(N):ru(N)?y.push(N):g.push(N);let A=[...f,..._,...g,...y].map(N=>({fileName:N,project:D}));this.updateErrorCheck(t,A,n,!1)}configurePlugin(t){this.projectService.configurePlugin(t)}getSmartSelectionRange(t,n){let{locations:i}=t,{file:s,languageService:o}=this.getFileAndLanguageServiceForSyntacticOperation(t),c=P.checkDefined(this.projectService.getScriptInfo(s));return Tr(i,f=>{let _=this.getPosition(f,c),g=o.getSmartSelectionRange(s,_);return n?this.mapSelectionRange(g,c):g})}toggleLineComment(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfo(i),c=this.getRange(t,o),f=s.toggleLineComment(i,c);if(n){let _=this.projectService.getScriptInfoForNormalizedPath(i);return f.map(g=>this.convertTextChangeToCodeEdit(g,_))}return f}toggleMultilineComment(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getRange(t,o),f=s.toggleMultilineComment(i,c);if(n){let _=this.projectService.getScriptInfoForNormalizedPath(i);return f.map(g=>this.convertTextChangeToCodeEdit(g,_))}return f}commentSelection(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getRange(t,o),f=s.commentSelection(i,c);if(n){let _=this.projectService.getScriptInfoForNormalizedPath(i);return f.map(g=>this.convertTextChangeToCodeEdit(g,_))}return f}uncommentSelection(t,n){let{file:i,languageService:s}=this.getFileAndLanguageServiceForSyntacticOperation(t),o=this.projectService.getScriptInfoForNormalizedPath(i),c=this.getRange(t,o),f=s.uncommentSelection(i,c);if(n){let _=this.projectService.getScriptInfoForNormalizedPath(i);return f.map(g=>this.convertTextChangeToCodeEdit(g,_))}return f}mapSelectionRange(t,n){let i={textSpan:Sg(t.textSpan,n)};return t.parent&&(i.parent=this.mapSelectionRange(t.parent,n)),i}getScriptInfoFromProjectService(t){let n=lc(t),i=this.projectService.getScriptInfoForNormalizedPath(n);return i||(this.projectService.logErrorForScriptInfoNotFound(n),M0.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:Sg(t.span,n),selectionSpan:Sg(t.selectionSpan,n)}}toProtocolCallHierarchyIncomingCall(t){let n=this.getScriptInfoFromProjectService(t.from.file);return{from:this.toProtocolCallHierarchyItem(t.from),fromSpans:t.fromSpans.map(i=>Sg(i,n))}}toProtocolCallHierarchyOutgoingCall(t,n){return{to:this.toProtocolCallHierarchyItem(t.to),fromSpans:t.fromSpans.map(i=>Sg(i,n))}}prepareCallHierarchy(t){let{file:n,project:i}=this.getFileAndProject(t),s=this.projectService.getScriptInfoForNormalizedPath(n);if(s){let o=this.getPosition(t,s),c=i.getLanguageService().prepareCallHierarchy(n,o);return c&&eY(c,f=>this.toProtocolCallHierarchyItem(f))}}provideCallHierarchyIncomingCalls(t){let{file:n,project:i}=this.getFileAndProject(t),s=this.getScriptInfoFromProjectService(n);return i.getLanguageService().provideCallHierarchyIncomingCalls(n,this.getPosition(t,s)).map(c=>this.toProtocolCallHierarchyIncomingCall(c))}provideCallHierarchyOutgoingCalls(t){let{file:n,project:i}=this.getFileAndProject(t),s=this.getScriptInfoFromProjectService(n);return i.getLanguageService().provideCallHierarchyOutgoingCalls(n,this.getPosition(t,s)).map(c=>this.toProtocolCallHierarchyOutgoingCall(c,s))}getCanonicalFileName(t){let n=this.host.useCaseSensitiveFileNames?t:h1(t);return ta(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){P.assert(this.currentRequestId===void 0),this.currentRequestId=t,this.cancellationToken.setRequest(t)}resetCurrentRequest(t){P.assert(this.currentRequestId===t),this.currentRequestId=void 0,this.cancellationToken.resetRequest(t)}executeWithRequestId(t,n,i){let s=this.performanceData;try{return this.performanceData=i,this.setCurrentRequest(t),n()}finally{this.resetCurrentRequest(t),this.performanceData=s}}executeCommand(t){let n=this.handlers.get(t.command);if(n){let i=this.executeWithRequestId(t.seq,()=>n(t),void 0);return this.projectService.enableRequestedPlugins(),i}else return this.logger.msg(`Unrecognized JSON command:${Tb(t)}`,"Err"),this.doOutput(void 0,"unknown",t.seq,!1,void 0,`Unrecognized JSON command: ${t.command}`),{responseRequired:!1}}onMessage(t){var n,i,s,o,c,f,_;this.gcTimer.scheduleCollect();let g,y=this.performanceData;this.logger.hasLevel(2)&&(g=this.hrtime(),this.logger.hasLevel(3)&&this.logger.info(`request:${XP(this.toStringMessage(t))}`));let b,D;try{b=this.parseMessage(t),D=b.arguments&&b.arguments.file?b.arguments:void 0,(n=yn)==null||n.instant(yn.Phase.Session,"request",{seq:b.seq,command:b.command}),(i=yn)==null||i.push(yn.Phase.Session,"executeCommand",{seq:b.seq,command:b.command},!0);let{response:k,responseRequired:A,performanceData:N}=this.executeCommand(b);if((s=yn)==null||s.pop(),this.logger.hasLevel(2)){let F=P1t(this.hrtime(g)).toFixed(4);A?this.logger.perftrc(`${b.seq}::${b.command}: elapsed time (in milliseconds) ${F}`):this.logger.perftrc(`${b.seq}::${b.command}: async elapsed time (in milliseconds) ${F}`)}(o=yn)==null||o.instant(yn.Phase.Session,"response",{seq:b.seq,command:b.command,success:!!k}),k?this.doOutput(k,b.command,b.seq,!0,N):A&&this.doOutput(void 0,b.command,b.seq,!1,N,"No content available.")}catch(k){if((c=yn)==null||c.popAll(),k instanceof Yw){(f=yn)==null||f.instant(yn.Phase.Session,"commandCanceled",{seq:b?.seq,command:b?.command}),this.doOutput({canceled:!0},b.command,b.seq,!0,this.performanceData);return}this.logErrorWorker(k,this.toStringMessage(t),D),(_=yn)==null||_.instant(yn.Phase.Session,"commandError",{seq:b?.seq,command:b?.command,message:k.message}),this.doOutput(void 0,b?b.command:"unknown",b?b.seq:0,!1,this.performanceData,"Error processing request. "+k.message+`
566
- `+k.stack)}finally{this.performanceData=y}}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 tLe(e){let t=e.diagnosticsDuration&&Cs(e.diagnosticsDuration,([n,i])=>({...i,file:n}));return{...e,diagnosticsDuration:t}}function Sg(e,t){return{start:t.positionToLineOffset(e.start),end:t.positionToLineOffset(Sc(e))}}function A0e(e,t,n){let i=Sg(e,n),s=t&&Sg(t,n);return s?{...i,contextStart:s.start,contextEnd:s.end}:i}function W1t(e,t){return{start:rLe(t,e.span.start),end:rLe(t,Sc(e.span)),newText:e.newText}}function rLe(e,t){return T0e(e)?V1t(e.getLineAndCharacterOfPosition(t)):e.positionToLineOffset(t)}function U1t(e,t){let n=e.ranges.map(i=>({start:t.positionToLineOffset(i.start),end:t.positionToLineOffset(i.start+i.length)}));return e.wordPattern?{ranges:n,wordPattern:e.wordPattern}:{ranges:n}}function V1t(e){return{line:e.line+1,offset:e.character+1}}function q1t(e){P.assert(e.textChanges.length===1);let t=Va(e.textChanges);return P.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 P0e(e,t,n,i){let s=$1t(e,t,i),{line:o,character:c}=Hk(fD(s),n);return{line:o+1,offset:c+1}}function $1t(e,t,n){for(let{fileName:i,textChanges:s}of n)if(i===t)for(let o=s.length-1;o>=0;o--){let{newText:c,span:{start:f,length:_}}=s[o];e=e.slice(0,f)+c+e.slice(f+_)}return e}function nLe(e,{fileName:t,textSpan:n,contextSpan:i,isWriteAccess:s,isDefinition:o},{disableLineTextInReferences:c}){let f=P.checkDefined(e.getScriptInfo(t)),_=A0e(n,i,f),g=c?void 0:G1t(f,_);return{file:t,..._,lineText:g,isWriteAccess:s,isDefinition:o}}function G1t(e,t){let n=e.lineToTextSpan(t.start.line-1);return e.getSnapshot().getText(n.start,Sc(n)).replace(/\r|\n/g,"")}function H1t(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 F6=4,N0e=(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))(N0e||{}),Y1t=class{constructor(){this.goSubtree=!0,this.lineIndex=new OF,this.endBranch=[],this.state=2,this.initialText="",this.trailingText="",this.lineIndex.root=new O6,this.startPath=[this.lineIndex.root],this.stack=[this.lineIndex.root]}get done(){return!1}insertLines(e,t){t&&(this.trailingText=""),e?e=this.initialText+e+this.trailingText:e=this.initialText+this.trailingText;let i=OF.linesFromText(e).lines;i.length>1&&i[i.length-1]===""&&i.pop();let s,o;for(let f=this.endBranch.length-1;f>=0;f--)this.endBranch[f].updateCounts(),this.endBranch[f].charCount()===0&&(o=this.endBranch[f],f>0?s=this.endBranch[f-1]:s=this.branchNode);o&&s.remove(o);let c=this.startPath[this.startPath.length-1];if(i.length>0)if(c.text=i[0],i.length>1){let f=new Array(i.length-1),_=c;for(let b=1;b<i.length;b++)f[b-1]=new NB(i[b]);let g=this.startPath.length-2;for(;g>=0;){let b=this.startPath[g];f=b.insertAt(_,f),g--,_=b}let y=f.length;for(;y>0;){let b=new O6;b.add(this.lineIndex.root),f=b.insertAt(this.lineIndex.root,f),y=f.length,this.lineIndex.root=b}this.lineIndex.root.updateCounts()}else for(let f=this.startPath.length-2;f>=0;f--)this.startPath[f].updateCounts();else{this.startPath[this.startPath.length-2].remove(c);for(let _=this.startPath.length-2;_>=0;_--)this.startPath[_].updateCounts()}return this.lineIndex}post(e,t,n){n===this.lineCollectionAtBranch&&(this.state=4),this.stack.pop()}pre(e,t,n,i,s){let o=this.stack[this.stack.length-1];this.state===2&&s===1&&(this.state=1,this.branchNode=o,this.lineCollectionAtBranch=n);let c;function f(_){return _.isLeaf()?new NB(""):new O6}switch(s){case 0:this.goSubtree=!1,this.state!==4&&o.add(n);break;case 1:this.state===4?this.goSubtree=!1:(c=f(n),o.add(c),this.startPath.push(c));break;case 2:this.state!==4?(c=f(n),o.add(c),this.startPath.push(c)):n.isLeaf()||(c=f(n),o.add(c),this.endBranch.push(c));break;case 3:this.goSubtree=!1;break;case 4:this.state!==4?this.goSubtree=!1:n.isLeaf()||(c=f(n),o.add(c),this.endBranch.push(c));break;case 5:this.goSubtree=!1,this.state!==1&&o.add(n);break}this.goSubtree&&this.stack.push(c)}leaf(e,t,n){this.state===1?this.initialText=n.text.substring(0,e):this.state===2?(this.initialText=n.text.substring(0,e),this.trailingText=n.text.substring(e+t)):this.trailingText=n.text.substring(e+t)}},Q1t=class{constructor(e,t,n){this.pos=e,this.deleteLen=t,this.insertedText=n}getTextChangeRange(){return Q3(hu(this.pos,this.deleteLen),this.insertedText?this.insertedText.length:0)}},DX=class nD{constructor(){this.changes=[],this.versions=new Array(nD.maxVersions),this.minVersion=0,this.currentVersion=0}versionToIndex(t){if(!(t<this.minVersion||t>this.currentVersion))return t%nD.maxVersions}currentVersionToIndex(){return this.currentVersion%nD.maxVersions}edit(t,n,i){this.changes.push(new Q1t(t,n,i)),(this.changes.length>nD.changeNumberThreshold||n>nD.changeLengthThreshold||i&&i.length>nD.changeLengthThreshold)&&this.getSnapshot()}getSnapshot(){return this._getSnapshot()}_getSnapshot(){let t=this.versions[this.currentVersionToIndex()];if(this.changes.length>0){let n=t.index;for(let i of this.changes)n=n.edit(i.pos,i.deleteLen,i.insertedText);t=new iLe(this.currentVersion+1,this,n,this.changes),this.currentVersion=t.version,this.versions[this.currentVersionToIndex()]=t,this.changes=[],this.currentVersion-this.minVersion>=nD.maxVersions&&(this.minVersion=this.currentVersion-nD.maxVersions+1)}return t}getSnapshotVersion(){return this._getSnapshot().version}getAbsolutePositionAndLineText(t){return this._getSnapshot().index.lineNumberToInfo(t)}lineOffsetToPosition(t,n){return this._getSnapshot().index.absolutePositionOfStartOfLine(t)+(n-1)}positionToLineOffset(t){return this._getSnapshot().index.positionToLineOffset(t)}lineToTextSpan(t){let n=this._getSnapshot().index,{lineText:i,absolutePosition:s}=n.lineNumberToInfo(t+1),o=i!==void 0?i.length:n.absolutePositionOfStartOfLine(t+2)-s;return hu(s,o)}getTextChangesBetweenVersions(t,n){if(t<n)if(t>=this.minVersion){let i=[];for(let s=t+1;s<=n;s++){let o=this.versions[this.versionToIndex(s)];for(let c of o.changesSincePreviousVersion)i.push(c.getTextChangeRange())}return Die(i)}else return;else return qO}getLineCount(){return this._getSnapshot().index.getLineCount()}static fromString(t){let n=new nD,i=new iLe(0,n,new OF);n.versions[n.currentVersion]=i;let s=OF.linesFromText(t);return i.index.load(s.lines),n}};DX.changeNumberThreshold=8,DX.changeLengthThreshold=256,DX.maxVersions=8;var CX=DX,iLe=class xKe{constructor(t,n,i,s=Ul){this.version=t,this.cache=n,this.index=i,this.changesSincePreviousVersion=s}getText(t,n){return this.index.getText(t,n-t)}getLength(){return this.index.getLength()}getChangeRange(t){if(t instanceof xKe&&this.cache===t.cache)return this.version<=t.version?qO:this.cache.getTextChangesBetweenVersions(t.version,this.version)}},OF=class Mxe{constructor(){this.checkEdits=!1}absolutePositionOfStartOfLine(t){return this.lineNumberToInfo(t).absolutePosition}positionToLineOffset(t){let{oneBasedLine:n,zeroBasedColumn:i}=this.root.charOffsetToLineInfo(1,t);return{line:n,offset:i+1}}positionToColumnAndLineText(t){return this.root.charOffsetToLineInfo(1,t)}getLineCount(){return this.root.lineCount()}lineNumberToInfo(t){let n=this.getLineCount();if(t<=n){let{position:i,leaf:s}=this.root.lineNumberToInfo(t,0);return{absolutePosition:i,lineText:s&&s.text}}else return{absolutePosition:this.root.charCount(),lineText:void 0}}load(t){if(t.length>0){let n=[];for(let i=0;i<t.length;i++)n[i]=new NB(t[i]);this.root=Mxe.buildTreeFromBottom(n)}else this.root=new O6}walk(t,n,i){this.root.walk(t,n,i)}getText(t,n){let i="";return n>0&&t<this.root.charCount()&&this.walk(t,n,{goSubtree:!0,done:!1,leaf:(s,o,c)=>{i=i.concat(c.text.substring(s,s+o))}}),i}getLength(){return this.root.charCount()}every(t,n,i){i||(i=this.root.charCount());let s={goSubtree:!0,done:!1,leaf(o,c,f){t(f,o,c)||(this.done=!0)}};return this.walk(n,i-n,s),!s.done}edit(t,n,i){if(this.root.charCount()===0)return P.assert(n===0),i!==void 0?(this.load(Mxe.linesFromText(i).lines),this):void 0;{let s;if(this.checkEdits){let f=this.getText(0,this.root.charCount());s=f.slice(0,t)+i+f.slice(t+n)}let o=new Y1t,c=!1;if(t>=this.root.charCount()){t=this.root.charCount()-1;let f=this.getText(t,1);i?i=f+i:i=f,n=0,c=!0}else if(n>0){let f=t+n,{zeroBasedColumn:_,lineText:g}=this.positionToColumnAndLineText(f);_===0&&(n+=g.length,i=i?i+g:g)}if(this.root.walk(t,n,o),o.insertLines(i,c),this.checkEdits){let f=o.lineIndex.getText(0,o.lineIndex.getLength());P.assert(s===f,"buffer edit mismatch")}return o.lineIndex}}static buildTreeFromBottom(t){if(t.length<F6)return new O6(t);let n=new Array(Math.ceil(t.length/F6)),i=0;for(let s=0;s<n.length;s++){let o=Math.min(i+F6,t.length);n[s]=new O6(t.slice(i,o)),i=o}return this.buildTreeFromBottom(n)}static linesFromText(t){let n=fD(t);if(n.length===0)return{lines:[],lineMap:n};let i=new Array(n.length),s=n.length-1;for(let c=0;c<s;c++)i[c]=t.substring(n[c],n[c+1]);let o=t.substring(n[s]);return o.length>0?i[s]=o:i.pop(),{lines:i,lineMap:n}}},O6=class Rxe{constructor(t=[]){this.children=t,this.totalChars=0,this.totalLines=0,t.length&&this.updateCounts()}isLeaf(){return!1}updateCounts(){this.totalChars=0,this.totalLines=0;for(let t of this.children)this.totalChars+=t.charCount(),this.totalLines+=t.lineCount()}execWalk(t,n,i,s,o){return i.pre&&i.pre(t,n,this.children[s],this,o),i.goSubtree?(this.children[s].walk(t,n,i),i.post&&i.post(t,n,this.children[s],this,o)):i.goSubtree=!0,i.done}skipChild(t,n,i,s,o){s.pre&&!s.done&&(s.pre(t,n,this.children[i],this,o),s.goSubtree=!0)}walk(t,n,i){let s=0,o=this.children[s].charCount(),c=t;for(;c>=o;)this.skipChild(c,n,s,i,0),c-=o,s++,o=this.children[s].charCount();if(c+n<=o){if(this.execWalk(c,n,i,s,2))return}else{if(this.execWalk(c,o-c,i,s,1))return;let f=n-(o-c);for(s++,o=this.children[s].charCount();f>o;){if(this.execWalk(0,o,i,s,3))return;f-=o,s++,o=this.children[s].charCount()}if(f>0&&this.execWalk(0,f,i,s,4))return}if(i.pre){let f=this.children.length;if(s<f-1)for(let _=s+1;_<f;_++)this.skipChild(0,0,_,i,5)}}charOffsetToLineInfo(t,n){if(this.children.length===0)return{oneBasedLine:t,zeroBasedColumn:n,lineText:void 0};for(let o of this.children){if(o.charCount()>n)return o.isLeaf()?{oneBasedLine:t,zeroBasedColumn:n,lineText:o.text}:o.charOffsetToLineInfo(t,n);n-=o.charCount(),t+=o.lineCount()}let i=this.lineCount();if(i===0)return{oneBasedLine:1,zeroBasedColumn:0,lineText:void 0};let s=P.checkDefined(this.lineNumberToInfo(i,0).leaf);return{oneBasedLine:i,zeroBasedColumn:s.charCount(),lineText:void 0}}lineNumberToInfo(t,n){for(let i of this.children){let s=i.lineCount();if(s>=t)return i.isLeaf()?{position:n,leaf:i}:i.lineNumberToInfo(t,n);t-=s,n+=i.charCount()}return{position:n,leaf:void 0}}splitAfter(t){let n,i=this.children.length;t++;let s=t;if(t<i){for(n=new Rxe;t<i;)n.add(this.children[t]),t++;n.updateCounts()}return this.children.length=s,n}remove(t){let n=this.findChildIndex(t),i=this.children.length;if(n<i-1)for(let s=n;s<i-1;s++)this.children[s]=this.children[s+1];this.children.pop()}findChildIndex(t){let n=this.children.indexOf(t);return P.assert(n!==-1),n}insertAt(t,n){let i=this.findChildIndex(t),s=this.children.length,o=n.length;if(s<F6&&i===s-1&&o===1)return this.add(n[0]),this.updateCounts(),[];{let c=this.splitAfter(i),f=0;for(i++;i<F6&&f<o;)this.children[i]=n[f],i++,f++;let _=[],g=0;if(f<o){g=Math.ceil((o-f)/F6),_=new Array(g);let y=0;for(let D=0;D<g;D++)_[D]=new Rxe;let b=_[0];for(;f<o;)b.add(n[f]),f++,b.children.length===F6&&(y++,b=_[y]);for(let D=_.length-1;D>=0;D--)_[D].children.length===0&&_.pop()}c&&_.push(c),this.updateCounts();for(let y=0;y<g;y++)_[y].updateCounts();return _}}add(t){this.children.push(t),P.assert(this.children.length<=F6)}charCount(){return this.totalChars}lineCount(){return this.totalLines}},NB=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}},sLe=class DKe{constructor(t,n,i,s,o,c){this.telemetryEnabled=t,this.logger=n,this.host=i,this.globalTypingsCacheLocation=s,this.event=o,this.maxActiveRequestCount=c,this.activeRequestCount=0,this.requestQueue=I3(),this.requestMap=new Map,this.requestedRegistry=!1,this.packageInstallId=0}isKnownTypesPackageName(t){var n;return yg.validatePackageName(t)!==yg.NameValidationResult.Ok?!1:(this.requestedRegistry||(this.requestedRegistry=!0,this.installer.send({kind:"typesRegistry"})),!!((n=this.typesRegistryCache)!=null&&n.has(t)))}installPackage(t){this.packageInstallId++;let n={kind:"installPackage",...t,id:this.packageInstallId},i=new Promise((s,o)=>{(this.packageInstalledPromise??(this.packageInstalledPromise=new Map)).set(this.packageInstallId,{resolve:s,reject:o})});return this.installer.send(n),i}attach(t){this.projectService=t,this.installer=this.createInstallerProcess()}onProjectClosed(t){this.installer.send({projectName:t.getProjectName(),kind:"closeProject"})}enqueueInstallTypingsRequest(t,n,i){let s=Whe(t,n,i);this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling throttled operation:${Tb(s)}`),this.activeRequestCount<this.maxActiveRequestCount?this.scheduleRequest(s):(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Deferring request for: ${s.projectName}`),this.requestQueue.enqueue(s),this.requestMap.set(s.projectName,s))}handleMessage(t){var n,i;switch(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Received response:${Tb(t)}`),t.kind){case QG:this.typesRegistryCache=new Map(Object.entries(t.typesRegistry));break;case GM:{let s=(n=this.packageInstalledPromise)==null?void 0:n.get(t.id);P.assertIsDefined(s,"Should find the promise for package install"),(i=this.packageInstalledPromise)==null||i.delete(t.id),t.success?s.resolve({successMessage:t.message}):s.reject(t.message),this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case X_e:{let s={message:t.message};this.event(s,"typesInstallerInitializationFailed");break}case XG:{let s={eventId:t.eventId,packages:t.packagesToInstall};this.event(s,"beginInstallTypes");break}case KG:{if(this.telemetryEnabled){let c={telemetryEventName:"typingsInstalled",payload:{installedPackages:t.packagesToInstall.join(","),installSuccess:t.installSuccess,typingsInstallerVersion:t.typingsInstallerVersion}};this.event(c,"telemetry")}let s={eventId:t.eventId,packages:t.packagesToInstall,success:t.installSuccess};this.event(s,"endInstallTypes");break}case $M:{this.projectService.updateTypingsForProject(t);break}case qM:{for(this.activeRequestCount>0?this.activeRequestCount--:P.fail("TIAdapter:: Received too many responses");!this.requestQueue.isEmpty();){let s=this.requestQueue.dequeue();if(this.requestMap.get(s.projectName)===s){this.requestMap.delete(s.projectName),this.scheduleRequest(s);break}this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Skipping defunct request for: ${s.projectName}`)}this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case C8: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:${Tb(t)}`),this.installer.send(t)},DKe.requestDelayMillis,`${t.projectName}::${t.kind}`)}};sLe.requestDelayMillis=100;var aLe=sLe,oLe={};j(oLe,{ActionInvalidate:()=>$M,ActionPackageInstalled:()=>GM,ActionSet:()=>qM,ActionWatchTypingLocations:()=>C8,Arguments:()=>ZG,AutoImportProviderProject:()=>o0e,AuxiliaryProject:()=>s0e,CharRangeSection:()=>N0e,CloseFileWatcherEvent:()=>dX,CommandNames:()=>Y9e,ConfigFileDiagEvent:()=>lX,ConfiguredProject:()=>c0e,ConfiguredProjectLoadKind:()=>d0e,CreateDirectoryWatcherEvent:()=>pX,CreateFileWatcherEvent:()=>fX,Errors:()=>M0,EventBeginInstallTypes:()=>XG,EventEndInstallTypes:()=>KG,EventInitializationFailed:()=>X_e,EventTypesRegistry:()=>QG,ExternalProject:()=>nX,GcTimer:()=>Yhe,InferredProject:()=>i0e,LargeFileReferencedEvent:()=>cX,LineIndex:()=>OF,LineLeaf:()=>NB,LineNode:()=>O6,LogLevel:()=>Jhe,Msg:()=>zhe,OpenFileInfoTelemetryEvent:()=>l0e,Project:()=>BC,ProjectInfoTelemetryEvent:()=>_X,ProjectKind:()=>wF,ProjectLanguageServiceStateEvent:()=>uX,ProjectLoadingFinishEvent:()=>oX,ProjectLoadingStartEvent:()=>aX,ProjectService:()=>S0e,ProjectsUpdatedInBackgroundEvent:()=>wB,ScriptInfo:()=>Zhe,ScriptVersionCache:()=>CX,Session:()=>eLe,TextStorage:()=>Khe,ThrottledOperations:()=>Hhe,TypingsInstallerAdapter:()=>aLe,allFilesAreJsOrDts:()=>t0e,allRootFilesAreJsOrDts:()=>e0e,asNormalizedPath:()=>T9e,convertCompilerOptions:()=>AB,convertFormatOptions:()=>N6,convertScriptKindName:()=>gX,convertTypeAcquisition:()=>_0e,convertUserPreferences:()=>f0e,convertWatchOptions:()=>IF,countEachFileTypes:()=>AF,createInstallTypingsRequest:()=>Whe,createModuleSpecifierCache:()=>D0e,createNormalizedPathMap:()=>x9e,createPackageJsonCache:()=>C0e,createSortedArray:()=>Ghe,emptyArray:()=>Ul,findArgument:()=>SAe,formatDiagnosticToProtocol:()=>FF,formatMessage:()=>k0e,getBaseConfigFileName:()=>rX,getLocationInNewDocument:()=>P0e,hasArgument:()=>bAe,hasNoTypeScriptSource:()=>r0e,indent:()=>XP,isBackgroundProject:()=>NF,isConfigFile:()=>T0e,isConfiguredProject:()=>Oy,isDynamicFileName:()=>EF,isExternalProject:()=>PF,isInferredProject:()=>P6,isInferredProjectName:()=>Uhe,isProjectDeferredClose:()=>EB,makeAutoImportProviderProjectName:()=>qhe,makeAuxiliaryProjectName:()=>$he,makeInferredProjectName:()=>Vhe,maxFileSize:()=>sX,maxProgramSizeForNonTsFiles:()=>iX,normalizedPathToPath:()=>A6,nowString:()=>TAe,nullCancellationToken:()=>$9e,nullTypingsInstaller:()=>PB,protocol:()=>Qhe,stringifyIndented:()=>Tb,toEvent:()=>E0e,toNormalizedPath:()=>lc,tryConvertScriptKindName:()=>mX,typingsInstaller:()=>jhe,updateProjectIfDirty:()=>Zp}),typeof console<"u"&&(P.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 hKe},set exports(u){hKe=u,typeof bre<"u"&&bre.exports&&(bre.exports=u)}})});var AMt={};FAt(AMt,{default:()=>Sre});module.exports=OAt(AMt);var NKe=go(require("node:fs")),Tre=go(require("node:readline")),Wxe=require("node:child_process"),TO=require("@oclif/core");var aWe=require("fs"),MZ=require("fs/promises"),oWe=require("events"),Ol=go(require("path"),1);var Dk=require("fs/promises"),$ze=require("stream"),Ck=require("path");function LAt(){return{root:".",fileFilter:u=>!0,directoryFilter:u=>!0,type:hbe,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096}}var Gze="READDIRP_RECURSIVE_ERROR",MAt=new Set(["ENOENT","EPERM","EACCES","ELOOP",Gze]),hbe="files",Hze="directories",wZ="files_directories",AZ="all",Uze=[hbe,Hze,wZ,AZ],RAt=new Set([Hze,wZ,AZ]),BAt=new Set([hbe,wZ,AZ]),jAt=u=>MAt.has(u.code),JAt=process.platform==="win32",Vze=u=>!0,qze=u=>{if(u===void 0)return Vze;if(typeof u=="function")return u;if(typeof u=="string"){let d=u.trim();return v=>v.basename===d}if(Array.isArray(u)){let d=u.map(v=>v.trim());return v=>d.some(C=>v.basename===C)}return Vze},gbe=class extends $ze.Readable{constructor(d={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:d.highWaterMark});let v={...LAt(),...d},{root:C,type:I}=v;this._fileFilter=qze(v.fileFilter),this._directoryFilter=qze(v.directoryFilter);let j=v.lstat?Dk.lstat:Dk.stat;JAt?this._stat=te=>j(te,{bigint:!0}):this._stat=j,this._maxDepth=v.depth,this._wantsDir=RAt.has(I),this._wantsFile=BAt.has(I),this._wantsEverything=I===AZ,this._root=(0,Ck.resolve)(C),this._isDirent=!v.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(C,1)],this.reading=!1,this.parent=void 0}async _read(d){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&d>0;){let v=this.parent,C=v&&v.files;if(C&&C.length>0){let{path:I,depth:j}=v,te=C.splice(0,d).map(je=>this._formatEntry(je,I)),be=await Promise.all(te);for(let je of be){if(!je){d--;return}if(this.destroyed)return;let ct=await this._getEntryType(je);ct==="directory"&&this._directoryFilter(je)?(j<=this._maxDepth&&this.parents.push(this._exploreDir(je.fullPath,j+1)),this._wantsDir&&(this.push(je),d--)):(ct==="file"||this._includeAsFile(je))&&this._fileFilter(je)&&this._wantsFile&&(this.push(je),d--)}}else{let I=this.parents.pop();if(!I){this.push(null);break}if(this.parent=await I,this.destroyed)return}}}catch(v){this.destroy(v)}finally{this.reading=!1}}}async _exploreDir(d,v){let C;try{C=await(0,Dk.readdir)(d,this._rdOptions)}catch(I){this._onError(I)}return{files:C,depth:v,path:d}}async _formatEntry(d,v){let C,I=this._isDirent?d.name:d;try{let j=(0,Ck.resolve)((0,Ck.join)(v,I));C={path:(0,Ck.relative)(this._root,j),fullPath:j,basename:I},C[this._statsProp]=this._isDirent?d:await this._stat(j)}catch(j){this._onError(j);return}return C}_onError(d){jAt(d)&&!this.destroyed?this.emit("warn",d):this.destroy(d)}async _getEntryType(d){if(!d&&this._statsProp in d)return"";let v=d[this._statsProp];if(v.isFile())return"file";if(v.isDirectory())return"directory";if(v&&v.isSymbolicLink()){let C=d.fullPath;try{let I=await(0,Dk.realpath)(C),j=await(0,Dk.lstat)(I);if(j.isFile())return"file";if(j.isDirectory()){let te=I.length;if(C.startsWith(I)&&C.substr(te,1)===Ck.sep){let be=new Error(`Circular symlink detected: "${C}" points to "${I}"`);return be.code=Gze,this._onError(be)}return"directory"}}catch(I){return this._onError(I),""}}}_includeAsFile(d){let v=d&&d[this._statsProp];return v&&this._wantsEverything&&!v.isDirectory()}},Yze=(u,d={})=>{let v=d.entryType||d.type;if(v==="both"&&(v=wZ),v&&(d.type=v),u){if(typeof u!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(v&&!Uze.includes(v))throw new Error(`readdirp: Invalid type passed. Use one of ${Uze.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return d.root=u,new gbe(d)};var c3=require("fs"),GS=require("fs/promises"),ap=go(require("path"),1),Xze=require("os"),zAt="data",bbe="end",Kze="close",OZ=()=>{};var Sbe=process.platform,Tbe=Sbe==="win32",WAt=Sbe==="darwin",UAt=Sbe==="linux",Zze=(0,Xze.type)()==="OS400",Fp={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},$S=Fp,VAt="watch",qAt={lstat:GS.lstat,stat:GS.stat},o3="listeners",PZ="errHandlers",B7="rawEmitters",$At=[o3,PZ,B7],GAt=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),HAt=u=>GAt.has(ap.extname(u).slice(1).toLowerCase()),vbe=(u,d)=>{u instanceof Set?u.forEach(d):d(u)},_J=(u,d,v)=>{let C=u[d];C instanceof Set||(u[d]=C=new Set([C])),C.add(v)},YAt=u=>d=>{let v=u[d];v instanceof Set?v.clear():delete u[d]},fJ=(u,d,v)=>{let C=u[d];C instanceof Set?C.delete(v):C===v&&delete u[d]},eWe=u=>u instanceof Set?u.size===0:!u,NZ=new Map;function Qze(u,d,v,C,I){let j=(te,be)=>{v(u),I(te,be,{watchedPath:u}),be&&u!==be&&IZ(ap.resolve(u,be),o3,ap.join(u,be))};try{return(0,c3.watch)(u,{persistent:d.persistent},j)}catch(te){C(te);return}}var IZ=(u,d,v,C,I)=>{let j=NZ.get(u);j&&vbe(j[d],te=>{te(v,C,I)})},QAt=(u,d,v,C)=>{let{listener:I,errHandler:j,rawEmitter:te}=C,be=NZ.get(d),je;if(!v.persistent)return je=Qze(u,v,I,j,te),je?je.close.bind(je):void 0;if(be)_J(be,o3,I),_J(be,PZ,j),_J(be,B7,te);else{if(je=Qze(u,v,IZ.bind(null,d,o3),j,IZ.bind(null,d,B7)),!je)return;je.on($S.ERROR,async ct=>{let kt=IZ.bind(null,d,PZ);if(be&&(be.watcherUnusable=!0),Tbe&&ct.code==="EPERM")try{await(await(0,GS.open)(u,"r")).close(),kt(ct)}catch{}else kt(ct)}),be={listeners:I,errHandlers:j,rawEmitters:te,watcher:je},NZ.set(d,be)}return()=>{fJ(be,o3,I),fJ(be,PZ,j),fJ(be,B7,te),eWe(be.listeners)&&(be.watcher.close(),NZ.delete(d),$At.forEach(YAt(be)),be.watcher=void 0,Object.freeze(be))}},ybe=new Map,XAt=(u,d,v,C)=>{let{listener:I,rawEmitter:j}=C,te=ybe.get(d),be=te&&te.options;return be&&(be.persistent<v.persistent||be.interval>v.interval)&&((0,c3.unwatchFile)(d),te=void 0),te?(_J(te,o3,I),_J(te,B7,j)):(te={listeners:I,rawEmitters:j,options:v,watcher:(0,c3.watchFile)(d,v,(je,ct)=>{vbe(te.rawEmitters,Bt=>{Bt($S.CHANGE,d,{curr:je,prev:ct})});let kt=je.mtimeMs;(je.size!==ct.size||kt>ct.mtimeMs||kt===0)&&vbe(te.listeners,Bt=>Bt(u,je))})},ybe.set(d,te)),()=>{fJ(te,o3,I),fJ(te,B7,j),eWe(te.listeners)&&(ybe.delete(d),(0,c3.unwatchFile)(d),te.options=te.watcher=void 0,Object.freeze(te))}},FZ=class{constructor(d){this.fsw=d,this._boundHandleError=v=>d._handleError(v)}_watchWithNodeFs(d,v){let C=this.fsw.options,I=ap.dirname(d),j=ap.basename(d);this.fsw._getWatchedDir(I).add(j);let be=ap.resolve(d),je={persistent:C.persistent};v||(v=OZ);let ct;if(C.usePolling){let kt=C.interval!==C.binaryInterval;je.interval=kt&&HAt(j)?C.binaryInterval:C.interval,ct=XAt(d,be,je,{listener:v,rawEmitter:this.fsw._emitRaw})}else ct=QAt(d,be,je,{listener:v,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return ct}_handleFile(d,v,C){if(this.fsw.closed)return;let I=ap.dirname(d),j=ap.basename(d),te=this.fsw._getWatchedDir(I),be=v;if(te.has(j))return;let je=async(kt,Bt)=>{if(this.fsw._throttle(VAt,d,5)){if(!Bt||Bt.mtimeMs===0)try{let he=await(0,GS.stat)(d);if(this.fsw.closed)return;let qr=he.atimeMs,Et=he.mtimeMs;if((!qr||qr<=Et||Et!==be.mtimeMs)&&this.fsw._emit($S.CHANGE,d,he),(WAt||UAt)&&be.ino!==he.ino){this.fsw._closeFile(kt),be=he;let Ke=this._watchWithNodeFs(d,je);Ke&&this.fsw._addPathCloser(kt,Ke)}else be=he}catch{this.fsw._remove(I,j)}else if(te.has(j)){let he=Bt.atimeMs,qr=Bt.mtimeMs;(!he||he<=qr||qr!==be.mtimeMs)&&this.fsw._emit($S.CHANGE,d,Bt),be=Bt}}},ct=this._watchWithNodeFs(d,je);if(!(C&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(d)){if(!this.fsw._throttle($S.ADD,d,0))return;this.fsw._emit($S.ADD,d,v)}return ct}async _handleSymlink(d,v,C,I){if(this.fsw.closed)return;let j=d.fullPath,te=this.fsw._getWatchedDir(v);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let be;try{be=await(0,GS.realpath)(C)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(te.has(I)?this.fsw._symlinkPaths.get(j)!==be&&(this.fsw._symlinkPaths.set(j,be),this.fsw._emit($S.CHANGE,C,d.stats)):(te.add(I),this.fsw._symlinkPaths.set(j,be),this.fsw._emit($S.ADD,C,d.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(j))return!0;this.fsw._symlinkPaths.set(j,!0)}_handleRead(d,v,C,I,j,te,be){if(d=ap.join(d,""),be=this.fsw._throttle("readdir",d,1e3),!be)return;let je=this.fsw._getWatchedDir(C.path),ct=new Set,kt=this.fsw._readdirp(d,{fileFilter:Bt=>C.filterPath(Bt),directoryFilter:Bt=>C.filterDir(Bt)});if(kt)return kt.on(zAt,async Bt=>{if(this.fsw.closed){kt=void 0;return}let he=Bt.path,qr=ap.join(d,he);if(ct.add(he),!(Bt.stats.isSymbolicLink()&&await this._handleSymlink(Bt,d,qr,he))){if(this.fsw.closed){kt=void 0;return}(he===I||!I&&!je.has(he))&&(this.fsw._incrReadyCount(),qr=ap.join(j,ap.relative(j,qr)),this._addToNodeFs(qr,v,C,te+1))}}).on($S.ERROR,this._boundHandleError),new Promise((Bt,he)=>{if(!kt)return he();kt.once(bbe,()=>{if(this.fsw.closed){kt=void 0;return}let qr=be?be.clear():!1;Bt(void 0),je.getChildren().filter(Et=>Et!==d&&!ct.has(Et)).forEach(Et=>{this.fsw._remove(d,Et)}),kt=void 0,qr&&this._handleRead(d,!1,C,I,j,te,be)})})}async _handleDir(d,v,C,I,j,te,be){let je=this.fsw._getWatchedDir(ap.dirname(d)),ct=je.has(ap.basename(d));!(C&&this.fsw.options.ignoreInitial)&&!j&&!ct&&this.fsw._emit($S.ADD_DIR,d,v),je.add(ap.basename(d)),this.fsw._getWatchedDir(d);let kt,Bt,he=this.fsw.options.depth;if((he==null||I<=he)&&!this.fsw._symlinkPaths.has(be)){if(!j&&(await this._handleRead(d,C,te,j,d,I,kt),this.fsw.closed))return;Bt=this._watchWithNodeFs(d,(qr,Et)=>{Et&&Et.mtimeMs===0||this._handleRead(qr,!1,te,j,d,I,kt)})}return Bt}async _addToNodeFs(d,v,C,I,j){let te=this.fsw._emitReady;if(this.fsw._isIgnored(d)||this.fsw.closed)return te(),!1;let be=this.fsw._getWatchHelpers(d);C&&(be.filterPath=je=>C.filterPath(je),be.filterDir=je=>C.filterDir(je));try{let je=await qAt[be.statMethod](be.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(be.watchPath,je))return te(),!1;let ct=this.fsw.options.followSymlinks,kt;if(je.isDirectory()){let Bt=ap.resolve(d),he=ct?await(0,GS.realpath)(d):d;if(this.fsw.closed||(kt=await this._handleDir(be.watchPath,je,v,I,j,be,he),this.fsw.closed))return;Bt!==he&&he!==void 0&&this.fsw._symlinkPaths.set(Bt,he)}else if(je.isSymbolicLink()){let Bt=ct?await(0,GS.realpath)(d):d;if(this.fsw.closed)return;let he=ap.dirname(be.watchPath);if(this.fsw._getWatchedDir(he).add(be.watchPath),this.fsw._emit($S.ADD,be.watchPath,je),kt=await this._handleDir(he,je,v,I,d,be,Bt),this.fsw.closed)return;Bt!==void 0&&this.fsw._symlinkPaths.set(ap.resolve(d),Bt)}else kt=this._handleFile(be.watchPath,je,v);return te(),kt&&this.fsw._addPathCloser(d,kt),!1}catch(je){if(this.fsw._handleError(je))return te(),d}}};var xbe="/",KAt="//",cWe=".",ZAt="..",ePt="string",tPt=/\\/g,tWe=/\/\//,rPt=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,nPt=/^\.[/\\]/;function LZ(u){return Array.isArray(u)?u:[u]}var Dbe=u=>typeof u=="object"&&u!==null&&!(u instanceof RegExp);function iPt(u){return typeof u=="function"?u:typeof u=="string"?d=>u===d:u instanceof RegExp?d=>u.test(d):typeof u=="object"&&u!==null?d=>{if(u.path===d)return!0;if(u.recursive){let v=Ol.relative(u.path,d);return v?!v.startsWith("..")&&!Ol.isAbsolute(v):!1}return!1}:()=>!1}function sPt(u){if(typeof u!="string")throw new Error("string expected");u=Ol.normalize(u),u=u.replace(/\\/g,"/");let d=!1;u.startsWith("//")&&(d=!0);let v=/\/\//;for(;u.match(v);)u=u.replace(v,"/");return d&&(u="/"+u),u}function rWe(u,d,v){let C=sPt(d);for(let I=0;I<u.length;I++){let j=u[I];if(j(C,v))return!0}return!1}function aPt(u,d){if(u==null)throw new TypeError("anymatch: specify first argument");let C=LZ(u).map(I=>iPt(I));return d==null?(I,j)=>rWe(C,I,j):rWe(C,d)}var nWe=u=>{let d=LZ(u).flat();if(!d.every(v=>typeof v===ePt))throw new TypeError(`Non-string provided as watch path: ${d}`);return d.map(lWe)},iWe=u=>{let d=u.replace(tPt,xbe),v=!1;for(d.startsWith(KAt)&&(v=!0);d.match(tWe);)d=d.replace(tWe,xbe);return v&&(d=xbe+d),d},lWe=u=>iWe(Ol.normalize(iWe(u))),sWe=(u="")=>d=>typeof d=="string"?lWe(Ol.isAbsolute(d)?d:Ol.join(u,d)):d,oPt=(u,d)=>Ol.isAbsolute(u)?u:Ol.join(d,u),cPt=Object.freeze(new Set),Cbe=class{constructor(d,v){this.path=d,this._removeWatcher=v,this.items=new Set}add(d){let{items:v}=this;v&&d!==cWe&&d!==ZAt&&v.add(d)}async remove(d){let{items:v}=this;if(!v||(v.delete(d),v.size>0))return;let C=this.path;try{await(0,MZ.readdir)(C)}catch{this._removeWatcher&&this._removeWatcher(Ol.dirname(C),Ol.basename(C))}}has(d){let{items:v}=this;if(v)return v.has(d)}getChildren(){let{items:d}=this;return d?[...d.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=OZ,this.items=cPt,Object.freeze(this)}},lPt="stat",uPt="lstat",kbe=class{constructor(d,v,C){this.fsw=C;let I=d;this.path=d=d.replace(nPt,""),this.watchPath=I,this.fullWatchPath=Ol.resolve(I),this.dirParts=[],this.dirParts.forEach(j=>{j.length>1&&j.pop()}),this.followSymlinks=v,this.statMethod=v?lPt:uPt}entryPath(d){return Ol.join(this.watchPath,Ol.relative(this.watchPath,d.fullPath))}filterPath(d){let{stats:v}=d;if(v&&v.isSymbolicLink())return this.filterDir(d);let C=this.entryPath(d);return this.fsw._isntIgnored(C,v)&&this.fsw._hasReadPermissions(v)}filterDir(d){return this.fsw._isntIgnored(this.entryPath(d),d.stats)}},Ebe=class extends oWe.EventEmitter{constructor(d={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let v=d.awaitWriteFinish,C={stabilityThreshold:2e3,pollInterval:100},I={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...d,ignored:d.ignored?LZ(d.ignored):LZ([]),awaitWriteFinish:v===!0?C:typeof v=="object"?{...C,...v}:!1};Zze&&(I.usePolling=!0),I.atomic===void 0&&(I.atomic=!I.usePolling);let j=process.env.CHOKIDAR_USEPOLLING;if(j!==void 0){let je=j.toLowerCase();je==="false"||je==="0"?I.usePolling=!1:je==="true"||je==="1"?I.usePolling=!0:I.usePolling=!!je}let te=process.env.CHOKIDAR_INTERVAL;te&&(I.interval=Number.parseInt(te,10));let be=0;this._emitReady=()=>{be++,be>=this._readyCount&&(this._emitReady=OZ,this._readyEmitted=!0,process.nextTick(()=>this.emit(Fp.READY)))},this._emitRaw=(...je)=>this.emit(Fp.RAW,...je),this._boundRemove=this._remove.bind(this),this.options=I,this._nodeFsHandler=new FZ(this),Object.freeze(I)}_addIgnoredPath(d){if(Dbe(d)){for(let v of this._ignoredPaths)if(Dbe(v)&&v.path===d.path&&v.recursive===d.recursive)return}this._ignoredPaths.add(d)}_removeIgnoredPath(d){if(this._ignoredPaths.delete(d),typeof d=="string")for(let v of this._ignoredPaths)Dbe(v)&&v.path===d&&this._ignoredPaths.delete(v)}add(d,v,C){let{cwd:I}=this.options;this.closed=!1,this._closePromise=void 0;let j=nWe(d);return I&&(j=j.map(te=>oPt(te,I))),j.forEach(te=>{this._removeIgnoredPath(te)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=j.length,Promise.all(j.map(async te=>{let be=await this._nodeFsHandler._addToNodeFs(te,!C,void 0,0,v);return be&&this._emitReady(),be})).then(te=>{this.closed||te.forEach(be=>{be&&this.add(Ol.dirname(be),Ol.basename(v||be))})}),this}unwatch(d){if(this.closed)return this;let v=nWe(d),{cwd:C}=this.options;return v.forEach(I=>{!Ol.isAbsolute(I)&&!this._closers.has(I)&&(C&&(I=Ol.join(C,I)),I=Ol.resolve(I)),this._closePath(I),this._addIgnoredPath(I),this._watched.has(I)&&this._addIgnoredPath({path:I,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let d=[];return this._closers.forEach(v=>v.forEach(C=>{let I=C();I instanceof Promise&&d.push(I)})),this._streams.forEach(v=>v.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(v=>v.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=d.length?Promise.all(d).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let d={};return this._watched.forEach((v,C)=>{let j=(this.options.cwd?Ol.relative(this.options.cwd,C):C)||cWe;d[j]=v.getChildren().sort()}),d}emitWithAll(d,v){this.emit(...v),d!==Fp.ERROR&&this.emit(Fp.ALL,...v)}async _emit(d,v,C){if(this.closed)return;let I=this.options;Tbe&&(v=Ol.normalize(v)),I.cwd&&(v=Ol.relative(I.cwd,v));let j=[d,v];C!=null&&j.push(C);let te=I.awaitWriteFinish,be;if(te&&(be=this._pendingWrites.get(v)))return be.lastChange=new Date,this;if(I.atomic){if(d===Fp.UNLINK)return this._pendingUnlinks.set(v,j),setTimeout(()=>{this._pendingUnlinks.forEach((je,ct)=>{this.emit(...je),this.emit(Fp.ALL,...je),this._pendingUnlinks.delete(ct)})},typeof I.atomic=="number"?I.atomic:100),this;d===Fp.ADD&&this._pendingUnlinks.has(v)&&(d=j[0]=Fp.CHANGE,this._pendingUnlinks.delete(v))}if(te&&(d===Fp.ADD||d===Fp.CHANGE)&&this._readyEmitted){let je=(ct,kt)=>{ct?(d=j[0]=Fp.ERROR,j[1]=ct,this.emitWithAll(d,j)):kt&&(j.length>2?j[2]=kt:j.push(kt),this.emitWithAll(d,j))};return this._awaitWriteFinish(v,te.stabilityThreshold,d,je),this}if(d===Fp.CHANGE&&!this._throttle(Fp.CHANGE,v,50))return this;if(I.alwaysStat&&C===void 0&&(d===Fp.ADD||d===Fp.ADD_DIR||d===Fp.CHANGE)){let je=I.cwd?Ol.join(I.cwd,v):v,ct;try{ct=await(0,MZ.stat)(je)}catch{}if(!ct||this.closed)return;j.push(ct)}return this.emitWithAll(d,j),this}_handleError(d){let v=d&&d.code;return d&&v!=="ENOENT"&&v!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||v!=="EPERM"&&v!=="EACCES")&&this.emit(Fp.ERROR,d),d||this.closed}_throttle(d,v,C){this._throttled.has(d)||this._throttled.set(d,new Map);let I=this._throttled.get(d);if(!I)throw new Error("invalid throttle");let j=I.get(v);if(j)return j.count++,!1;let te,be=()=>{let ct=I.get(v),kt=ct?ct.count:0;return I.delete(v),clearTimeout(te),ct&&clearTimeout(ct.timeoutObject),kt};te=setTimeout(be,C);let je={timeoutObject:te,clear:be,count:0};return I.set(v,je),je}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(d,v,C,I){let j=this.options.awaitWriteFinish;if(typeof j!="object")return;let te=j.pollInterval,be,je=d;this.options.cwd&&!Ol.isAbsolute(d)&&(je=Ol.join(this.options.cwd,d));let ct=new Date,kt=this._pendingWrites;function Bt(he){(0,aWe.stat)(je,(qr,Et)=>{if(qr||!kt.has(d)){qr&&qr.code!=="ENOENT"&&I(qr);return}let Ke=Number(new Date);he&&Et.size!==he.size&&(kt.get(d).lastChange=Ke);let Ln=kt.get(d);Ke-Ln.lastChange>=v?(kt.delete(d),I(void 0,Et)):be=setTimeout(Bt,te,Et)})}kt.has(d)||(kt.set(d,{lastChange:ct,cancelWait:()=>(kt.delete(d),clearTimeout(be),C)}),be=setTimeout(Bt,te))}_isIgnored(d,v){if(this.options.atomic&&rPt.test(d))return!0;if(!this._userIgnored){let{cwd:C}=this.options,j=(this.options.ignored||[]).map(sWe(C)),be=[...[...this._ignoredPaths].map(sWe(C)),...j];this._userIgnored=aPt(be,void 0)}return this._userIgnored(d,v)}_isntIgnored(d,v){return!this._isIgnored(d,v)}_getWatchHelpers(d){return new kbe(d,this.options.followSymlinks,this)}_getWatchedDir(d){let v=Ol.resolve(d);return this._watched.has(v)||this._watched.set(v,new Cbe(v,this._boundRemove)),this._watched.get(v)}_hasReadPermissions(d){return this.options.ignorePermissionErrors?!0:!!(Number(d.mode)&256)}_remove(d,v,C){let I=Ol.join(d,v),j=Ol.resolve(I);if(C=C??(this._watched.has(I)||this._watched.has(j)),!this._throttle("remove",I,100))return;!C&&this._watched.size===1&&this.add(d,v,!0),this._getWatchedDir(I).getChildren().forEach(he=>this._remove(I,he));let je=this._getWatchedDir(d),ct=je.has(v);je.remove(v),this._symlinkPaths.has(j)&&this._symlinkPaths.delete(j);let kt=I;if(this.options.cwd&&(kt=Ol.relative(this.options.cwd,I)),this.options.awaitWriteFinish&&this._pendingWrites.has(kt)&&this._pendingWrites.get(kt).cancelWait()===Fp.ADD)return;this._watched.delete(I),this._watched.delete(j);let Bt=C?Fp.UNLINK_DIR:Fp.UNLINK;ct&&!this._isIgnored(I)&&this._emit(Bt,I),this._closePath(I)}_closePath(d){this._closeFile(d);let v=Ol.dirname(d);this._getWatchedDir(v).remove(Ol.basename(d))}_closeFile(d){let v=this._closers.get(d);v&&(v.forEach(C=>C()),this._closers.delete(d))}_addPathCloser(d,v){if(!v)return;let C=this._closers.get(d);C||(C=[],this._closers.set(d,C)),C.push(v)}_readdirp(d,v){if(this.closed)return;let C={type:Fp.ALL,alwaysStat:!0,lstat:!0,...v,depth:0},I=Yze(d,C);return this._streams.add(I),I.once(Kze,()=>{I=void 0}),I.once(bbe,()=>{I&&(this._streams.delete(I),I=void 0)}),I}};function uWe(u,d={}){let v=new Ebe(d);return v.add(u),v}var _1=go(RZ());var pJ=go(require("node:fs")),BZ=go(require("node:path")),mWe=go(require("node:os"));var fWe=go(require("node:path")),pWe=go(require("node:fs"));function yw(){let u;try{u=fWe.resolve("package.json")}catch(v){throw new Error(`cannot resolve package manifest path: ${v}`)}let d;try{d=JSON.parse(pWe.readFileSync(u,"utf8"))}catch(v){throw new Error(`cannot read package manifest: ${v}`)}return d.name=d.name.replace(/^@workaround/g,""),d}var dWe={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"],dPt="e69bae0ec90f5e838555",kk={},jZ;function Gx(){let u=yw();if(!u.name)throw new Error("extension name in manifest cannot be empty");return BZ.join(vWe(),"extensions",u.name)}function gWe(){let u=JZ(jZ);return u?.startsWith("x")?u==="x"?"com.raycast-x.macos":`com.raycast-x.macos.${u.replace("x-","")}`:u?`com.raycast.macos.${u}`:"com.raycast.macos"}function hWe(){return`raycast${JZ(jZ)}`}function yWe(u){jZ=u;try{kk=JSON.parse(pJ.readFileSync(BZ.join(vWe(),"config.json"),"utf8"))}catch(d){if(d instanceof Error&&d.code==="ENOENT")return;throw new Error(`Failed to read config file: ${d}`)}}function mPt(u){switch(u){case"raycastApiURL":return process.env.RAY_APIURL||kk.APIURL||dWe.url;case"raycastAccessToken":return process.env.RAY_TOKEN||kk.Token||kk.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||kk.ClientID||dWe.clientID;case"githubClientId":return process.env.RAY_GithubClientID||kk.GithubClientID||dPt;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||kk.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof kk.Target>"u"?JZ("release"):kk.Target)}}function JZ(u){switch(u){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 mPt("flavorName")}}function gPt(){let u=JZ(jZ);return u==""?"raycast":`raycast-${u}`}function vWe(){let u=BZ.join(mWe.default.homedir(),".config",gPt());return pJ.mkdirSync(u,{recursive:!0}),u}var vw=require("@oclif/core");var Vf=go(RZ());var TJ=go(require("node:process"),1);var bWe=(u=0)=>d=>`\x1B[${d+u}m`,SWe=(u=0)=>d=>`\x1B[${38+u};5;${d}m`,TWe=(u=0)=>(d,v,C)=>`\x1B[${38+u};2;${d};${v};${C}m`,op={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]}},JMt=Object.keys(op.modifier),hPt=Object.keys(op.color),yPt=Object.keys(op.bgColor),zMt=[...hPt,...yPt];function vPt(){let u=new Map;for(let[d,v]of Object.entries(op)){for(let[C,I]of Object.entries(v))op[C]={open:`\x1B[${I[0]}m`,close:`\x1B[${I[1]}m`},v[C]=op[C],u.set(I[0],I[1]);Object.defineProperty(op,d,{value:v,enumerable:!1})}return Object.defineProperty(op,"codes",{value:u,enumerable:!1}),op.color.close="\x1B[39m",op.bgColor.close="\x1B[49m",op.color.ansi=bWe(),op.color.ansi256=SWe(),op.color.ansi16m=TWe(),op.bgColor.ansi=bWe(10),op.bgColor.ansi256=SWe(10),op.bgColor.ansi16m=TWe(10),Object.defineProperties(op,{rgbToAnsi256:{value(d,v,C){return d===v&&v===C?d<8?16:d>248?231:Math.round((d-8)/247*24)+232:16+36*Math.round(d/255*5)+6*Math.round(v/255*5)+Math.round(C/255*5)},enumerable:!1},hexToRgb:{value(d){let v=/[a-f\d]{6}|[a-f\d]{3}/i.exec(d.toString(16));if(!v)return[0,0,0];let[C]=v;C.length===3&&(C=[...C].map(j=>j+j).join(""));let I=Number.parseInt(C,16);return[I>>16&255,I>>8&255,I&255]},enumerable:!1},hexToAnsi256:{value:d=>op.rgbToAnsi256(...op.hexToRgb(d)),enumerable:!1},ansi256ToAnsi:{value(d){if(d<8)return 30+d;if(d<16)return 90+(d-8);let v,C,I;if(d>=232)v=((d-232)*10+8)/255,C=v,I=v;else{d-=16;let be=d%36;v=Math.floor(d/36)/5,C=Math.floor(be/6)/5,I=be%6/5}let j=Math.max(v,C,I)*2;if(j===0)return 30;let te=30+(Math.round(I)<<2|Math.round(C)<<1|Math.round(v));return j===2&&(te+=60),te},enumerable:!1},rgbToAnsi:{value:(d,v,C)=>op.ansi256ToAnsi(op.rgbToAnsi256(d,v,C)),enumerable:!1},hexToAnsi:{value:d=>op.ansi256ToAnsi(op.hexToAnsi256(d)),enumerable:!1}}),op}var bPt=vPt(),HS=bPt;var WZ=go(require("node:process"),1),DWe=go(require("node:os"),1),wbe=go(require("node:tty"),1);function o2(u,d=globalThis.Deno?globalThis.Deno.args:WZ.default.argv){let v=u.startsWith("-")?"":u.length===1?"-":"--",C=d.indexOf(v+u),I=d.indexOf("--");return C!==-1&&(I===-1||C<I)}var{env:Op}=WZ.default,zZ;o2("no-color")||o2("no-colors")||o2("color=false")||o2("color=never")?zZ=0:(o2("color")||o2("colors")||o2("color=true")||o2("color=always"))&&(zZ=1);function SPt(){if("FORCE_COLOR"in Op)return Op.FORCE_COLOR==="true"?1:Op.FORCE_COLOR==="false"?0:Op.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Op.FORCE_COLOR,10),3)}function TPt(u){return u===0?!1:{level:u,hasBasic:!0,has256:u>=2,has16m:u>=3}}function xPt(u,{streamIsTTY:d,sniffFlags:v=!0}={}){let C=SPt();C!==void 0&&(zZ=C);let I=v?zZ:C;if(I===0)return 0;if(v){if(o2("color=16m")||o2("color=full")||o2("color=truecolor"))return 3;if(o2("color=256"))return 2}if("TF_BUILD"in Op&&"AGENT_NAME"in Op)return 1;if(u&&!d&&I===void 0)return 0;let j=I||0;if(Op.TERM==="dumb")return j;if(WZ.default.platform==="win32"){let te=DWe.default.release().split(".");return Number(te[0])>=10&&Number(te[2])>=10586?Number(te[2])>=14931?3:2:1}if("CI"in Op)return"GITHUB_ACTIONS"in Op||"GITEA_ACTIONS"in Op?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(te=>te in Op)||Op.CI_NAME==="codeship"?1:j;if("TEAMCITY_VERSION"in Op)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Op.TEAMCITY_VERSION)?1:0;if(Op.COLORTERM==="truecolor"||Op.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in Op){let te=Number.parseInt((Op.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Op.TERM_PROGRAM){case"iTerm.app":return te>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Op.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Op.TERM)||"COLORTERM"in Op?1:j}function xWe(u,d={}){let v=xPt(u,{streamIsTTY:u&&u.isTTY,...d});return TPt(v)}var DPt={stdout:xWe({isTTY:wbe.default.isatty(1)}),stderr:xWe({isTTY:wbe.default.isatty(2)})},CWe=DPt;function kWe(u,d,v){let C=u.indexOf(d);if(C===-1)return u;let I=d.length,j=0,te="";do te+=u.slice(j,C)+d+v,j=C+I,C=u.indexOf(d,j);while(C!==-1);return te+=u.slice(j),te}function EWe(u,d,v,C){let I=0,j="";do{let te=u[C-1]==="\r";j+=u.slice(I,te?C-1:C)+d+(te?`\r
566
+ `+k.stack)}finally{this.performanceData=y}}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 tLe(e){let t=e.diagnosticsDuration&&Cs(e.diagnosticsDuration,([n,i])=>({...i,file:n}));return{...e,diagnosticsDuration:t}}function Sg(e,t){return{start:t.positionToLineOffset(e.start),end:t.positionToLineOffset(Sc(e))}}function A0e(e,t,n){let i=Sg(e,n),s=t&&Sg(t,n);return s?{...i,contextStart:s.start,contextEnd:s.end}:i}function W1t(e,t){return{start:rLe(t,e.span.start),end:rLe(t,Sc(e.span)),newText:e.newText}}function rLe(e,t){return T0e(e)?V1t(e.getLineAndCharacterOfPosition(t)):e.positionToLineOffset(t)}function U1t(e,t){let n=e.ranges.map(i=>({start:t.positionToLineOffset(i.start),end:t.positionToLineOffset(i.start+i.length)}));return e.wordPattern?{ranges:n,wordPattern:e.wordPattern}:{ranges:n}}function V1t(e){return{line:e.line+1,offset:e.character+1}}function q1t(e){P.assert(e.textChanges.length===1);let t=Va(e.textChanges);return P.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 P0e(e,t,n,i){let s=$1t(e,t,i),{line:o,character:c}=Hk(fD(s),n);return{line:o+1,offset:c+1}}function $1t(e,t,n){for(let{fileName:i,textChanges:s}of n)if(i===t)for(let o=s.length-1;o>=0;o--){let{newText:c,span:{start:f,length:_}}=s[o];e=e.slice(0,f)+c+e.slice(f+_)}return e}function nLe(e,{fileName:t,textSpan:n,contextSpan:i,isWriteAccess:s,isDefinition:o},{disableLineTextInReferences:c}){let f=P.checkDefined(e.getScriptInfo(t)),_=A0e(n,i,f),g=c?void 0:G1t(f,_);return{file:t,..._,lineText:g,isWriteAccess:s,isDefinition:o}}function G1t(e,t){let n=e.lineToTextSpan(t.start.line-1);return e.getSnapshot().getText(n.start,Sc(n)).replace(/\r|\n/g,"")}function H1t(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 F6=4,N0e=(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))(N0e||{}),Y1t=class{constructor(){this.goSubtree=!0,this.lineIndex=new OF,this.endBranch=[],this.state=2,this.initialText="",this.trailingText="",this.lineIndex.root=new O6,this.startPath=[this.lineIndex.root],this.stack=[this.lineIndex.root]}get done(){return!1}insertLines(e,t){t&&(this.trailingText=""),e?e=this.initialText+e+this.trailingText:e=this.initialText+this.trailingText;let i=OF.linesFromText(e).lines;i.length>1&&i[i.length-1]===""&&i.pop();let s,o;for(let f=this.endBranch.length-1;f>=0;f--)this.endBranch[f].updateCounts(),this.endBranch[f].charCount()===0&&(o=this.endBranch[f],f>0?s=this.endBranch[f-1]:s=this.branchNode);o&&s.remove(o);let c=this.startPath[this.startPath.length-1];if(i.length>0)if(c.text=i[0],i.length>1){let f=new Array(i.length-1),_=c;for(let b=1;b<i.length;b++)f[b-1]=new NB(i[b]);let g=this.startPath.length-2;for(;g>=0;){let b=this.startPath[g];f=b.insertAt(_,f),g--,_=b}let y=f.length;for(;y>0;){let b=new O6;b.add(this.lineIndex.root),f=b.insertAt(this.lineIndex.root,f),y=f.length,this.lineIndex.root=b}this.lineIndex.root.updateCounts()}else for(let f=this.startPath.length-2;f>=0;f--)this.startPath[f].updateCounts();else{this.startPath[this.startPath.length-2].remove(c);for(let _=this.startPath.length-2;_>=0;_--)this.startPath[_].updateCounts()}return this.lineIndex}post(e,t,n){n===this.lineCollectionAtBranch&&(this.state=4),this.stack.pop()}pre(e,t,n,i,s){let o=this.stack[this.stack.length-1];this.state===2&&s===1&&(this.state=1,this.branchNode=o,this.lineCollectionAtBranch=n);let c;function f(_){return _.isLeaf()?new NB(""):new O6}switch(s){case 0:this.goSubtree=!1,this.state!==4&&o.add(n);break;case 1:this.state===4?this.goSubtree=!1:(c=f(n),o.add(c),this.startPath.push(c));break;case 2:this.state!==4?(c=f(n),o.add(c),this.startPath.push(c)):n.isLeaf()||(c=f(n),o.add(c),this.endBranch.push(c));break;case 3:this.goSubtree=!1;break;case 4:this.state!==4?this.goSubtree=!1:n.isLeaf()||(c=f(n),o.add(c),this.endBranch.push(c));break;case 5:this.goSubtree=!1,this.state!==1&&o.add(n);break}this.goSubtree&&this.stack.push(c)}leaf(e,t,n){this.state===1?this.initialText=n.text.substring(0,e):this.state===2?(this.initialText=n.text.substring(0,e),this.trailingText=n.text.substring(e+t)):this.trailingText=n.text.substring(e+t)}},Q1t=class{constructor(e,t,n){this.pos=e,this.deleteLen=t,this.insertedText=n}getTextChangeRange(){return Q3(hu(this.pos,this.deleteLen),this.insertedText?this.insertedText.length:0)}},DX=class nD{constructor(){this.changes=[],this.versions=new Array(nD.maxVersions),this.minVersion=0,this.currentVersion=0}versionToIndex(t){if(!(t<this.minVersion||t>this.currentVersion))return t%nD.maxVersions}currentVersionToIndex(){return this.currentVersion%nD.maxVersions}edit(t,n,i){this.changes.push(new Q1t(t,n,i)),(this.changes.length>nD.changeNumberThreshold||n>nD.changeLengthThreshold||i&&i.length>nD.changeLengthThreshold)&&this.getSnapshot()}getSnapshot(){return this._getSnapshot()}_getSnapshot(){let t=this.versions[this.currentVersionToIndex()];if(this.changes.length>0){let n=t.index;for(let i of this.changes)n=n.edit(i.pos,i.deleteLen,i.insertedText);t=new iLe(this.currentVersion+1,this,n,this.changes),this.currentVersion=t.version,this.versions[this.currentVersionToIndex()]=t,this.changes=[],this.currentVersion-this.minVersion>=nD.maxVersions&&(this.minVersion=this.currentVersion-nD.maxVersions+1)}return t}getSnapshotVersion(){return this._getSnapshot().version}getAbsolutePositionAndLineText(t){return this._getSnapshot().index.lineNumberToInfo(t)}lineOffsetToPosition(t,n){return this._getSnapshot().index.absolutePositionOfStartOfLine(t)+(n-1)}positionToLineOffset(t){return this._getSnapshot().index.positionToLineOffset(t)}lineToTextSpan(t){let n=this._getSnapshot().index,{lineText:i,absolutePosition:s}=n.lineNumberToInfo(t+1),o=i!==void 0?i.length:n.absolutePositionOfStartOfLine(t+2)-s;return hu(s,o)}getTextChangesBetweenVersions(t,n){if(t<n)if(t>=this.minVersion){let i=[];for(let s=t+1;s<=n;s++){let o=this.versions[this.versionToIndex(s)];for(let c of o.changesSincePreviousVersion)i.push(c.getTextChangeRange())}return Die(i)}else return;else return qO}getLineCount(){return this._getSnapshot().index.getLineCount()}static fromString(t){let n=new nD,i=new iLe(0,n,new OF);n.versions[n.currentVersion]=i;let s=OF.linesFromText(t);return i.index.load(s.lines),n}};DX.changeNumberThreshold=8,DX.changeLengthThreshold=256,DX.maxVersions=8;var CX=DX,iLe=class xKe{constructor(t,n,i,s=Ul){this.version=t,this.cache=n,this.index=i,this.changesSincePreviousVersion=s}getText(t,n){return this.index.getText(t,n-t)}getLength(){return this.index.getLength()}getChangeRange(t){if(t instanceof xKe&&this.cache===t.cache)return this.version<=t.version?qO:this.cache.getTextChangesBetweenVersions(t.version,this.version)}},OF=class Mxe{constructor(){this.checkEdits=!1}absolutePositionOfStartOfLine(t){return this.lineNumberToInfo(t).absolutePosition}positionToLineOffset(t){let{oneBasedLine:n,zeroBasedColumn:i}=this.root.charOffsetToLineInfo(1,t);return{line:n,offset:i+1}}positionToColumnAndLineText(t){return this.root.charOffsetToLineInfo(1,t)}getLineCount(){return this.root.lineCount()}lineNumberToInfo(t){let n=this.getLineCount();if(t<=n){let{position:i,leaf:s}=this.root.lineNumberToInfo(t,0);return{absolutePosition:i,lineText:s&&s.text}}else return{absolutePosition:this.root.charCount(),lineText:void 0}}load(t){if(t.length>0){let n=[];for(let i=0;i<t.length;i++)n[i]=new NB(t[i]);this.root=Mxe.buildTreeFromBottom(n)}else this.root=new O6}walk(t,n,i){this.root.walk(t,n,i)}getText(t,n){let i="";return n>0&&t<this.root.charCount()&&this.walk(t,n,{goSubtree:!0,done:!1,leaf:(s,o,c)=>{i=i.concat(c.text.substring(s,s+o))}}),i}getLength(){return this.root.charCount()}every(t,n,i){i||(i=this.root.charCount());let s={goSubtree:!0,done:!1,leaf(o,c,f){t(f,o,c)||(this.done=!0)}};return this.walk(n,i-n,s),!s.done}edit(t,n,i){if(this.root.charCount()===0)return P.assert(n===0),i!==void 0?(this.load(Mxe.linesFromText(i).lines),this):void 0;{let s;if(this.checkEdits){let f=this.getText(0,this.root.charCount());s=f.slice(0,t)+i+f.slice(t+n)}let o=new Y1t,c=!1;if(t>=this.root.charCount()){t=this.root.charCount()-1;let f=this.getText(t,1);i?i=f+i:i=f,n=0,c=!0}else if(n>0){let f=t+n,{zeroBasedColumn:_,lineText:g}=this.positionToColumnAndLineText(f);_===0&&(n+=g.length,i=i?i+g:g)}if(this.root.walk(t,n,o),o.insertLines(i,c),this.checkEdits){let f=o.lineIndex.getText(0,o.lineIndex.getLength());P.assert(s===f,"buffer edit mismatch")}return o.lineIndex}}static buildTreeFromBottom(t){if(t.length<F6)return new O6(t);let n=new Array(Math.ceil(t.length/F6)),i=0;for(let s=0;s<n.length;s++){let o=Math.min(i+F6,t.length);n[s]=new O6(t.slice(i,o)),i=o}return this.buildTreeFromBottom(n)}static linesFromText(t){let n=fD(t);if(n.length===0)return{lines:[],lineMap:n};let i=new Array(n.length),s=n.length-1;for(let c=0;c<s;c++)i[c]=t.substring(n[c],n[c+1]);let o=t.substring(n[s]);return o.length>0?i[s]=o:i.pop(),{lines:i,lineMap:n}}},O6=class Rxe{constructor(t=[]){this.children=t,this.totalChars=0,this.totalLines=0,t.length&&this.updateCounts()}isLeaf(){return!1}updateCounts(){this.totalChars=0,this.totalLines=0;for(let t of this.children)this.totalChars+=t.charCount(),this.totalLines+=t.lineCount()}execWalk(t,n,i,s,o){return i.pre&&i.pre(t,n,this.children[s],this,o),i.goSubtree?(this.children[s].walk(t,n,i),i.post&&i.post(t,n,this.children[s],this,o)):i.goSubtree=!0,i.done}skipChild(t,n,i,s,o){s.pre&&!s.done&&(s.pre(t,n,this.children[i],this,o),s.goSubtree=!0)}walk(t,n,i){let s=0,o=this.children[s].charCount(),c=t;for(;c>=o;)this.skipChild(c,n,s,i,0),c-=o,s++,o=this.children[s].charCount();if(c+n<=o){if(this.execWalk(c,n,i,s,2))return}else{if(this.execWalk(c,o-c,i,s,1))return;let f=n-(o-c);for(s++,o=this.children[s].charCount();f>o;){if(this.execWalk(0,o,i,s,3))return;f-=o,s++,o=this.children[s].charCount()}if(f>0&&this.execWalk(0,f,i,s,4))return}if(i.pre){let f=this.children.length;if(s<f-1)for(let _=s+1;_<f;_++)this.skipChild(0,0,_,i,5)}}charOffsetToLineInfo(t,n){if(this.children.length===0)return{oneBasedLine:t,zeroBasedColumn:n,lineText:void 0};for(let o of this.children){if(o.charCount()>n)return o.isLeaf()?{oneBasedLine:t,zeroBasedColumn:n,lineText:o.text}:o.charOffsetToLineInfo(t,n);n-=o.charCount(),t+=o.lineCount()}let i=this.lineCount();if(i===0)return{oneBasedLine:1,zeroBasedColumn:0,lineText:void 0};let s=P.checkDefined(this.lineNumberToInfo(i,0).leaf);return{oneBasedLine:i,zeroBasedColumn:s.charCount(),lineText:void 0}}lineNumberToInfo(t,n){for(let i of this.children){let s=i.lineCount();if(s>=t)return i.isLeaf()?{position:n,leaf:i}:i.lineNumberToInfo(t,n);t-=s,n+=i.charCount()}return{position:n,leaf:void 0}}splitAfter(t){let n,i=this.children.length;t++;let s=t;if(t<i){for(n=new Rxe;t<i;)n.add(this.children[t]),t++;n.updateCounts()}return this.children.length=s,n}remove(t){let n=this.findChildIndex(t),i=this.children.length;if(n<i-1)for(let s=n;s<i-1;s++)this.children[s]=this.children[s+1];this.children.pop()}findChildIndex(t){let n=this.children.indexOf(t);return P.assert(n!==-1),n}insertAt(t,n){let i=this.findChildIndex(t),s=this.children.length,o=n.length;if(s<F6&&i===s-1&&o===1)return this.add(n[0]),this.updateCounts(),[];{let c=this.splitAfter(i),f=0;for(i++;i<F6&&f<o;)this.children[i]=n[f],i++,f++;let _=[],g=0;if(f<o){g=Math.ceil((o-f)/F6),_=new Array(g);let y=0;for(let D=0;D<g;D++)_[D]=new Rxe;let b=_[0];for(;f<o;)b.add(n[f]),f++,b.children.length===F6&&(y++,b=_[y]);for(let D=_.length-1;D>=0;D--)_[D].children.length===0&&_.pop()}c&&_.push(c),this.updateCounts();for(let y=0;y<g;y++)_[y].updateCounts();return _}}add(t){this.children.push(t),P.assert(this.children.length<=F6)}charCount(){return this.totalChars}lineCount(){return this.totalLines}},NB=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}},sLe=class DKe{constructor(t,n,i,s,o,c){this.telemetryEnabled=t,this.logger=n,this.host=i,this.globalTypingsCacheLocation=s,this.event=o,this.maxActiveRequestCount=c,this.activeRequestCount=0,this.requestQueue=I3(),this.requestMap=new Map,this.requestedRegistry=!1,this.packageInstallId=0}isKnownTypesPackageName(t){var n;return yg.validatePackageName(t)!==yg.NameValidationResult.Ok?!1:(this.requestedRegistry||(this.requestedRegistry=!0,this.installer.send({kind:"typesRegistry"})),!!((n=this.typesRegistryCache)!=null&&n.has(t)))}installPackage(t){this.packageInstallId++;let n={kind:"installPackage",...t,id:this.packageInstallId},i=new Promise((s,o)=>{(this.packageInstalledPromise??(this.packageInstalledPromise=new Map)).set(this.packageInstallId,{resolve:s,reject:o})});return this.installer.send(n),i}attach(t){this.projectService=t,this.installer=this.createInstallerProcess()}onProjectClosed(t){this.installer.send({projectName:t.getProjectName(),kind:"closeProject"})}enqueueInstallTypingsRequest(t,n,i){let s=Whe(t,n,i);this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling throttled operation:${Tb(s)}`),this.activeRequestCount<this.maxActiveRequestCount?this.scheduleRequest(s):(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Deferring request for: ${s.projectName}`),this.requestQueue.enqueue(s),this.requestMap.set(s.projectName,s))}handleMessage(t){var n,i;switch(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Received response:${Tb(t)}`),t.kind){case QG:this.typesRegistryCache=new Map(Object.entries(t.typesRegistry));break;case GM:{let s=(n=this.packageInstalledPromise)==null?void 0:n.get(t.id);P.assertIsDefined(s,"Should find the promise for package install"),(i=this.packageInstalledPromise)==null||i.delete(t.id),t.success?s.resolve({successMessage:t.message}):s.reject(t.message),this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case X_e:{let s={message:t.message};this.event(s,"typesInstallerInitializationFailed");break}case XG:{let s={eventId:t.eventId,packages:t.packagesToInstall};this.event(s,"beginInstallTypes");break}case KG:{if(this.telemetryEnabled){let c={telemetryEventName:"typingsInstalled",payload:{installedPackages:t.packagesToInstall.join(","),installSuccess:t.installSuccess,typingsInstallerVersion:t.typingsInstallerVersion}};this.event(c,"telemetry")}let s={eventId:t.eventId,packages:t.packagesToInstall,success:t.installSuccess};this.event(s,"endInstallTypes");break}case $M:{this.projectService.updateTypingsForProject(t);break}case qM:{for(this.activeRequestCount>0?this.activeRequestCount--:P.fail("TIAdapter:: Received too many responses");!this.requestQueue.isEmpty();){let s=this.requestQueue.dequeue();if(this.requestMap.get(s.projectName)===s){this.requestMap.delete(s.projectName),this.scheduleRequest(s);break}this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Skipping defunct request for: ${s.projectName}`)}this.projectService.updateTypingsForProject(t),this.event(t,"setTypings");break}case C8: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:${Tb(t)}`),this.installer.send(t)},DKe.requestDelayMillis,`${t.projectName}::${t.kind}`)}};sLe.requestDelayMillis=100;var aLe=sLe,oLe={};j(oLe,{ActionInvalidate:()=>$M,ActionPackageInstalled:()=>GM,ActionSet:()=>qM,ActionWatchTypingLocations:()=>C8,Arguments:()=>ZG,AutoImportProviderProject:()=>o0e,AuxiliaryProject:()=>s0e,CharRangeSection:()=>N0e,CloseFileWatcherEvent:()=>dX,CommandNames:()=>Y9e,ConfigFileDiagEvent:()=>lX,ConfiguredProject:()=>c0e,ConfiguredProjectLoadKind:()=>d0e,CreateDirectoryWatcherEvent:()=>pX,CreateFileWatcherEvent:()=>fX,Errors:()=>M0,EventBeginInstallTypes:()=>XG,EventEndInstallTypes:()=>KG,EventInitializationFailed:()=>X_e,EventTypesRegistry:()=>QG,ExternalProject:()=>nX,GcTimer:()=>Yhe,InferredProject:()=>i0e,LargeFileReferencedEvent:()=>cX,LineIndex:()=>OF,LineLeaf:()=>NB,LineNode:()=>O6,LogLevel:()=>Jhe,Msg:()=>zhe,OpenFileInfoTelemetryEvent:()=>l0e,Project:()=>BC,ProjectInfoTelemetryEvent:()=>_X,ProjectKind:()=>wF,ProjectLanguageServiceStateEvent:()=>uX,ProjectLoadingFinishEvent:()=>oX,ProjectLoadingStartEvent:()=>aX,ProjectService:()=>S0e,ProjectsUpdatedInBackgroundEvent:()=>wB,ScriptInfo:()=>Zhe,ScriptVersionCache:()=>CX,Session:()=>eLe,TextStorage:()=>Khe,ThrottledOperations:()=>Hhe,TypingsInstallerAdapter:()=>aLe,allFilesAreJsOrDts:()=>t0e,allRootFilesAreJsOrDts:()=>e0e,asNormalizedPath:()=>T9e,convertCompilerOptions:()=>AB,convertFormatOptions:()=>N6,convertScriptKindName:()=>gX,convertTypeAcquisition:()=>_0e,convertUserPreferences:()=>f0e,convertWatchOptions:()=>IF,countEachFileTypes:()=>AF,createInstallTypingsRequest:()=>Whe,createModuleSpecifierCache:()=>D0e,createNormalizedPathMap:()=>x9e,createPackageJsonCache:()=>C0e,createSortedArray:()=>Ghe,emptyArray:()=>Ul,findArgument:()=>SAe,formatDiagnosticToProtocol:()=>FF,formatMessage:()=>k0e,getBaseConfigFileName:()=>rX,getLocationInNewDocument:()=>P0e,hasArgument:()=>bAe,hasNoTypeScriptSource:()=>r0e,indent:()=>XP,isBackgroundProject:()=>NF,isConfigFile:()=>T0e,isConfiguredProject:()=>Oy,isDynamicFileName:()=>EF,isExternalProject:()=>PF,isInferredProject:()=>P6,isInferredProjectName:()=>Uhe,isProjectDeferredClose:()=>EB,makeAutoImportProviderProjectName:()=>qhe,makeAuxiliaryProjectName:()=>$he,makeInferredProjectName:()=>Vhe,maxFileSize:()=>sX,maxProgramSizeForNonTsFiles:()=>iX,normalizedPathToPath:()=>A6,nowString:()=>TAe,nullCancellationToken:()=>$9e,nullTypingsInstaller:()=>PB,protocol:()=>Qhe,stringifyIndented:()=>Tb,toEvent:()=>E0e,toNormalizedPath:()=>lc,tryConvertScriptKindName:()=>mX,typingsInstaller:()=>jhe,updateProjectIfDirty:()=>Zp}),typeof console<"u"&&(P.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 hKe},set exports(u){hKe=u,typeof bre<"u"&&bre.exports&&(bre.exports=u)}})});var AMt={};FAt(AMt,{default:()=>Sre});module.exports=OAt(AMt);var NKe=go(require("node:fs")),Tre=go(require("node:readline")),Wxe=require("node:child_process"),TO=require("@oclif/core");var aWe=require("fs"),MZ=require("fs/promises"),oWe=require("events"),Ol=go(require("path"),1);var Dk=require("fs/promises"),$ze=require("stream"),Ck=require("path");function LAt(){return{root:".",fileFilter:u=>!0,directoryFilter:u=>!0,type:hbe,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096}}var Gze="READDIRP_RECURSIVE_ERROR",MAt=new Set(["ENOENT","EPERM","EACCES","ELOOP",Gze]),hbe="files",Hze="directories",wZ="files_directories",AZ="all",Uze=[hbe,Hze,wZ,AZ],RAt=new Set([Hze,wZ,AZ]),BAt=new Set([hbe,wZ,AZ]),jAt=u=>MAt.has(u.code),JAt=process.platform==="win32",Vze=u=>!0,qze=u=>{if(u===void 0)return Vze;if(typeof u=="function")return u;if(typeof u=="string"){let d=u.trim();return v=>v.basename===d}if(Array.isArray(u)){let d=u.map(v=>v.trim());return v=>d.some(C=>v.basename===C)}return Vze},gbe=class extends $ze.Readable{constructor(d={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:d.highWaterMark});let v={...LAt(),...d},{root:C,type:I}=v;this._fileFilter=qze(v.fileFilter),this._directoryFilter=qze(v.directoryFilter);let j=v.lstat?Dk.lstat:Dk.stat;JAt?this._stat=te=>j(te,{bigint:!0}):this._stat=j,this._maxDepth=v.depth,this._wantsDir=RAt.has(I),this._wantsFile=BAt.has(I),this._wantsEverything=I===AZ,this._root=(0,Ck.resolve)(C),this._isDirent=!v.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(C,1)],this.reading=!1,this.parent=void 0}async _read(d){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&d>0;){let v=this.parent,C=v&&v.files;if(C&&C.length>0){let{path:I,depth:j}=v,te=C.splice(0,d).map(je=>this._formatEntry(je,I)),be=await Promise.all(te);for(let je of be){if(!je){d--;return}if(this.destroyed)return;let ct=await this._getEntryType(je);ct==="directory"&&this._directoryFilter(je)?(j<=this._maxDepth&&this.parents.push(this._exploreDir(je.fullPath,j+1)),this._wantsDir&&(this.push(je),d--)):(ct==="file"||this._includeAsFile(je))&&this._fileFilter(je)&&this._wantsFile&&(this.push(je),d--)}}else{let I=this.parents.pop();if(!I){this.push(null);break}if(this.parent=await I,this.destroyed)return}}}catch(v){this.destroy(v)}finally{this.reading=!1}}}async _exploreDir(d,v){let C;try{C=await(0,Dk.readdir)(d,this._rdOptions)}catch(I){this._onError(I)}return{files:C,depth:v,path:d}}async _formatEntry(d,v){let C,I=this._isDirent?d.name:d;try{let j=(0,Ck.resolve)((0,Ck.join)(v,I));C={path:(0,Ck.relative)(this._root,j),fullPath:j,basename:I},C[this._statsProp]=this._isDirent?d:await this._stat(j)}catch(j){this._onError(j);return}return C}_onError(d){jAt(d)&&!this.destroyed?this.emit("warn",d):this.destroy(d)}async _getEntryType(d){if(!d&&this._statsProp in d)return"";let v=d[this._statsProp];if(v.isFile())return"file";if(v.isDirectory())return"directory";if(v&&v.isSymbolicLink()){let C=d.fullPath;try{let I=await(0,Dk.realpath)(C),j=await(0,Dk.lstat)(I);if(j.isFile())return"file";if(j.isDirectory()){let te=I.length;if(C.startsWith(I)&&C.substr(te,1)===Ck.sep){let be=new Error(`Circular symlink detected: "${C}" points to "${I}"`);return be.code=Gze,this._onError(be)}return"directory"}}catch(I){return this._onError(I),""}}}_includeAsFile(d){let v=d&&d[this._statsProp];return v&&this._wantsEverything&&!v.isDirectory()}},Yze=(u,d={})=>{let v=d.entryType||d.type;if(v==="both"&&(v=wZ),v&&(d.type=v),u){if(typeof u!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(v&&!Uze.includes(v))throw new Error(`readdirp: Invalid type passed. Use one of ${Uze.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return d.root=u,new gbe(d)};var c3=require("fs"),GS=require("fs/promises"),ap=go(require("path"),1),Xze=require("os"),zAt="data",bbe="end",Kze="close",OZ=()=>{};var Sbe=process.platform,Tbe=Sbe==="win32",WAt=Sbe==="darwin",UAt=Sbe==="linux",Zze=(0,Xze.type)()==="OS400",Fp={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},$S=Fp,VAt="watch",qAt={lstat:GS.lstat,stat:GS.stat},o3="listeners",PZ="errHandlers",B7="rawEmitters",$At=[o3,PZ,B7],GAt=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),HAt=u=>GAt.has(ap.extname(u).slice(1).toLowerCase()),vbe=(u,d)=>{u instanceof Set?u.forEach(d):d(u)},_J=(u,d,v)=>{let C=u[d];C instanceof Set||(u[d]=C=new Set([C])),C.add(v)},YAt=u=>d=>{let v=u[d];v instanceof Set?v.clear():delete u[d]},fJ=(u,d,v)=>{let C=u[d];C instanceof Set?C.delete(v):C===v&&delete u[d]},eWe=u=>u instanceof Set?u.size===0:!u,NZ=new Map;function Qze(u,d,v,C,I){let j=(te,be)=>{v(u),I(te,be,{watchedPath:u}),be&&u!==be&&IZ(ap.resolve(u,be),o3,ap.join(u,be))};try{return(0,c3.watch)(u,{persistent:d.persistent},j)}catch(te){C(te);return}}var IZ=(u,d,v,C,I)=>{let j=NZ.get(u);j&&vbe(j[d],te=>{te(v,C,I)})},QAt=(u,d,v,C)=>{let{listener:I,errHandler:j,rawEmitter:te}=C,be=NZ.get(d),je;if(!v.persistent)return je=Qze(u,v,I,j,te),je?je.close.bind(je):void 0;if(be)_J(be,o3,I),_J(be,PZ,j),_J(be,B7,te);else{if(je=Qze(u,v,IZ.bind(null,d,o3),j,IZ.bind(null,d,B7)),!je)return;je.on($S.ERROR,async ct=>{let kt=IZ.bind(null,d,PZ);if(be&&(be.watcherUnusable=!0),Tbe&&ct.code==="EPERM")try{await(await(0,GS.open)(u,"r")).close(),kt(ct)}catch{}else kt(ct)}),be={listeners:I,errHandlers:j,rawEmitters:te,watcher:je},NZ.set(d,be)}return()=>{fJ(be,o3,I),fJ(be,PZ,j),fJ(be,B7,te),eWe(be.listeners)&&(be.watcher.close(),NZ.delete(d),$At.forEach(YAt(be)),be.watcher=void 0,Object.freeze(be))}},ybe=new Map,XAt=(u,d,v,C)=>{let{listener:I,rawEmitter:j}=C,te=ybe.get(d),be=te&&te.options;return be&&(be.persistent<v.persistent||be.interval>v.interval)&&((0,c3.unwatchFile)(d),te=void 0),te?(_J(te,o3,I),_J(te,B7,j)):(te={listeners:I,rawEmitters:j,options:v,watcher:(0,c3.watchFile)(d,v,(je,ct)=>{vbe(te.rawEmitters,Bt=>{Bt($S.CHANGE,d,{curr:je,prev:ct})});let kt=je.mtimeMs;(je.size!==ct.size||kt>ct.mtimeMs||kt===0)&&vbe(te.listeners,Bt=>Bt(u,je))})},ybe.set(d,te)),()=>{fJ(te,o3,I),fJ(te,B7,j),eWe(te.listeners)&&(ybe.delete(d),(0,c3.unwatchFile)(d),te.options=te.watcher=void 0,Object.freeze(te))}},FZ=class{constructor(d){this.fsw=d,this._boundHandleError=v=>d._handleError(v)}_watchWithNodeFs(d,v){let C=this.fsw.options,I=ap.dirname(d),j=ap.basename(d);this.fsw._getWatchedDir(I).add(j);let be=ap.resolve(d),je={persistent:C.persistent};v||(v=OZ);let ct;if(C.usePolling){let kt=C.interval!==C.binaryInterval;je.interval=kt&&HAt(j)?C.binaryInterval:C.interval,ct=XAt(d,be,je,{listener:v,rawEmitter:this.fsw._emitRaw})}else ct=QAt(d,be,je,{listener:v,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return ct}_handleFile(d,v,C){if(this.fsw.closed)return;let I=ap.dirname(d),j=ap.basename(d),te=this.fsw._getWatchedDir(I),be=v;if(te.has(j))return;let je=async(kt,Bt)=>{if(this.fsw._throttle(VAt,d,5)){if(!Bt||Bt.mtimeMs===0)try{let he=await(0,GS.stat)(d);if(this.fsw.closed)return;let qr=he.atimeMs,Et=he.mtimeMs;if((!qr||qr<=Et||Et!==be.mtimeMs)&&this.fsw._emit($S.CHANGE,d,he),(WAt||UAt)&&be.ino!==he.ino){this.fsw._closeFile(kt),be=he;let Ke=this._watchWithNodeFs(d,je);Ke&&this.fsw._addPathCloser(kt,Ke)}else be=he}catch{this.fsw._remove(I,j)}else if(te.has(j)){let he=Bt.atimeMs,qr=Bt.mtimeMs;(!he||he<=qr||qr!==be.mtimeMs)&&this.fsw._emit($S.CHANGE,d,Bt),be=Bt}}},ct=this._watchWithNodeFs(d,je);if(!(C&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(d)){if(!this.fsw._throttle($S.ADD,d,0))return;this.fsw._emit($S.ADD,d,v)}return ct}async _handleSymlink(d,v,C,I){if(this.fsw.closed)return;let j=d.fullPath,te=this.fsw._getWatchedDir(v);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let be;try{be=await(0,GS.realpath)(C)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(te.has(I)?this.fsw._symlinkPaths.get(j)!==be&&(this.fsw._symlinkPaths.set(j,be),this.fsw._emit($S.CHANGE,C,d.stats)):(te.add(I),this.fsw._symlinkPaths.set(j,be),this.fsw._emit($S.ADD,C,d.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(j))return!0;this.fsw._symlinkPaths.set(j,!0)}_handleRead(d,v,C,I,j,te,be){if(d=ap.join(d,""),be=this.fsw._throttle("readdir",d,1e3),!be)return;let je=this.fsw._getWatchedDir(C.path),ct=new Set,kt=this.fsw._readdirp(d,{fileFilter:Bt=>C.filterPath(Bt),directoryFilter:Bt=>C.filterDir(Bt)});if(kt)return kt.on(zAt,async Bt=>{if(this.fsw.closed){kt=void 0;return}let he=Bt.path,qr=ap.join(d,he);if(ct.add(he),!(Bt.stats.isSymbolicLink()&&await this._handleSymlink(Bt,d,qr,he))){if(this.fsw.closed){kt=void 0;return}(he===I||!I&&!je.has(he))&&(this.fsw._incrReadyCount(),qr=ap.join(j,ap.relative(j,qr)),this._addToNodeFs(qr,v,C,te+1))}}).on($S.ERROR,this._boundHandleError),new Promise((Bt,he)=>{if(!kt)return he();kt.once(bbe,()=>{if(this.fsw.closed){kt=void 0;return}let qr=be?be.clear():!1;Bt(void 0),je.getChildren().filter(Et=>Et!==d&&!ct.has(Et)).forEach(Et=>{this.fsw._remove(d,Et)}),kt=void 0,qr&&this._handleRead(d,!1,C,I,j,te,be)})})}async _handleDir(d,v,C,I,j,te,be){let je=this.fsw._getWatchedDir(ap.dirname(d)),ct=je.has(ap.basename(d));!(C&&this.fsw.options.ignoreInitial)&&!j&&!ct&&this.fsw._emit($S.ADD_DIR,d,v),je.add(ap.basename(d)),this.fsw._getWatchedDir(d);let kt,Bt,he=this.fsw.options.depth;if((he==null||I<=he)&&!this.fsw._symlinkPaths.has(be)){if(!j&&(await this._handleRead(d,C,te,j,d,I,kt),this.fsw.closed))return;Bt=this._watchWithNodeFs(d,(qr,Et)=>{Et&&Et.mtimeMs===0||this._handleRead(qr,!1,te,j,d,I,kt)})}return Bt}async _addToNodeFs(d,v,C,I,j){let te=this.fsw._emitReady;if(this.fsw._isIgnored(d)||this.fsw.closed)return te(),!1;let be=this.fsw._getWatchHelpers(d);C&&(be.filterPath=je=>C.filterPath(je),be.filterDir=je=>C.filterDir(je));try{let je=await qAt[be.statMethod](be.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(be.watchPath,je))return te(),!1;let ct=this.fsw.options.followSymlinks,kt;if(je.isDirectory()){let Bt=ap.resolve(d),he=ct?await(0,GS.realpath)(d):d;if(this.fsw.closed||(kt=await this._handleDir(be.watchPath,je,v,I,j,be,he),this.fsw.closed))return;Bt!==he&&he!==void 0&&this.fsw._symlinkPaths.set(Bt,he)}else if(je.isSymbolicLink()){let Bt=ct?await(0,GS.realpath)(d):d;if(this.fsw.closed)return;let he=ap.dirname(be.watchPath);if(this.fsw._getWatchedDir(he).add(be.watchPath),this.fsw._emit($S.ADD,be.watchPath,je),kt=await this._handleDir(he,je,v,I,d,be,Bt),this.fsw.closed)return;Bt!==void 0&&this.fsw._symlinkPaths.set(ap.resolve(d),Bt)}else kt=this._handleFile(be.watchPath,je,v);return te(),kt&&this.fsw._addPathCloser(d,kt),!1}catch(je){if(this.fsw._handleError(je))return te(),d}}};var xbe="/",KAt="//",cWe=".",ZAt="..",ePt="string",tPt=/\\/g,tWe=/\/\//,rPt=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,nPt=/^\.[/\\]/;function LZ(u){return Array.isArray(u)?u:[u]}var Dbe=u=>typeof u=="object"&&u!==null&&!(u instanceof RegExp);function iPt(u){return typeof u=="function"?u:typeof u=="string"?d=>u===d:u instanceof RegExp?d=>u.test(d):typeof u=="object"&&u!==null?d=>{if(u.path===d)return!0;if(u.recursive){let v=Ol.relative(u.path,d);return v?!v.startsWith("..")&&!Ol.isAbsolute(v):!1}return!1}:()=>!1}function sPt(u){if(typeof u!="string")throw new Error("string expected");u=Ol.normalize(u),u=u.replace(/\\/g,"/");let d=!1;u.startsWith("//")&&(d=!0);let v=/\/\//;for(;u.match(v);)u=u.replace(v,"/");return d&&(u="/"+u),u}function rWe(u,d,v){let C=sPt(d);for(let I=0;I<u.length;I++){let j=u[I];if(j(C,v))return!0}return!1}function aPt(u,d){if(u==null)throw new TypeError("anymatch: specify first argument");let C=LZ(u).map(I=>iPt(I));return d==null?(I,j)=>rWe(C,I,j):rWe(C,d)}var nWe=u=>{let d=LZ(u).flat();if(!d.every(v=>typeof v===ePt))throw new TypeError(`Non-string provided as watch path: ${d}`);return d.map(lWe)},iWe=u=>{let d=u.replace(tPt,xbe),v=!1;for(d.startsWith(KAt)&&(v=!0);d.match(tWe);)d=d.replace(tWe,xbe);return v&&(d=xbe+d),d},lWe=u=>iWe(Ol.normalize(iWe(u))),sWe=(u="")=>d=>typeof d=="string"?lWe(Ol.isAbsolute(d)?d:Ol.join(u,d)):d,oPt=(u,d)=>Ol.isAbsolute(u)?u:Ol.join(d,u),cPt=Object.freeze(new Set),Cbe=class{constructor(d,v){this.path=d,this._removeWatcher=v,this.items=new Set}add(d){let{items:v}=this;v&&d!==cWe&&d!==ZAt&&v.add(d)}async remove(d){let{items:v}=this;if(!v||(v.delete(d),v.size>0))return;let C=this.path;try{await(0,MZ.readdir)(C)}catch{this._removeWatcher&&this._removeWatcher(Ol.dirname(C),Ol.basename(C))}}has(d){let{items:v}=this;if(v)return v.has(d)}getChildren(){let{items:d}=this;return d?[...d.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=OZ,this.items=cPt,Object.freeze(this)}},lPt="stat",uPt="lstat",kbe=class{constructor(d,v,C){this.fsw=C;let I=d;this.path=d=d.replace(nPt,""),this.watchPath=I,this.fullWatchPath=Ol.resolve(I),this.dirParts=[],this.dirParts.forEach(j=>{j.length>1&&j.pop()}),this.followSymlinks=v,this.statMethod=v?lPt:uPt}entryPath(d){return Ol.join(this.watchPath,Ol.relative(this.watchPath,d.fullPath))}filterPath(d){let{stats:v}=d;if(v&&v.isSymbolicLink())return this.filterDir(d);let C=this.entryPath(d);return this.fsw._isntIgnored(C,v)&&this.fsw._hasReadPermissions(v)}filterDir(d){return this.fsw._isntIgnored(this.entryPath(d),d.stats)}},Ebe=class extends oWe.EventEmitter{constructor(d={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let v=d.awaitWriteFinish,C={stabilityThreshold:2e3,pollInterval:100},I={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...d,ignored:d.ignored?LZ(d.ignored):LZ([]),awaitWriteFinish:v===!0?C:typeof v=="object"?{...C,...v}:!1};Zze&&(I.usePolling=!0),I.atomic===void 0&&(I.atomic=!I.usePolling);let j=process.env.CHOKIDAR_USEPOLLING;if(j!==void 0){let je=j.toLowerCase();je==="false"||je==="0"?I.usePolling=!1:je==="true"||je==="1"?I.usePolling=!0:I.usePolling=!!je}let te=process.env.CHOKIDAR_INTERVAL;te&&(I.interval=Number.parseInt(te,10));let be=0;this._emitReady=()=>{be++,be>=this._readyCount&&(this._emitReady=OZ,this._readyEmitted=!0,process.nextTick(()=>this.emit(Fp.READY)))},this._emitRaw=(...je)=>this.emit(Fp.RAW,...je),this._boundRemove=this._remove.bind(this),this.options=I,this._nodeFsHandler=new FZ(this),Object.freeze(I)}_addIgnoredPath(d){if(Dbe(d)){for(let v of this._ignoredPaths)if(Dbe(v)&&v.path===d.path&&v.recursive===d.recursive)return}this._ignoredPaths.add(d)}_removeIgnoredPath(d){if(this._ignoredPaths.delete(d),typeof d=="string")for(let v of this._ignoredPaths)Dbe(v)&&v.path===d&&this._ignoredPaths.delete(v)}add(d,v,C){let{cwd:I}=this.options;this.closed=!1,this._closePromise=void 0;let j=nWe(d);return I&&(j=j.map(te=>oPt(te,I))),j.forEach(te=>{this._removeIgnoredPath(te)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=j.length,Promise.all(j.map(async te=>{let be=await this._nodeFsHandler._addToNodeFs(te,!C,void 0,0,v);return be&&this._emitReady(),be})).then(te=>{this.closed||te.forEach(be=>{be&&this.add(Ol.dirname(be),Ol.basename(v||be))})}),this}unwatch(d){if(this.closed)return this;let v=nWe(d),{cwd:C}=this.options;return v.forEach(I=>{!Ol.isAbsolute(I)&&!this._closers.has(I)&&(C&&(I=Ol.join(C,I)),I=Ol.resolve(I)),this._closePath(I),this._addIgnoredPath(I),this._watched.has(I)&&this._addIgnoredPath({path:I,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let d=[];return this._closers.forEach(v=>v.forEach(C=>{let I=C();I instanceof Promise&&d.push(I)})),this._streams.forEach(v=>v.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(v=>v.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=d.length?Promise.all(d).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let d={};return this._watched.forEach((v,C)=>{let j=(this.options.cwd?Ol.relative(this.options.cwd,C):C)||cWe;d[j]=v.getChildren().sort()}),d}emitWithAll(d,v){this.emit(...v),d!==Fp.ERROR&&this.emit(Fp.ALL,...v)}async _emit(d,v,C){if(this.closed)return;let I=this.options;Tbe&&(v=Ol.normalize(v)),I.cwd&&(v=Ol.relative(I.cwd,v));let j=[d,v];C!=null&&j.push(C);let te=I.awaitWriteFinish,be;if(te&&(be=this._pendingWrites.get(v)))return be.lastChange=new Date,this;if(I.atomic){if(d===Fp.UNLINK)return this._pendingUnlinks.set(v,j),setTimeout(()=>{this._pendingUnlinks.forEach((je,ct)=>{this.emit(...je),this.emit(Fp.ALL,...je),this._pendingUnlinks.delete(ct)})},typeof I.atomic=="number"?I.atomic:100),this;d===Fp.ADD&&this._pendingUnlinks.has(v)&&(d=j[0]=Fp.CHANGE,this._pendingUnlinks.delete(v))}if(te&&(d===Fp.ADD||d===Fp.CHANGE)&&this._readyEmitted){let je=(ct,kt)=>{ct?(d=j[0]=Fp.ERROR,j[1]=ct,this.emitWithAll(d,j)):kt&&(j.length>2?j[2]=kt:j.push(kt),this.emitWithAll(d,j))};return this._awaitWriteFinish(v,te.stabilityThreshold,d,je),this}if(d===Fp.CHANGE&&!this._throttle(Fp.CHANGE,v,50))return this;if(I.alwaysStat&&C===void 0&&(d===Fp.ADD||d===Fp.ADD_DIR||d===Fp.CHANGE)){let je=I.cwd?Ol.join(I.cwd,v):v,ct;try{ct=await(0,MZ.stat)(je)}catch{}if(!ct||this.closed)return;j.push(ct)}return this.emitWithAll(d,j),this}_handleError(d){let v=d&&d.code;return d&&v!=="ENOENT"&&v!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||v!=="EPERM"&&v!=="EACCES")&&this.emit(Fp.ERROR,d),d||this.closed}_throttle(d,v,C){this._throttled.has(d)||this._throttled.set(d,new Map);let I=this._throttled.get(d);if(!I)throw new Error("invalid throttle");let j=I.get(v);if(j)return j.count++,!1;let te,be=()=>{let ct=I.get(v),kt=ct?ct.count:0;return I.delete(v),clearTimeout(te),ct&&clearTimeout(ct.timeoutObject),kt};te=setTimeout(be,C);let je={timeoutObject:te,clear:be,count:0};return I.set(v,je),je}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(d,v,C,I){let j=this.options.awaitWriteFinish;if(typeof j!="object")return;let te=j.pollInterval,be,je=d;this.options.cwd&&!Ol.isAbsolute(d)&&(je=Ol.join(this.options.cwd,d));let ct=new Date,kt=this._pendingWrites;function Bt(he){(0,aWe.stat)(je,(qr,Et)=>{if(qr||!kt.has(d)){qr&&qr.code!=="ENOENT"&&I(qr);return}let Ke=Number(new Date);he&&Et.size!==he.size&&(kt.get(d).lastChange=Ke);let Ln=kt.get(d);Ke-Ln.lastChange>=v?(kt.delete(d),I(void 0,Et)):be=setTimeout(Bt,te,Et)})}kt.has(d)||(kt.set(d,{lastChange:ct,cancelWait:()=>(kt.delete(d),clearTimeout(be),C)}),be=setTimeout(Bt,te))}_isIgnored(d,v){if(this.options.atomic&&rPt.test(d))return!0;if(!this._userIgnored){let{cwd:C}=this.options,j=(this.options.ignored||[]).map(sWe(C)),be=[...[...this._ignoredPaths].map(sWe(C)),...j];this._userIgnored=aPt(be,void 0)}return this._userIgnored(d,v)}_isntIgnored(d,v){return!this._isIgnored(d,v)}_getWatchHelpers(d){return new kbe(d,this.options.followSymlinks,this)}_getWatchedDir(d){let v=Ol.resolve(d);return this._watched.has(v)||this._watched.set(v,new Cbe(v,this._boundRemove)),this._watched.get(v)}_hasReadPermissions(d){return this.options.ignorePermissionErrors?!0:!!(Number(d.mode)&256)}_remove(d,v,C){let I=Ol.join(d,v),j=Ol.resolve(I);if(C=C??(this._watched.has(I)||this._watched.has(j)),!this._throttle("remove",I,100))return;!C&&this._watched.size===1&&this.add(d,v,!0),this._getWatchedDir(I).getChildren().forEach(he=>this._remove(I,he));let je=this._getWatchedDir(d),ct=je.has(v);je.remove(v),this._symlinkPaths.has(j)&&this._symlinkPaths.delete(j);let kt=I;if(this.options.cwd&&(kt=Ol.relative(this.options.cwd,I)),this.options.awaitWriteFinish&&this._pendingWrites.has(kt)&&this._pendingWrites.get(kt).cancelWait()===Fp.ADD)return;this._watched.delete(I),this._watched.delete(j);let Bt=C?Fp.UNLINK_DIR:Fp.UNLINK;ct&&!this._isIgnored(I)&&this._emit(Bt,I),this._closePath(I)}_closePath(d){this._closeFile(d);let v=Ol.dirname(d);this._getWatchedDir(v).remove(Ol.basename(d))}_closeFile(d){let v=this._closers.get(d);v&&(v.forEach(C=>C()),this._closers.delete(d))}_addPathCloser(d,v){if(!v)return;let C=this._closers.get(d);C||(C=[],this._closers.set(d,C)),C.push(v)}_readdirp(d,v){if(this.closed)return;let C={type:Fp.ALL,alwaysStat:!0,lstat:!0,...v,depth:0},I=Yze(d,C);return this._streams.add(I),I.once(Kze,()=>{I=void 0}),I.once(bbe,()=>{I&&(this._streams.delete(I),I=void 0)}),I}};function uWe(u,d={}){let v=new Ebe(d);return v.add(u),v}var _1=go(RZ());var pJ=go(require("node:fs")),BZ=go(require("node:path")),mWe=go(require("node:os"));var fWe=go(require("node:path")),pWe=go(require("node:fs"));function yw(){let u;try{u=fWe.resolve("package.json")}catch(v){throw new Error(`cannot resolve package manifest path: ${v}`)}let d;try{d=JSON.parse(pWe.readFileSync(u,"utf8"))}catch(v){throw new Error(`cannot read package manifest: ${v}`)}return d.name=d.name.replace(/^@workaround/g,""),d}var dWe={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"],dPt="e69bae0ec90f5e838555",kk={},jZ;function Gx(){let u=yw();if(!u.name)throw new Error("extension name in manifest cannot be empty");return BZ.join(vWe(),"extensions",u.name)}function gWe(){let u=JZ(jZ);return u?.startsWith("x")?u==="x"?"com.raycast-x.macos":`com.raycast-x.macos.${u.replace("x-","")}`:u?`com.raycast.macos.${u}`:"com.raycast.macos"}function hWe(){let u=JZ(jZ);return u?.startsWith("x")?u==="x"?"com.raycast-x":`com.raycast-x.${u.replace("x-","")}`:`raycast${u}`}function yWe(u){jZ=u;try{kk=JSON.parse(pJ.readFileSync(BZ.join(vWe(),"config.json"),"utf8"))}catch(d){if(d instanceof Error&&d.code==="ENOENT")return;throw new Error(`Failed to read config file: ${d}`)}}function mPt(u){switch(u){case"raycastApiURL":return process.env.RAY_APIURL||kk.APIURL||dWe.url;case"raycastAccessToken":return process.env.RAY_TOKEN||kk.Token||kk.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||kk.ClientID||dWe.clientID;case"githubClientId":return process.env.RAY_GithubClientID||kk.GithubClientID||dPt;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||kk.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof kk.Target>"u"?JZ("release"):kk.Target)}}function JZ(u){switch(u){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 mPt("flavorName")}}function gPt(){let u=JZ(jZ);return u==""?"raycast":`raycast-${u}`}function vWe(){let u=BZ.join(mWe.default.homedir(),".config",gPt());return pJ.mkdirSync(u,{recursive:!0}),u}var vw=require("@oclif/core");var Vf=go(RZ());var TJ=go(require("node:process"),1);var bWe=(u=0)=>d=>`\x1B[${d+u}m`,SWe=(u=0)=>d=>`\x1B[${38+u};5;${d}m`,TWe=(u=0)=>(d,v,C)=>`\x1B[${38+u};2;${d};${v};${C}m`,op={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]}},JMt=Object.keys(op.modifier),hPt=Object.keys(op.color),yPt=Object.keys(op.bgColor),zMt=[...hPt,...yPt];function vPt(){let u=new Map;for(let[d,v]of Object.entries(op)){for(let[C,I]of Object.entries(v))op[C]={open:`\x1B[${I[0]}m`,close:`\x1B[${I[1]}m`},v[C]=op[C],u.set(I[0],I[1]);Object.defineProperty(op,d,{value:v,enumerable:!1})}return Object.defineProperty(op,"codes",{value:u,enumerable:!1}),op.color.close="\x1B[39m",op.bgColor.close="\x1B[49m",op.color.ansi=bWe(),op.color.ansi256=SWe(),op.color.ansi16m=TWe(),op.bgColor.ansi=bWe(10),op.bgColor.ansi256=SWe(10),op.bgColor.ansi16m=TWe(10),Object.defineProperties(op,{rgbToAnsi256:{value(d,v,C){return d===v&&v===C?d<8?16:d>248?231:Math.round((d-8)/247*24)+232:16+36*Math.round(d/255*5)+6*Math.round(v/255*5)+Math.round(C/255*5)},enumerable:!1},hexToRgb:{value(d){let v=/[a-f\d]{6}|[a-f\d]{3}/i.exec(d.toString(16));if(!v)return[0,0,0];let[C]=v;C.length===3&&(C=[...C].map(j=>j+j).join(""));let I=Number.parseInt(C,16);return[I>>16&255,I>>8&255,I&255]},enumerable:!1},hexToAnsi256:{value:d=>op.rgbToAnsi256(...op.hexToRgb(d)),enumerable:!1},ansi256ToAnsi:{value(d){if(d<8)return 30+d;if(d<16)return 90+(d-8);let v,C,I;if(d>=232)v=((d-232)*10+8)/255,C=v,I=v;else{d-=16;let be=d%36;v=Math.floor(d/36)/5,C=Math.floor(be/6)/5,I=be%6/5}let j=Math.max(v,C,I)*2;if(j===0)return 30;let te=30+(Math.round(I)<<2|Math.round(C)<<1|Math.round(v));return j===2&&(te+=60),te},enumerable:!1},rgbToAnsi:{value:(d,v,C)=>op.ansi256ToAnsi(op.rgbToAnsi256(d,v,C)),enumerable:!1},hexToAnsi:{value:d=>op.ansi256ToAnsi(op.hexToAnsi256(d)),enumerable:!1}}),op}var bPt=vPt(),HS=bPt;var WZ=go(require("node:process"),1),DWe=go(require("node:os"),1),wbe=go(require("node:tty"),1);function o2(u,d=globalThis.Deno?globalThis.Deno.args:WZ.default.argv){let v=u.startsWith("-")?"":u.length===1?"-":"--",C=d.indexOf(v+u),I=d.indexOf("--");return C!==-1&&(I===-1||C<I)}var{env:Op}=WZ.default,zZ;o2("no-color")||o2("no-colors")||o2("color=false")||o2("color=never")?zZ=0:(o2("color")||o2("colors")||o2("color=true")||o2("color=always"))&&(zZ=1);function SPt(){if("FORCE_COLOR"in Op)return Op.FORCE_COLOR==="true"?1:Op.FORCE_COLOR==="false"?0:Op.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Op.FORCE_COLOR,10),3)}function TPt(u){return u===0?!1:{level:u,hasBasic:!0,has256:u>=2,has16m:u>=3}}function xPt(u,{streamIsTTY:d,sniffFlags:v=!0}={}){let C=SPt();C!==void 0&&(zZ=C);let I=v?zZ:C;if(I===0)return 0;if(v){if(o2("color=16m")||o2("color=full")||o2("color=truecolor"))return 3;if(o2("color=256"))return 2}if("TF_BUILD"in Op&&"AGENT_NAME"in Op)return 1;if(u&&!d&&I===void 0)return 0;let j=I||0;if(Op.TERM==="dumb")return j;if(WZ.default.platform==="win32"){let te=DWe.default.release().split(".");return Number(te[0])>=10&&Number(te[2])>=10586?Number(te[2])>=14931?3:2:1}if("CI"in Op)return"GITHUB_ACTIONS"in Op||"GITEA_ACTIONS"in Op?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(te=>te in Op)||Op.CI_NAME==="codeship"?1:j;if("TEAMCITY_VERSION"in Op)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Op.TEAMCITY_VERSION)?1:0;if(Op.COLORTERM==="truecolor"||Op.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in Op){let te=Number.parseInt((Op.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Op.TERM_PROGRAM){case"iTerm.app":return te>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Op.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Op.TERM)||"COLORTERM"in Op?1:j}function xWe(u,d={}){let v=xPt(u,{streamIsTTY:u&&u.isTTY,...d});return TPt(v)}var DPt={stdout:xWe({isTTY:wbe.default.isatty(1)}),stderr:xWe({isTTY:wbe.default.isatty(2)})},CWe=DPt;function kWe(u,d,v){let C=u.indexOf(d);if(C===-1)return u;let I=d.length,j=0,te="";do te+=u.slice(j,C)+d+v,j=C+I,C=u.indexOf(d,j);while(C!==-1);return te+=u.slice(j),te}function EWe(u,d,v,C){let I=0,j="";do{let te=u[C-1]==="\r";j+=u.slice(I,te?C-1:C)+d+(te?`\r
567
567
  `:`
568
568
  `)+v,I=C+1,C=u.indexOf(`
569
569
  `,I)}while(C!==-1);return j+=u.slice(I),j}var{stdout:wWe,stderr:AWe}=CWe,Abe=Symbol("GENERATOR"),j7=Symbol("STYLER"),dJ=Symbol("IS_EMPTY"),PWe=["ansi","ansi","ansi256","ansi16m"],J7=Object.create(null),CPt=(u,d={})=>{if(d.level&&!(Number.isInteger(d.level)&&d.level>=0&&d.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let v=wWe?wWe.level:0;u.level=d.level===void 0?v:d.level};var kPt=u=>{let d=(...v)=>v.join(" ");return CPt(d,u),Object.setPrototypeOf(d,mJ.prototype),d};function mJ(u){return kPt(u)}Object.setPrototypeOf(mJ.prototype,Function.prototype);for(let[u,d]of Object.entries(HS))J7[u]={get(){let v=UZ(this,Nbe(d.open,d.close,this[j7]),this[dJ]);return Object.defineProperty(this,u,{value:v}),v}};J7.visible={get(){let u=UZ(this,this[j7],!0);return Object.defineProperty(this,"visible",{value:u}),u}};var Pbe=(u,d,v,...C)=>u==="rgb"?d==="ansi16m"?HS[v].ansi16m(...C):d==="ansi256"?HS[v].ansi256(HS.rgbToAnsi256(...C)):HS[v].ansi(HS.rgbToAnsi(...C)):u==="hex"?Pbe("rgb",d,v,...HS.hexToRgb(...C)):HS[v][u](...C),EPt=["rgb","hex","ansi256"];for(let u of EPt){J7[u]={get(){let{level:v}=this;return function(...C){let I=Nbe(Pbe(u,PWe[v],"color",...C),HS.color.close,this[j7]);return UZ(this,I,this[dJ])}}};let d="bg"+u[0].toUpperCase()+u.slice(1);J7[d]={get(){let{level:v}=this;return function(...C){let I=Nbe(Pbe(u,PWe[v],"bgColor",...C),HS.bgColor.close,this[j7]);return UZ(this,I,this[dJ])}}}}var wPt=Object.defineProperties(()=>{},{...J7,level:{enumerable:!0,get(){return this[Abe].level},set(u){this[Abe].level=u}}}),Nbe=(u,d,v)=>{let C,I;return v===void 0?(C=u,I=d):(C=v.openAll+u,I=d+v.closeAll),{open:u,close:d,openAll:C,closeAll:I,parent:v}},UZ=(u,d,v)=>{let C=(...I)=>APt(C,I.length===1?""+I[0]:I.join(" "));return Object.setPrototypeOf(C,wPt),C[Abe]=u,C[j7]=d,C[dJ]=v,C},APt=(u,d)=>{if(u.level<=0||!d)return u[dJ]?"":d;let v=u[j7];if(v===void 0)return d;let{openAll:C,closeAll:I}=v;if(d.includes("\x1B"))for(;v!==void 0;)d=kWe(d,v.close,v.open),v=v.parent;let j=d.indexOf(`
@@ -75,7 +75,7 @@ ${t}`,Ck=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Tk=Objec
75
75
  `);return i!==-1&&(t=hE(t,o,n,i)),n+t+o};Object.defineProperties(Ei.prototype,Kn);var Wk=Ei(),rW=Ei({level:yE?yE.level:0});var Ht=Wk;var Qe=N(require("node:process"),1);function fp(){return Qe.default.platform!=="win32"?Qe.default.env.TERM!=="linux":!!Qe.default.env.CI||!!Qe.default.env.WT_SESSION||!!Qe.default.env.TERMINUS_SUBLIME||Qe.default.env.ConEmuTask==="{cmd::Cmder}"||Qe.default.env.TERM_PROGRAM==="Terminus-Sublime"||Qe.default.env.TERM_PROGRAM==="vscode"||Qe.default.env.TERM==="xterm-256color"||Qe.default.env.TERM==="alacritty"||Qe.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Vk={info:Ht.blue("\u2139"),success:Ht.green("\u2714"),warning:Ht.yellow("\u26A0"),error:Ht.red("\u2716")},Gk={info:Ht.blue("i"),success:Ht.green("\u221A"),warning:Ht.yellow("\u203C"),error:Ht.red("\xD7")},Hk=fp()?Vk:Gk,vi=Hk;function dp({onlyFirst:e=!1}={}){let r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,e?void 0:"g")}var Yk=dp();function Fi(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Yk,"")}function bE(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function _E(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function wE(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101631&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129673||e>=129679&&e<=129734||e>=129742&&e<=129756||e>=129759&&e<=129769||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function Kk(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function SE(e,{ambiguousAsWide:t=!1}={}){return Kk(e),_E(e)||wE(e)||t&&bE(e)?2:1}var FE=N(vE(),1),Jk=new Intl.Segmenter,Qk=/^\p{Default_Ignorable_Code_Point}$/u;function pp(e,t={}){if(typeof e!="string"||e.length===0)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:n=!1}=t;if(n||(e=Fi(e)),e.length===0)return 0;let o=0,i={ambiguousAsWide:!r};for(let{segment:a}of Jk.segment(e)){let l=a.codePointAt(0);if(!(l<=31||l>=127&&l<=159)&&!(l>=8203&&l<=8207||l===65279)&&!(l>=768&&l<=879||l>=6832&&l<=6911||l>=7616&&l<=7679||l>=8400&&l<=8447||l>=65056&&l<=65071)&&!(l>=55296&&l<=57343)&&!(l>=65024&&l<=65039)&&!Qk.test(a)){if((0,FE.default)().test(a)){o+=2;continue}o+=SE(l,i)}}return o}function mp({stream:e=process.stdout}={}){return!!(e&&e.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}var gt=N(require("node:process"),1),Xk=3,hp=class{#e=0;start(){this.#e++,this.#e===1&&this.#r()}stop(){if(this.#e<=0)throw new Error("`stop` called more times than `start`");this.#e--,this.#e===0&&this.#t()}#r(){gt.default.platform==="win32"||!gt.default.stdin.isTTY||(gt.default.stdin.setRawMode(!0),gt.default.stdin.on("data",this.#n),gt.default.stdin.resume())}#t(){gt.default.stdin.isTTY&&(gt.default.stdin.off("data",this.#n),gt.default.stdin.pause(),gt.default.stdin.setRawMode(!1))}#n(t){t[0]===Xk&&gt.default.emit("SIGINT")}},Zk=new hp,gp=Zk;var e3=N(sp(),1),yp=class{#e=0;#r=!1;#t=0;#n=-1;#a=0;#o;#s;#i;#p;#h;#c;#f;#d;#g;#u;#l;color;constructor(t){typeof t=="string"&&(t={text:t}),this.#o={color:"cyan",stream:Ci.default.stderr,discardStdin:!0,hideCursor:!0,...t},this.color=this.#o.color,this.spinner=this.#o.spinner,this.#h=this.#o.interval,this.#i=this.#o.stream,this.#c=typeof this.#o.isEnabled=="boolean"?this.#o.isEnabled:mp({stream:this.#i}),this.#f=typeof this.#o.isSilent=="boolean"?this.#o.isSilent:!1,this.text=this.#o.text,this.prefixText=this.#o.prefixText,this.suffixText=this.#o.suffixText,this.indent=this.#o.indent,Ci.default.env.NODE_ENV==="test"&&(this._stream=this.#i,this._isEnabled=this.#c,Object.defineProperty(this,"_linesToClear",{get(){return this.#e},set(r){this.#e=r}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#n}}),Object.defineProperty(this,"_lineCount",{get(){return this.#t}}))}get indent(){return this.#d}set indent(t=0){if(!(t>=0&&Number.isInteger(t)))throw new Error("The `indent` option must be an integer from 0 and up");this.#d=t,this.#m()}get interval(){return this.#h??this.#s.interval??100}get spinner(){return this.#s}set spinner(t){if(this.#n=-1,this.#h=void 0,typeof t=="object"){if(t.frames===void 0)throw new Error("The given spinner must have a `frames` property");this.#s=t}else if(!bo())this.#s=Ti.default.line;else if(t===void 0)this.#s=Ti.default.dots;else if(t!=="default"&&Ti.default[t])this.#s=Ti.default[t];else throw new Error(`There is no built-in spinner named '${t}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#g}set text(t=""){this.#g=t,this.#m()}get prefixText(){return this.#u}set prefixText(t=""){this.#u=t,this.#m()}get suffixText(){return this.#l}set suffixText(t=""){this.#l=t,this.#m()}get isSpinning(){return this.#p!==void 0}#y(t=this.#u,r=" "){return typeof t=="string"&&t!==""?t+r:typeof t=="function"?t()+r:""}#D(t=this.#l,r=" "){return typeof t=="string"&&t!==""?r+t:typeof t=="function"?r+t():""}#m(){let t=this.#i.columns??80,r=this.#y(this.#u,"-"),n=this.#D(this.#l,"-"),o=" ".repeat(this.#d)+r+"--"+this.#g+"--"+n;this.#t=0;for(let i of Fi(o).split(`
76
76
  `))this.#t+=Math.max(1,Math.ceil(pp(i,{countAnsiEscapeCodes:!0})/t))}get isEnabled(){return this.#c&&!this.#f}set isEnabled(t){if(typeof t!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");this.#c=t}get isSilent(){return this.#f}set isSilent(t){if(typeof t!="boolean")throw new TypeError("The `isSilent` option must be a boolean");this.#f=t}frame(){let t=Date.now();(this.#n===-1||t-this.#a>=this.interval)&&(this.#n=++this.#n%this.#s.frames.length,this.#a=t);let{frames:r}=this.#s,n=r[this.#n];this.color&&(n=eE[this.color](n));let o=typeof this.#u=="string"&&this.#u!==""?this.#u+" ":"",i=typeof this.text=="string"?" "+this.text:"",a=typeof this.#l=="string"&&this.#l!==""?" "+this.#l:"";return o+n+i+a}clear(){if(!this.#c||!this.#i.isTTY)return this;this.#i.cursorTo(0);for(let t=0;t<this.#e;t++)t>0&&this.#i.moveCursor(0,-1),this.#i.clearLine(1);return(this.#d||this.lastIndent!==this.#d)&&this.#i.cursorTo(this.#d),this.lastIndent=this.#d,this.#e=0,this}render(){return this.#f?this:(this.clear(),this.#i.write(this.frame()),this.#e=this.#t,this)}start(t){return t&&(this.text=t),this.#f?this:this.#c?this.isSpinning?this:(this.#o.hideCursor&&ip.hide(this.#i),this.#o.discardStdin&&Ci.default.stdin.isTTY&&(this.#r=!0,gp.start()),this.render(),this.#p=setInterval(this.render.bind(this),this.interval),this):(this.text&&this.#i.write(`- ${this.text}
77
77
  `),this)}stop(){return this.#c?(clearInterval(this.#p),this.#p=void 0,this.#n=0,this.clear(),this.#o.hideCursor&&ip.show(this.#i),this.#o.discardStdin&&Ci.default.stdin.isTTY&&this.#r&&(gp.stop(),this.#r=!1),this):this}succeed(t){return this.stopAndPersist({symbol:vi.success,text:t})}fail(t){return this.stopAndPersist({symbol:vi.error,text:t})}warn(t){return this.stopAndPersist({symbol:vi.warning,text:t})}info(t){return this.stopAndPersist({symbol:vi.info,text:t})}stopAndPersist(t={}){if(this.#f)return this;let r=t.prefixText??this.#u,n=this.#y(r," "),o=t.symbol??" ",i=t.text??this.text,l=typeof i=="string"?(o?" ":"")+i:"",c=t.suffixText??this.#l,d=this.#D(c," "),p=n+o+l+d+`
78
- `;return this.stop(),this.#i.write(p),this}};function Dp(e){return new yp(e)}var CE=(0,fe.blue)((0,fe.dim)("internal only"));function Jn(e,t,r){console.log(Yt[e]+t),typeof r?.exit<"u"&&process.exit(r.exit)}async function _r(e,t,r){if(!TE){Jn("wait",e);try{let o=await t();o&&console.log(o),Jn("success",e);return}catch(o){return Jn("error",e),r?.printError!==!1&&console.log((0,fe.red)(o.message)),o}}let n=Dp({spinner:"simpleDots",prefixText:Yt.wait+e}).start();try{let o=await t();n.stop(),Jn("success",e),o&&console.log(o)}catch(o){return n.stop(),Jn("error",e),r?.printError!==!1&&console.error(o.message),o}}var Yt={wait:`\u{1F550}${(0,fe.blue)("wait")} - `,info:`${process.env.GITHUB_ACTIONS==="true"?"\u2139\uFE0F":"\u2139\uFE0F "}${(0,fe.cyan)("info")} - `,success:`\u2705${(0,fe.green)("ready")} - `,warn:`${process.env.GITHUB_ACTIONS==="true"?"\u26A0\uFE0F":"\u26A0\uFE0F "}${(0,fe.yellow)("warn")} - `,error:`\u{1F4A5}${(0,fe.red)("error")} - `,event:`\u26A1\uFE0F${(0,fe.magenta)("event")} - `,paymentPrompt:`\u{1F4B0}${(0,fe.yellowBright)("plan")} - `},TE=!0;function RE(e,t){e||(Yt.wait=`${(0,fe.blue)("wait")} - `,Yt.info=`${(0,fe.cyan)("info")} - `,Yt.success=`${(0,fe.green)("ready")} - `,Yt.warn=`${(0,fe.yellow)("warn")} - `,Yt.error=`${(0,fe.red)("error")} - `,Yt.event=`${(0,fe.magenta)("event")} - `,Yt.paymentPrompt=`${(0,fe.yellowBright)("plan")} - `),t&&(TE=!1)}var wr=require("@oclif/core");var Ri=N(require("node:fs")),_p=N(require("node:path")),xE=N(require("node:os"));var AE=N(require("node:path")),$E=N(require("node:fs"));function bp(){let e;try{e=AE.resolve("package.json")}catch(r){throw new Error(`cannot resolve package manifest path: ${r}`)}let t;try{t=JSON.parse($E.readFileSync(e,"utf8"))}catch(r){throw new Error(`cannot read package manifest: ${r}`)}return t.name=t.name.replace(/^@workaround/g,""),t}var Wr={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"],t3="e69bae0ec90f5e838555",Kt={},PE;function OE(e){PE=e;try{Kt=JSON.parse(Ri.readFileSync(_p.join(n3(),"config.json"),"utf8"))}catch(t){if(t instanceof Error&&t.code==="ENOENT")return;throw new Error(`Failed to read config file: ${t}`)}}function Qn(e){switch(e){case"raycastApiURL":return process.env.RAY_APIURL||Kt.APIURL||Wr.url;case"raycastAccessToken":return process.env.RAY_TOKEN||Kt.Token||Kt.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||Kt.ClientID||Wr.clientID;case"githubClientId":return process.env.RAY_GithubClientID||Kt.GithubClientID||t3;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||Kt.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof Kt.Target>"u"?BE("release"):Kt.Target)}}function BE(e){switch(e){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 Qn("flavorName")}}function r3(){let e=BE(PE);return e==""?"raycast":`raycast-${e}`}function n3(){let e=_p.join(xE.default.homedir(),".config",r3());return Ri.mkdirSync(e,{recursive:!0}),e}var Tu=class extends wr.Command{static baseFlags={"exit-on-error":wr.Flags.boolean({default:!0,helpGroup:"GLOBAL",aliases:["exitOnError"],deprecateAliases:!0,summary:"Always exit with non-zero code on error",allowNo:!0}),emoji:wr.Flags.boolean({default:!1,helpGroup:"GLOBAL",summary:"Prefix output with emojis \u{1F308}"}),help:wr.Flags.boolean({default:!1,helpGroup:"GLOBAL",summary:"Show the help message for the command"}),"non-interactive":wr.Flags.boolean({char:"I",default:!1,helpGroup:"GLOBAL",summary:"Disable interactive outputs, useful for CI"}),target:wr.Flags.option({char:"t",description:"Raycast app target",helpGroup:"GLOBAL",multiple:!1,options:["debug","internal","release","x","x-debug","x-internal"],hidden:!0})()};flags;args;async init(){await super.init(),process.on("SIGINT",()=>process.exit(1));let{args:t,flags:r}=await this.parse({flags:this.ctor.flags,baseFlags:super.ctor.baseFlags,enableJsonFlag:this.ctor.enableJsonFlag,args:this.ctor.args,strict:this.ctor.strict});this.flags=r,this.args=t,OE(this.flags.target),RE(this.flags.emoji,this.flags["non-interactive"])}error(t,r){return r?.message&&t instanceof Error&&(t.message=`${r.message} (${t.message})`,delete r.message),super.error(t,r)}async catch(t){return super.catch(t)}async finally(t){return super.finally(t)}};var y3=require("@oclif/core");var h3=require("@oclif/core"),KE=N(hf()),g3=N(YE());async function Rp(e,t){let r;try{r=await(0,KE.default)(e,{method:t.method||"GET",headers:{"Content-Type":"application/json",Accept:"application/json",...t.token?{Authorization:`Bearer ${t.token}`}:void 0},body:t.body})}catch(n){throw new Error(`HTTP request: ${n.message}`)}if(!r.ok){switch(r.status){case 401:throw new Jt(r,"not authorized - please log in first using `npx ray login`");case 403:throw new Jt(r,"forbidden - you don't have permissions to perform the request");case 402:throw new Jt(r,"the limit of free commands has been reached")}let n=await r.text(),o;try{o=JSON.parse(n)}catch{throw new Jt(r,`HTTP error: ${r.status} - ${n}`)}throw Array.isArray(o.errors)&&o.errors.length>0?new Jt(r,`error: ${o.errors[0].status} - ${o.errors[0].title}`):new Jt(r,`HTTP error: ${r.status} - ${n}`)}return await r.json()}var Jt=class extends Error{constructor(t,r){let n=t.headers.get("X-Request-Id");n?super(`${r} (${t.url} RequestID: ${n})`):super(r),this.name="HTTPError"}};var JW=`${Wr.url}/sessions/success`,QW=`${Wr.url}/sessions/failure`;function Pu(e){let t=Qn("raycastApiURL"),r=Qn("raycastAccessToken");return Rp(`${t}/api/v1/users/${e}`,{token:r})}function JE(e){let t=Qn("raycastApiURL"),r=Qn("raycastAccessToken");return Rp(`${t}/api/v1/organizations/${e}`,{token:r})}var Bu=class e extends Tu{static description="Validate the extension manifest and metadata, and lint its source code";static flags={fix:Ou.Flags.boolean({char:"f",default:!1,description:"Attempt to fix linting issues"}),relaxed:Ou.Flags.boolean({char:"r",description:"Use relaxed linting mode to skip validation of: package.json schema, icons and metadata.",default:!1}),schema:Ou.Flags.string({char:"s",description:"Path to JSON schema for package.json validation "+CE,default:`${Wr.url}/schemas/extension.json`,hidden:!0})};async run(){let{flags:t}=await this.parse(e);await ev({skipOwner:!1,fix:t.fix,relaxed:t.relaxed,skipLockFiles:process.env.CI?.toLowerCase()!=="true",schema:t.schema})||this.error("linting issues found (tip: try re-running with '--fix')")}};async function ev(e){let t=!0;try{let r=bp();t=await D3(r,e),t=await b3(r,e)&&t,t=await _3(r,e)&&t,t=await w3(r,e)&&t}catch(r){console.error("error reading manifest:",r),t=!1}return t=await S3(e)&&t,t=await E3(e)&&t,t}async function D3(e,t){return await _r("validate package.json file",async()=>{let n=[],o=[];try{await Pu(e.author)}catch(i){i.message.includes("Couldn't find User")?n.push({pointer:"/author",message:`Invalid author "${e.author}". Use the Raycast username`,level:"error"}):n.push({pointer:"/author",message:`Invalid author "${e.author}". ${i.message}`,level:"error"})}if(await Promise.all((e.contributors||[]).map(async(i,a)=>{try{await Pu(i)}catch(l){l.message.includes("Couldn't find User")?n.push({pointer:"/contributors/"+a,message:`Invalid contributor "${e.author}". Use the Raycast username`,level:"error"}):n.push({pointer:"/contributors/"+a,message:`Invalid contributor "${e.author}". ${l.message}`,level:"error"})}i===e.author&&n.push({pointer:"/contributors/"+a,message:`Author "${e.author}" should not be added as a contributor`,level:"error"})})),await Promise.all((e.pastContributors||[]).map(async(i,a)=>{try{await Pu(i)}catch(l){l.message.includes("Couldn't find User")?n.push({pointer:"/pastContributors/"+a,message:`Invalid contributor "${e.author}". Use the Raycast username`,level:"error"}):n.push({pointer:"/pastContributors/"+a,message:`Invalid contributor "${e.author}". ${l.message}`,level:"error"})}})),e.owner&&!t.skipOwner)try{await JE(e.owner)}catch(i){i.message.includes("Couldn't find Organization")?n.push({pointer:"/owner",message:`Invalid owner "${e.owner}". Use the Raycast organization handle`,level:"error"}):n.push({pointer:"/owner",message:`Invalid owner "${e.author}". ${i.message}`,level:"error"})}if(!t.relaxed){let i=new ZE.default({allErrors:!0});try{let a=await(await(0,XE.default)(t.schema)).json();delete a.$schema;let l=i.compile(a);l(e)||n.push(...(l.errors||[]).map(c=>({pointer:c.instancePath,message:c.message||"",level:"error"})))}catch(a){n.push({message:`Failed compiling JSON schema: ${a.message}`,level:"error"})}e.name.startsWith("@workaround/")&&o.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,Vr.titleCase)(e.title)!==e.title&&o.push({pointer:"/title",message:`Extension's title has to be Title Cased. Expected "${(0,Vr.titleCase)(e.title)}"`,level:"warning"}),Zn(e.title)||o.push({pointer:"/title",message:'Raycast is spelled "Raycast"',level:"warning"}),Zn(e.description)||o.push({pointer:"/description",message:'Raycast is spelled "Raycast"',level:"warning"}),e.commands.forEach((a,l)=>{(0,Vr.titleCase)(a.title)!==a.title&&o.push({pointer:`/commands/${l}/title`,message:`Command's title has to be Title Cased. Expected "${(0,Vr.titleCase)(a.title)}"`,level:"warning"}),Zn(a.title)||o.push({pointer:`/commands/${l}/title`,message:'Raycast is spelled "Raycast"',level:"warning"}),Zn(a.description)||o.push({pointer:`/commands/${l}/description`,message:'Raycast is spelled "Raycast"',level:"warning"})}),e.tools?.forEach((a,l)=>{(0,Vr.titleCase)(a.title)!==a.title&&o.push({pointer:`/tools/${l}/title`,message:`Tool's title has to be Title Cased. Expected "${(0,Vr.titleCase)(a.title)}"`,level:"warning"}),Zn(a.title)||o.push({pointer:`/tools/${l}/title`,message:'Raycast is spelled "Raycast"',level:"warning"}),Zn(a.description)||o.push({pointer:`/tools/${l}/description`,message:'Raycast is spelled "Raycast"',level:"warning"})})}if(n.length>0)throw new Error(`${_e.resolve("package.json")}
78
+ `;return this.stop(),this.#i.write(p),this}};function Dp(e){return new yp(e)}var CE=(0,fe.blue)((0,fe.dim)("internal only"));function Jn(e,t,r){console.log(Yt[e]+t),typeof r?.exit<"u"&&process.exit(r.exit)}async function _r(e,t,r){if(!TE){Jn("wait",e);try{let o=await t();o&&console.log(o),Jn("success",e);return}catch(o){return Jn("error",e),r?.printError!==!1&&console.log((0,fe.red)(o.message)),o}}let n=Dp({spinner:"simpleDots",prefixText:Yt.wait+e}).start();try{let o=await t();n.stop(),Jn("success",e),o&&console.log(o)}catch(o){return n.stop(),Jn("error",e),r?.printError!==!1&&console.error(o.message),o}}var Yt={wait:`\u{1F550}${(0,fe.blue)("wait")} - `,info:`${process.env.GITHUB_ACTIONS==="true"?"\u2139\uFE0F":"\u2139\uFE0F "}${(0,fe.cyan)("info")} - `,success:`\u2705${(0,fe.green)("ready")} - `,warn:`${process.env.GITHUB_ACTIONS==="true"?"\u26A0\uFE0F":"\u26A0\uFE0F "}${(0,fe.yellow)("warn")} - `,error:`\u{1F4A5}${(0,fe.red)("error")} - `,event:`\u26A1\uFE0F${(0,fe.magenta)("event")} - `,paymentPrompt:`\u{1F4B0}${(0,fe.yellowBright)("plan")} - `},TE=!0;function RE(e,t){e||(Yt.wait=`${(0,fe.blue)("wait")} - `,Yt.info=`${(0,fe.cyan)("info")} - `,Yt.success=`${(0,fe.green)("ready")} - `,Yt.warn=`${(0,fe.yellow)("warn")} - `,Yt.error=`${(0,fe.red)("error")} - `,Yt.event=`${(0,fe.magenta)("event")} - `,Yt.paymentPrompt=`${(0,fe.yellowBright)("plan")} - `),t&&(TE=!1)}var wr=require("@oclif/core");var Ri=N(require("node:fs")),_p=N(require("node:path")),xE=N(require("node:os"));var AE=N(require("node:path")),$E=N(require("node:fs"));function bp(){let e;try{e=AE.resolve("package.json")}catch(r){throw new Error(`cannot resolve package manifest path: ${r}`)}let t;try{t=JSON.parse($E.readFileSync(e,"utf8"))}catch(r){throw new Error(`cannot read package manifest: ${r}`)}return t.name=t.name.replace(/^@workaround/g,""),t}var Wr={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"],t3="e69bae0ec90f5e838555",Kt={},PE;function OE(e){PE=e;try{Kt=JSON.parse(Ri.readFileSync(_p.join(n3(),"config.json"),"utf8"))}catch(t){if(t instanceof Error&&t.code==="ENOENT")return;throw new Error(`Failed to read config file: ${t}`)}}function Qn(e){switch(e){case"raycastApiURL":return process.env.RAY_APIURL||Kt.APIURL||Wr.url;case"raycastAccessToken":return process.env.RAY_TOKEN||Kt.Token||Kt.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||Kt.ClientID||Wr.clientID;case"githubClientId":return process.env.RAY_GithubClientID||Kt.GithubClientID||t3;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||Kt.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof Kt.Target>"u"?BE("release"):Kt.Target)}}function BE(e){switch(e){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 Qn("flavorName")}}function r3(){let e=BE(PE);return e==""?"raycast":`raycast-${e}`}function n3(){let e=_p.join(xE.default.homedir(),".config",r3());return Ri.mkdirSync(e,{recursive:!0}),e}var Tu=class extends wr.Command{static baseFlags={"exit-on-error":wr.Flags.boolean({default:!0,helpGroup:"GLOBAL",aliases:["exitOnError"],deprecateAliases:!0,summary:"Always exit with non-zero code on error",allowNo:!0}),emoji:wr.Flags.boolean({default:!1,helpGroup:"GLOBAL",summary:"Prefix output with emojis \u{1F308}"}),help:wr.Flags.boolean({default:!1,helpGroup:"GLOBAL",summary:"Show the help message for the command"}),"non-interactive":wr.Flags.boolean({char:"I",default:!1,helpGroup:"GLOBAL",summary:"Disable interactive outputs, useful for CI"}),target:wr.Flags.option({char:"t",description:"Raycast app target",helpGroup:"GLOBAL",multiple:!1,options:["debug","internal","release","x","x-debug","x-internal"],hidden:!0})()};flags;args;async init(){await super.init(),process.on("SIGINT",()=>process.exit(1));let{args:t,flags:r}=await this.parse({flags:this.ctor.flags,baseFlags:super.ctor.baseFlags,enableJsonFlag:this.ctor.enableJsonFlag,args:this.ctor.args,strict:this.ctor.strict});this.flags=r,this.args=t,OE(this.flags.target),RE(this.flags.emoji,this.flags["non-interactive"])}error(t,r){return r?.message&&t instanceof Error&&(t.message=`${r.message} (${t.message})`,delete r.message),super.error(t,r)}async catch(t){return super.catch(t)}async finally(t){return super.finally(t)}};var y3=require("@oclif/core");var h3=require("@oclif/core"),KE=N(hf()),g3=N(YE());async function Rp(e,t){let r;try{r=await(0,KE.default)(e,{method:t.method||"GET",headers:{"Content-Type":"application/json",Accept:"application/json",...t.token?{Authorization:`Bearer ${t.token}`}:void 0},body:t.body})}catch(n){throw new Error(`HTTP request: ${n.message}`)}if(!r.ok){switch(r.status){case 401:throw new Jt(r,"not authorized - please log in first using `npx ray login`");case 403:throw new Jt(r,"forbidden - you don't have permissions to perform the request");case 402:throw new Jt(r,"the limit of free commands has been reached")}let n=await r.text(),o;try{o=JSON.parse(n)}catch{throw new Jt(r,`HTTP error: ${r.status} - ${n}`)}throw Array.isArray(o.errors)&&o.errors.length>0?new Jt(r,`error: ${o.errors[0].status} - ${o.errors[0].title}`):new Jt(r,`HTTP error: ${r.status} - ${n}`)}return await r.json()}var Jt=class extends Error{constructor(t,r){let n=t.headers.get("X-Request-Id");n?super(`${r} (${t.url} RequestID: ${n})`):super(r),this.name="HTTPError"}};var JW=`${Wr.url}/sessions/success`,QW=`${Wr.url}/sessions/failure`;function Pu(e){let t=Qn("raycastApiURL"),r=Qn("raycastAccessToken");return Rp(`${t}/api/v1/users/${e}`,{token:r})}function JE(e){let t=Qn("raycastApiURL"),r=Qn("raycastAccessToken");return Rp(`${t}/api/v1/organizations/${e}`,{token:r})}var Bu=class e extends Tu{static description="Validate the extension manifest and metadata, and lint its source code";static flags={fix:Ou.Flags.boolean({char:"f",default:!1,description:"Attempt to fix linting issues"}),relaxed:Ou.Flags.boolean({char:"r",description:"Use relaxed linting mode to skip validation of: package.json schema, icons and metadata.",default:!1}),schema:Ou.Flags.string({char:"s",description:"Path to JSON schema for package.json validation "+CE,default:`${Wr.url}/schemas/extension.json`,hidden:!0})};async run(){let{flags:t}=await this.parse(e);await ev({skipOwner:!1,fix:t.fix,relaxed:t.relaxed,skipLockFiles:process.env.CI?.toLowerCase()!=="true",schema:t.schema})||this.error("linting issues found (tip: try re-running with '--fix')")}};async function ev(e){let t=!0;try{let r=bp();t=await D3(r,e),t=await b3(r,e)&&t,t=await _3(r,e)&&t,t=await w3(r,e)&&t}catch(r){console.error("error reading manifest:",r),t=!1}return t=await S3(e)&&t,t=await E3(e)&&t,t}async function D3(e,t){return await _r("validate package.json file",async()=>{let n=[],o=[];try{await Pu(e.author)}catch(i){i.message.includes("Couldn't find User")?n.push({pointer:"/author",message:`Invalid author "${e.author}". Use the Raycast username`,level:"error"}):n.push({pointer:"/author",message:`Invalid author "${e.author}". ${i.message}`,level:"error"})}if(await Promise.all((e.contributors||[]).map(async(i,a)=>{try{await Pu(i)}catch(l){l.message.includes("Couldn't find User")?n.push({pointer:"/contributors/"+a,message:`Invalid contributor "${i}". Use the Raycast username`,level:"error"}):n.push({pointer:"/contributors/"+a,message:`Invalid contributor "${i}". ${l.message}`,level:"error"})}i===e.author&&n.push({pointer:"/contributors/"+a,message:`Author "${i}" should not be added as a contributor`,level:"error"})})),await Promise.all((e.pastContributors||[]).map(async(i,a)=>{try{await Pu(i)}catch(l){l.message.includes("Couldn't find User")?n.push({pointer:"/pastContributors/"+a,message:`Invalid contributor "${i}". Use the Raycast username`,level:"error"}):n.push({pointer:"/pastContributors/"+a,message:`Invalid contributor "${i}". ${l.message}`,level:"error"})}})),e.owner&&!t.skipOwner)try{await JE(e.owner)}catch(i){i.message.includes("Couldn't find Organization")?n.push({pointer:"/owner",message:`Invalid owner "${e.owner}". Use the Raycast organization handle`,level:"error"}):n.push({pointer:"/owner",message:`Invalid owner "${e.owner}". ${i.message}`,level:"error"})}if(!t.relaxed){let i=new ZE.default({allErrors:!0});try{let a=await(await(0,XE.default)(t.schema)).json();delete a.$schema;let l=i.compile(a);l(e)||n.push(...(l.errors||[]).map(c=>({pointer:c.instancePath,message:c.message||"",level:"error"})))}catch(a){n.push({message:`Failed compiling JSON schema: ${a.message}`,level:"error"})}e.name.startsWith("@workaround/")&&o.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,Vr.titleCase)(e.title)!==e.title&&o.push({pointer:"/title",message:`Extension's title has to be Title Cased. Expected "${(0,Vr.titleCase)(e.title)}"`,level:"warning"}),Zn(e.title)||o.push({pointer:"/title",message:'Raycast is spelled "Raycast"',level:"warning"}),Zn(e.description)||o.push({pointer:"/description",message:'Raycast is spelled "Raycast"',level:"warning"}),e.commands.forEach((a,l)=>{(0,Vr.titleCase)(a.title)!==a.title&&o.push({pointer:`/commands/${l}/title`,message:`Command's title has to be Title Cased. Expected "${(0,Vr.titleCase)(a.title)}"`,level:"warning"}),Zn(a.title)||o.push({pointer:`/commands/${l}/title`,message:'Raycast is spelled "Raycast"',level:"warning"}),Zn(a.description)||o.push({pointer:`/commands/${l}/description`,message:'Raycast is spelled "Raycast"',level:"warning"})}),e.tools?.forEach((a,l)=>{(0,Vr.titleCase)(a.title)!==a.title&&o.push({pointer:`/tools/${l}/title`,message:`Tool's title has to be Title Cased. Expected "${(0,Vr.titleCase)(a.title)}"`,level:"warning"}),Zn(a.title)||o.push({pointer:`/tools/${l}/title`,message:'Raycast is spelled "Raycast"',level:"warning"}),Zn(a.description)||o.push({pointer:`/tools/${l}/description`,message:'Raycast is spelled "Raycast"',level:"warning"})})}if(n.length>0)throw new Error(`${_e.resolve("package.json")}
79
79
  ${Qt(n.concat(o))}`);o.length>0&&console.log((0,Iu.yellow)(`${_e.resolve("package.json")}
80
80
  ${Qt(n.concat(o))}`))})===void 0}async function b3(e,t){if(t.relaxed||t.skipLockFiles)return!0;let r=await _r("validate package-lock.json",async()=>{let n=_e.resolve("package-lock.json"),o;try{o=require(n)}catch{throw new Error("missing package-lock.json. Run 'npm install' to generate the file")}if(o.lockfileVersion===1)throw new Error(`${n}
81
81
  4:20 error Wrong 'lockfileVersion'. Version '${o.lockfileVersion}' is unsupported. Update to npm v7 or higher`)});return r?!1:(r=await _r("validate other lock files",async()=>{if(Xe.existsSync("yarn.lock"))throw new Error("yarn is not supported. Remove the `yarn.lock` file and run `npm install` instead");if(Xe.existsSync("pnpm-lock.yaml"))throw new Error("pnpm is not supported. Remove the `pnpm-lock.yaml` file and run `npm install` instead");if(Xe.existsSync("shrinkwrap.json"))throw new Error("shrinkwrap is not supported. Remove the `shrinkwrap.json` file and run `npm install` instead");if(Xe.existsSync("npm-shrinkwrap.json"))throw new Error("shrinkwrap is not supported. Remove the `npm-shrinkwrap.json` file and run `npm install` instead")}),r===void 0)}async function _3(e,t){return t.relaxed?!0:await _r("validate extension icons",async()=>{let n=[],o=_e.resolve(_e.join("assets",e.icon)),i=Gr(o,{type:"icon"});if(i&&n.push(`${o}
@@ -1 +1 @@
1
- "use strict";var D=Object.create;var m=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var S=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),U=(n,e)=>{for(var s in e)m(n,s,{get:e[s],enumerable:!0})},A=(n,e,s,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of O(e))!F.call(n,i)&&i!==s&&m(n,i,{get:()=>e[i],enumerable:!(c=L(e,i))||c.enumerable});return n};var h=(n,e,s)=>(s=n!=null?D(R(n)):{},A(e||!n||!n.__esModule?m(s,"default",{value:n,enumerable:!0}):s,n)),j=n=>A(m({},"__esModule",{value:!0}),n);var $=S((Q,B)=>{var J=require("node:tty"),H=J?.WriteStream?.prototype?.hasColors?.()??!1,t=(n,e)=>{if(!H)return i=>i;let s=`\x1B[${n}m`,c=`\x1B[${e}m`;return i=>{let f=i+"",d=f.indexOf(c);if(d===-1)return s+f+c;let w=s,p=0;for(;d!==-1;)w+=f.slice(p,d)+s,p=d+c.length,d=f.indexOf(c,p);return w+=f.slice(p)+c,w}},r={};r.reset=t(0,0);r.bold=t(1,22);r.dim=t(2,22);r.italic=t(3,23);r.underline=t(4,24);r.overline=t(53,55);r.inverse=t(7,27);r.hidden=t(8,28);r.strikethrough=t(9,29);r.black=t(30,39);r.red=t(31,39);r.green=t(32,39);r.yellow=t(33,39);r.blue=t(34,39);r.magenta=t(35,39);r.cyan=t(36,39);r.white=t(37,39);r.gray=t(90,39);r.bgBlack=t(40,49);r.bgRed=t(41,49);r.bgGreen=t(42,49);r.bgYellow=t(43,49);r.bgBlue=t(44,49);r.bgMagenta=t(45,49);r.bgCyan=t(46,49);r.bgWhite=t(47,49);r.bgGray=t(100,49);r.redBright=t(91,39);r.greenBright=t(92,39);r.yellowBright=t(93,39);r.blueBright=t(94,39);r.magentaBright=t(95,39);r.cyanBright=t(96,39);r.whiteBright=t(97,39);r.bgRedBright=t(101,49);r.bgGreenBright=t(102,49);r.bgYellowBright=t(103,49);r.bgBlueBright=t(104,49);r.bgMagentaBright=t(105,49);r.bgCyanBright=t(106,49);r.bgWhiteBright=t(107,49);B.exports=r});var V={};U(V,{default:()=>x});module.exports=j(V);var g=require("@oclif/core");var u=h(require("node:fs")),y=h(require("node:path")),T=h(require("node:os"));var I={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"],_="e69bae0ec90f5e838555",a={},E;function C(n){E=n;try{a=JSON.parse(u.readFileSync(y.join(v(),"config.json"),"utf8"))}catch(e){if(e instanceof Error&&e.code==="ENOENT")return;throw new Error(`Failed to read config file: ${e}`)}}function Y(n){switch(n){case"raycastApiURL":return process.env.RAY_APIURL||a.APIURL||I.url;case"raycastAccessToken":return process.env.RAY_TOKEN||a.Token||a.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||a.ClientID||I.clientID;case"githubClientId":return process.env.RAY_GithubClientID||a.GithubClientID||_;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||a.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof a.Target>"u"?k("release"):a.Target)}}function N(n,e){switch(n){case"raycastApiURL":e===void 0?delete a.APIURL:a.APIURL=e;break;case"raycastAccessToken":e===void 0?delete a.Token:a.Token=e,delete a.AccessToken;break;case"raycastClientId":e===void 0?delete a.ClientID:a.ClientID=e;break;case"githubAccessToken":e===void 0?delete a.GithubAccessToken:a.GithubAccessToken=e;break;case"flavorName":e===void 0?delete a.Target:a.Target=e;break}let s=v();u.writeFileSync(y.join(s,"config.json"),JSON.stringify(a,null," "),"utf8")}function k(n){switch(n){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 Y("flavorName")}}function M(){let n=k(E);return n==""?"raycast":`raycast-${n}`}function v(){let n=y.join(T.default.homedir(),".config",M());return u.mkdirSync(n,{recursive:!0}),n}var o=h($());var ee=(0,o.blue)((0,o.dim)("internal only"));function P(n,e,s){console.log(l[n]+e),typeof s?.exit<"u"&&process.exit(s.exit)}var l={wait:`\u{1F550}${(0,o.blue)("wait")} - `,info:`${process.env.GITHUB_ACTIONS==="true"?"\u2139\uFE0F":"\u2139\uFE0F "}${(0,o.cyan)("info")} - `,success:`\u2705${(0,o.green)("ready")} - `,warn:`${process.env.GITHUB_ACTIONS==="true"?"\u26A0\uFE0F":"\u26A0\uFE0F "}${(0,o.yellow)("warn")} - `,error:`\u{1F4A5}${(0,o.red)("error")} - `,event:`\u26A1\uFE0F${(0,o.magenta)("event")} - `,paymentPrompt:`\u{1F4B0}${(0,o.yellowBright)("plan")} - `},K=!0;function G(n,e){n||(l.wait=`${(0,o.blue)("wait")} - `,l.info=`${(0,o.cyan)("info")} - `,l.success=`${(0,o.green)("ready")} - `,l.warn=`${(0,o.yellow)("warn")} - `,l.error=`${(0,o.red)("error")} - `,l.event=`${(0,o.magenta)("event")} - `,l.paymentPrompt=`${(0,o.yellowBright)("plan")} - `),e&&(K=!1)}var b=class extends g.Command{static baseFlags={"exit-on-error":g.Flags.boolean({default:!0,helpGroup:"GLOBAL",aliases:["exitOnError"],deprecateAliases:!0,summary:"Always exit with non-zero code on error",allowNo:!0}),emoji:g.Flags.boolean({default:!1,helpGroup:"GLOBAL",summary:"Prefix output with emojis \u{1F308}"}),help:g.Flags.boolean({default:!1,helpGroup:"GLOBAL",summary:"Show the help message for the command"}),"non-interactive":g.Flags.boolean({char:"I",default:!1,helpGroup:"GLOBAL",summary:"Disable interactive outputs, useful for CI"}),target:g.Flags.option({char:"t",description:"Raycast app target",helpGroup:"GLOBAL",multiple:!1,options:["debug","internal","release","x","x-debug","x-internal"],hidden:!0})()};flags;args;async init(){await super.init(),process.on("SIGINT",()=>process.exit(1));let{args:e,flags:s}=await this.parse({flags:this.ctor.flags,baseFlags:super.ctor.baseFlags,enableJsonFlag:this.ctor.enableJsonFlag,args:this.ctor.args,strict:this.ctor.strict});this.flags=s,this.args=e,C(this.flags.target),G(this.flags.emoji,this.flags["non-interactive"])}error(e,s){return s?.message&&e instanceof Error&&(e.message=`${s.message} (${e.message})`,delete s.message),super.error(e,s)}async catch(e){return super.catch(e)}async finally(e){return super.finally(e)}};var x=class extends b{static description="Log out of your Raycast account";async run(){try{N("raycastAccessToken",void 0)}catch(e){this.error(`failed clearing token (${e.message})`)}P("success","logged out successfully")}};
1
+ "use strict";var D=Object.create;var m=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var S=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),U=(n,e)=>{for(var s in e)m(n,s,{get:e[s],enumerable:!0})},A=(n,e,s,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of O(e))!F.call(n,i)&&i!==s&&m(n,i,{get:()=>e[i],enumerable:!(c=L(e,i))||c.enumerable});return n};var h=(n,e,s)=>(s=n!=null?D(R(n)):{},A(e||!n||!n.__esModule?m(s,"default",{value:n,enumerable:!0}):s,n)),j=n=>A(m({},"__esModule",{value:!0}),n);var $=S((Q,B)=>{var J=require("node:tty"),H=J?.WriteStream?.prototype?.hasColors?.()??!1,t=(n,e)=>{if(!H)return i=>i;let s=`\x1B[${n}m`,c=`\x1B[${e}m`;return i=>{let f=i+"",d=f.indexOf(c);if(d===-1)return s+f+c;let w=s,p=0;for(;d!==-1;)w+=f.slice(p,d)+s,p=d+c.length,d=f.indexOf(c,p);return w+=f.slice(p)+c,w}},r={};r.reset=t(0,0);r.bold=t(1,22);r.dim=t(2,22);r.italic=t(3,23);r.underline=t(4,24);r.overline=t(53,55);r.inverse=t(7,27);r.hidden=t(8,28);r.strikethrough=t(9,29);r.black=t(30,39);r.red=t(31,39);r.green=t(32,39);r.yellow=t(33,39);r.blue=t(34,39);r.magenta=t(35,39);r.cyan=t(36,39);r.white=t(37,39);r.gray=t(90,39);r.bgBlack=t(40,49);r.bgRed=t(41,49);r.bgGreen=t(42,49);r.bgYellow=t(43,49);r.bgBlue=t(44,49);r.bgMagenta=t(45,49);r.bgCyan=t(46,49);r.bgWhite=t(47,49);r.bgGray=t(100,49);r.redBright=t(91,39);r.greenBright=t(92,39);r.yellowBright=t(93,39);r.blueBright=t(94,39);r.magentaBright=t(95,39);r.cyanBright=t(96,39);r.whiteBright=t(97,39);r.bgRedBright=t(101,49);r.bgGreenBright=t(102,49);r.bgYellowBright=t(103,49);r.bgBlueBright=t(104,49);r.bgMagentaBright=t(105,49);r.bgCyanBright=t(106,49);r.bgWhiteBright=t(107,49);B.exports=r});var V={};U(V,{default:()=>x});module.exports=j(V);var u=require("@oclif/core");var g=h(require("node:fs")),y=h(require("node:path")),T=h(require("node:os"));var I={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"],_="e69bae0ec90f5e838555",o={},E;function C(n){E=n;try{o=JSON.parse(g.readFileSync(y.join(v(),"config.json"),"utf8"))}catch(e){if(e instanceof Error&&e.code==="ENOENT")return;throw new Error(`Failed to read config file: ${e}`)}}function Y(n){switch(n){case"raycastApiURL":return process.env.RAY_APIURL||o.APIURL||I.url;case"raycastAccessToken":return process.env.RAY_TOKEN||o.Token||o.AccessToken||"";case"raycastClientId":return process.env.RAY_CLIENT_ID||o.ClientID||I.clientID;case"githubClientId":return process.env.RAY_GithubClientID||o.GithubClientID||_;case"githubAccessToken":return process.env.GITHUB_ACCESS_TOKEN||o.GithubAccessToken||"";case"flavorName":return process.env.RAY_Target||(typeof o.Target>"u"?k("release"):o.Target)}}function N(n,e){switch(n){case"raycastApiURL":e===void 0?delete o.APIURL:o.APIURL=e;break;case"raycastAccessToken":e===void 0?delete o.Token:o.Token=e,delete o.AccessToken;break;case"raycastClientId":e===void 0?delete o.ClientID:o.ClientID=e;break;case"githubAccessToken":e===void 0?delete o.GithubAccessToken:o.GithubAccessToken=e;break;case"flavorName":e===void 0?delete o.Target:o.Target=e;break}let s=v();g.writeFileSync(y.join(s,"config.json"),JSON.stringify(o,null," "),"utf8")}function k(n){switch(n){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 Y("flavorName")}}function M(){let n=k(E);return n==""?"raycast":`raycast-${n}`}function v(){let n=y.join(T.default.homedir(),".config",M());return g.mkdirSync(n,{recursive:!0}),n}var a=h($());var ee=(0,a.blue)((0,a.dim)("internal only"));function P(n,e,s){console.log(l[n]+e),typeof s?.exit<"u"&&process.exit(s.exit)}var l={wait:`\u{1F550}${(0,a.blue)("wait")} - `,info:`${process.env.GITHUB_ACTIONS==="true"?"\u2139\uFE0F":"\u2139\uFE0F "}${(0,a.cyan)("info")} - `,success:`\u2705${(0,a.green)("ready")} - `,warn:`${process.env.GITHUB_ACTIONS==="true"?"\u26A0\uFE0F":"\u26A0\uFE0F "}${(0,a.yellow)("warn")} - `,error:`\u{1F4A5}${(0,a.red)("error")} - `,event:`\u26A1\uFE0F${(0,a.magenta)("event")} - `,paymentPrompt:`\u{1F4B0}${(0,a.yellowBright)("plan")} - `},K=!0;function G(n,e){n||(l.wait=`${(0,a.blue)("wait")} - `,l.info=`${(0,a.cyan)("info")} - `,l.success=`${(0,a.green)("ready")} - `,l.warn=`${(0,a.yellow)("warn")} - `,l.error=`${(0,a.red)("error")} - `,l.event=`${(0,a.magenta)("event")} - `,l.paymentPrompt=`${(0,a.yellowBright)("plan")} - `),e&&(K=!1)}var b=class extends u.Command{static baseFlags={"exit-on-error":u.Flags.boolean({default:!0,helpGroup:"GLOBAL",aliases:["exitOnError"],deprecateAliases:!0,summary:"Always exit with non-zero code on error",allowNo:!0}),emoji:u.Flags.boolean({default:!1,helpGroup:"GLOBAL",summary:"Prefix output with emojis \u{1F308}"}),help:u.Flags.boolean({default:!1,helpGroup:"GLOBAL",summary:"Show the help message for the command"}),"non-interactive":u.Flags.boolean({char:"I",default:!1,helpGroup:"GLOBAL",summary:"Disable interactive outputs, useful for CI"}),target:u.Flags.option({char:"t",description:"Raycast app target",helpGroup:"GLOBAL",multiple:!1,options:["debug","internal","release","x","x-debug","x-internal"],hidden:!0})()};flags;args;async init(){await super.init(),process.on("SIGINT",()=>process.exit(1));let{args:e,flags:s}=await this.parse({flags:this.ctor.flags,baseFlags:super.ctor.baseFlags,enableJsonFlag:this.ctor.enableJsonFlag,args:this.ctor.args,strict:this.ctor.strict});this.flags=s,this.args=e,C(this.flags.target),G(this.flags.emoji,this.flags["non-interactive"])}error(e,s){return s?.message&&e instanceof Error&&(e.message=`${s.message} (${e.message})`,delete s.message),super.error(e,s)}async catch(e){return super.catch(e)}async finally(e){return super.finally(e)}};var x=class extends b{static description="Log out of your Raycast account";async run(){try{N("raycastAccessToken",void 0)}catch(e){this.error(`failed clearing token (${e.message})`)}P("success","logged out successfully")}};