/**
 * The Office apps which can host Office Add-ins.
 */ export enum OfficeApp { Excel = "excel" , OneNote = "onenote" , Outlook = "outlook" , PowerPoint = "powerpoint" , Project = "project" , Word = "word" } const officeApps = Object . keys ( OfficeApp ) . map < OfficeApp > ( ( key ) => parseOfficeApp ( key ) ) ; param host export function getOfficeAppForManifestHost ( host ) { switch ( host . toLowerCase ( ) ) { case "document" : return OfficeApp . Word ; case "mailbox" : return OfficeApp . Outlook ; case "notebook" : return OfficeApp . OneNote ; case "presentation" : return OfficeApp . PowerPoint ; case "project" : return OfficeApp . Project ; case "workbook" : return OfficeApp . Excel ; default : return undefined ; } } param app export function getOfficeAppName ( app ) { switch ( app ) { case OfficeApp . Excel : return "Excel" ; case OfficeApp . OneNote : return "OneNote" ; case OfficeApp . Outlook : return "Outlook" ; case OfficeApp . PowerPoint : return "PowerPoint" ; case OfficeApp . Project : return "Project" ; case OfficeApp . Word : return "Word" ; default : throw new Error ( `Unable to provide name for Office app "${ app }"` ) ; } } param apps export function getOfficeAppNames ( apps ) { return apps . map ( ( app ) => getOfficeAppName ( app ) ) ; } /**
 * Returns the Office apps that support Office add-ins.
 */ export function getOfficeApps ( ) { return officeApps ; } param hosts export function getOfficeAppsForManifestHosts ( hosts ? ) { const apps = [ ] ; if ( hosts ) { hosts . forEach ( ( host ) => { const app = getOfficeAppForManifestHost ( host ) ; if ( app ) { apps . push ( app ) ; } } ) ; } return apps ; } param value throws export function parseOfficeApp ( value ) { const officeApp = toOfficeApp ( value ) ; if ( ! officeApp ) { throw new Error ( `"${ value }" is not a valid Office app.` ) ; } return officeApp ; } param input throws export function parseOfficeApps ( input ) { if ( input . trim ( ) . toLowerCase ( ) === "all" ) { return getOfficeApps ( ) ; } else { return input . split ( "," ) . map < OfficeApp > ( ( appString ) => parseOfficeApp ( appString ) ) ; } } param value export function toOfficeApp ( value ) { switch ( value ? value . trim ( ) . toLowerCase ( ) : value ) { case OfficeApp . Excel : return OfficeApp . Excel ; case OfficeApp . OneNote : return OfficeApp . OneNote ; case OfficeApp . Outlook : return OfficeApp . Outlook ; case OfficeApp . PowerPoint : return OfficeApp . PowerPoint ; case OfficeApp . Project : return OfficeApp . Project ; case OfficeApp . Word : return OfficeApp . Word ; default : return undefined ; } }