this.BX=this.BX||{};(function(e,t){"use strict";function _(e){if(!t.Type.isStringFilled(e)){return""}return e.replace("YYYY","Y").replace("MMMM","F").replace("MM","m").replace("M","M").replace("DD","d").replace("G","g").replace(/GG/i,"G").replace("H","h").replace(/HH/i,"H").replace("MI","i").replace("SS","s").replace("TT","A").replace("T","a")}const r=new t.Cache.MemoryCache;function s(e){return r.remember(`main.date.format.${e}`,(()=>{let r=t.Extension.getSettings("main.date").get(`formats.${e}`);if(t.Type.isStringFilled(r)&&(e==="FORMAT_DATE"||e==="FORMAT_DATETIME")){r=_(r)}return r}))}let n=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"isAmPmMode",value:function e(t){if(t===true){return this._getMessage("AMPM_MODE")}return this._getMessage("AMPM_MODE")!==false}},{key:"convertToUTC",value:function e(_){if(!t.Type.isDate(_)){return null}return new Date(Date.UTC(_.getFullYear(),_.getMonth(),_.getDate(),_.getHours(),_.getMinutes(),_.getSeconds(),_.getMilliseconds()))}},{key:"getNewDate",value:function e(t){return new Date(this.getBrowserTimestamp(t))}},{key:"getBrowserTimestamp",value:function e(t){t=parseInt(t,10);const _=new Date(t*1e3).getTimezoneOffset()*60;return(parseInt(t,10)+parseInt(this._getMessage("SERVER_TZ_OFFSET"))+_)*1e3}},{key:"getServerTimestamp",value:function e(t){t=parseInt(t,10);const _=new Date(t).getTimezoneOffset()*60;return Math.round(t/1e3-(parseInt(this._getMessage("SERVER_TZ_OFFSET"),10)+parseInt(_,10)))}},{key:"formatLastActivityDate",value:function e(t,_,r){const s=this.isAmPmMode(true);const n=s===this.AM_PM_MODE.LOWER?"g:i a":s===this.AM_PM_MODE.UPPER?"g:i A":"H:i";const a=[["tomorrow","#01#"+n],["now","#02#"],["todayFuture","#03#"+n],["yesterday","#04#"+n],["-",this.convertBitrixFormat(this._getMessage("FORMAT_DATETIME")).replace(/:s/g,"")],["s60","sago"],["i60","iago"],["H5","Hago"],["H24","#03#"+n],["d31","dago"],["m12>1","mago"],["m12>0","dago"],["","#05#"]];let D=this.format(a,t,_,r);let i=null;if((i=/^#(\d+)#(.*)/.exec(D))!=null){switch(i[1]){case"01":D=this._getMessage("FD_LAST_SEEN_TOMORROW").replace("#TIME#",i[2]);break;case"02":D=this._getMessage("FD_LAST_SEEN_NOW");break;case"03":D=this._getMessage("FD_LAST_SEEN_TODAY").replace("#TIME#",i[2]);break;case"04":D=this._getMessage("FD_LAST_SEEN_YESTERDAY").replace("#TIME#",i[2]);break;case"05":D=this._getMessage("FD_LAST_SEEN_MORE_YEAR");break;default:D=i[2];break}}return D}},{key:"_getMessage",value:function e(_){return t.Loc.getMessage(_)}},{key:"parse",value:function e(_,r,s,n){if(t.Type.isStringFilled(_)){if(!s){s=this._getMessage("FORMAT_DATE")}if(!n){n=this._getMessage("FORMAT_DATETIME")}let e="";for(let t=1;t<=12;t++){e=e+"|"+this._getMessage("MON_"+t)}const t=new RegExp("([0-9]+|[a-z]+"+e+")","ig");const a=_.match(t);let D=s.match(/(DD|MI|MMMM|MM|M|YYYY)/gi);const i=[];const o=[];const M={};if(!a){return null}if(a.length>D.length){D=n.match(/(DD|MI|MMMM|MM|M|YYYY|HH|H|SS|TT|T|GG|G)/gi)}for(let e=0,t=a.length;ee==="MMMM"));if(O>0){i[O]=this.getMonthIndex(i[O]);o[O]="MM"}else{O=o.findIndex((e=>e==="M"));if(O>0){i[O]=this.getMonthIndex(i[O]);o[O]="MM"}}for(let e=0,t=o.length;e0&&M["MM"]>0&&M["YYYY"]>0){const e=new Date;if(r){e.setUTCDate(1);e.setUTCFullYear(M["YYYY"]);e.setUTCMonth(M["MM"]-1);e.setUTCDate(M["DD"]);e.setUTCHours(0,0,0,0)}else{e.setDate(1);e.setFullYear(M["YYYY"]);e.setMonth(M["MM"]-1);e.setDate(M["DD"]);e.setHours(0,0,0,0)}if((!isNaN(M["HH"])||!isNaN(M["GG"])||!isNaN(M["H"])||!isNaN(M["G"]))&&!isNaN(M["MI"])){if(!isNaN(M["H"])||!isNaN(M["G"])){const e=(M["T"]||M["TT"]||"am").toUpperCase()==="PM",t=parseInt(M["H"]||M["G"]||0,10);if(e){M["HH"]=t+(t===12?0:12)}else{M["HH"]=t<12?t:0}}else{M["HH"]=parseInt(M["HH"]||M["GG"]||0,10)}if(isNaN(M["SS"])){M["SS"]=0}if(r){e.setUTCHours(M["HH"],M["MI"],M["SS"])}else{e.setHours(M["HH"],M["MI"],M["SS"])}}return e}}return null}},{key:"getMonthIndex",value:function e(t){const _=t.toUpperCase();const r=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"];const s=["january","february","march","april","may","june","july","august","september","october","november","december"];for(let e=1;e<=12;e++){if(_===this._getMessage("MON_"+e).toUpperCase()||_===this._getMessage("MONTH_"+e).toUpperCase()||_===r[e-1].toUpperCase()||_===s[e-1].toUpperCase()){return e}}return t}},{key:"format",value:function e(_,r,s,n){const a=t.Type.isDate(r)?new Date(r.getTime()):t.Type.isNumber(r)?new Date(r*1e3):new Date;const D=t.Type.isDate(s)?new Date(s.getTime()):t.Type.isNumber(s)?new Date(s*1e3):new Date;const i=!!n;const o=this;if(t.Type.isArray(_)){return l(_,a,D,i)}else{if(!t.Type.isStringFilled(_)){return""}}const M=(_.match(/{{([^{}]*)}}/g)||[]).map((e=>(e.match(/[^{}]+/)||[""])[0]));if(M.length>0){M.forEach(((e,t)=>{_=_.replace("{{"+e+"}}","{{"+t+"}}")}))}const O=/\\?(sago|iago|isago|Hago|dago|mago|Yago|sdiff|idiff|Hdiff|ddiff|mdiff|Ydiff|sshort|ishort|Hshort|dshort|mhort|Yshort|yesterday|today|tommorow|tomorrow|[a-z])/gi;const T={d:()=>u(a).toString().padStart(2,"0"),D:()=>this._getMessage("DOW_"+S(a)),j:()=>u(a),l:()=>this._getMessage("DAY_OF_WEEK_"+S(a)),N:()=>S(a)||7,S:()=>{if(u(a)%10==1&&u(a)!=11){return"st"}else if(u(a)%10==2&&u(a)!=12){return"nd"}else if(u(a)%10==3&&u(a)!=13){return"rd"}else{return"th"}},w:()=>S(a),z:()=>{const e=new Date(c(a),0,1);const t=new Date(c(a),F(a),u(a));return Math.ceil((t-e)/(24*3600*1e3))},W:()=>{const e=new Date(a.getTime());const t=(S(a)+6)%7;A(e,u(e)-t+3);const _=e.getTime();H(e,0,1);if(S(e)!=4){H(e,0,1+(4-S(e)+7)%7)}const r=1+Math.ceil((_-e)/(7*24*3600*1e3));return r.toString().padStart(2,"0")},F:()=>this._getMessage("MONTH_"+(F(a)+1)+"_S"),f:()=>this._getMessage("MONTH_"+(F(a)+1)),m:()=>(F(a)+1).toString().padStart(2,"0"),M:()=>this._getMessage("MON_"+(F(a)+1)),n:()=>F(a)+1,t:()=>{const e=i?new Date(Date.UTC(c(a),F(a)+1,0)):new Date(c(a),F(a)+1,0);return u(e)},L:()=>{const e=c(a);return e%4==0&&e%100!=0||e%400==0?1:0},o:()=>{const e=new Date(a.getTime());A(e,u(e)-(S(a)+6)%7+3);return c(e)},Y:()=>c(a),y:()=>c(a).toString().slice(2),a:()=>E(a)>11?"pm":"am",A:()=>E(a)>11?"PM":"AM",B:()=>{const e=(a.getUTCHours()+1)%24+a.getUTCMinutes()/60+a.getUTCSeconds()/3600;return Math.floor(e*1e3/24).toString().padStart(3,"0")},g:()=>E(a)%12||12,G:()=>E(a),h:()=>(E(a)%12||12).toString().padStart(2,"0"),H:()=>E(a).toString().padStart(2,"0"),i:()=>m(a).toString().padStart(2,"0"),s:()=>R(a).toString().padStart(2,"0"),u:()=>(h(a)*1e3).toString().padStart(6,"0"),e:()=>{if(i){return"UTC"}return""},I:()=>{if(i){return 0}const e=new Date(c(a),0,1);const t=Date.UTC(c(a),0,1);const _=new Date(c(a),6,0);const r=Date.UTC(c(a),6,0);return 0+(e-t!==_-r)},O:()=>{if(i){return"+0000"}const e=a.getTimezoneOffset();const t=Math.abs(e);return(e>0?"-":"+")+(Math.floor(t/60)*100+t%60).toString().padStart(4,"0")},P:function(){if(i){return"+00:00"}const e=this.O();return e.substr(0,3)+":"+e.substr(3)},Z:()=>{if(i){return 0}return-a.getTimezoneOffset()*60},c:()=>"Y-m-d\\TH:i:sP".replace(O,d),r:()=>"D, d M Y H:i:s O".replace(O,d),U:()=>Math.floor(a.getTime()/1e3),sago:()=>p(U((D-a)/1e3),{0:"FD_SECOND_AGO_0",1:"FD_SECOND_AGO_1","10_20":"FD_SECOND_AGO_10_20",MOD_1:"FD_SECOND_AGO_MOD_1",MOD_2_4:"FD_SECOND_AGO_MOD_2_4",MOD_OTHER:"FD_SECOND_AGO_MOD_OTHER"}),sdiff:()=>p(U((D-a)/1e3),{0:"FD_SECOND_DIFF_0",1:"FD_SECOND_DIFF_1","10_20":"FD_SECOND_DIFF_10_20",MOD_1:"FD_SECOND_DIFF_MOD_1",MOD_2_4:"FD_SECOND_DIFF_MOD_2_4",MOD_OTHER:"FD_SECOND_DIFF_MOD_OTHER"}),sshort:()=>this._getMessage("FD_SECOND_SHORT").replace(/#VALUE#/g,U((D-a)/1e3)),iago:()=>p(U((D-a)/60/1e3),{0:"FD_MINUTE_AGO_0",1:"FD_MINUTE_AGO_1","10_20":"FD_MINUTE_AGO_10_20",MOD_1:"FD_MINUTE_AGO_MOD_1",MOD_2_4:"FD_MINUTE_AGO_MOD_2_4",MOD_OTHER:"FD_MINUTE_AGO_MOD_OTHER"}),idiff:()=>p(U((D-a)/60/1e3),{0:"FD_MINUTE_DIFF_0",1:"FD_MINUTE_DIFF_1","10_20":"FD_MINUTE_DIFF_10_20",MOD_1:"FD_MINUTE_DIFF_MOD_1",MOD_2_4:"FD_MINUTE_DIFF_MOD_2_4",MOD_OTHER:"FD_MINUTE_DIFF_MOD_OTHER"}),isago:()=>{const e=U((D-a)/60/1e3);let t=p(e,{0:"FD_MINUTE_0",1:"FD_MINUTE_1","10_20":"FD_MINUTE_10_20",MOD_1:"FD_MINUTE_MOD_1",MOD_2_4:"FD_MINUTE_MOD_2_4",MOD_OTHER:"FD_MINUTE_MOD_OTHER"});t+=" ";const _=U((D-a)/1e3)-e*60;t+=p(_,{0:"FD_SECOND_AGO_0",1:"FD_SECOND_AGO_1","10_20":"FD_SECOND_AGO_10_20",MOD_1:"FD_SECOND_AGO_MOD_1",MOD_2_4:"FD_SECOND_AGO_MOD_2_4",MOD_OTHER:"FD_SECOND_AGO_MOD_OTHER"});return t},ishort:()=>this._getMessage("FD_MINUTE_SHORT").replace(/#VALUE#/g,U((D-a)/60/1e3)),Hago:()=>p(U((D-a)/60/60/1e3),{0:"FD_HOUR_AGO_0",1:"FD_HOUR_AGO_1","10_20":"FD_HOUR_AGO_10_20",MOD_1:"FD_HOUR_AGO_MOD_1",MOD_2_4:"FD_HOUR_AGO_MOD_2_4",MOD_OTHER:"FD_HOUR_AGO_MOD_OTHER"}),Hdiff:()=>p(U((D-a)/60/60/1e3),{0:"FD_HOUR_DIFF_0",1:"FD_HOUR_DIFF_1","10_20":"FD_HOUR_DIFF_10_20",MOD_1:"FD_HOUR_DIFF_MOD_1",MOD_2_4:"FD_HOUR_DIFF_MOD_2_4",MOD_OTHER:"FD_HOUR_DIFF_MOD_OTHER"}),Hshort:()=>this._getMessage("FD_HOUR_SHORT").replace(/#VALUE#/g,U((D-a)/60/60/1e3)),yesterday:()=>this._getMessage("FD_YESTERDAY"),today:()=>this._getMessage("FD_TODAY"),tommorow:()=>this._getMessage("FD_TOMORROW"),tomorrow:()=>this._getMessage("FD_TOMORROW"),dago:()=>p(U((D-a)/60/60/24/1e3),{0:"FD_DAY_AGO_0",1:"FD_DAY_AGO_1","10_20":"FD_DAY_AGO_10_20",MOD_1:"FD_DAY_AGO_MOD_1",MOD_2_4:"FD_DAY_AGO_MOD_2_4",MOD_OTHER:"FD_DAY_AGO_MOD_OTHER"}),ddiff:()=>p(U((D-a)/60/60/24/1e3),{0:"FD_DAY_DIFF_0",1:"FD_DAY_DIFF_1","10_20":"FD_DAY_DIFF_10_20",MOD_1:"FD_DAY_DIFF_MOD_1",MOD_2_4:"FD_DAY_DIFF_MOD_2_4",MOD_OTHER:"FD_DAY_DIFF_MOD_OTHER"}),dshort:()=>this._getMessage("FD_DAY_SHORT").replace(/#VALUE#/g,U((D-a)/60/60/24/1e3)),mago:()=>p(U((D-a)/60/60/24/31/1e3),{0:"FD_MONTH_AGO_0",1:"FD_MONTH_AGO_1","10_20":"FD_MONTH_AGO_10_20",MOD_1:"FD_MONTH_AGO_MOD_1",MOD_2_4:"FD_MONTH_AGO_MOD_2_4",MOD_OTHER:"FD_MONTH_AGO_MOD_OTHER"}),mdiff:()=>p(U((D-a)/60/60/24/31/1e3),{0:"FD_MONTH_DIFF_0",1:"FD_MONTH_DIFF_1","10_20":"FD_MONTH_DIFF_10_20",MOD_1:"FD_MONTH_DIFF_MOD_1",MOD_2_4:"FD_MONTH_DIFF_MOD_2_4",MOD_OTHER:"FD_MONTH_DIFF_MOD_OTHER"}),mshort:()=>this._getMessage("FD_MONTH_SHORT").replace(/#VALUE#/g,U((D-a)/60/60/24/31/1e3)),Yago:()=>p(U((D-a)/60/60/24/365/1e3),{0:"FD_YEARS_AGO_0",1:"FD_YEARS_AGO_1","10_20":"FD_YEARS_AGO_10_20",MOD_1:"FD_YEARS_AGO_MOD_1",MOD_2_4:"FD_YEARS_AGO_MOD_2_4",MOD_OTHER:"FD_YEARS_AGO_MOD_OTHER"}),Ydiff:()=>p(U((D-a)/60/60/24/365/1e3),{0:"FD_YEARS_DIFF_0",1:"FD_YEARS_DIFF_1","10_20":"FD_YEARS_DIFF_10_20",MOD_1:"FD_YEARS_DIFF_MOD_1",MOD_2_4:"FD_YEARS_DIFF_MOD_2_4",MOD_OTHER:"FD_YEARS_DIFF_MOD_OTHER"}),Yshort:()=>p(U((D-a)/60/60/24/365/1e3),{0:"FD_YEARS_SHORT_0",1:"FD_YEARS_SHORT_1","10_20":"FD_YEARS_SHORT_10_20",MOD_1:"FD_YEARS_SHORT_MOD_1",MOD_2_4:"FD_YEARS_SHORT_MOD_2_4",MOD_OTHER:"FD_YEARS_SHORT_MOD_OTHER"}),x:()=>{const e=this.isAmPmMode(true);const t=e===this.AM_PM_MODE.LOWER?"g:i a":e===this.AM_PM_MODE.UPPER?"g:i A":"H:i";return this.format([["tomorrow","tomorrow, "+t],["-",this.convertBitrixFormat(this._getMessage("FORMAT_DATETIME")).replace(/:s/g,"")],["s","sago"],["i","iago"],["today","today, "+t],["yesterday","yesterday, "+t],["",this.convertBitrixFormat(this._getMessage("FORMAT_DATETIME")).replace(/:s/g,"")]],a,D,i)},X:()=>{const e=this.isAmPmMode(true);const t=e===this.AM_PM_MODE.LOWER?"g:i a":e===this.AM_PM_MODE.UPPER?"g:i A":"H:i";const _=this.format([["tomorrow","tomorrow"],["-",this.convertBitrixFormat(this._getMessage("FORMAT_DATE"))],["today","today"],["yesterday","yesterday"],["",this.convertBitrixFormat(this._getMessage("FORMAT_DATE"))]],a,D,i);const r=this.format([["tomorrow",t],["today",t],["yesterday",t],["",""]],a,D,i);if(r.length>0){return this._getMessage("FD_DAY_AT_TIME").replace(/#DAY#/g,_).replace(/#TIME#/g,r)}else{return _}},Q:()=>{const e=U((D-a)/60/60/24/1e3);if(e==0){return this._getMessage("FD_DAY_DIFF_1").replace(/#VALUE#/g,1)}else{return this.format([["d","ddiff"],["m","mdiff"],["","Ydiff"]],a,D)}}};let g=false;if(_[0]&&_[0]=="^"){g=true;_=_.substr(1)}let f=_.replace(O,d);if(g){f=f.replace(/\s*00:00:00\s*/g,"").replace(/(\d\d:\d\d)(:00)/g,"$1").replace(/(\s*00:00\s*)(?!:)/g,"")}if(M.length>0){M.forEach((function(e,t){f=f.replace("{{"+t+"}}",e)}))}return f;function l(e,t,_,r){const s=U((_-t)/1e3);for(let n=0;n?(\d+)?/.exec(a))!=null){if(i[1]&&i[2]){if(si[2]){return o.format(D,t,_,r)}}else if(s?(\d+)?/.exec(a))!=null){if(i[1]&&i[2]){if(si[2]*60){return o.format(D,t,_,r)}}else if(s?(\d+)?/.exec(a))!=null){if(i[1]&&i[2]){if(si[2]*60*60){return o.format(D,t,_,r)}}else if(s?(\d+)?/.exec(a))!=null){if(i[1]&&i[2]){if(si[2]*24*60*60){return o.format(D,t,_,r)}}else if(s?(\d+)?/.exec(a))!=null){if(i[1]&&i[2]){if(si[2]*31*24*60*60){return o.format(D,t,_,r)}}else if(s=a&&t=a&&t=a&&t=a&&t0?o.format(e[e.length-1][1],t,_,r):""}function c(e){return i?e.getUTCFullYear():e.getFullYear()}function u(e){return i?e.getUTCDate():e.getDate()}function F(e){return i?e.getUTCMonth():e.getMonth()}function E(e){return i?e.getUTCHours():e.getHours()}function m(e){return i?e.getUTCMinutes():e.getMinutes()}function R(e){return i?e.getUTCSeconds():e.getSeconds()}function h(e){return i?e.getUTCMilliseconds():e.getMilliseconds()}function S(e){return i?e.getUTCDay():e.getDay()}function A(e,t){return i?e.setUTCDate(t):e.setDate(t)}function H(e,t,_){return i?e.setUTCMonth(t,_):e.setMonth(t,_)}function p(e,t){const _=e<100?Math.abs(e):Math.abs(e%100);const r=_%10;let s="";if(_==0){s=o._getMessage(t["0"])}else if(_==1){s=o._getMessage(t["1"])}else if(_>=10&&_<=20){s=o._getMessage(t["10_20"])}else if(r==1){s=o._getMessage(t["MOD_1"])}else if(2<=r&&r<=4){s=o._getMessage(t["MOD_2_4"])}else{s=o._getMessage(t["MOD_OTHER"])}return s.replace(/#VALUE#/g,e)}function d(e,t){if(T[e]){return T[e]()}else{return t}}function U(e){return e>=0?Math.floor(e):Math.ceil(e)}}}]);return e}();babelHelpers.defineProperty(n,"AM_PM_MODE",{UPPER:1,LOWER:2,NONE:false});babelHelpers.defineProperty(n,"convertBitrixFormat",_);babelHelpers.defineProperty(n,"getFormat",s);const a=new t.Cache.MemoryCache;const D={get SERVER_TO_UTC(){return a.remember("SERVER_TO_UTC",(()=>t.Text.toInteger(t.Loc.getMessage("SERVER_TZ_OFFSET"))))},get USER_TO_SERVER(){return a.remember("USER_TO_SERVER",(()=>t.Text.toInteger(t.Loc.getMessage("USER_TZ_OFFSET"))))},get BROWSER_TO_UTC(){return a.remember("BROWSER_TO_UTC",(()=>t.Text.toInteger((new Date).getTimezoneOffset()*60)))}};Object.freeze(D);function i(e,t,_){o(e,t);return _}function o(e,t){if(e!==t){throw new TypeError("Private static access of wrong provenance")}}let M=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"getTimestamp",value:function e(){return Math.round(Date.now()/1e3)}},{key:"getDate",value:function e(){return new Date(this.getTimestamp()*1e3)}},{key:"toUser",value:function e(_){return t.Text.toInteger(_)+D.USER_TO_SERVER}},{key:"toServer",value:function t(_){return i(this,e,O).call(this,_)+D.SERVER_TO_UTC}}]);return e}();function O(e){return t.Text.toInteger(e)-D.BROWSER_TO_UTC}let T=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"getTimestamp",value:function e(){return M.toUser(M.getTimestamp())}},{key:"getDate",value:function e(){return new Date(this.getTimestamp()*1e3)}},{key:"toBrowser",value:function e(_){return t.Text.toInteger(_)+D.BROWSER_TO_UTC-D.SERVER_TO_UTC-D.USER_TO_SERVER}},{key:"toServer",value:function e(_){return t.Text.toInteger(_)-D.USER_TO_SERVER}}]);return e}();let g=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"getTimestamp",value:function e(){return M.toServer(M.getTimestamp())}},{key:"getDate",value:function e(){return new Date(this.getTimestamp()*1e3)}},{key:"toUser",value:function e(_){return t.Text.toInteger(_)+D.USER_TO_SERVER}},{key:"toBrowser",value:function e(_){return t.Text.toInteger(_)+D.BROWSER_TO_UTC-D.SERVER_TO_UTC}}]);return e}();const f=n;const l=Object.freeze({Offset:D,BrowserTime:M,UserTime:T,ServerTime:g});e.DateTimeFormat=n;e.Date=f;e.Timezone=l})(this.BX.Main=this.BX.Main||{},BX); //# sourceMappingURL=main.date.map.js