/*! Copyright (c) Epic Systems Corporation 2012 - 2018 */
var WP=WP||{};void 0===WP.FdiUtils&&(WP.FdiUtils={}),WP.FdiUtils.handleFDILink=function WP$FdiUtils$handleFDILink(e){var t,i,n;t=$afe.jq(e.target),e.preventDefault(),(i=t.closest("[data-fdi-context]")).length>0&&(n=i.safeAttr("data-fdi-context"),WP.FdiUtils.ExecuteFDILink(n))},WP.FdiUtils.ExecuteFDILink=function WP$FdiUtils$ExecuteFDILink(e){var t,i,n,d,l,o,a;l="",""!==e&&(i=(t=JSON.parse(e)).fdi,n=t.csn,d=t.ord,o=t.DocumentID,a=t.eptId,delete t.fdi,delete t.csn,delete t.ord,delete t.DocumentID,delete t.eptId,l=WP.FdiUtils.buildFDILinkParamString(i,n,d,t,o,a)),getCSRFTokenAsQS((function(e){$.ajax({url:makeLink("Extensibility/Redirection/FdiData"+l),type:"POST",dataType:"json",data:e,success:function(e){WP.FdiUtils.fdiJSONSuccess(e,l)}})}))},WP.FdiUtils.fdiJSONSuccess=function WP$FdiUtils$fdiJSONSuccess(e,t){var i,n,d,l;switch(i=e.url,n=e.launchmode,l=e.IsFdiPost,4===n&&(i=makeLink(i)),l&&(i=makeLink("Extensibility/Redirection/FdiRedirection"+t)),n){case 1:case 4:window.location.href=i;break;default:null!=(d=openWindow(i,"","",null,!0,!1,!0))&&void 0!==d||WP.DOM.Browser.isIE||WP.DOM.Browser.isLegacyEdge||WP.FdiUtils.PopupBlocked(i)}},WP.FdiUtils.PopupBlocked=function WP$FdiUtils$PopupBlocked(e){var t;$$WP.Strings.setDefaultNamespace("Global"),(t=new $$WPComp.MessageComponent({TitleText:$$WP.Strings.get("BlockedPopupTitle"),Message:$$WP.Strings.get("BlockedPopupMessageWithLink"),ToolbarButtons:[new $$WPComp.ComplexObjects.Button($$WP.Strings.get("BlockedPopupLaunchBtnTitle"),null,"completeworkflow","LaunchLink"),new $$WPComp.ComplexObjects.Button($$WP.Strings.get("BlockedPopupCancelBtnTitle"),null,"cancelworkflow","")],IsCloseable:!0})).addEventListener("click",$.proxy(this.LaunchClickHandler,this,e)),$$WPUtil.quickPopup(t)},WP.FdiUtils.LaunchClickHandler=function WP$FdiTuils$LaunchClickHandler(e,t){t&&t.dataId&&"toolbarLaunchLink"===t.dataId&&openWindow(e,"","",null,!0,!1,!0)},WP.FdiUtils.buildFDILinkParamString=function WP$FdiUtils$buildFDILinkParamString(e,t,i,n,d,l){var o;return o="",e?(o=$$WPUtil.addUrlParameter(o,"fdi",encodeURIComponent(e)),t&&(o=$$WPUtil.addUrlParameter(o,"csn",encodeURIComponent(t))),i&&(o=$$WPUtil.addUrlParameter(o,"ord",encodeURIComponent(i))),$.isEmptyObject(n)||(o=$$WPUtil.addUrlParameter(o,"extra",encodeURIComponent(JSON.stringify(n)))),d&&(o=$$WPUtil.addUrlParameter(o,"DocumentID",encodeURIComponent(d))),l&&(o=$$WPUtil.addUrlParameter(o,"eptID",encodeURIComponent(l))),o):""};