'use strict' ; import { ExtensionContext , window , MessageItem } from 'vscode' ; import { ValDownloader } from './ValDownloader' ; const NEVER_DOWNLOAD_VAL = 'neverDownloadVal' ; export class ValDownloadReminder { private downloadValLater = false ; constructor ( private context , private val ) { } async suggestValDownloadConfigurationIfAbsent ( ) { const isInstalled = await this . val . isInstalled ( ) ; if ( ! isInstalled ) { this . suggestValDownloadConfiguration ( true ) ; } } async suggestValDownloadConfiguration ( showNever ) { if ( this . downloadValLater || this . context . globalState . get ( NEVER_DOWNLOAD_VAL ) ) { return ; } const downloadValNow = { title : "Download now..." } ; const downloadValNever = { title : "Never" } ; const downloadValLater = { title : "Later" , isCloseAffordance : true } ; const options = [ downloadValNow , downloadValLater ] ; if ( showNever ) { options . splice ( 2 , 0 , downloadValNever ) ; } const message = "To enable all features, get PDDL parser and plan validator and evaluator. Download the [build](https://dev.azure.com/schlumberger/ai-planning-validation) of [VAL tools](https://github.com/KCL-Planning/VAL)." ; const choice = await window . showInformationMessage ( message , ... options ) ; switch ( choice ) { case downloadValNow : this . launchDownload ( ) ; break ; case downloadValLater : this . downloadValLater = true ; break ; case downloadValNever : this . context . globalState . update ( NEVER_DOWNLOAD_VAL , true ) ; break ; default : break ; } } async launchDownload ( ) { try { await this . val . downloadConfigureAndCleanUp ( ) ; } catch ( ex ) { const error = ex as Error ; window . showErrorMessage ( error . message ?? "" + error ) ; } } }