var SGADateFormat=function(){var t=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,i=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,r=/[^-+\dA-Z]/g,n=function(n,t){for(n=String(n),t=t||2;n.length99?Math.round(a/10):a),t:s<12?"a":"p",tt:s<12?"am":"pm",T:s<12?"A":"P",TT:s<12?"AM":"PM",Z:e?"UTC":(String(u).match(i)||[""]).pop().replace(r,""),o:(v>0?"-":"+")+n(Math.floor(Math.abs(v)/60)*100+Math.abs(v)%60,4),S:["th","st","nd","rd"][c%10>3?0:(c%100-c%10!=10)*c%10]};return f.replace(t,function(n){return n in k?k[n]:n.slice(1,n.length-1)})}}();SGADateFormat.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};SGADateFormat.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]};Date.prototype.format=function(n,t){return SGADateFormat(this,n,t)};Date.prototype.addDays=function(n){let t=new Date(this.valueOf());return t.setDate(t.getDate()+n),t};Date.prototype.addHours=function(n){let t=new Date(this.valueOf());return t.setTime(t.getTime()+n*36e5),t};Date.prototype.addMonths=function(n){let t=new Date(this.valueOf());return t.setMonth(t.getMonth()+n),t};Date.prototype.addSeconds=function(n){let t=new Date(this.valueOf());return t.setTime(t.getTime()+n*1e3),t};Date.prototype.addYears=function(n){let t=new Date(this.valueOf());return t.setFullYear(t.getFullYear()+n),t};Date.prototype.daysInMonth=function(){return new Date(this.valueOf()).endOfMonth().getDate()};Date.prototype.endOfMonth=function(){let n=new Date(this.valueOf());return new Date(n.getFullYear(),n.getMonth()+1,0)};Date.prototype.endOfYear=function(){let n=new Date(this.valueOf());return new Date(n.getFullYear()+1,0,0)};Date.prototype.startOfMonth=function(){let n=new Date(this.valueOf());return new Date(n.getFullYear(),n.getMonth(),1)};Date.prototype.toUTC=function(){let n=new Date(this.valueOf());return new Date(n.getTime()+n.getTimezoneOffset()*6e4)};const E_ErrCode=Object.freeze({Success:0,LoginExpired:1,AccessRestricted:2,UserDbMissing:3,NoAuthority:4,RecExists:5,RecNotFound:6,CreateDbStoredProcedureFailed:7,DbError:8,DbCommitFailed:9,InvalidJSModel:10,MinReqError:11,DatabaseTimeout:37,InvalidAntiForgeryToken:39,InternalError:9999,Ajax:10001,OperationBusy:10002,MaxBytes:10003,FunctionDisabled:10004,getErrCode:function(n){let t=SGACommon.isNullOrUndefined;if(!t(n))try{switch(n.status){case 400:let i=$.parseJSON(n.responseText);if(!t(i)&&!t(i.ErrCode))return i.ErrCode;break;case 413:return E_ErrCode.MaxBytes}}catch(i){}return null},showDlg:function(n,t,i,r,u,f){switch(n){case E_ErrCode.Success:return;case E_ErrCode.LoginExpired:SGADialog.show(t,getStrRes("msg_unable_to_perform_the_task_because_your_login_has_expired")+"
"+getStrRes("msg_please_login_again"),"err","ok",null,null,i,r);break;case E_ErrCode.AccessRestricted:SGADialog.show(t,getStrRes("msg_unable_to_perform_the_task_because_your_access_has_been_restricted_to_a_certain_ip_address_and_or_a_certain_time"),"err","ok",null,null,i,r);break;case E_ErrCode.UserDbMissing:case E_ErrCode.CreateDbStoredProcedureFailed:case E_ErrCode.DbError:case E_ErrCode.DbCommitFailed:SGADialog.show(t,getStrRes("msg_html_internal_database_error_has_occurred_please_try_it_again_shortly")+"

"+getStrRes("msg_html_if_problem_persists_please_report_this_error_to_the_support_team")+" ["+getStrRes("error_code")+": "+n+"]","err","ok",null,null,i,r);break;case E_ErrCode.DatabaseTimeout:SGADialog.show(t,getStrRes("msg_html_database_timeout_has_occurred_when_trying_to_perform_the_requested_action")+"

"+getStrRes("msg_html_if_problem_persists_please_report_this_error_to_the_support_team"),"err","ok",null,null,i,r);break;case E_ErrCode.NoAuthority:SGADialog.show(t,getStrRes("msg_html_you_have_no_authority_to_perform_this_action")+"
"+getStrRes("msg_please_reload_your_page"),"err","ok",null,null,i,r);break;case E_ErrCode.RecExists:SGADialog.show(t,getStrRes("msg_the_record_already_exists_in_the_database")+"
"+getStrRes("msg_please_reload_your_page"),"info","ok",null,null,i,r);break;case E_ErrCode.RecNotFound:SGADialog.show(t,getStrRes("msg_the_record_is_no_longer_exists_in_the_database")+"
"+getStrRes("msg_please_reload_your_page"),"info","ok",null,null,i,r);break;case E_ErrCode.InvalidJSModel:SGADialog.show(t,getStrRes("msg_internal_error_on_passing_data_to_the_server_has_occurred")+"

"+getStrRes("msg_html_if_problem_persists_please_report_this_error_to_the_support_team"),"err","ok",null,null,i,r);break;case E_ErrCode.MinReqError:SGADialog.show(t,getStrRes("msg_unable_to_save_this_record_because_some_fields_requirement_are_not_met")+"

"+getStrRes("msg_html_if_problem_persists_please_report_this_error_to_the_support_team"),"info","ok",null,null,i,r);break;case E_ErrCode.InvalidAntiForgeryToken:SGADialog.showModal(t,getStrRes("msg_your_browser_session_has_expired_we_will_reload_your_browser_to_refresh_your_session"),"warn","ok",null,null,function(){location.reload()},null);break;case E_ErrCode.InternalError:SGADialog.show(t,getStrRes("msg_server_internal_error_has_occurred_when_trying_to_perform_the_task")+"

"+getStrRes("msg_html_if_problem_persists_please_report_this_error_to_the_support_team"),"err","ok",null,null,i,r);break;case E_ErrCode.Ajax:{let n=getStrRes("msg_the_server_is_not_responding")+"
"+getStrRes("msg_please_try_it_again_later");u===0?n=getStrRes("msg_there_is_problem_with_your_internet_connection")+"
"+getStrRes("msg_please_check_your_connection"):addErrorLog("AJAX exception has occurred. \nErrCode: "+u+" \nErrMsg: "+f);SGADialog.show(t,n,"err","ok",null,null,i,r)}break;case E_ErrCode.OperationBusy:SGADialog.show(t,getStrRes("msg_server_operation_is_in_progress")+" "+getStrRes("msg_please_wait"),"info","ok",null,null,i,r);break;case E_ErrCode.MaxBytes:SGADialog.show(t,getStrRes("msg_unable_to_perform_the_task_because_the_request_has_exceeded_server_maximum_byte_size"),"warn","ok",null,null,i,r);break;case E_ErrCode.FunctionDisabled:SGADialog.show(t,getStrRes("msg_html_this_function_is_not_supported_please_contact_the_support_team_to_report_this_error"),"err","ok",null,null,i,r);break;default:SGADialog.show(t,getStrRes("msg_unhandled_error_has_occurred_when_performing_the_task")+"

"+getStrRes("msg_html_if_problem_persists_please_report_this_error_to_the_support_team")+" ["+getStrRes("error_code")+": "+n+"]","err","ok",null,null,i,r)}},showAjaxDlg:function(n,t){let i=SGACommon.isNullOrUndefined,r=E_ErrCode.getErrCode(t);if(i(r))E_ErrCode.showDlg(E_ErrCode.Ajax,n,null,null,i(t)?null:t.status,i(t)?null:t.statusText);else if(E_ErrCode.showDlg(r,n),r===E_ErrCode.InvalidAntiForgeryToken)return!1;return!0}}),SGAGFormat=Object.freeze({clearFormat:function(n){return n.data("glb-mark",!1)},clearRootFormat:function(n){return n!==null&&n!==undefined&&n instanceof jQuery||(n=$(document.documentElement)),n.find("[data-type]").each(function(){SGAGFormat.clearFormat($(this))}),n},currency:function(n,t,i,r){let o=SGAString.isNullOrWhitespace;SGAGlobal.isInt(t)||(t=2);i=o(i)?"":SGAString.trim(i)+" ";let s=(i===""?"c":"n")+t,h=n.data("glb-mark")===!0,u=n.data("glb-symbol");if(SGAString.isNullOrEmpty(u)&&(u=""),n.data("glb-symbol",i),n.is("input")){let t=n.data("placeholderval"),r=!1;o(t)&&(r=h,t=n.attr("placeholder"),u!==""&&(t=String(t).replace(u,"")));SGAGlobal.isNumeric(t)?n.attr("placeholder",i+SGAGlobal.format(SGAGFormat.parseFloat(r,t),s)):o(t)&&n.attr("placeholder",i+SGAGlobal.format(0,s))}let e=n.val(),f=e.replace(u,""),a=!1;if(!SGAGlobal.isNumeric(f)&&(e=n.html(),a=!0,f=e.replace(u,""),!SGAGlobal.isNumeric(f)))return n;let c=r?Math.pow(10,t):1,l=i+SGAGlobal.format(c!==1?Math.floor(SGAGFormat.parseFloat(h,f)*c)/c:SGAGFormat.parseFloat(h,f),s);return l!==e&&(a?n.html(l):n.val(l)),SGAGFormat.markedFormatted(n)},custom:function(n,t,i){let f=SGAString.isNullOrWhitespace;if(f(t)||f(i))return SGAGFormat.format(n,!1,t);let r=n.val(),u=r,e=n.data("glb-mark")===!0,o=!1;if(f(r)&&(r=n.html(),o=!0,f(r)))return n;switch(t.toLowerCase()){case"currency":case"decimal":case"number":u=SGAGlobal.format(SGAGFormat.parseFloat(e,r),i);break;case"date":if(SGAGlobal.isJSDateTime(r))r=r.split("T")[0];else if(!SGAGlobal.isJSDate(r))return n;u=SGAGlobal.convertToLocalDate(r,i);break;case"datetime":u=e&&!SGAGlobal.isJSDateTime(r)?r:SGAGlobal.convertToLocalDateTime(r,!1,!1,i);break;case"percent":u=SGAGlobal.format(SGAGFormat.parseFloat(e,r)/100,i);break;case"time":u=e&&!SGAGlobal.isJSDateTime(r)?r:SGAGlobal.convertToLocalTime(r,!0,i);break;case"timecounter":u=SGAGlobal.isInt(r)?SGAGlobal.convertToTimeCounter(r,!0):r}return o?n.html(u):n.val(u),SGAGFormat.markedFormatted(n)},date:function(n,t){let e=SGABool.tryParseBool(n.data("datepicker-static"),!0),u=SGABool.parseBool(n.data("datepicker-init"));if(n.is("input")&&(!e||!u)){let r=SGAGlobal.getDatepickerPattern().replace("yyyy","yy").replace("yy","yyyy"),i=$('meta[name="page-culture"]').attr("langcode");SGACommon.isNullOrUndefined($.fn.datepicker)||SGACommon.isNullOrUndefined($.fn.datepicker.dates)||(i=i?i in $.fn.datepicker.dates?i:i.split("-")[0]:"en");n.is("[readonly]")||((t===null||t===undefined)&&(t={}),t.autoclose||(t.autoclose=!0),t.todayBtn||(t.todayBtn="linked"),t.orientation||(t.orientation="auto"),t.changeMonth||(t.changeMonth=!0),t.changeYear||(t.changeYear=!0),t.format=r,t.language=i,u&&n.datepicker("destroy"),n.datepicker(t),n.data("datepicker-init",!0),u=!0);SGAString.isNullOrWhitespace(n.attr("placeholder"))&&n.attr("placeholder",r)}let i=n.val(),f=!1;if(SGAGlobal.isJSDateTime(i))i=i.split("T")[0];else if(!SGAGlobal.isJSDate(i))if(i=n.html(),f=!0,SGAGlobal.isJSDateTime(i))i=i.split("T")[0];else if(!SGAGlobal.isJSDate(i))return n;let r=n.data("glb-mark")===!0?i:SGAGlobal.convertToLocalDate(i);return r!==i&&(f?n.html(r):(n.val(r),n.is("input")&&!n.is("[readonly]")&&r&&SGAGlobal.isDate(r)&&(u?n.datepicker("setDate",SGAGlobal.parseDate(r)):n.val(r)))),SGAGFormat.markedFormatted(n)},dateTime:function(n,t,i){let r=n.val(),f=!1;if(!SGAGlobal.isJSDateTime(r)&&(r=n.html(),f=!0,!SGAGlobal.isJSDateTime(r)))return n;let u=n.data("glb-mark")===!0&&!SGAGlobal.isJSDateTime(r)?r:SGAGlobal.convertToLocalDateTime(r,t,i);return u!==r&&(f?n.html(u):n.val(u)),SGAGFormat.markedFormatted(n)},decimal:function(n,t){let o=SGAString.isNullOrWhitespace;SGAGlobal.isInt(t)||(t=2);let f="n"+t,s=n.data("glb-mark")===!0,i=n.data("glb-symbol");if(SGAString.isNullOrEmpty(i)&&(i=""),n.data("glb-symbol",""),n.is("input")){let t=n.data("placeholderval"),r=!1;o(t)&&(r=s,t=n.attr("placeholder"),i!==""&&(t=String(t).replace(i,"")));SGAGlobal.isNumeric(t)?n.attr("placeholder",SGAGlobal.format(SGAGFormat.parseFloat(r,t),f)):o(t)&&n.attr("placeholder",SGAGlobal.format(0,f))}let r=n.val(),u=r.replace(i,""),h=!1;if(!SGAGlobal.isNumeric(u)&&(r=n.html(),h=!0,u=r.replace(i,""),!SGAGlobal.isNumeric(u)))return n;let e=SGAGlobal.format(SGAGFormat.parseFloat(s,u),f);return e!==r&&(h?n.html(e):n.val(e)),SGAGFormat.markedFormatted(n)},format:function(n,t,i){if(i=SGAString.coalesceNullOrWhitespace(i,n.data("type")),!SGAString.isNullOrWhitespace(i)){switch(i.toLowerCase()){case"currency":SGAGFormat.currency(n,n.data("decimalprecision"),n.data("currencysymbol"),n.data("currencyfloor"));break;case"custom":SGAGFormat.custom(n,n.data("formattype"),n.data("pattern"));break;case"date":SGAGFormat.date(n);break;case"datetime":SGAGFormat.dateTime(n,n.data("tolocaltime"),n.data("seconds"));break;case"decimal":SGAGFormat.decimal(n,n.data("decimalprecision"));break;case"number":SGAGFormat.number(n);break;case"percent":SGAGFormat.percent(n,n.data("decimalprecision"),n.data("nospace"));break;case"time":SGAGFormat.time(n);break;case"timecounter":SGAGFormat.timeCounter(n)}if(SGABool.tryParseBool(t,!1)&&n.is("input:text"))n.on("blur",function(){SGAGFormat.format($(this))})}return n},formatRoot:function(n){return n!==null&&n!==undefined&&n instanceof jQuery||(n=$(document.documentElement)),n.find("[data-type]").each(function(){SGAGFormat.format($(this),!0)}),n},markedFormatted:function(n){return n.data("glb-mark",!0)},number:function(n){let u="n0",e=n.data("glb-mark")===!0,t=n.data("glb-symbol"),o=SGAString.isNullOrWhitespace;if(SGAString.isNullOrEmpty(t)&&(t=""),n.data("glb-symbol",""),n.is("input")){let i=n.data("placeholderval"),r=!1;o(i)&&(r=e,i=n.attr("placeholder"),t!==""&&(i=String(i).replace(t,"")));SGAGlobal.isNumeric(i)?n.attr("placeholder",SGAGlobal.format(SGAGFormat.parseFloat(r,i),u)):o(i)&&n.attr("placeholder",SGAGlobal.format(0,u))}let i=n.val(),r=i.replace(t,""),s=!1;if(!SGAGlobal.isNumeric(r)&&(i=n.html(),s=!0,r=i.replace(t,""),!SGAGlobal.isNumeric(r)))return n;let f=SGAGlobal.format(SGAGFormat.parseFloat(e,r),u);return f!==i&&(s?n.html(f):n.val(f)),SGAGFormat.markedFormatted(n)},parseFloat:function(n,t){let i=n?SGAGlobal.parseFloat(t):parseFloat(t);return isNaN(i)?n?parseFloat(t):SGAGlobal.parseFloat(t):i},percent:function(n,t,i){let s=SGAString.isNullOrWhitespace;SGAGlobal.isInt(t)||(t=2);let o="p"+t,h=n.data("glb-mark")===!0,r=n.data("glb-symbol");if(SGAString.isNullOrEmpty(r)&&(r=""),n.data("glb-symbol",""),n.is("input")){let t=n.data("placeholderval"),i=!1;s(t)&&(i=h,t=n.attr("placeholder"),r!==""&&(t=String(t).replace(r,"")));SGAGlobal.isNumeric(t)?n.attr("placeholder",SGAGlobal.format(SGAGFormat.parseFloat(i,t),o)):s(t)&&n.attr("placeholder",SGAGlobal.format(0,o))}let f=n.val(),e=f.replace(r,""),c=!1;if(!SGAGlobal.isNumeric(e)&&(f=n.html(),c=!0,e=f.replace(r,""),!SGAGlobal.isNumeric(e)))return n;let u=SGAGlobal.format(SGAGFormat.parseFloat(h,e)/100,o);return i&&(u=u.replace(" %","%")),u!==f&&(c?n.html(u):n.val(u)),SGAGFormat.markedFormatted(n)},time:function(n){let t=n.val(),r=!1;if(!SGAGlobal.isJSDateTime(t)&&(t=n.html(),r=!0,!SGAGlobal.isJSDateTime(t)))return n;let i=n.data("glb-mark")===!0?t:SGAGlobal.convertToLocalTime(t,n.data("seconds")!==!1);return i!==t&&(r?n.html(i):n.val(i)),SGAGFormat.markedFormatted(n)},timeCounter:function(n){let t=n.val(),r=!1;if(!SGAGlobal.isInt(t)&&(t=n.html(),r=!0,!SGAGlobal.isInt(t)))return n;let i=SGAGlobal.convertToTimeCounter(t,n.data("seconds")!==!1);return i!==t&&(r?n.html(i):n.val(i)),SGAGFormat.markedFormatted(n)}});$(document).ready(function(){SGAGFormat.formatRoot(null)})