erNames.AsyncContext],c.preprocess&&(l=c.preprocess(l));var u=new window.Excel.RequestContext,d=c.call(u,l);u.sync().then(function(){var e=d.value,t=e.status;delete e.status,delete e["@odata.type"],c.postprocess&&(e=c.postprocess(e,l)),0!=t&&(e=m.DDA.ErrorCodeManager.getErrorArgs(t)),b(i,t,e)}).catch(function(e){b(i,13991,null)})}else{var f;f=m.HostParameterMap.toHost(s,i);var p=(new Date).getTime();o({dispId:s,hostCallArgs:f,onCalling:function(){},onReceiving:function(){},onComplete:function(e,t){var n;n=0==e?m.HostParameterMap.fromHost(s,t):t;var o=a.processResponse(e,n,r,i);b(i,e,o),m.AppTelemetry&&m.AppTelemetry.onMethodDone(s,f,Math.abs((new Date).getTime()-p),e)}})}}catch(e){h(e,a,t,i)}},e.AddEventHandler=function(t,n,o,e){var r,i,a,s=!1;function c(e){var t;0==e&&((s?n.addObjectEventHandler(i,r[m.ParameterNames.Id],a):n.addEventHandler(i,a))||(e=13991));0!=e&&(t=m.DDA.ErrorCodeManager.getErrorArgs(e)),b(r,e,t)}try{var l=m.AsyncMethodCalls.get(m.AsyncMethods.AddHandlerAsync);if(r=l.verifyAndExtractCall(t,o,n),i=r[m.ParameterNames.EventType],a=r[m.ParameterNames.Handler],e)return void c(0);var u=y()[i],d=(s=g(u))?r[m.ParameterNames.Id]:o.id||"";if(0==(s?n.getObjectEventHandlerCount(i,d):n.getEventHandlerCount(i)))v("registerEventAsync")({eventType:i,dispId:u,targetId:d,onCalling:function(){},onReceiving:function(){},onComplete:c,onEvent:function(e){var t=m.HostParameterMap.fromHost(u,e);s?n.fireObjectEvent(d,m.manufactureEventArgs(i,d,t)):n.fireEvent(m.manufactureEventArgs(i,o,t))}});else c(0)}catch(e){h(e,l,t,r)}},e.RemoveEventHandler=function(t,e,n){var o,r,i,a=!1;function s(e){var t;0!=e&&(t=m.DDA.ErrorCodeManager.getErrorArgs(e)),b(o,e,t)}try{var c=m.AsyncMethodCalls.get(m.AsyncMethods.RemoveHandlerAsync);r=(o=c.verifyAndExtractCall(t,n,e))[m.ParameterNames.EventType],i=o[m.ParameterNames.Handler];var l,u,d=y()[r],f=(a=g(d))?o[m.ParameterNames.Id]:n.id||"";l=null===i?(u=a?e.clearObjectEventHandlers(r,f):e.clearEventHandlers(r),0):(u=a?e.removeObjectEventHandler(r,f,i):e.removeEventHandler(r,i))?0:5003;var p=a?e.getObjectEventHandlerCount(r,f):e.getEventHandlerCount(r);if(u&&0==p)v("unregisterEventAsync")({eventType:r,dispId:d,targetId:f,onCalling:function(){},onReceiving:function(){},onComplete:s});else s(l)}catch(e){h(e,c,t,o)}},e.OpenDialog=function(t,r,i){var o,a,s=m.EventType.DialogMessageReceived,c=m.EventType.DialogEventReceived;function e(e){if(0!=e)n=m.DDA.ErrorCodeManager.getErrorArgs(e);else{var t={};t.id=a,t.data=r;var n=l.processResponse(e,t,i,o);m.DialogShownStatus.hasDialogShown=!0,r.clearEventHandlers(s),r.clearEventHandlers(c)}b(o,e,n)}try{if(null!=s&&null!=c||e(5e3),null==m.AsyncMethods.DisplayDialogAsync)return void e(5001);var l=m.AsyncMethodCalls.get(m.AsyncMethods.DisplayDialogAsync);o=l.verifyAndExtractCall(t,i,r);var u=y()[s],n=v("openDialog");a=JSON.stringify(o),m.DialogShownStatus.hasDialogShown||(r.clearQueuedEvent(s),r.clearQueuedEvent(c),r.clearQueuedEvent(m.EventType.DialogParentMessageReceived)),n({eventType:s,dispId:u,targetId:a,onCalling:function(){},onReceiving:function(){},onComplete:e,onEvent:function(e){var t=m.HostParameterMap.fromHost(u,e),n=m.manufactureEventArgs(s,i,t);if(n.type==c){m.DDA.ErrorCodeManager.getErrorArgs(n.error);var o={};o.code=status||5001,n.error=new m.DDA.Error(o[m.DDA.AsyncResultEnum.ErrorProperties.Name],o[m.DDA.AsyncResultEnum.ErrorProperties.Message],o[m.DDA.AsyncResultEnum.Err