function renameProperty(n,t,i){return t==i?n:(n.hasOwnProperty(t)&&(n[i]=n[t],delete n[t]),n)}function customParseFloat(n){return n&&(n=parseFloat(n),!isNaN(n))?n:0}function customParseInt(n){return n&&(n=parseInt(n),!isNaN(n))?n:0}function loadAjax(n,t,i){$.ajax({url:n,method:"GET",type:i?i:"html",cache:!1,success:function(n){t&&t(n)}})}function getQueryStringParameterByName(n,t){t||(t=location.search);n=n.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+n+"=([^&#]*)"),i=r.exec(t);return i===null?"":decodeURIComponent(i[1].replace(/\+/g," "))}function updateQueryStringParameter(n,t,i){var r=new RegExp("([?&])"+t+"=.*?(&|$)","i"),u=n.indexOf("?")!==-1?"&":"?";return n.match(r)?n.replace(r,"$1"+t+"="+i+"$2"):n+u+t+"="+i}function getUrlAbsolutePath(n){var t="",i=!0;if(URL)try{t=new URL(n).pathname}catch(r){i=!1}else i=!1;return i||(t="/"+n.replace(/^[a-z]{4,5}\:\/{2}[a-z]{1,}\:[0-9]{1,4}.(.*)/,"$1")),t}function openInNewTab(n){var t=window.open(n,"_blank");t.focus()}function parseDateFromString(n){return $.datepicker.parseDate($.datepicker._defaults.dateFormat,n)}function parseStringFromDate(n){return $.datepicker.formatDate($.datepicker._defaults.dateFormat,n)}function rotateImgCanvas(n,t,i){var u=document.createElement("canvas"),f=n.getContext("2d"),r=new Image;r.onload=function(){u.height=r.width;u.width=r.height;var n=u.getContext("2d");f.clearRect(0,0,r.width,r.height);n.save();n.translate(r.height/2,r.width/2);n.rotate(t*TO_RADIANS);n.drawImage(r,-(r.width/2),-(r.height/2));n.restore();i(u)};r.src=n.toDataURL("image/jpeg",1)}function reloadCanvasSmooth(n,t){var r=n.getContext("2d"),i=$("").addClass("canvas-snapshot").css({width:n.width,height:n.height});i[0].onload=function(){r.clearRect(0,0,n.width,n.height);t(i)};i[0].src=n.toDataURL("image/png");$(n).after(i)}function cloneCanvas(n){var t=document.createElement("canvas"),i=t.getContext("2d");return t.width=n.width,t.height=n.height,i.drawImage(n,0,0),t}function signedNumber(n,t){return n?n>0?"+"+n.toFixed(t?t:0):n.toFixed(t?t:0):"0"}function secondsToTimeString(n){n=parseInt(n,10);var t=Math.floor(n/3600),i=Math.floor((n-t*3600)/60),r=n-t*3600-i*60;return t=t<=0?"":(t<10?"0":"")+t+":",i=(i<10?"0":"")+i+":",r=(r<10?"0":"")+r,t+i+r}function dataURItoBlob(n){for(var u,f,i=atob(n.split(",")[1]),e=n.split(",")[0].split(":")[1].split(";")[0],r=new ArrayBuffer(i.length),o=new Uint8Array(r),t=0;t<\/div>",buttonClass:"form-control",nonSelectedText:"Ничего не выбрано",allSelectedText:"Выбрано все",nSelectedText:" - Выбрано"});n.find("table.sortable").each(function(){var n=$(this),t=n.find("thead th");t.each(function(i){var u=$(this),f=$('').html(u.html()),r=$('');u.empty().append(f).append(r);f.click(function(u){u.preventDefault();var f=r.hasClass("ASC")?"ASC":r.hasClass("DESC")?"DESC":"";f||(f="DESC");t.find(".sort").removeClass("ASC DESC");f=f=="DESC"?"ASC":"DESC";r.addClass(f);sortTable(i,f,n)})})});n.find("form").each(function(){var n=$(this).find(".ienumerable");n.length>0&&(n.each(function(){var t=$(this).data("inititemcustomevents"),n;t&&(n=window[t],typeof n=="function"&&$(this).find(".container_basedto").each(function(){n($(this))}));reorderIenumerableDtos($(this))}),revalidateForm($(this)))});$.each(n.find(".remove_basedto"),function(){initRemoveEvent($(this))});n.find(".new-item[data-container]").click(function(){var f=$(this).data("container"),t=$(f),o=f.replace("#container_",""),i=$("#template-"+o).html(),e=t.find(".container_basedto").length,n,r,u;i=i.replace(/\[0\]/g,"["+e+"]").replace(/\_0\_/g,"_"+e+"_");n=$(i);t.append(n);r=t.data("inititemcustomevents");r&&(u=window[r],typeof u=="function"&&u(n));initPageEvents(n);revalidateForm(n.closest("form"))});n.find(".image-uploader[data-base64inputname]").change(function(){var t=this.files,i,r,n;t&&t.length&&(r=$(this).closest("form").find('input[name="'+$(this).data("base64inputname")+'"]'),i=t[0],$(this).val(""),/^image\/\w+$/.test(i.type)?(n=new FileReader,n.readAsDataURL(i),n.onload=function(){var t=n.result.replace("data:image/png;base64,","").replace("data:image/jpeg;base64,","");r.val(t)},n.onerror=function(){window.alert("Пожалуйста выберите картинку.")}):window.alert("Пожалуйста выберите картинку."))});n.find(".search_reset").click(function(){var n=$(this).closest("form");n.find(":input[name]:not(.special_input)").val("");n.submit()});typeof initPopupSelect!="undefined"&&initPopupSelect(n);$.each(n.find(".symbol-count"),function(){var n=$(this),t=$("");t.addClass("symbol-count-counter");n.on("input",function(){var i=n.val();t.text(i.length)});n.after(t)})}function reorderIenumerableDtos(n,t){var i=n.attr("id").replace("container_","");i=i.replace("_",".");var f=n.find(".container_basedto"),r=new RegExp(i+"\\[.*?\\]\\s?"),u=new RegExp(i+"\\_.*?\\_\\s?");$.each(f,function(n){var t=$(this);t.find(":input[name]").each(function(){var e=$(this).attr("name"),o,f,s;r.test(e)&&(o=e.replace(r,i+"["+n.toString()+"]"),$(this).attr("name",o),t.find('span[data-valmsg-for="'+e+'"]').attr("data-valmsg-for",o));f=$(this).attr("id");f&&u.test(f)&&(s=f.replace(u,i+"_"+n.toString()+"_"),$(this).attr("id",s),t.find('label[for="'+f+'"]').attr("for",s))})});t&&revalidateForm(n.closest("form"))}function initRemoveEvent(n){n.click(function(){var n=$(this).closest(".ienumerable");$(this).closest(".container_basedto").remove();reorderIenumerableDtos(n,!0)})}function revalidateForm(n){n.removeData("validator");n.removeData("unobtrusiveValidation");$.validator.unobtrusive.parse(n)}function showFormErrors(n,t){var o=$(n),s,u,i,f,r,e,h,c;if(o.find("[data-valmsg-summary=true], .validation-summary-errors").remove(),t&&t.responseJSON&&t.responseJSON.ModelState){s=o.data("validator");u=[];for(i in t.responseJSON.ModelState)for(f=null,i!="this"&&(r=i,r&&r.indexOf("model.")!=-1&&(r=r.replace("model.","")),f=o.find(':input[name="'+r+'"]')),e=0;e0?s.errorList.push({element:f[0],message:t.responseJSON.ModelState[i][e]}):i=="this"&&u.push({message:t.responseJSON.ModelState[i][e]});return u&&u.length>0&&(h=$("
").addClass("validation-summary-errors"),c=$("