function toggleCardEdit(n,t){t===!0?($(".accountCard[data-card="+n+"] span[data-card-mode=read]").hide(),$(".accountCard[data-card="+n+"] span[data-card-mode=write]").show(),$(".accountCard[data-card="+n+"] input[type=text]").focus()):($(".accountCard[data-card="+n+"] span[data-card-mode=read]").show(),$(".accountCard[data-card="+n+"] span[data-card-mode=write]").hide())}function cardEdited(n){var t=n;$("#"+t.index+"_err").empty();$(".accountCard[data-card="+t.index+"] span[data-card-mode=read] label[data-card-label]").text(t.cardName);t.error?($("#"+t.index+"_err").append(t.error),$(".accountCard[data-card="+t.index+"] input[type=text][name=cardName]").focus()):toggleCardEdit(t.index,!1)}function saveCardName(n){n.preventDefault();var t=$(n.currentTarget),i=t.serialize();$.ajax({type:t.prop("method"),url:t.prop("action"),data:i}).done(function(n){cardEdited(n)})}function initToggleRequiredInsuranceImages(){$("#MedicalInsurancePayer, #BIN").on("input propertychange paste",function(){let n=($("#isPrescImageSaved").val()||"false").toLowerCase()==="true",t=($("#isMedImageSaved").val()||"false").toLowerCase()==="true";$("#MedicalInsurancePayer").val().length>0?$("input[name=InsuranceCardMedical]").data("rule-required",!t):($("input[name=InsuranceCardMedical]").data("rule-required",!1),$("[data-valmsg-for=InsuranceCardMedical]").removeClass("field-validation-error").addClass("field-validation-valid").empty());$("#BIN").val().length>0?$("input[name=InsuranceCardPrescription]").data("rule-required",!n):($("input[name=InsuranceCardPrescription]").data("rule-required",!1),$("[data-valmsg-for=InsuranceCardPrescription]").removeClass("field-validation-error").addClass("field-validation-valid").empty())})}function showOrHidePaidQuestion(){let t=$("#paid");if(!(t.length<1)){let r=t.data("suppress-groups");if(r){let i="",n=$("input[name=CardId]");n.length>0&&(n.attr("type")==="hidden"?i=n.val():n.attr("type")==="radio"&&(i=n.filter(":checked").val()));let u=r.indexOf(i.split("_")[0])>-1;u?t.hide():t.show()}}}function initFiles(){$("input[type=file].file").on("change",function(n){if(f=n.target,sel="span[data-input-id="+n.target.id+"]",$(sel).empty(),f.files.length>0){$("form").data("validator")&&$("form").data("validator").element(f);var i=!(f.files[0].name.substr(f.files[0].name.lastIndexOf(".")).toLowerCase()===".pdf"),t="";t=i?'<span class="text-nowrap"><span class="glyphicon glyphicon-paperclip"><\/span>&nbsp;<a href="#" class="showAttachment">'+displayName(f.files[0].name,26)+"<\/a>":'<span class="text-nowrap"><span class="glyphicon glyphicon-paperclip"><\/span>&nbsp;<span class="showAttachment">'+displayName(f.files[0].name,26)+"<\/span>";t=t+'<a href="#" class="remAttachment"><span class="glyphicon glyphicon-remove" style="display:inline-block;margin-left: 12px;color: red;"><\/span><\/a><\/span>';$(sel).append(t);i&&$(sel+" a.showAttachment").click(function(n){n.preventDefault();var t=$(n.target).closest("[data-input-id]").data("input-id");showFile(t)});$(sel+" a.remAttachment").click(function(n){n.preventDefault();$("#"+$(n.target).closest("[data-input-id]").data("input-id")).val("").change()})}});$("form").data("validator")?$("form").data("validator").settings.ignore=$("form").data("validator").settings.ignore.replace(":hidden",":hidden:not(input[type=file].file.validate)"):$.validator&&($.validator.defaults.ignore=$.validator.defaults.ignore.replace(":hidden",":hidden:not(input[type=file].file.validate)"))}function showFile(n){var i,t;if(input=$("#"+n).get(0),input.files&&input.files[0]){i=input.files[0].name.substr(input.files[0].name.lastIndexOf(".")).toLowerCase();try{t=new FileReader;t.onload=function(t){$(".viewFileModal[data-input-id="+n+"] .modal-body").append('<img class="img-responsive" id="uploadPreview" />');i!==".pdf"&&$("#uploadPreview").attr("src",t.target.result);$(".viewFileModal[data-input-id="+n+"]").modal("show")};t.readAsDataURL(input.files[0])}catch(r){$(".viewFileModal[data-input-id="+n+"] .modal-body").empty()}}else $(".viewFileModal[data-input-id="+n+"] .modal-body").empty()}function displayName(n,t){let i=(n||"").replace(/[&<>"']/g,"");return i.length<=t?i:i.substring(0,t-3)+"..."}function displayFileSize(n){return n<1024?n+"bytes":n>=1024&&n<1048576?(n/1024).toFixed(1)+"KB":(n/1048576).toFixed(1)+"MB"}function startLogoutTimer(){autoLogoutTime!==undefined&&autoLogoutTime>0&&(autoLogout&&clearTimeout(autoLogout),autoLogout=setTimeout(timeOutPopup,autoLogoutTime))}function countDown(){$("#logoutCountdown").length===0||parseInt($("#logoutCountdown").html())<=0?countdownInterval&&clearInterval(countdownInterval):$("#logoutCountdown").text(parseInt($("#logoutCountdown").text())-1)}function timeOutPopup(){autoLogout&&clearTimeout(autoLogout);autoLogout=setTimeout(()=>{window.location.href=URL_LOGOUT},6e4);countdownInterval!==undefined&&clearInterval(countdownInterval);countdownInterval=setInterval(countDown,1e3);$("#autoLogoutModal").modal("show")}function keepAlive(){$("#logoutCountdown").text("60");autoLogout&&clearTimeout(autoLogout);countdownInterval&&clearInterval(countdownInterval);$.ajax(URL_KEEP_ALIVE,{complete:keepAliveComplete,cache:!1})}function keepAliveComplete(n){n.status===403&&(window.location.href=URL_LOGOUT)}(function(n){n.validator.addMethod("smsOptInPhone",function(t,i,r){var u=n(r).is(":checked"),f=(t||"").toLowerCase();return u===!0?f==="home"?!1:!0:!0});n.validator.addMethod("claimLocationPrescriberAllowed",function(t,i,r){var u,f;return(t||"").toLowerCase()!=="prescriber"?!0:(u=n("[name=CardId]:checked"),u.length===0&&(u=n("[type=hidden][name=CardId]")),f=(u.val().split("_")||[])[0].toLowerCase(),(r||"").toLowerCase().indexOf(f)===-1)?!1:!0});n.validator.addMethod("claimLocationPharmacyAllowed",function(t,i,r){var u,f;return(t||"").toLowerCase()!=="pharmacy"?!0:(u=n("[name=CardId]:checked"),u.length===0&&(u=n("[type=hidden][name=CardId]")),f=(u.val().split("_")||[])[0].toLowerCase(),(r||"").toLowerCase().indexOf(f)>-1)?!1:!0})})(jQuery);jQuery.fn.extend({toggleInputs:function(n,t){return!(this instanceof jQuery)||this.length===0?this:(n?(this.show(t),this.find("input, select, textarea").prop("disabled",!1)):(this.hide(t),this.find("input, select, textarea").prop("disabled",!0)),this)},clearForm:function(){return!(this instanceof jQuery)||this.length===0?this:(this.find("input[type=text],input[type=number],input[type=date],input[type=tel], select, textarea").val("").removeClass("input-validation-error"),this.find("input[type=checkbox]").prop("checked",!1),this.find("input[type=hidden]").not("input[type=checkbox] + input[type=hidden], [name$=RequestVerificationToken]").val(""),this.validate().resetForm(),this.find("[data-valmsg-summary=true]").removeClass("validation-summary-errors").addClass("validation-summary-valid").find("ul").empty(),this.find("[data-valmsg-replace]").removeClass("field-validation-error").addClass("field-validation-valid").empty(),this.find("input[type=tel]").mask("(999) 999-9999"),Modernizr.inputtypes.date||this.find("input[type=date]").mask("99/99/9999"),this)}});$(".viewFileModal").on("hidden.bs.modal",function(){$(this).find("modal-body").empty()}).on("click",function(){$(".viewFileModal").modal("hide")});(function(n){n.validator.addMethod("filenotempty",function(n,t){var i=t.files[0];return i?i.size===0?!1:!0:!0});n.validator.addMethod("filemaxsize",function(n,t,i){var r=t.files[0];return r?r.size>i?!1:!0:!0});n.validator.addMethod("fileaccepts",function(n,t,i){var r=t.files[0],u,f;return r?(u=(i||"").replace(/ /g,"").split(","),f=r.name.substr(r.name.lastIndexOf(".")).toLowerCase(),jQuery.inArray(f,u)<0)?!1:!0:!0});n.validator.addMethod("filechars",function(n,t,i){var f=t.files[0];if(!f)return!0;for(var e=(i||"").replace(/ /g,"").split(","),r=0,u=!1;r<f.name.length&&!u;){for(cc=0;cc<e.length&&!u;)e[cc]===f.name.charCodeAt(r)&&(u=!0),cc=cc+1;r=r+1}return!u});n.validator.addMethod("filesnotempty",function(t,i){let u=!0;n(i).data("filesnotempty-invalid",[]);let f=[];var r=i.files;if(!r||r.length===0)return u;for(let n=0;n<r.length;n++)r[n].size===0&&(f.push(r[n].name),u=!1);return n(i).data("filesnotempty-invalid",f),u});n.validator.addMethod("filesmaxsize",function(t,i,r){let f=!0;n(i).data("filesmaxsize-invalid",[]);let e=[];var u=i.files;if(!u||u.length===0)return f;for(let n=0;n<u.length;n++)u[n].size>r&&(e.push(u[n].name),f=!1);return n(i).data("filesmaxsize-invalid",e),f});n.validator.addMethod("filesaccepts",function(t,i,r){var u,o,s;let f=!0;n(i).data("filesaccepts-invalid",[]);let e=[];if(u=i.files,!u||u.length===0)return f;o=(r||"").replace(/ /g,"").split(",");for(let n=0;n<u.length;n++)s=u[n].name.substr(u[n].name.lastIndexOf(".")).toLowerCase(),jQuery.inArray(s,o)<0&&(e.push(u[n].name),f=!1);return n(i).data("filesaccepts-invalid",e),f});n.validator.addMethod("fileschars",function(t,i,r){var u;let o=!0;n(i).data("fileschars-invalid",[]);let s=[];if(u=i.files,!u||u.length===0)return o;for(let n=0;n<u.length;n++){for(var f=!1,h=(r||"").replace(/ /g,"").split(","),e=0;e<u.name.length&&!f;){for(cc=0;cc<h.length&&!f;)h[cc]===u.name.charCodeAt(e)&&(f=!0),cc=cc+1;e=e+1}f&&(s.push(u[n].name),o=!1)}return n(i).data("fileschars-invalid",s),o});n.validator.addMethod("filescount",function(n,t,i){var r=t.files;return r?r.length>i?!1:!0:!0})})(jQuery);jQuery.fn.extend({fileUpload:function(n,t){return n==="validate"?t===!0?this.addClass("validate"):this.removeClass("validate"):n==="required"&&(t===!0?this.data("rule-required","true"):this.data("rule-required","false")),this}});var autoLogout,autoLogoutTime,countdownInterval;$(document).ready(function(){$(document).ajaxComplete(startLogoutTimer);startLogoutTimer()});jQuery.fn.extend({pagedList:function(){var n;if(!(this instanceof jQuery)||this.length===0||this.prop("tagName").toLowerCase()!=="table"||(n=this.closest("div.listContainer"),n.length!==1))return this;var u=this.data("page-index")||0,i=this.data("last-page")||0,r=$("#"+this.prop("id")+" thead > tr > th[data-sort-field]");if(n.data("sort")!==undefined?(sortCol=n.data("sort")[0],isDesc=n.data("sort")[1]):(sortCol=r.first().attr("data-sort-field"),isDesc=!1,n.data("sort",[sortCol,isDesc])),sortCol!==undefined&&sortCol!==""&&r.filter("[data-sort-field="+sortCol+"]").append(isDesc===!0?'&nbsp;<span class="glyphicon glyphicon-chevron-down"><\/span>':'&nbsp;<span class="glyphicon glyphicon-chevron-up"><\/span>'),i>0){var f=Math.min(i,Math.max(0,u-3)+4),e=Math.max(0,f-4),t=$("#"+this.prop("id")+" + nav ul.pagination");$('<li><a href="#">First<\/a><\/li>').appendTo(t).on("click",function(n,t,i){return function(r){r.preventDefault();$(this).pageList({pageIndex:n,sortBy:t,sortDescending:i})}}(0,sortCol,isDesc));for(p=e;p<=f;p++)if(p===u)t.append('<li class="active"><span>'+(p+1)+"<\/span><\/li>");else $('<li><a href="#">'+(p+1)+"<\/a><\/li>").appendTo(t).on("click",function(n,t,i){return function(r){r.preventDefault();$(this).pageList({pageIndex:n,sortBy:t,sortDescending:i})}}(p,sortCol,isDesc));$('<li><a href="#">Last<\/a><\/li>').appendTo(t).on("click",function(n,t,i){return function(r){r.preventDefault();$(this).pageList({pageIndex:n,sortBy:t,sortDescending:i})}}(i,sortCol,isDesc))}r.off("click").on("click",function(){$(this).pageList({pageIndex:0})});return this},pageList:function(n){var o;if(!(this instanceof jQuery)||this.length===0)return this;var l=new Number(n.pageIndex),r=n.sortBy,f=n.sortDescending,s=n.args,i,t,h,e=!1,u,c;return(this.prop("tagName").toLowerCase()==="div"?t=this:(tagName=this.prop("tagName").toLowerCase(),tagName==="table"?i=this:tagName==="li"?i=$("#"+this.closest("nav").data("table-id")):tagName==="th"&&(i=this.closest("table.pagedList"),r=this.attr("data-sort-field")),t=i.closest("div.listContainer")),h=t.data("list-page-url"),h===undefined)?this:(u=t.data("sort"),c=t.data("page-args"),r===undefined&&(r=u!==undefined?u[0]:""),u!==undefined&&r===u[0]&&(f===undefined||f===null)&&(e=!u[1]),f!==undefined&&f!==null&&(e=f),t.data("sort",[r,e]),o={pageIndex:l,sortBy:r,isDescending:e},s?(t.data("page-args",s),$.extend(o,s)):c&&$.extend(o,c),t.showLoading().load(h,o,function(n,t,r){if(r.status===200){var u=$(n).first();u.prop("tagName")&&u.prop("tagName").toLowerCase()!=="table"&&(u=$(n).find("table.pagedList"));i=$("#"+u.prop("id"));i.length>0&&i.pagedList()}else $(this).empty().append("<p class='text-warning'>Unable to load the requested data.&nbsp;&nbsp;Please try again.<\/p>")}),this)},showLoading:function(n){return n&&n.disableTrigger(),$(this).find("table.pagedList tbody").empty(),$(this).children("nav").remove(),$(this).children(".listLoading").removeClass("hidden"),$(this)},disableTrigger:function(){return this.addClass("disabled loading").prop("disabled",!0)},enableTrigger:function(){return this.removeClass("disabled loading").prop("disabled",!1)}});$(document).ajaxComplete(function(){$(".loading.disabled").enableTrigger()}),function(n){n.validator.addMethod("istrue",function(n){return n&&n.toLowerCase()==="true"?!0:!1});n.validator.unobtrusive.adapters.addBool("istrue");n.validator.addMethod("minmaxdate",function(n,t,i){var r=new Date(n);return this.optional(t)||r>=new Date(i[0])&&r<=new Date(i[1])});n.validator.addMethod("mindate",function(n,t,i){var r=new Date(n);return this.optional(t)||r>=new Date(i)});n.validator.addMethod("maxdate",function(n,t,i){var r=new Date(n);return this.optional(t)||r<=new Date(i)});n.validator.unobtrusive.adapters.addMinMax("daterange","mindate","maxdate","minmaxdate");n.validator.unobtrusive.adapters.addSingleVal("maxdate","maxdate","maxdate");n.validator.addMethod("requiredif",function(t,i,r){var u=n(i),f=n('input[name="'+r.otherprop+'"], select[name="'+r.otherprop+'"]'),s,o,h,c,e,l;return(f.length===0&&(f=n('input[name$=".'+r.otherprop+'"], select[name$=".'+r.otherprop+'"]')),s=r.otherpropval,o=r.requiredval,f.length===0)?!0:(h=f.prop("type").toUpperCase(),c=h==="CHECKBOX"?f.is(":checked")?"True":"False":h==="RADIO"?f.filter(":checked").val()||"":f.val(),s===undefined&&c!==""||s===c)?(l=u.prop("type").toUpperCase(),l==="CHECKBOX")?o==="False"?!u.is(":checked"):u.is(":checked"):(l==="RADIO"?(u=n('input[type="radio"][name="'+u.prop("name")+'"]'),e=u.filter(":checked").val()):e=u.val(),o?e===o:e&&e!=""):!0});n.validator.unobtrusive.adapters.add("requiredif",["otherprop","otherpropval","requiredval"],function(n){n.rules.requiredif={otherprop:n.params.otherprop||"",otherpropval:n.params.otherpropval,requiredval:n.params.requiredval||""};n.messages.requiredif=n.message});n.validator.addMethod("realDate",function(n){if(!n||n.length==0)return!0;var t=n.split("/"),i=new Date(t[2],Number(t[0])-1,t[1]);return!!(i&&i.getMonth()+1==Number(t[0])&&i.getDate()==Number(t[1])&&i.getFullYear()==Number(t[2]))})}(jQuery)