define(["serverNotifications","events","globalize","require"],function(serverNotifications,events,globalize,require){"use strict";function sendToast(text){require(["toast"],function(toast){toast(text)})}function showPackageInstallNotification(apiClient,installation,status){apiClient.getCurrentUser().then(function(user){var notification;user.Policy.IsAdministrator&&(notification={},"completed"===status?notification.title=globalize.translate("PackageInstallCompleted").replace("{0}",installation.Name+" "+installation.Version):"cancelled"===status?notification.title=globalize.translate("PackageInstallCancelled").replace("{0}",installation.Name+" "+installation.Version):"failed"===status?notification.title=globalize.translate("PackageInstallFailed").replace("{0}",installation.Name+" "+installation.Version):"progress"===status&&(notification.title=globalize.translate("InstallingPackage").replace("{0}",installation.Name+" "+installation.Version)),notification.title&&sendToast(notification.title))})}events.on(serverNotifications,"PackageInstallationCompleted",function(e,apiClient,data){showPackageInstallNotification(apiClient,data,"completed")}),events.on(serverNotifications,"PackageInstallationFailed",function(e,apiClient,data){showPackageInstallNotification(apiClient,data,"failed")}),events.on(serverNotifications,"PackageInstallationCancelled",function(e,apiClient,data){showPackageInstallNotification(apiClient,data,"cancelled")}),events.on(serverNotifications,"PackageInstalling",function(e,apiClient,data){showPackageInstallNotification(apiClient,data,"progress")}),events.on(serverNotifications,"ServerShuttingDown",function(e,apiClient,data){sendToast(globalize.translate("ServerNameIsShuttingDown",apiClient.serverInfo().Name))}),events.on(serverNotifications,"ServerRestarting",function(e,apiClient,data){sendToast(globalize.translate("ServerNameIsRestarting",apiClient.serverInfo().Name))}),events.on(serverNotifications,"RestartRequired",function(e,apiClient){sendToast(globalize.translate("PleaseRestartServerName",apiClient.serverInfo().Name))})});