define(['jquery','mage/translate','Magento_Customer/js/customer-data','Magento_Paypal/js/in-context/express-checkout-smart-buttons','Magento_Ui/js/modal/alert','mage/cookies'],function($,$t,customerData,checkoutSmartButtons,alert){'use strict';return{defaults:{paymentActionError:$t('Something went wrong with your request. Please try again later.'),signInMessage:$t('To check out, please sign in with your email address.')},renderPayPalButtons:function(element){checkoutSmartButtons(this.prepareClientConfig(),element);},validate:function(actions){this.actions=actions||this.actions;},onClick:function(){},beforePayment:function(resolve,reject){return $.Deferred().resolve();},afterPayment:function(res,resolve,reject){if(res.success){return resolve(res.token);} return reject(new Error(res['error_message']));},catchPayment:function(err,resolve,reject){this.addAlert(this.paymentActionError);reject(err);},beforeOnAuthorize:function(resolve,reject,actions){$('body').trigger('processStart');return $.Deferred().resolve();},afterOnAuthorize:function(res,resolve,reject,actions){$('body').trigger('processStop');if(res.success){resolve();return actions.redirect(res.redirectUrl);} return reject(new Error(res['error_message']));},catchOnAuthorize:function(err,resolve,reject){$('body').trigger('processStop');this.addAlert(this.paymentActionError);reject(err);},onCancel:function(data,actions){$('body').trigger('processStop');actions.redirect(this.clientConfig.onCancelUrl);},onError:function(err){},addError:function(message,type){type=type||'error';customerData.set('messages',{messages:[{type:type,text:message}],'data_id':Math.floor(Date.now()/ 1000)});},addAlert:function(message){alert({content:message});},getButtonId:function(){return this.inContextId;},prepareClientConfig:function(){this.clientConfig.rendererComponent=this;this.clientConfig.formKey=$.mage.cookies.get('form_key');return this.clientConfig;}};});