szdl-utils-kit 0.2.26 → 0.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +161 -161
- package/dist/index.js +727 -622
- package/dist/index.umd.cjs +2 -2
- package/dist/types/batch.d.ts +71 -71
- package/dist/types/bx-boot.d.ts +176 -176
- package/dist/types/bx-helper.d.ts +27 -27
- package/dist/types/bx-logger.d.ts +43 -43
- package/dist/types/index.d.ts +14 -14
- package/package.json +41 -41
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`):s(JSON.parse(c.responseText))):h&&h(c))},c.open("GET",t,!1),c.send()},w={"%d":{format:function(t){return r(t.day()||i.MIN_DAY,2)},parse:function(t){var s=Number(t);return{day:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%m":{format:function(t){return r(t.month()||i.MIN_MONTH,2)},parse:function(t){var s=Number(t);return{month:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%Y":{format:function(t){return r(t.year()||i.MIN_YEAR,4)},parse:function(t){var s=Number(t);return{year:isNaN(s)?e:s}},minLength:4,maxLength:4,type:"number"},"%w":{format:function(t){return t.dayOfWeek()||i.MIN_DAY_OF_WEEK},parse:function(){return{}},minLength:1,maxLength:1,type:"number"},"%a":{format:function(t){var s=t.dayOfWeek();return Ht[s!==e?s:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%A":{format:function(t){var s=t.dayOfWeek();return bt[s!==e?s:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%b":{format:function(t){var s=i.options("monthFromZero")?t.month():t.month()-1;return Xt[s!==e?s:i.MIN_MONTH]},parse:function(t){var s=i.monthNames().indexOf(t)+(i.options("monthFromZero")?0:1);return{month:s!==-1?s:e}},minLength:1,maxLength:999,type:"word"},"%B":{format:function(t){var s=i.options("monthFromZero")?t.month():t.month()-1;return X[s!==e?s:i.MIN_MONTH]},parse:function(t){var s=i.monthNames(!0).indexOf(t)+(i.options("monthFromZero")?0:1);return{month:s!==-1?s:e}},minLength:1,maxLength:999,type:"word"},"%H":{format:function(t){return r(t.hours()||i.MIN_HOURS,2)},parse:function(t){var s=Number(t);return{hours:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%M":{format:function(t){return r(t.minutes()||i.MIN_MINUTES,2)},parse:function(t){var s=Number(t);return{minutes:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%S":{format:function(t){return r(t.seconds()||i.MIN_SECONDS,2)},parse:function(t){var s=Number(t);return{seconds:isNaN(s)?e:s}},minLength:2,maxLength:2,type:"number"},"%s":{format:function(t){return t.timestamp()},parse:function(t){return isNaN(Number(t))?{}:i(Number(t)).get()},minLength:1,maxLength:20,type:"number"},"%F":{format:function(t){return r(t.year()||i.MIN_YEAR,4)+"-"+r(t.month()||i.MIN_MONTH,2)+"-"+r(t.day()||i.MIN_DAY,2)},parse:function(t){var s=Number(t.slice(0,4)),h=Number(t.slice(5,7)),c=Number(t.slice(8,10));return{year:s,month:h,day:c}},minLength:10,maxLength:10,type:"string"},"%D":{format:function(t){return r(t.month()||i.MIN_MONTH,2)+"/"+r(t.day()||i.MIN_DAY,2)+"/"+r(t.year()||i.MIN_YEAR,4)},parse:function(t){var s=Number(t.slice(0,2)),h=Number(t.slice(3,5)),c=Number(t.slice(6,10));return{year:c,month:s,day:h}},minLength:10,maxLength:10,type:"string"}},jt={useMilliseconds:!1,monthFromZero:!1},S;S=function(t,s,h){return this._d=new Date,this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t!==e&&this.set(t,s,h),this},S.fn=S.prototype,S.fn.dayCount=function(){var t=this.month(),s=i.MAX_DAY_IN_MONTHS[t-(i.options("monthFromZero")?0:1)];return this.leapYear()&&t===(i.options("monthFromZero")?1:2)&&(s+=1),s},S.fn.year=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_YEAR&&Number(t)<=i.MAX_YEAR?(this._d.setFullYear(Number(t)),this._i.year=!1):this._i.year=Number(t):(this._d.setFullYear(i.MIN_YEAR),this._i.year=!1);else return this._i.year===!1?this._d.getFullYear():this._i.year;return this},S.fn.month=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_MONTH&&Number(t)<=i.MAX_MONTH?(this._d.setMonth(i.options("monthFromZero")?Number(t):Number(t)-1),this._i.month=!1):this._i.month=Number(t):(this._d.setMonth(i.options("monthFromZero")?i.MIN_MONTH:i.MIN_MONTH-1),this._i.month=!1);else return this._i.month===!1?i.options("monthFromZero")?this._d.getMonth():this._d.getMonth()+1:this._i.month;return this},S.fn.day=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_DAY&&Number(t)<=this.dayCount()?(this._d.setDate(Number(t)),this._i.day=!1):this._i.day=Number(t):(this._d.setDate(i.MIN_DAY),this._i.day=!1);else return this._i.day===!1?this._d.getDate():this._i.day;return this},S.fn.hours=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_HOURS&&Number(t)<=i.MAX_HOURS?(this._d.setHours(Number(t)),this._i.hours=!1):this._i.hours=Number(t):(this._d.setHours(i.MIN_HOURS),this._i.hours=!1);else return this._i.hours===!1?this._d.getHours():this._i.hours;return this},S.fn.minutes=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_MINUTES&&Number(t)<=i.MAX_MINUTES?(this._d.setMinutes(Number(t)),this._i.minutes=!1):this._i.minutes=Number(t):(this._d.setMinutes(i.MIN_MINUTES),this._i.minutes=!1);else return this._i.minutes===!1?this._d.getMinutes():this._i.minutes;return this},S.fn.seconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_SECONDS&&Number(t)<=i.MAX_SECONDS?(this._d.setSeconds(Number(t)),this._i.seconds=!1):this._i.seconds=Number(t):(this._d.setSeconds(i.MIN_SECONDS),this._i.seconds=!1);else return this._i.seconds===!1?this._d.getSeconds():this._i.seconds;return this},S.fn.milliseconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_MILLISECONDS&&Number(t)<=i.MAX_MILLISECONDS?(this._d.setMilliseconds(Number(t)),this._i.milliseconds=!1):this._i.milliseconds=Number(t):(this._d.setMilliseconds(i.MIN_MILLISECONDS),this._i.milliseconds=!1);else return this._i.milliseconds===!1?this._d.getMilliseconds():this._i.milliseconds;return this},S.fn.week=function(){var t=new Date(this.year(),0,1),s=i(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc()*1e3;return Math.ceil(((s-t.getTime())/864e5+t.getDay()+1)/7)},S.fn.set=function(t,s,h){if(this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t===e)return this._d=new Date,this;if(t instanceof Date)return this._d=t,this;if(typeof t=="number")return this._d=new Date(t*(i.options("useMilliseconds")?1:1e3)),this;if(typeof t=="object"&&(t instanceof Array?(this.day(i.MIN_DAY),this.year(t[0]),this.month(t[1]),this.day(t[2]),this.hours(t[3]),this.minutes(t[4]),this.seconds(t[5]),this.milliseconds(t[6])):(this.day(i.MIN_DAY),this.year(t.year),this.month(t.month),this.day(t.day),this.hours(t.hours),this.minutes(t.minutes),this.seconds(t.seconds),this.milliseconds(t.milliseconds))),typeof t=="string"){var c,p=[],d,L,K=[],Y=0,I=0,b,W,H={},D;if(t===e)return d=a(this,h),d===e&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),d;for(s===e&&(s=i.detectFormat(t));Y<s.length;){if(s.charAt(Y)==="%"){if(L=s.charAt(Y)+s.charAt(Y+1),w[L]!==e){switch(b=0,W="",w[L].type){case"number":for(;b<w[L].maxLength&&I+b<t.length&&!isNaN(Number(t.charAt(I+b)));)W+=t.charAt(I+b),b+=1;break;case"word":for(;b<w[L].maxLength&&I+b<t.length&&/^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(I+b));)W+=t.charAt(I+b),b+=1;break;case"string":for(;b<w[L].maxLength&&I+b<t.length;)W+=t.charAt(I+b),b+=1;break}if(b<w[L].minLength)return d=a(this,h),d===e&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),d;p.push(L),K.push(W),b-=1,I+=b,Y+=1}}else if(t.charAt(I)!==s.charAt(Y))return d=a(this,h),d===e&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),d;Y+=1,I+=1}for(c in p)p.hasOwnProperty(c)&&w.hasOwnProperty(p[c])&&(D=w[p[c]].parse(K[c]),H={year:D.year!==e?D.year:H.year,month:D.month!==e?D.month:H.month,day:D.day!==e?D.day:H.day,hours:D.hours!==e?D.hours:H.hours,minutes:D.minutes!==e?D.minutes:H.minutes,seconds:D.seconds!==e?D.seconds:H.seconds});this.day(i.MIN_DAY),this.year(H.year),this.month(H.month),this.day(H.day),this.hours(H.hours),this.minutes(H.minutes),this.seconds(H.seconds),this.milliseconds(H.milliseconds)}return this},S.fn.leapYear=function(){var t=this.year();return t%4===0?t%100===0?t%400===0:!0:!1},S.fn.timestamp=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(i.options("useMilliseconds")?1:1e3)+this._d.getTimezoneOffset()*6e4),this):i.options("useMilliseconds")?this._d.getTime()-this._d.getTimezoneOffset()*6e4:Math.floor(this._d.getTime()/1e3)-this._d.getTimezoneOffset()*60},S.fn.utc=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(i.options("useMilliseconds")?1:1e3)),this):i.options("useMilliseconds")?this._d.getTime():Math.floor(this._d.getTime()/1e3)},S.fn.dayOfWeek=function(t){if(t==="long")return bt[this._d.getDay()];if(t==="short")return Ht[this._d.getDay()];if(t===e)return this._d.getDay();if(t===0||t==="Sunday")return this.calc({day:-this.dayOfWeek()});if(t===1||t==="Monday")return this.calc({day:(this.dayOfWeek()===0?-6:1)-this.dayOfWeek()});if(t===2||t==="Tuesday")return this.calc({day:(this.dayOfWeek()===0?-5:2)-this.dayOfWeek()});if(t===3||t==="Wednesday")return this.calc({day:(this.dayOfWeek()===0?-4:3)-this.dayOfWeek()});if(t===4||t==="Thursday")return this.calc({day:(this.dayOfWeek()===0?-3:4)-this.dayOfWeek()});if(t===5||t==="Friday")return this.calc({day:(this.dayOfWeek()===0?-2:5)-this.dayOfWeek()});if(t===6||t==="Saturday")return this.calc({day:(this.dayOfWeek()===0?-1:6)-this.dayOfWeek()})},S.fn.timezone=function(t){switch(t){case"hours":return Math.floor(this._d.getTimezoneOffset()/60);case"minutes":return this._d.getTimezoneOffset();default:return this._d.getTimezoneOffset()*60}},S.fn.get=function(t){switch(t){case"Date":return new Date(this.year(),this.month()-(i.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds());case"DateUTC":return new Date(Date.UTC(this.year(),this.month()-(i.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()));case"Array":return[this.year(),this.month(),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()];default:return{year:this.year(),month:this.month(),week:this.week(),day:this.day(),hours:this.hours(),minutes:this.minutes(),seconds:this.seconds(),milliseconds:this.milliseconds(),utc:this.utc(),dayOfWeek:this.dayOfWeek(),dayOfWeekShort:this.dayOfWeek("short"),dayOfWeekLong:this.dayOfWeek("long"),timestamp:this.timestamp()}}},S.fn.format=function(t){for(var s=0,h="",c;s<t.length;)t.charAt(s)==="%"?(c=t.charAt(s)+t.charAt(s+1),w[c]!==e?(h+=w[c].format(this),s+=1):h+="%"):h+=t.charAt(s),s+=1;return h},S.fn.valid=function(){return this._i.year===!1&&this._i.month===!1&&this._i.day===!1&&this._i.hours===!1&&this._i.minutes===!1&&this._i.seconds===!1&&this._i.milliseconds===!1},S.fn.errors=function(){return this._i},S.fn.between=function(t,s){var h=this.timestamp(),c=t.timestamp();switch(s){case"year":return Math.floor((c-h)/31556952);case"month":return Math.floor((c-h)/2629746);case"day":return Math.floor((c-h)/86400);case"hours":return Math.floor((c-h)/3600);case"minutes":return Math.floor((c-h)/60);case"seconds":return c-h;default:return e}},S.fn.calc=function(t){return t.year!==e&&this._d.setFullYear(this._d.getFullYear()+t.year),t.month!==e&&this._d.setMonth(this._d.getMonth()+t.month),t.day!==e&&this._d.setDate(this._d.getDate()+t.day),t.hours!==e&&this._d.setHours(this._d.getHours()+t.hours),t.minutes!==e&&this._d.setMinutes(this._d.getMinutes()+t.minutes),t.seconds!==e&&this._d.setSeconds(this._d.getSeconds()+t.seconds),t.milliseconds!==e&&this._d.setMilliseconds(this._d.getMilliseconds()+t.milliseconds),this},i=function(t,s,h){return new S(t,s,h)},i.MIN_YEAR=1e3,i.MAX_YEAR=3e3,i.MIN_MONTH=1,i.MAX_MONTH=12,i.MIN_DAY=1,i.MAX_DAY_IN_MONTHS=[31,28,31,30,31,30,31,31,30,31,30,31],i.MIN_DAY_OF_WEEK=0,i.MAX_DAY_OF_WEEK=6,i.MIN_HOURS=0,i.MAX_HOURS=23,i.MIN_MINUTES=0,i.MAX_MINUTES=59,i.MIN_SECONDS=0,i.MAX_SECONDS=59,i.MIN_MILLISECONDS=0,i.MAX_MILLISECONDS=999,i.VERSION="0.2.18",i.options=function(t,s){if(t===e)return jt;if(jt.hasOwnProperty(t)){if(s===e)return jt[t];jt[t]=s,t==="monthFromZero"&&(i.MIN_MONTH=s?0:1,i.MAX_MONTH=s?11:12)}return e},i.noConflict=function(){return n.tempus=u,i},i.generate=function(t){var s,h,c,p,d,L,K,Y;if(typeof t.dateFrom!="number"&&(t.dateFrom instanceof S?s=t.dateFrom.utc():s=i(t.dateFrom,t.formatFrom).utc()),typeof t.dateTo!="number"&&(t.dateTo instanceof S?h=t.dateTo.utc():h=i(t.dateTo,t.formatTo!==e?t.formatTo:t.formatFrom).utc()),typeof t.period=="number"?d={year:0,month:0,day:0,hours:0,minutes:0,seconds:t.period}:typeof t.period=="string"?d={year:t.period==="year"?1:0,month:t.period==="month"?1:0,day:t.period==="day"?1:0,hours:t.period==="hours"?1:0,minutes:t.period==="minutes"?1:0,seconds:t.period==="seconds"?1:0}:typeof t.period=="object"&&(d={year:t.period.year!==e?t.period.year:0,month:t.period.month!==e?t.period.month:0,day:t.period.day!==e?t.period.day:0,hours:t.period.hours!==e?t.period.hours:0,minutes:t.period.minutes!==e?t.period.minutes:0,seconds:t.period.seconds!==e?t.period.seconds:0}),t.groupBy===e?L=t.asObject===!0?{}:[]:(L=[],L.push([]),K=i(s).get()[t.groupBy]),Y=function(W,H,D){return t.asObject===!0?t.format!==e?W[i(H).format(t.format)]={}:W[i(H).format("%F %H:%M:%S")]={}:t.format!==e?W.push(D?null:i(H).format(t.format)):W.push(D?null:i(H)),W},t.groupBy!==e&&t.fillNulls){var I={year:d.year?-d.year:e,month:d.month?-d.month:e,day:d.day?-d.day:e,hours:d.hours?-d.hours:e,minutes:d.minutes?-d.minutes:e,seconds:d.seconds?-d.seconds:e,milliseconds:d.milliseconds?-d.milliseconds:e};for(c=i(s).calc(I).utc();i(c).get()[t.groupBy]===K;)Y(L[L.length-1],c,!0),c=i(c).calc(I).utc();if(t.groupBy==="week"){var b=i(s).dayOfWeek();for(c=i(s).dayOfWeek(0).utc();L[0].length<b&&c<s;)Y(L[L.length-1],c,!0),c=i(c).calc(d).utc()}}for(;s<=h;)t.groupBy===e?Y(L,s):i(s).get()[t.groupBy]===K?Y(L[L.length-1],s):(L.push([]),Y(L[L.length-1],s),K=i(s).get()[t.groupBy]),s=i(s).calc(d).utc();if(t.groupBy!==e&&t.fillNulls)for(p=i(h).calc(d).utc();i(p).get()[t.groupBy]===K;)Y(L[L.length-1],p,!0),p=i(p).calc(d).utc();return L},i.monthNames=function(t){switch(t){case"long":return X;default:return Xt}},i.dayNames=function(t){switch(t){case"long":return bt;default:return Ht}},i.lang=function(t){if(t!==e)m=t,N[m]===e&&(m="en"),X=P(),Xt=pt(),bt=ot(),Ht=x();else return m;return e},i.availableLangs=function(){return Object.keys(N)},i.registerFormat=function(t,s,h,c,p,d){w[t]={format:s,parse:h,minLength:c,maxLength:p,type:d}},i.unregisterFormat=function(t){delete w[t]},i.detectFormat=function(t){var s,h,c;return s=O(t,0),s!==""&&(c=10),h=t.charAt(c),(h==="T"||h===" ")&&(s+=h,c+=1),s+=l(t,c),s},R={TempusDate:S},i.classes=function(t,s){if(s===e)return R[t];R[t]=s},i.loadTranslations=function(t){typeof t=="object"?N=t:typeof t=="string"&&de(t,function(s){N=s},function(s){})},m=(E.language||E.systemLanguage||E.userLanguage||"en").substr(0,2).toLowerCase(),N[m]===e&&(m="en"),X=P(),Xt=pt(),bt=ot(),Ht=x(),G.exports&&(A=G.exports=i),A.tempus=i}).call(T)})(ht,ht.exports);var Oe=ht.exports;const mt=M(Oe);class j{constructor(A,e={}){f(this,at);f(this,Nt);f(this,_t);f(this,Ot);f(this,yt);f(this,dt);f(this,It);f(this,Ut);f(this,gt);f(this,Et);f(this,Tt);f(this,lt);f(this,Rt);f(this,Gt);f(this,it);f(this,ct);f(this,St);f(this,q,null);f(this,ft,null);f(this,v,[]);f(this,B,{});f(this,J,50);f(this,Q,50);f(this,$,!0);f(this,tt,null);f(this,U,null);f(this,Z,null);f(this,Bt,100);f(this,et,"no");f(this,F,!1);f(this,At,!1);f(this,st,!1);C(this,"errors",{});C(this,"answerData",{});y(this,q,A),y(this,ft,e)}get serial(){return o(this,F)}get limitCommandSerial(){return o(this,Q)}set limitCommandSerial(A){if(A<10)throw new Error("limitCommandSerial не может быть меньше 10");A>=10&&A<50&&(y(this,J,A),y(this,Q,A)),y(this,Q,A)}setSerial(){y(this,F,!0),y(this,At,!0),y(this,st,!1)}setParallel(){y(this,F,!1),y(this,At,!1),y(this,st,!0)}stop(){y(this,$,!1)}async batch(A,e){o(this,Z)&&_(this,Nt,Kt).call(this),e&&y(this,tt,e),o(this,At)===!1&&y(this,F,!1),Object.keys(A).length>o(this,Q)&&y(this,F,!0),y(this,$,!0),y(this,v,[]),y(this,B,{}),this.errors={},this.answerData={};const n=_(this,Ot,vt).call(this,A);if(Object.keys(A).length<o(this,Q)){const r=n.map((a,l)=>_(this,yt,$t).call(this,a,n[l]));return Promise.allSettled(r).then(a=>{let l={};for(let O of a)O.status==="fulfilled"&&(l={...l,...O.value});return l})}else{let r={},a=0,l=1,O=Object.keys(A).length||1,u=i=>{a+=Object.keys(i).length,l=Math.round(a/O*100)};for(let[i,R]of Object.entries(n)){let E=await _(this,yt,$t).call(this,R,n[i],!0);u(R),e&&e({percent:l}),r={...r,...E}}return r}}async batchTotalCount(A,e){y(this,B,{}),this.errors={};let n=1,r=0,a=Object.keys(A).length||1,l=u=>{r+=Object.keys(u).length,n=Math.round(r/a*100)};e&&e({percent:n});const O=_(this,Ot,vt).call(this,A);if(o(this,st)){const u=O.map(i=>_(this,dt,te).call(this,i).then(R=>(l(i),e&&e({percent:n}),R)));return Promise.allSettled(u).then(i=>{let R={};for(let E of i)E.status==="fulfilled"&&(R={...R,...E.value});return R})}else{let u={};for(let i of O){let R=await _(this,dt,te).call(this,i);l(i),e&&e({percent:n}),u={...u,...R}}return u}}}q=new WeakMap,ft=new WeakMap,v=new WeakMap,B=new WeakMap,J=new WeakMap,Q=new WeakMap,$=new WeakMap,tt=new WeakMap,U=new WeakMap,Z=new WeakMap,Bt=new WeakMap,et=new WeakMap,F=new WeakMap,At=new WeakMap,st=new WeakMap,at=new WeakSet,xt=function(){let A=0;if(!o(this,U))return Math.round(A);let e=0,n=0;return Object.values(o(this,U)).forEach(r=>{const{total:a,count:l}=r;e+=a??0,n+=l??0}),e?A=n/e*100:A=100,{percent:Math.round(A),allCount:n,allTotal:e}},Nt=new WeakSet,Kt=function(){clearInterval(o(this,Z)),y(this,Z,""),y(this,U,""),y(this,tt,""),y(this,et,"no")},_t=new WeakSet,qt=function({key:A,value:e}){const n=_(this,it,Dt).call(this,e.data()),r=Array.isArray(n)?n.length:0,a=_(this,ct,Zt).call(this,e.total(),r);let l=1;n&&(l=r),o(this,tt)&&(o(this,U)||y(this,U,{}),o(this,U)[A]&&o(this,U)[A].count&&(l+=o(this,U)[A].count),o(this,U)[A]={total:a,count:l},o(this,Z)||y(this,Z,setInterval(()=>{const{percent:O,allCount:u,allTotal:i}=o(this,at,xt);(o(this,et)==="no"||o(this,et)<o(this,at,xt).percent)&&(o(this,tt).call(this,{data:o(this,U),percent:O,allCount:u,allTotal:i}),y(this,et,o(this,at,xt).percent)),O===100&&_(this,Nt,Kt).call(this)},o(this,Bt))))},Ot=new WeakSet,vt=function(A){const e=[],n=Object.entries(A);for(let r=0;r<n.length;r+=o(this,J)){const a=n.slice(r,r+o(this,J));e.push(Object.fromEntries(a))}return e},yt=new WeakSet,$t=function(A,e,n){return new Promise(r=>{const a=_(this,Rt,ie).call(this,e),l=[];let O=0,u=0;o(this,q).call(this,A,i=>{Object.entries(i).forEach(([R,E])=>{let m={};const N=E.error();if(N){let{query:{method:x},answer:X}=E;this.errors[R]={error:N,method:x},O+=1}if(E!=null&&E.answer&&Object.keys(E.answer).length){for(let[x,X]of Object.entries(E.answer))x!="result"&&X&&(m[x]=X);Object.keys(m).length&&(this.answerData[R]=m)}const P=_(this,it,Dt).call(this,E.data()),pt=Array.isArray(P)?P.length:0,ot=_(this,ct,Zt).call(this,E.total(),pt);if(Array.isArray(P)?o(this,B)[R]=P:typeof P=="object"&&P!==null&&Object.keys(P).length===0?o(this,B)[R]=[]:o(this,B)[R]=P,u+=ot,n||_(this,_t,qt).call(this,{key:R,value:E}),ot>o(this,J)&&ot>pt){const x=Math.ceil(ot/o(this,J))-1,X=Array.from({length:x});l.push([R,a[R],X])}}),u>5e3&&o(this,At)===!1&&o(this,st)===!1&&y(this,F,!0),O>0&&_(this,St,re).call(this),l.length?(_(this,It,he).call(this,l),_(this,Ut,ae).call(this).then(()=>r(_(this,lt,Qt).call(this)))):r(_(this,lt,Qt).call(this))})})},dt=new WeakSet,te=function(A){return new Promise(e=>{const n=_(this,Rt,ie).call(this,A);let r=0;o(this,q).call(this,n,a=>{Object.entries(a).forEach(([l,O])=>{const u=O.error();u&&(this.errors[l]=u,r+=1);const i=_(this,it,Dt).call(this,O.data()),R=Array.isArray(i)?i.length:0,E=_(this,ct,Zt).call(this,O.total(),R);o(this,B)[l]=E}),r>0&&_(this,St,re).call(this),e(_(this,lt,Qt).call(this))})})},It=new WeakSet,he=function(A){let e=[];A.forEach(([n,r,a])=>{a.forEach((l,O)=>{const u=O+1,i=o(this,J)*u,E=[[n,u].join("_"),_(this,Gt,le).call(this,r,i)];e.length===o(this,J)?(o(this,v).push(e),e=[E]):e.push(E)})}),e.length&&o(this,v).push(e)},Ut=new WeakSet,ae=function(){const A=[],e=[],n=r=>{Object.entries(r).forEach(([a,l])=>{const[O]=a.split("_"),u=_(this,it,Dt).call(this,l.data());Array.isArray(u)&&o(this,B)[O].push(...u),_(this,_t,qt).call(this,{key:O,value:l})})};return o(this,v).forEach((r,a)=>{const l=Object.fromEntries(r),O=()=>new Promise(u=>o(this,q).call(this,l,i=>{o(this,F)?n(i):e[a]=i,u()}));A.push(O)}),o(this,F)?_(this,Et,Ae).call(this,A):_(this,Tt,se).call(this,A).then(()=>{e.forEach(n)})},gt=new WeakSet,ee=function(){return new Promise(A=>setTimeout(A,500))},Et=new WeakSet,Ae=function(A){if(!A.length)return Promise.resolve();const e=A.shift();return Promise.allSettled([e(),_(this,gt,ee).call(this)]).then(()=>o(this,$)?_(this,Et,Ae).call(this,A):Promise.resolve())},Tt=new WeakSet,se=function(A){if(!A.length)return Promise.resolve();const e=A.shift();return _(this,gt,ee).call(this).then(()=>e()).then(()=>o(this,$)?_(this,Tt,se).call(this,A):Promise.resolve())},lt=new WeakSet,Qt=function(){return Object.entries(o(this,ft)).forEach(([A,e])=>{o(this,B)[A]&&(o(this,B)[A]=e(o(this,B)[A]))}),o(this,B)},Rt=new WeakSet,ie=function(A){return Object.entries(A).reduce((e,[n,r])=>{if(Array.isArray(r)){const[a,l={}]=r;e[n]=[a,l]}else{const{method:a,params:l={}}=r;e[n]=[a,l]}return e},{})},Gt=new WeakSet,le=function(A,e){const[n,r]=A;return[n,{start:e,...r}]},it=new WeakSet,Dt=function(A){return((A==null?void 0:A.items)||(A==null?void 0:A.documents)||(A==null?void 0:A.tasks))??A},ct=new WeakSet,Zt=function(A,e){return A!==A&&(A=0),A===0&&e===0?0:A||e},St=new WeakSet,re=function(){console.group(`${this.constructor.name}: Ошибки в методах!`),Object.entries(this.errors).forEach(([A,e])=>{console.info(`[${A}]`,e)}),console.groupEnd()};class Vt{constructor(){f(this,rt,{})}get hash(){return this.createHash(8)}createHash(A){let e="abcdefghijklmnopqrstuvwxyz0123456789",n="";A=A||6;for(let r=0;r<A;r++)n+=e.charAt(Math.floor(Math.random()*e.length));return n}actionFilter({keyTimer:A,duration:e=10,action:n}){o(this,rt)[A]&&(clearTimeout(o(this,rt)[A]),o(this,rt)[A]=null),n&&(o(this,rt)[A]=setTimeout(()=>{n()},e))}async noSleep(){let A=document.createElement("video");A.classList.add("no-sleep"),A.addEventListener("loadeddata",()=>{A.style.position="fixed",A.style.left="-9999px",document.querySelector("body").append(A),A.play()}),A.addEventListener("ended",()=>{this.actionFilter({keyTimer:"no-sleep",duration:5e3,action:()=>A.play()})}),A.src="data:video/mp4;base64,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"}downloadFileJson(A,e){let n=new Blob([JSON.stringify(A)],{type:"application/json"}),r=URL.createObjectURL(n),a=document.createElement("a");a.style.display="none",a.href=r,a.download=`${e}.json`,document.body.appendChild(a),a.click(),setTimeout(()=>{document.body.removeChild(a),URL.revokeObjectURL(r)},200)}}rt=new WeakMap;const Yt=new Vt;class oe{constructor(){f(this,Ct);f(this,Mt);f(this,Ft);f(this,Pt);f(this,Wt);f(this,k,"logger");f(this,V,!1);f(this,wt,2e3);f(this,nt,new Map);f(this,Lt,{});f(this,z,null);f(this,ut,!1);C(this,"periodClear",3);_(this,Ct,ce).call(this)}async init(){let A=new j(BX24.callBatch),{entityList:e}=await A.batch({entityList:{method:"entity.get"}});if(e&&Array.isArray(e))if(e.find(r=>r.ENTITY==o(this,k)))y(this,V,!0);else{let{entityAdd:r}=await A.batch({entityAdd:{method:"entity.add",params:{ENTITY:o(this,k),NAME:o(this,k),ACCESS:{AU:"X"}}}});r&&y(this,V,!0)}return _(this,Pt,me).call(this),o(this,V)}start({type:A,data:e}){if(!o(this,V)){_(this,Mt,ne).call(this,"entity");return}const n=Yt.hash;return o(this,nt).set(n,{type:A,data:e,userInfo:o(this,Lt),errorList:[],status:"",answer:null,date:new Date().getTime()}),n}stop({key:A,errorList:e,status:n,answer:r}){if(!o(this,V)){_(this,Mt,ne).call(this,"entity");return}let a=o(this,nt).get(A);e&&(a.errorList=e),n&&(a.status=n),r&&(a.answer=r),Yt.actionFilter({keyTimer:"add.entity.items",duration:o(this,wt),action:async()=>{var l;await _(this,Ft,ue).call(this),(l=a==null?void 0:a.data)!=null&&l.updateList&&y(this,ut,!0)}})}async getEntityList(A){var r;if((r=o(this,z))!=null&&r.length&&!o(this,ut))return o(this,z);let e=new j(BX24.callBatch),{entityList:n}=await e.batch({entityList:{method:"entity.item.get",params:{ENTITY:o(this,k),SORT:{ID:"DESC"}}}},A);return n=n.map(a=>{const{ID:l,DATE_CREATE:O,DETAIL_TEXT:u}=a;return{...JSON.parse(u),id:l,dateCreate:O}}),y(this,ut,!1),n}async downAllEntityJson(){let A=await this.getEntityList(),e=mt().format("%Y-%m-%d");Yt.downloadFileJson(A,`sdklogger-entity-data__${e}`)}}k=new WeakMap,V=new WeakMap,wt=new WeakMap,nt=new WeakMap,Lt=new WeakMap,z=new WeakMap,ut=new WeakMap,Ct=new WeakSet,ce=async function(){const A=new j(BX24.callBatch),e=BX24.isAdmin(),{curUser:n}=await A.batch({curUser:{method:"user.current"}});y(this,Lt,{isAdmin:e,curUser:n})},Mt=new WeakSet,ne=function(A){A=="entity"&&Yt.actionFilter({keyTimer:"error.logger.entity",duration:500,action:()=>{console.error("Хранилище для логгера не инициализировано")}})},Ft=new WeakSet,ue=async function(){let A={},e=new j(BX24.callBatch);for(let[n,r]of o(this,nt).entries())r.status&&(A[n]={method:"entity.item.add",params:{ENTITY:o(this,k),NAME:o(this,k),DETAIL_TEXT:JSON.stringify(r)}});if(Object.keys(A).length){let n=await e.batch(A),{errors:r}=e;for(let[a,l]of Object.entries({...n,...r}))o(this,nt).delete(a);return!0}},Pt=new WeakSet,me=async function(){let A=new j(BX24.callBatch),{serverTime:e}=await A.batch({serverTime:{method:"server.time"}});o(this,z)||y(this,z,await this.getEntityList());let n=o(this,z).filter(r=>{let{dateCreate:a}=r;return mt(new Date(a)).between(mt(new Date(e)),"month")>=this.periodClear});_(this,Wt,fe).call(this,n)},Wt=new WeakSet,fe=async function(A){let e=new j(BX24.callBatch),n=A.map(r=>{let{id:a}=r;return{method:"entity.item.delete",params:{ENTITY:o(this,k),ID:a}}});return await e.batch(n)};class ye{constructor(A){f(this,Jt);f(this,kt);C(this,"domain","");C(this,"isAdmin",!1);C(this,"appInfo",null);C(this,"appConst",null);C(this,"userInfo",null);C(this,"placeData",null);C(this,"placeInfo",null);C(this,"logger",new oe);this.appConst=A}init(){return new Promise(A=>{let e=setInterval(()=>{window.BX24&&BX24.init(async()=>{console.info("init BX24"),clearInterval(e),this.domain=BX24.getDomain(),this.isAdmin=BX24.isAdmin(),this.placeInfo=BX24.placement.info(),await this.logger.init();const[n,r]=await Promise.all([_(this,Jt,Ne).call(this),_(this,kt,_e).call(this)]);this.appInfo=n,this.userInfo=r,new Vt().noSleep(),A(!0)})},100)})}userOption(A,e){return e?BX24.userOption.set(A,e):BX24.userOption.get(A)}call({method:A,params:e,updateList:n}){let r=this.logger.start({type:"call",data:{method:A,params:e,updateList:n}});return new Promise(a=>{e||(e={}),BX24.callMethod(A,e,l=>{let O={};if(l!=null&&l.answer)for(let[u,i]of Object.entries(l.answer))u!="result"&&i&&(O[u]=i);if(l.error()){let u=l.error();console.error(u),this.logger.stop({answer:O,key:r,status:"fail",errorList:[u.toSting()]}),a(!1)}else{let u=l.data();u!=null&&u.items&&(u=u.items),this.logger.stop({answer:O,key:r,status:"success"}),a(u)}})})}async batch(A,e,{updateList:n,errorCall:r,limitCommandSerial:a}={}){let l=new j(BX24.callBatch),O=this.logger.start({type:"batch",data:{commandList:A,updateList:n}});a&&(l.limitCommandSerial=a);try{let u=await l.batch(A,e);if(Object.keys(l.errors).length){let i=Object.entries(l.errors).map(([R,E])=>{var m;return{key:R,error:`${E==null?void 0:E.method} ${(m=E==null?void 0:E.error)==null?void 0:m.toString()}`.trim()}});r&&r(l.errors),this.logger.stop({key:O,status:"fail",errorList:i,answer:l.answerData})}else this.logger.stop({key:O,status:"success",answer:l.answerData});return u}catch(u){let i=u==null?void 0:u.toString();return this.logger.stop({key:O,status:"fail-runtime",errorList:[i],answer:l.answerData}),console.error(u),!1}}async batchTotalCount(A,e){let n=new j(BX24.callBatch),r=this.logger.start({type:"batch",data:{commandList:A}});try{let a=await n.batchTotalCount(A,e);if(Object.keys(n.errors).length){let l=Object.entries(n.errors).map(([O,u])=>({key:O,error:u.toSting()}));this.logger.stop({key:r,status:"fail",errorList:l})}else this.logger.stop({key:r,status:"success"});return a}catch(a){return this.logger.stop({key:r,status:"fail",errorList:[a.toSting()]}),console.error(a),!1}}getPlacement(){return this.call({method:"placement.get"}).then(A=>(this.placeData||(this.placeData=A),A))}async placementBind(A){this.placeData||(this.placeData=await this.getPlacement());const{appName:e,pathApp:n}=this.appConst,r=this.placeData.map(l=>l.placement);let a=this.placeData.find(l=>l.placement==A);r.includes(A)?a.handler!=n&&(window.placementUnBind||(window.placementUnBind={}),window.placementUnBind[A]||this.placementUnBind(a).then(()=>{window.placementUnBind[A]||(window.placementUnBind[A]=!0,this.placementBind(A))})):this.call({method:"placement.bind",params:{PLACEMENT:A,HANDLER:n,LANG_ALL:{ru:{TITLE:e}}}}).then(l=>{l?console.info("Приложение успешно встроено в",A):console.warn("Приложение не может быть встроено в",A)})}placementUnBind(A){const{pathApp:e,appName:n}=this.appConst;return this.call({method:"placement.unbind",params:{PLACEMENT:A,HANDLER:e,LANG_ALL:{ru:{TITLE:n}}}}).then(r=>(console.log("Встройка отвязана",A),r))}getBotList(){return this.call({method:"imbot.bot.list",params:{}}).then(A=>{let e=Object.values(A);return console.log("chat-bot list:",e),e})}regBot({code:A,type:e,name:n}){const{appName:r,pathApp:a,chatBotLogo:l}=this.appConst,O=this.appInfo.ID;return this.call({method:"imbot.register",params:{CODE:A??this.appInfo.CODE,TYPE:e??"O",EVENT_HANDLER:a,OPENLINE:"Y",CLIENT_ID:"",PROPERTIES:{NAME:`${n??r} - бот #${O}`,LAST_NAME:"",COLOR:"GREEN",EMAIL:"",PERSONAL_BIRTHDAY:mt().format("%Y-%m-%d"),WORK_POSITION:"Почтальон",PERSONAL_WWW:"",PERSONAL_GENDER:"M",PERSONAL_PHOTO:l??""}}}).then(u=>(console.log("Чат-бот добавлен",u),u))}unRegBot(A){return this.call({method:"imbot.unregister",params:{BOT_ID:A}}).then(e=>(console.log("чат-бот удален",e),e))}getLoggerList(A){return this.logger.getEntityList(A)}}Jt=new WeakSet,Ne=function(){return this.call({method:"app.info"})},kt=new WeakSet,_e=function(){return this.call({method:"user.current"})},g.Batch=j,g.BxBoot=ye,g.BxHelper=Vt,g.BxLogger=oe,g.tempus=mt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
var Se=Object.defineProperty;var pe=(T,p,b)=>p in T?Se(T,p,{enumerable:!0,configurable:!0,writable:!0,value:b}):T[p]=b;var W=(T,p,b)=>(pe(T,typeof p!="symbol"?p+"":p,b),b),ee=(T,p,b)=>{if(!p.has(T))throw TypeError("Cannot "+b)};var h=(T,p,b)=>(ee(T,p,"read from private field"),b?b.call(T):p.get(T)),O=(T,p,b)=>{if(p.has(T))throw TypeError("Cannot add the same private member more than once");p instanceof WeakSet?p.add(T):p.set(T,b)},g=(T,p,b,ft)=>(ee(T,p,"write to private field"),ft?ft.call(T,b):p.set(T,b),b);var _=(T,p,b)=>(ee(T,p,"access private method"),b);(function(T,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(T=typeof globalThis<"u"?globalThis:T||self,p(T["szdl-utils-kit"]={}))})(this,function(T){var tt,Rt,et,w,V,z,At,st,k,$,Gt,ot,F,it,at,Nt,Vt,Ot,zt,St,Ae,_t,Kt,pt,se,Mt,ie,Lt,re,Ct,me,kt,ue,bt,ne,Dt,oe,Ht,ae,yt,vt,Yt,he,Ft,fe,ht,Ut,dt,qt,gt,$t,Pt,Ne,lt,K,rt,Wt,ct,Bt,nt,Et,jt,Oe,It,le,Jt,_e,Xt,ye,xt,de,Qt,ge,Zt,Ee;"use strict";var p=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function b(j){return j&&j.__esModule&&Object.prototype.hasOwnProperty.call(j,"default")?j.default:j}var ft={exports:{}};(function(j,e){(function(A){Array.prototype.indexOf||(Array.prototype.indexOf=function(t,s){var l,m;for(l=s||0,m=this.length;l<m;l+=1)if(this[l]===t)return l;return-1});var n=this,r=function(t,s){for(var l=t.toString();l.length<s;)l="0"+l;return l},a=function(t,s){return s!==A?(t.year(s.year()||s.year),t.month(s.month()||s.month),t.day(s.day()||s.day),t.hours(s.hours()||s.hours),t.minutes(s.minutes()||s.minutes),t.seconds(s.seconds()||s.seconds),t.milliseconds(s.milliseconds()||s.milliseconds),t):A},o=function(t,s){var l,m="";return l=t.slice(s,s+1),l!==""&&!isNaN(Number(l))&&(m+="%H"),l=t.charAt(s+2),l!==""&&l===":"&&(m+=l),l=t.slice(s+3,s+4),l!==""&&!isNaN(Number(l))&&(m+="%M"),l=t.charAt(s+5),l!==""&&l===":"&&(m+=l),l=t.slice(s+6,s+7),l!==""&&!isNaN(Number(l))&&(m+="%S"),m},f=function(t,s){var l,m=[t.slice(s,s+1),t.charAt(s+2),t.slice(s+3,s+4),t.charAt(s+5),t.slice(s+6,s+9)],M;return!isNaN(Number(m[0]))&&!isNaN(Number(m[2]))&&!isNaN(Number(m[4]))?(m[1]==="."&&m[3]==="."?l="%d.%m.%Y":m[1]==="-"&&m[3]==="-"?l="%m-%d-%Y":m[1]==="/"&&m[3]==="/"&&(l="%m/%d/%Y"),l):(M=[t.slice(s,s+3),t.charAt(s+4),t.slice(s+5,s+6),t.charAt(s+7),t.slice(s+8,s+9)],!isNaN(Number(M[0]))&&!isNaN(Number(M[2]))&&!isNaN(Number(M[4]))?(M[1]==="-"&&M[3]==="-"&&(l="%Y-%m-%d"),l):"")},c=n.tempus,i,d,y=n.navigator||{},u="en",N={en:{JANUARY_SHORT:"Jan",FEBRUARY_SHORT:"Feb",MARCH_SHORT:"Mar",APRIL_SHORT:"Apr",MAY_SHORT:"May",JUNE_SHORT:"Jun",JULY_SHORT:"Jul",AUGUST_SHORT:"Aug",SEPTEMBER_SHORT:"Sep",OCTOBER_SHORT:"Oct",NOVEMBER_SHORT:"Nov",DECEMBER_SHORT:"Dec",JANUARY_LONG:"January",FEBRUARY_LONG:"February",MARCH_LONG:"March",APRIL_LONG:"April",MAY_LONG:"May",JUNE_LONG:"June",JULY_LONG:"July",AUGUST_LONG:"August",SEPTEMBER_LONG:"September",OCTOBER_LONG:"October",NOVEMBER_LONG:"November",DECEMBER_LONG:"December",SUNDAY_SHORT:"Sun",MONDAY_SHORT:"Mon",TUESDAY_SHORT:"Tue",WEDNESDAY_SHORT:"Wed",THURSDAY_SHORT:"Thu",FRIDAY_SHORT:"Fri",SATURDAY_SHORT:"Sat",SUNDAY_LONG:"Sunday",MONDAY_LONG:"Monday",TUESDAY_LONG:"Tuesday",WEDNESDAY_LONG:"Wednesday",THURSDAY_LONG:"Thursday",FRIDAY_LONG:"Friday",SATURDAY_LONG:"Saturday"},ru:{JANUARY_SHORT:"Янв",FEBRUARY_SHORT:"Фев",MARCH_SHORT:"Мар",APRIL_SHORT:"Апр",MAY_SHORT:"Май",JUNE_SHORT:"Июн",JULY_SHORT:"Июл",AUGUST_SHORT:"Авг",SEPTEMBER_SHORT:"Сен",OCTOBER_SHORT:"Окт",NOVEMBER_SHORT:"Ноя",DECEMBER_SHORT:"Дек",JANUARY_LONG:"Январь",FEBRUARY_LONG:"Февраль",MARCH_LONG:"Март",APRIL_LONG:"Апрель",MAY_LONG:"Май",JUNE_LONG:"Июнь",JULY_LONG:"Июль",AUGUST_LONG:"Август",SEPTEMBER_LONG:"Сентябрь",OCTOBER_LONG:"Октябрь",NOVEMBER_LONG:"Ноябрь",DECEMBER_LONG:"Декабрь",SUNDAY_SHORT:"Вс",MONDAY_SHORT:"Пн",TUESDAY_SHORT:"Вт",WEDNESDAY_SHORT:"Ср",THURSDAY_SHORT:"Чт",FRIDAY_SHORT:"Пт",SATURDAY_SHORT:"Сб",SUNDAY_LONG:"Воскресенье",MONDAY_LONG:"Понедельник",TUESDAY_LONG:"Вторник",WEDNESDAY_LONG:"Среда",THURSDAY_LONG:"Четверг",FRIDAY_LONG:"Пятница",SATURDAY_LONG:"Суббота"},ua:{JANUARY_SHORT:"Січ",FEBRUARY_SHORT:"Лют",MARCH_SHORT:"Берез",APRIL_SHORT:"Квіт",MAY_SHORT:"Трав",JUNE_SHORT:"Черв",JULY_SHORT:"Лип",AUGUST_SHORT:"Серп",SEPTEMBER_SHORT:"Верес",OCTOBER_SHORT:"Жовт",NOVEMBER_SHORT:"Листоп",DECEMBER_SHORT:"Груд",JANUARY_LONG:"Січень",FEBRUARY_LONG:"Лютий",MARCH_LONG:"Березень",APRIL_LONG:"Квітень",MAY_LONG:"Травень",JUNE_LONG:"Червень",JULY_LONG:"Липень",AUGUST_LONG:"Серпень",SEPTEMBER_LONG:"Вересень",OCTOBER_LONG:"Жовтень",NOVEMBER_LONG:"Листопад",DECEMBER_LONG:"Грудень",SUNDAY_SHORT:"Нд",MONDAY_SHORT:"Пн",TUESDAY_SHORT:"Вт",WEDNESDAY_SHORT:"Ср",THURSDAY_SHORT:"Чт",FRIDAY_SHORT:"Пт",SATURDAY_SHORT:"Сб",SUNDAY_LONG:"Неділя",MONDAY_LONG:"Понеділок",TUESDAY_LONG:"Вівторок",WEDNESDAY_LONG:"Середа",THURSDAY_LONG:"Четвер",FRIDAY_LONG:"П’ятниця",SATURDAY_LONG:"Субота"},de:{JANUARY_SHORT:"Jan",FEBRUARY_SHORT:"Feb",MARCH_SHORT:"März",APRIL_SHORT:"Apr",MAY_SHORT:"Mai",JUNE_SHORT:"Juni",JULY_SHORT:"Juli",AUGUST_SHORT:"Aug",SEPTEMBER_SHORT:"Sept",OCTOBER_SHORT:"Okt",NOVEMBER_SHORT:"Nov",DECEMBER_SHORT:"Dez",JANUARY_LONG:"Januar",FEBRUARY_LONG:"Februar",MARCH_LONG:"März",APRIL_LONG:"April",MAY_LONG:"Mai",JUNE_LONG:"Juni",JULY_LONG:"Juli",AUGUST_LONG:"August",SEPTEMBER_LONG:"September",OCTOBER_LONG:"Oktober",NOVEMBER_LONG:"November",DECEMBER_LONG:"Dezember",SUNDAY_SHORT:"So",MONDAY_SHORT:"Mo",TUESDAY_SHORT:"Di",WEDNESDAY_SHORT:"Mi",THURSDAY_SHORT:"Do",FRIDAY_SHORT:"Fr",SATURDAY_SHORT:"Sa",SUNDAY_LONG:"Sonntag",MONDAY_LONG:"Montag",TUESDAY_LONG:"Dienstag",WEDNESDAY_LONG:"Mittwoch",THURSDAY_LONG:"Donnerstag",FRIDAY_LONG:"Freitag",SATURDAY_LONG:"Samstag"}},I=function(){return[N[u].JANUARY_LONG,N[u].FEBRUARY_LONG,N[u].MARCH_LONG,N[u].APRIL_LONG,N[u].MAY_LONG,N[u].JUNE_LONG,N[u].JULY_LONG,N[u].AUGUST_LONG,N[u].SEPTEMBER_LONG,N[u].OCTOBER_LONG,N[u].NOVEMBER_LONG,N[u].DECEMBER_LONG]},X=function(){return[N[u].JANUARY_SHORT,N[u].FEBRUARY_SHORT,N[u].MARCH_SHORT,N[u].APRIL_SHORT,N[u].MAY_SHORT,N[u].JUNE_SHORT,N[u].JULY_SHORT,N[u].AUGUST_SHORT,N[u].SEPTEMBER_SHORT,N[u].OCTOBER_SHORT,N[u].NOVEMBER_SHORT,N[u].DECEMBER_SHORT]},P=function(){return[N[u].SUNDAY_LONG,N[u].MONDAY_LONG,N[u].TUESDAY_LONG,N[u].WEDNESDAY_LONG,N[u].THURSDAY_LONG,N[u].FRIDAY_LONG,N[u].SATURDAY_LONG]},H=function(){return[N[u].SUNDAY_SHORT,N[u].MONDAY_SHORT,N[u].TUESDAY_SHORT,N[u].WEDNESDAY_SHORT,N[u].THURSDAY_SHORT,N[u].FRIDAY_SHORT,N[u].SATURDAY_SHORT]},L,v,q,x,mt=function(t,s,l){var m;n.XMLHttpRequest?m=new XMLHttpRequest:m=new ActiveXObject("Microsoft.XMLHTTP"),m.onreadystatechange=function(){m.readyState===4&&(m.status===200?s&&(n.JSON===A?alert(`Please, include json2 into your project if you want use old browsers!
|
|
2
|
+
https://github.com/douglascrockford/JSON-js/blob/master/json2.js`):s(JSON.parse(m.responseText))):l&&l(m))},m.open("GET",t,!1),m.send()},G={"%d":{format:function(t){return r(t.day()||i.MIN_DAY,2)},parse:function(t){var s=Number(t);return{day:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%m":{format:function(t){return r(t.month()||i.MIN_MONTH,2)},parse:function(t){var s=Number(t);return{month:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%Y":{format:function(t){return r(t.year()||i.MIN_YEAR,4)},parse:function(t){var s=Number(t);return{year:isNaN(s)?A:s}},minLength:4,maxLength:4,type:"number"},"%w":{format:function(t){return t.dayOfWeek()||i.MIN_DAY_OF_WEEK},parse:function(){return{}},minLength:1,maxLength:1,type:"number"},"%a":{format:function(t){var s=t.dayOfWeek();return x[s!==A?s:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%A":{format:function(t){var s=t.dayOfWeek();return q[s!==A?s:i.MIN_DAY_OF_WEEK]},parse:function(){return{}},minLength:1,maxLength:999,type:"word"},"%b":{format:function(t){var s=i.options("monthFromZero")?t.month():t.month()-1;return v[s!==A?s:i.MIN_MONTH]},parse:function(t){var s=i.monthNames().indexOf(t)+(i.options("monthFromZero")?0:1);return{month:s!==-1?s:A}},minLength:1,maxLength:999,type:"word"},"%B":{format:function(t){var s=i.options("monthFromZero")?t.month():t.month()-1;return L[s!==A?s:i.MIN_MONTH]},parse:function(t){var s=i.monthNames(!0).indexOf(t)+(i.options("monthFromZero")?0:1);return{month:s!==-1?s:A}},minLength:1,maxLength:999,type:"word"},"%H":{format:function(t){return r(t.hours()||i.MIN_HOURS,2)},parse:function(t){var s=Number(t);return{hours:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%M":{format:function(t){return r(t.minutes()||i.MIN_MINUTES,2)},parse:function(t){var s=Number(t);return{minutes:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%S":{format:function(t){return r(t.seconds()||i.MIN_SECONDS,2)},parse:function(t){var s=Number(t);return{seconds:isNaN(s)?A:s}},minLength:2,maxLength:2,type:"number"},"%s":{format:function(t){return t.timestamp()},parse:function(t){return isNaN(Number(t))?{}:i(Number(t)).get()},minLength:1,maxLength:20,type:"number"},"%F":{format:function(t){return r(t.year()||i.MIN_YEAR,4)+"-"+r(t.month()||i.MIN_MONTH,2)+"-"+r(t.day()||i.MIN_DAY,2)},parse:function(t){var s=Number(t.slice(0,4)),l=Number(t.slice(5,7)),m=Number(t.slice(8,10));return{year:s,month:l,day:m}},minLength:10,maxLength:10,type:"string"},"%D":{format:function(t){return r(t.month()||i.MIN_MONTH,2)+"/"+r(t.day()||i.MIN_DAY,2)+"/"+r(t.year()||i.MIN_YEAR,4)},parse:function(t){var s=Number(t.slice(0,2)),l=Number(t.slice(3,5)),m=Number(t.slice(6,10));return{year:m,month:s,day:l}},minLength:10,maxLength:10,type:"string"}},ut={useMilliseconds:!1,monthFromZero:!1},R;R=function(t,s,l){return this._d=new Date,this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t!==A&&this.set(t,s,l),this},R.fn=R.prototype,R.fn.dayCount=function(){var t=this.month(),s=i.MAX_DAY_IN_MONTHS[t-(i.options("monthFromZero")?0:1)];return this.leapYear()&&t===(i.options("monthFromZero")?1:2)&&(s+=1),s},R.fn.year=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_YEAR&&Number(t)<=i.MAX_YEAR?(this._d.setFullYear(Number(t)),this._i.year=!1):this._i.year=Number(t):(this._d.setFullYear(i.MIN_YEAR),this._i.year=!1);else return this._i.year===!1?this._d.getFullYear():this._i.year;return this},R.fn.month=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_MONTH&&Number(t)<=i.MAX_MONTH?(this._d.setMonth(i.options("monthFromZero")?Number(t):Number(t)-1),this._i.month=!1):this._i.month=Number(t):(this._d.setMonth(i.options("monthFromZero")?i.MIN_MONTH:i.MIN_MONTH-1),this._i.month=!1);else return this._i.month===!1?i.options("monthFromZero")?this._d.getMonth():this._d.getMonth()+1:this._i.month;return this},R.fn.day=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_DAY&&Number(t)<=this.dayCount()?(this._d.setDate(Number(t)),this._i.day=!1):this._i.day=Number(t):(this._d.setDate(i.MIN_DAY),this._i.day=!1);else return this._i.day===!1?this._d.getDate():this._i.day;return this},R.fn.hours=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_HOURS&&Number(t)<=i.MAX_HOURS?(this._d.setHours(Number(t)),this._i.hours=!1):this._i.hours=Number(t):(this._d.setHours(i.MIN_HOURS),this._i.hours=!1);else return this._i.hours===!1?this._d.getHours():this._i.hours;return this},R.fn.minutes=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_MINUTES&&Number(t)<=i.MAX_MINUTES?(this._d.setMinutes(Number(t)),this._i.minutes=!1):this._i.minutes=Number(t):(this._d.setMinutes(i.MIN_MINUTES),this._i.minutes=!1);else return this._i.minutes===!1?this._d.getMinutes():this._i.minutes;return this},R.fn.seconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_SECONDS&&Number(t)<=i.MAX_SECONDS?(this._d.setSeconds(Number(t)),this._i.seconds=!1):this._i.seconds=Number(t):(this._d.setSeconds(i.MIN_SECONDS),this._i.seconds=!1);else return this._i.seconds===!1?this._d.getSeconds():this._i.seconds;return this},R.fn.milliseconds=function(t){if(arguments.length!==0)(typeof t=="number"||typeof t=="string")&&!isNaN(Number(t))?Number(t)>=i.MIN_MILLISECONDS&&Number(t)<=i.MAX_MILLISECONDS?(this._d.setMilliseconds(Number(t)),this._i.milliseconds=!1):this._i.milliseconds=Number(t):(this._d.setMilliseconds(i.MIN_MILLISECONDS),this._i.milliseconds=!1);else return this._i.milliseconds===!1?this._d.getMilliseconds():this._i.milliseconds;return this},R.fn.week=function(){var t=new Date(this.year(),0,1),s=i(this.utc()).hours(0).minutes(0).seconds(0).milliseconds(0).utc()*1e3;return Math.ceil(((s-t.getTime())/864e5+t.getDay()+1)/7)},R.fn.set=function(t,s,l){if(this._i={year:!1,month:!1,day:!1,hours:!1,minutes:!1,seconds:!1,milliseconds:!1},t===A)return this._d=new Date,this;if(t instanceof Date)return this._d=t,this;if(typeof t=="number")return this._d=new Date(t*(i.options("useMilliseconds")?1:1e3)),this;if(typeof t=="object"&&(t instanceof Array?(this.day(i.MIN_DAY),this.year(t[0]),this.month(t[1]),this.day(t[2]),this.hours(t[3]),this.minutes(t[4]),this.seconds(t[5]),this.milliseconds(t[6])):(this.day(i.MIN_DAY),this.year(t.year),this.month(t.month),this.day(t.day),this.hours(t.hours),this.minutes(t.minutes),this.seconds(t.seconds),this.milliseconds(t.milliseconds))),typeof t=="string"){var m,M=[],E,S,J=[],B=0,C=0,D,Q,Y={},U;if(t===A)return E=a(this,l),E===A&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),E;for(s===A&&(s=i.detectFormat(t));B<s.length;){if(s.charAt(B)==="%"){if(S=s.charAt(B)+s.charAt(B+1),G[S]!==A){switch(D=0,Q="",G[S].type){case"number":for(;D<G[S].maxLength&&C+D<t.length&&!isNaN(Number(t.charAt(C+D)));)Q+=t.charAt(C+D),D+=1;break;case"word":for(;D<G[S].maxLength&&C+D<t.length&&/^[\u00BF-\u1FFF\u2C00-\uD7FF\w]+$/.test(t.charAt(C+D));)Q+=t.charAt(C+D),D+=1;break;case"string":for(;D<G[S].maxLength&&C+D<t.length;)Q+=t.charAt(C+D),D+=1;break}if(D<G[S].minLength)return E=a(this,l),E===A&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),E;M.push(S),J.push(Q),D-=1,C+=D,B+=1}}else if(t.charAt(C)!==s.charAt(B))return E=a(this,l),E===A&&(this._i={year:-1,month:-1,day:-1,hours:-1,minutes:-1,seconds:-1,milliseconds:-1}),E;B+=1,C+=1}for(m in M)M.hasOwnProperty(m)&&G.hasOwnProperty(M[m])&&(U=G[M[m]].parse(J[m]),Y={year:U.year!==A?U.year:Y.year,month:U.month!==A?U.month:Y.month,day:U.day!==A?U.day:Y.day,hours:U.hours!==A?U.hours:Y.hours,minutes:U.minutes!==A?U.minutes:Y.minutes,seconds:U.seconds!==A?U.seconds:Y.seconds});this.day(i.MIN_DAY),this.year(Y.year),this.month(Y.month),this.day(Y.day),this.hours(Y.hours),this.minutes(Y.minutes),this.seconds(Y.seconds),this.milliseconds(Y.milliseconds)}return this},R.fn.leapYear=function(){var t=this.year();return t%4===0?t%100===0?t%400===0:!0:!1},R.fn.timestamp=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(i.options("useMilliseconds")?1:1e3)+this._d.getTimezoneOffset()*6e4),this):i.options("useMilliseconds")?this._d.getTime()-this._d.getTimezoneOffset()*6e4:Math.floor(this._d.getTime()/1e3)-this._d.getTimezoneOffset()*60},R.fn.utc=function(t){return arguments.length!==0?(this._d=new Date(Number(t)*(i.options("useMilliseconds")?1:1e3)),this):i.options("useMilliseconds")?this._d.getTime():Math.floor(this._d.getTime()/1e3)},R.fn.dayOfWeek=function(t){if(t==="long")return q[this._d.getDay()];if(t==="short")return x[this._d.getDay()];if(t===A)return this._d.getDay();if(t===0||t==="Sunday")return this.calc({day:-this.dayOfWeek()});if(t===1||t==="Monday")return this.calc({day:(this.dayOfWeek()===0?-6:1)-this.dayOfWeek()});if(t===2||t==="Tuesday")return this.calc({day:(this.dayOfWeek()===0?-5:2)-this.dayOfWeek()});if(t===3||t==="Wednesday")return this.calc({day:(this.dayOfWeek()===0?-4:3)-this.dayOfWeek()});if(t===4||t==="Thursday")return this.calc({day:(this.dayOfWeek()===0?-3:4)-this.dayOfWeek()});if(t===5||t==="Friday")return this.calc({day:(this.dayOfWeek()===0?-2:5)-this.dayOfWeek()});if(t===6||t==="Saturday")return this.calc({day:(this.dayOfWeek()===0?-1:6)-this.dayOfWeek()})},R.fn.timezone=function(t){switch(t){case"hours":return Math.floor(this._d.getTimezoneOffset()/60);case"minutes":return this._d.getTimezoneOffset();default:return this._d.getTimezoneOffset()*60}},R.fn.get=function(t){switch(t){case"Date":return new Date(this.year(),this.month()-(i.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds());case"DateUTC":return new Date(Date.UTC(this.year(),this.month()-(i.options("monthFromZero")?0:1),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()));case"Array":return[this.year(),this.month(),this.day(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()];default:return{year:this.year(),month:this.month(),week:this.week(),day:this.day(),hours:this.hours(),minutes:this.minutes(),seconds:this.seconds(),milliseconds:this.milliseconds(),utc:this.utc(),dayOfWeek:this.dayOfWeek(),dayOfWeekShort:this.dayOfWeek("short"),dayOfWeekLong:this.dayOfWeek("long"),timestamp:this.timestamp()}}},R.fn.format=function(t){for(var s=0,l="",m;s<t.length;)t.charAt(s)==="%"?(m=t.charAt(s)+t.charAt(s+1),G[m]!==A?(l+=G[m].format(this),s+=1):l+="%"):l+=t.charAt(s),s+=1;return l},R.fn.valid=function(){return this._i.year===!1&&this._i.month===!1&&this._i.day===!1&&this._i.hours===!1&&this._i.minutes===!1&&this._i.seconds===!1&&this._i.milliseconds===!1},R.fn.errors=function(){return this._i},R.fn.between=function(t,s){var l=this.timestamp(),m=t.timestamp();switch(s){case"year":return Math.floor((m-l)/31556952);case"month":return Math.floor((m-l)/2629746);case"day":return Math.floor((m-l)/86400);case"hours":return Math.floor((m-l)/3600);case"minutes":return Math.floor((m-l)/60);case"seconds":return m-l;default:return A}},R.fn.calc=function(t){return t.year!==A&&this._d.setFullYear(this._d.getFullYear()+t.year),t.month!==A&&this._d.setMonth(this._d.getMonth()+t.month),t.day!==A&&this._d.setDate(this._d.getDate()+t.day),t.hours!==A&&this._d.setHours(this._d.getHours()+t.hours),t.minutes!==A&&this._d.setMinutes(this._d.getMinutes()+t.minutes),t.seconds!==A&&this._d.setSeconds(this._d.getSeconds()+t.seconds),t.milliseconds!==A&&this._d.setMilliseconds(this._d.getMilliseconds()+t.milliseconds),this},i=function(t,s,l){return new R(t,s,l)},i.MIN_YEAR=1e3,i.MAX_YEAR=3e3,i.MIN_MONTH=1,i.MAX_MONTH=12,i.MIN_DAY=1,i.MAX_DAY_IN_MONTHS=[31,28,31,30,31,30,31,31,30,31,30,31],i.MIN_DAY_OF_WEEK=0,i.MAX_DAY_OF_WEEK=6,i.MIN_HOURS=0,i.MAX_HOURS=23,i.MIN_MINUTES=0,i.MAX_MINUTES=59,i.MIN_SECONDS=0,i.MAX_SECONDS=59,i.MIN_MILLISECONDS=0,i.MAX_MILLISECONDS=999,i.VERSION="0.2.18",i.options=function(t,s){if(t===A)return ut;if(ut.hasOwnProperty(t)){if(s===A)return ut[t];ut[t]=s,t==="monthFromZero"&&(i.MIN_MONTH=s?0:1,i.MAX_MONTH=s?11:12)}return A},i.noConflict=function(){return n.tempus=c,i},i.generate=function(t){var s,l,m,M,E,S,J,B;if(typeof t.dateFrom!="number"&&(t.dateFrom instanceof R?s=t.dateFrom.utc():s=i(t.dateFrom,t.formatFrom).utc()),typeof t.dateTo!="number"&&(t.dateTo instanceof R?l=t.dateTo.utc():l=i(t.dateTo,t.formatTo!==A?t.formatTo:t.formatFrom).utc()),typeof t.period=="number"?E={year:0,month:0,day:0,hours:0,minutes:0,seconds:t.period}:typeof t.period=="string"?E={year:t.period==="year"?1:0,month:t.period==="month"?1:0,day:t.period==="day"?1:0,hours:t.period==="hours"?1:0,minutes:t.period==="minutes"?1:0,seconds:t.period==="seconds"?1:0}:typeof t.period=="object"&&(E={year:t.period.year!==A?t.period.year:0,month:t.period.month!==A?t.period.month:0,day:t.period.day!==A?t.period.day:0,hours:t.period.hours!==A?t.period.hours:0,minutes:t.period.minutes!==A?t.period.minutes:0,seconds:t.period.seconds!==A?t.period.seconds:0}),t.groupBy===A?S=t.asObject===!0?{}:[]:(S=[],S.push([]),J=i(s).get()[t.groupBy]),B=function(Q,Y,U){return t.asObject===!0?t.format!==A?Q[i(Y).format(t.format)]={}:Q[i(Y).format("%F %H:%M:%S")]={}:t.format!==A?Q.push(U?null:i(Y).format(t.format)):Q.push(U?null:i(Y)),Q},t.groupBy!==A&&t.fillNulls){var C={year:E.year?-E.year:A,month:E.month?-E.month:A,day:E.day?-E.day:A,hours:E.hours?-E.hours:A,minutes:E.minutes?-E.minutes:A,seconds:E.seconds?-E.seconds:A,milliseconds:E.milliseconds?-E.milliseconds:A};for(m=i(s).calc(C).utc();i(m).get()[t.groupBy]===J;)B(S[S.length-1],m,!0),m=i(m).calc(C).utc();if(t.groupBy==="week"){var D=i(s).dayOfWeek();for(m=i(s).dayOfWeek(0).utc();S[0].length<D&&m<s;)B(S[S.length-1],m,!0),m=i(m).calc(E).utc()}}for(;s<=l;)t.groupBy===A?B(S,s):i(s).get()[t.groupBy]===J?B(S[S.length-1],s):(S.push([]),B(S[S.length-1],s),J=i(s).get()[t.groupBy]),s=i(s).calc(E).utc();if(t.groupBy!==A&&t.fillNulls)for(M=i(l).calc(E).utc();i(M).get()[t.groupBy]===J;)B(S[S.length-1],M,!0),M=i(M).calc(E).utc();return S},i.monthNames=function(t){switch(t){case"long":return L;default:return v}},i.dayNames=function(t){switch(t){case"long":return q;default:return x}},i.lang=function(t){if(t!==A)u=t,N[u]===A&&(u="en"),L=I(),v=X(),q=P(),x=H();else return u;return A},i.availableLangs=function(){return Object.keys(N)},i.registerFormat=function(t,s,l,m,M,E){G[t]={format:s,parse:l,minLength:m,maxLength:M,type:E}},i.unregisterFormat=function(t){delete G[t]},i.detectFormat=function(t){var s,l,m;return s=f(t,0),s!==""&&(m=10),l=t.charAt(m),(l==="T"||l===" ")&&(s+=l,m+=1),s+=o(t,m),s},d={TempusDate:R},i.classes=function(t,s){if(s===A)return d[t];d[t]=s},i.loadTranslations=function(t){typeof t=="object"?N=t:typeof t=="string"&&mt(t,function(s){N=s},function(s){})},u=(y.language||y.systemLanguage||y.userLanguage||"en").substr(0,2).toLowerCase(),N[u]===A&&(u="en"),L=I(),v=X(),q=P(),x=H(),j.exports&&(e=j.exports=i),e.tempus=i}).call(p)})(ft,ft.exports);var Te=ft.exports;const Tt=b(Te);class Z{constructor(e,A={}){O(this,Nt);O(this,Ot);O(this,St);O(this,_t);O(this,pt);O(this,Mt);O(this,Lt);O(this,Ct);O(this,kt);O(this,bt);O(this,Dt);O(this,Ht);O(this,yt);O(this,Yt);O(this,Ft);O(this,ht);O(this,dt);O(this,gt);O(this,Pt);O(this,tt,null);O(this,Rt,null);O(this,et,[]);O(this,w,{});O(this,V,50);O(this,z,50);O(this,At,!0);O(this,st,null);O(this,k,null);O(this,$,null);O(this,Gt,100);O(this,ot,"no");O(this,F,!1);O(this,it,!1);O(this,at,!1);W(this,"errors",{});W(this,"answerData",{});W(this,"timeLimit",!1);g(this,tt,e),g(this,Rt,A)}get serial(){return h(this,F)}get limitCommandSerial(){return h(this,z)}set limitCommandSerial(e){if(e<10)throw new Error("limitCommandSerial не может быть меньше 10");e>=10&&e<50&&(g(this,V,e),g(this,z,e)),g(this,z,e)}setSerial(){g(this,F,!0),g(this,it,!0),g(this,at,!1)}setParallel(){g(this,F,!1),g(this,it,!1),g(this,at,!0)}stop(){g(this,At,!1)}async batch(e,A){h(this,$)&&_(this,Ot,zt).call(this),A&&g(this,st,A),h(this,it)===!1&&g(this,F,!1),Object.keys(e).length>h(this,z)&&g(this,F,!0),g(this,At,!0),g(this,et,[]),g(this,w,{}),this.errors={},this.answerData={};const n=_(this,_t,Kt).call(this,e);if(Object.keys(e).length<h(this,z)){const r=n.map((a,o)=>_(this,pt,se).call(this,a,n[o]));return Promise.allSettled(r).then(a=>{let o={};for(let f of a)f.status==="fulfilled"&&(o={...o,...f.value});return o})}else{let r={},a=0,o=1,f=Object.keys(e).length||1,c=i=>{a+=Object.keys(i).length,o=Math.round(a/f*100)};for(let[i,d]of Object.entries(n)){let y=await _(this,pt,se).call(this,d,n[i],!0);c(d),A&&A({percent:o}),r={...r,...y}}return r}}async batchUpdateField(e,A){h(this,$)&&_(this,Ot,zt).call(this),A&&g(this,st,A),h(this,it)===!1&&g(this,F,!1),Object.keys(e).length>h(this,z)&&g(this,F,!0),g(this,At,!0),g(this,et,[]),g(this,w,{}),this.errors={},this.answerData={};const n=_(this,_t,Kt).call(this,e);if(Object.keys(e).length<h(this,z)){let r={};for(let[a,o]of Object.entries(n)){let f=await _(this,Mt,ie).call(this,o,n[a]);r={...r,...f}}return r}else{let r={},a=0,o=1,f=Object.keys(e).length||1,c=i=>{a+=Object.keys(i).length,o=Math.round(a/f*100)};for(let[i,d]of Object.entries(n)){let y=await _(this,Mt,ie).call(this,d,n[i],!0);c(d),A&&A({percent:o}),r={...r,...y},this.timeLimit&&(console.log("Был достигнут лимит operating time - сделана остановка на 2 минуты, timeLimit = ",this.timeLimit),await new Promise(u=>setTimeout(u,12e4)),this.timeLimit=!1,console.log("Остановка в 2 минуты по лимиту operating time закончена, timeLimit = ",this.timeLimit))}return r}}async batchTotalCount(e,A){g(this,w,{}),this.errors={};let n=1,r=0,a=Object.keys(e).length||1,o=c=>{r+=Object.keys(c).length,n=Math.round(r/a*100)};A&&A({percent:n});const f=_(this,_t,Kt).call(this,e);if(h(this,at)){const c=f.map(i=>_(this,Lt,re).call(this,i).then(d=>(o(i),A&&A({percent:n}),d)));return Promise.allSettled(c).then(i=>{let d={};for(let y of i)y.status==="fulfilled"&&(d={...d,...y.value});return d})}else{let c={};for(let i of f){let d=await _(this,Lt,re).call(this,i);o(i),A&&A({percent:n}),c={...c,...d}}return c}}}tt=new WeakMap,Rt=new WeakMap,et=new WeakMap,w=new WeakMap,V=new WeakMap,z=new WeakMap,At=new WeakMap,st=new WeakMap,k=new WeakMap,$=new WeakMap,Gt=new WeakMap,ot=new WeakMap,F=new WeakMap,it=new WeakMap,at=new WeakMap,Nt=new WeakSet,Vt=function(){let e=0;if(!h(this,k))return Math.round(e);let A=0,n=0;return Object.values(h(this,k)).forEach(r=>{const{total:a,count:o}=r;A+=a??0,n+=o??0}),A?e=n/A*100:e=100,{percent:Math.round(e),allCount:n,allTotal:A}},Ot=new WeakSet,zt=function(){clearInterval(h(this,$)),g(this,$,""),g(this,k,""),g(this,st,""),g(this,ot,"no")},St=new WeakSet,Ae=function({key:e,value:A}){const n=_(this,ht,Ut).call(this,A.data()),r=Array.isArray(n)?n.length:0,a=_(this,dt,qt).call(this,A.total(),r);let o=1;n&&(o=r),h(this,st)&&(h(this,k)||g(this,k,{}),h(this,k)[e]&&h(this,k)[e].count&&(o+=h(this,k)[e].count),h(this,k)[e]={total:a,count:o},h(this,$)||g(this,$,setInterval(()=>{const{percent:f,allCount:c,allTotal:i}=h(this,Nt,Vt);(h(this,ot)==="no"||h(this,ot)<h(this,Nt,Vt).percent)&&(h(this,st).call(this,{data:h(this,k),percent:f,allCount:c,allTotal:i}),g(this,ot,h(this,Nt,Vt).percent)),f===100&&_(this,Ot,zt).call(this)},h(this,Gt))))},_t=new WeakSet,Kt=function(e){const A=[],n=Object.entries(e);for(let r=0;r<n.length;r+=h(this,V)){const a=n.slice(r,r+h(this,V));A.push(Object.fromEntries(a))}return A},pt=new WeakSet,se=function(e,A,n){return new Promise(r=>{const a=_(this,Yt,he).call(this,A),o=[];let f=0,c=0;h(this,tt).call(this,e,i=>{Object.entries(i).forEach(([d,y])=>{let u={};const N=y.error();if(N){let{query:{method:H},answer:L}=y;this.errors[d]={error:N,method:H},f+=1}if(y!=null&&y.answer&&Object.keys(y.answer).length){for(let[H,L]of Object.entries(y.answer))H!="result"&&L&&(u[H]=L);Object.keys(u).length&&(this.answerData[d]=u)}const I=_(this,ht,Ut).call(this,y.data()),X=Array.isArray(I)?I.length:0,P=_(this,dt,qt).call(this,y.total(),X);if(Array.isArray(I)?h(this,w)[d]=I:typeof I=="object"&&I!==null&&Object.keys(I).length===0?h(this,w)[d]=[]:h(this,w)[d]=I,c+=P,n||_(this,St,Ae).call(this,{key:d,value:y}),P>h(this,V)&&P>X){const H=Math.ceil(P/h(this,V))-1,L=Array.from({length:H});o.push([d,a[d],L])}}),c>5e3&&h(this,it)===!1&&h(this,at)===!1&&g(this,F,!0),f>0&&_(this,gt,$t).call(this),o.length?(_(this,Ct,me).call(this,o),_(this,kt,ue).call(this).then(()=>r(_(this,yt,vt).call(this)))):r(_(this,yt,vt).call(this))})})},Mt=new WeakSet,ie=function(e,A,n){let r=_(this,Pt,Ne).call(this,e);return new Promise(a=>{let o=0;h(this,tt).call(this,"batch",r,f=>{var y,u,N,I,X,P;let c=((u=(y=f==null?void 0:f.answer)==null?void 0:y.result)==null?void 0:u.result)??null,i=((I=(N=f==null?void 0:f.answer)==null?void 0:N.result)==null?void 0:I.result_error)??null,d=((P=(X=f==null?void 0:f.answer)==null?void 0:X.result)==null?void 0:P.result_time)??null;(c||Object.keys(c).length)&&Object.entries(c).forEach(([H,L])=>{this.answerData[H]=L}),(i||Object.keys(i).length)&&Object.entries(i).forEach(([H,L])=>{var x,mt;let v=((x=e[H])==null?void 0:x.method)??null,q=((mt=e[H])==null?void 0:mt.params)??null;this.errors[H]={error:L,method:v,params:q},o+=1}),(d||Object.keys(d).length)&&Object.entries(d).forEach(([H,L])=>{((L==null?void 0:L.operating)??0)>=475&&(this.timeLimit=!0)}),o>0&&_(this,gt,$t).call(this),a(this.answerData)})})},Lt=new WeakSet,re=function(e){return new Promise(A=>{const n=_(this,Yt,he).call(this,e);let r=0;h(this,tt).call(this,n,a=>{Object.entries(a).forEach(([o,f])=>{const c=f.error();c&&(this.errors[o]=c,r+=1);const i=_(this,ht,Ut).call(this,f.data()),d=Array.isArray(i)?i.length:0,y=_(this,dt,qt).call(this,f.total(),d);h(this,w)[o]=y}),r>0&&_(this,gt,$t).call(this),A(_(this,yt,vt).call(this))})})},Ct=new WeakSet,me=function(e){let A=[];e.forEach(([n,r,a])=>{a.forEach((o,f)=>{const c=f+1,i=h(this,V)*c,y=[[n,c].join("_"),_(this,Ft,fe).call(this,r,i)];A.length===h(this,V)?(h(this,et).push(A),A=[y]):A.push(y)})}),A.length&&h(this,et).push(A)},kt=new WeakSet,ue=function(){const e=[],A=[],n=r=>{Object.entries(r).forEach(([a,o])=>{const[f]=a.split("_"),c=_(this,ht,Ut).call(this,o.data());Array.isArray(c)&&h(this,w)[f].push(...c),_(this,St,Ae).call(this,{key:f,value:o})})};return h(this,et).forEach((r,a)=>{const o=Object.fromEntries(r),f=()=>new Promise(c=>h(this,tt).call(this,o,i=>{h(this,F)?n(i):A[a]=i,c()}));e.push(f)}),h(this,F)?_(this,Dt,oe).call(this,e):_(this,Ht,ae).call(this,e).then(()=>{A.forEach(n)})},bt=new WeakSet,ne=function(){return new Promise(e=>setTimeout(e,500))},Dt=new WeakSet,oe=function(e){if(!e.length)return Promise.resolve();const A=e.shift();return Promise.allSettled([A(),_(this,bt,ne).call(this)]).then(()=>h(this,At)?_(this,Dt,oe).call(this,e):Promise.resolve())},Ht=new WeakSet,ae=function(e){if(!e.length)return Promise.resolve();const A=e.shift();return _(this,bt,ne).call(this).then(()=>A()).then(()=>h(this,At)?_(this,Ht,ae).call(this,e):Promise.resolve())},yt=new WeakSet,vt=function(){return Object.entries(h(this,Rt)).forEach(([e,A])=>{h(this,w)[e]&&(h(this,w)[e]=A(h(this,w)[e]))}),h(this,w)},Yt=new WeakSet,he=function(e){return Object.entries(e).reduce((A,[n,r])=>{if(Array.isArray(r)){const[a,o={}]=r;A[n]=[a,o]}else{const{method:a,params:o={}}=r;A[n]=[a,o]}return A},{})},Ft=new WeakSet,fe=function(e,A){const[n,r]=e;return[n,{start:A,...r}]},ht=new WeakSet,Ut=function(e){return((e==null?void 0:e.items)||(e==null?void 0:e.documents)||(e==null?void 0:e.tasks))??e},dt=new WeakSet,qt=function(e,A){return e!==e&&(e=0),e===0&&A===0?0:e||A},gt=new WeakSet,$t=function(){console.group(`${this.constructor.name}: Ошибки в методах!`),Object.entries(this.errors).forEach(([e,A])=>{console.info(`[${e}]`,A)}),console.groupEnd()},Pt=new WeakSet,Ne=function(e){var n,r,a,o,f,c,i,d,y,u,N,I,X,P,H,L,v,q,x,mt,G,ut,R,t;let A={halt:0,cmd:{}};for(let s in e){const l=s;let m=(n=e[s])!=null&&n.method?(r=e[s])==null?void 0:r.method:"",M="",E="",S="";const J=(o=(a=e[s])==null?void 0:a.params)==null?void 0:o.fields;if((c=(f=e[s])==null?void 0:f.params)!=null&&c.entityTypeId?(M=`?entityTypeId=${parseInt((d=(i=e[s])==null?void 0:i.params)==null?void 0:d.entityTypeId)}`,(u=(y=e[s])==null?void 0:y.params)!=null&&u.id&&(E=`&id=${(I=(N=e[s])==null?void 0:N.params)==null?void 0:I.id}`),(P=(X=e[s])==null?void 0:X.params)!=null&&P.ID&&(E=`&ID=${(L=(H=e[s])==null?void 0:H.params)==null?void 0:L.ID}`)):((q=(v=e[s])==null?void 0:v.params)!=null&&q.id&&(E=`?id=${(mt=(x=e[s])==null?void 0:x.params)==null?void 0:mt.id}`),(ut=(G=e[s])==null?void 0:G.params)!=null&&ut.ID&&(E=`?ID=${(t=(R=e[s])==null?void 0:R.params)==null?void 0:t.ID}`)),Object.keys(J).length>0)for(let B in J)S+=`&fields[${B}]=${J[B]}`;A.cmd[l]=`${m}${M}${E}${S}`.trim()}return A};class te{constructor(){O(this,lt,{})}get hash(){return this.createHash(8)}createHash(e){let A="abcdefghijklmnopqrstuvwxyz0123456789",n="";e=e||6;for(let r=0;r<e;r++)n+=A.charAt(Math.floor(Math.random()*A.length));return n}actionFilter({keyTimer:e,duration:A=10,action:n}){h(this,lt)[e]&&(clearTimeout(h(this,lt)[e]),h(this,lt)[e]=null),n&&(h(this,lt)[e]=setTimeout(()=>{n()},A))}async noSleep(){let e=document.createElement("video");e.classList.add("no-sleep"),e.addEventListener("loadeddata",()=>{e.style.position="fixed",e.style.left="-9999px",document.querySelector("body").append(e),e.play()}),e.addEventListener("ended",()=>{this.actionFilter({keyTimer:"no-sleep",duration:5e3,action:()=>e.play()})}),e.src="data:video/mp4;base64,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"}downloadFileJson(e,A){let n=new Blob([JSON.stringify(e)],{type:"application/json"}),r=URL.createObjectURL(n),a=document.createElement("a");a.style.display="none",a.href=r,a.download=`${A}.json`,document.body.appendChild(a),a.click(),setTimeout(()=>{document.body.removeChild(a),URL.revokeObjectURL(r)},200)}}lt=new WeakMap;const wt=new te;class ce{constructor(){O(this,jt);O(this,It);O(this,Jt);O(this,Xt);O(this,xt);O(this,K,"logger");O(this,rt,!1);O(this,Wt,2e3);O(this,ct,new Map);O(this,Bt,{});O(this,nt,null);O(this,Et,!1);W(this,"periodClear",3);_(this,jt,Oe).call(this)}async init(){let e=new Z(BX24.callBatch),{entityList:A}=await e.batch({entityList:{method:"entity.get"}});if(A&&Array.isArray(A))if(A.find(r=>r.ENTITY==h(this,K)))g(this,rt,!0);else{let{entityAdd:r}=await e.batch({entityAdd:{method:"entity.add",params:{ENTITY:h(this,K),NAME:h(this,K),ACCESS:{AU:"X"}}}});r&&g(this,rt,!0)}return _(this,Xt,ye).call(this),h(this,rt)}start({type:e,data:A}){if(!h(this,rt)){_(this,It,le).call(this,"entity");return}const n=wt.hash;return h(this,ct).set(n,{type:e,data:A,userInfo:h(this,Bt),errorList:[],status:"",answer:null,date:new Date().getTime()}),n}stop({key:e,errorList:A,status:n,answer:r}){if(!h(this,rt)){_(this,It,le).call(this,"entity");return}let a=h(this,ct).get(e);A&&(a.errorList=A),n&&(a.status=n),r&&(a.answer=r),wt.actionFilter({keyTimer:"add.entity.items",duration:h(this,Wt),action:async()=>{var o;await _(this,Jt,_e).call(this),(o=a==null?void 0:a.data)!=null&&o.updateList&&g(this,Et,!0)}})}async getEntityList(e){var r;if((r=h(this,nt))!=null&&r.length&&!h(this,Et))return h(this,nt);let A=new Z(BX24.callBatch),{entityList:n}=await A.batch({entityList:{method:"entity.item.get",params:{ENTITY:h(this,K),SORT:{ID:"DESC"}}}},e);return n=n.map(a=>{const{ID:o,DATE_CREATE:f,DETAIL_TEXT:c}=a;return{...JSON.parse(c),id:o,dateCreate:f}}),g(this,Et,!1),n}async downAllEntityJson(){let e=await this.getEntityList(),A=Tt().format("%Y-%m-%d");wt.downloadFileJson(e,`sdklogger-entity-data__${A}`)}}K=new WeakMap,rt=new WeakMap,Wt=new WeakMap,ct=new WeakMap,Bt=new WeakMap,nt=new WeakMap,Et=new WeakMap,jt=new WeakSet,Oe=async function(){const e=new Z(BX24.callBatch),A=BX24.isAdmin(),{curUser:n}=await e.batch({curUser:{method:"user.current"}});g(this,Bt,{isAdmin:A,curUser:n})},It=new WeakSet,le=function(e){e=="entity"&&wt.actionFilter({keyTimer:"error.logger.entity",duration:500,action:()=>{console.error("Хранилище для логгера не инициализировано")}})},Jt=new WeakSet,_e=async function(){let e={},A=new Z(BX24.callBatch);for(let[n,r]of h(this,ct).entries())r.status&&(e[n]={method:"entity.item.add",params:{ENTITY:h(this,K),NAME:h(this,K),DETAIL_TEXT:JSON.stringify(r)}});if(Object.keys(e).length){let n=await A.batch(e),{errors:r}=A;for(let[a,o]of Object.entries({...n,...r}))h(this,ct).delete(a);return!0}},Xt=new WeakSet,ye=async function(){let e=new Z(BX24.callBatch),{serverTime:A}=await e.batch({serverTime:{method:"server.time"}});h(this,nt)||g(this,nt,await this.getEntityList());let n=h(this,nt).filter(r=>{let{dateCreate:a}=r;return Tt(new Date(a)).between(Tt(new Date(A)),"month")>=this.periodClear});_(this,xt,de).call(this,n)},xt=new WeakSet,de=async function(e){let A=new Z(BX24.callBatch),n=e.map(r=>{let{id:a}=r;return{method:"entity.item.delete",params:{ENTITY:h(this,K),ID:a}}});return await A.batch(n)};class Re{constructor(e){O(this,Qt);O(this,Zt);W(this,"domain","");W(this,"isAdmin",!1);W(this,"appInfo",null);W(this,"appConst",null);W(this,"userInfo",null);W(this,"placeData",null);W(this,"placeInfo",null);W(this,"logger",new ce);this.appConst=e}init(){return new Promise(e=>{let A=setInterval(()=>{window.BX24&&BX24.init(async()=>{console.info("init BX24"),clearInterval(A),this.domain=BX24.getDomain(),this.isAdmin=BX24.isAdmin(),this.placeInfo=BX24.placement.info(),await this.logger.init();const[n,r]=await Promise.all([_(this,Qt,ge).call(this),_(this,Zt,Ee).call(this)]);this.appInfo=n,this.userInfo=r,new te().noSleep(),e(!0)})},100)})}userOption(e,A){return A?BX24.userOption.set(e,A):BX24.userOption.get(e)}call({method:e,params:A,updateList:n}){let r=this.logger.start({type:"call",data:{method:e,params:A,updateList:n}});return new Promise(a=>{A||(A={}),BX24.callMethod(e,A,o=>{let f={};if(o!=null&&o.answer)for(let[c,i]of Object.entries(o.answer))c!="result"&&i&&(f[c]=i);if(o.error()){let c=o.error();console.error(c),this.logger.stop({answer:f,key:r,status:"fail",errorList:[c.toString()]}),a(!1)}else{let c=o.data();c!=null&&c.items&&(c=c.items),this.logger.stop({answer:f,key:r,status:"success"}),a(c)}})})}async batch(e,A,{updateList:n,errorCall:r,limitCommandSerial:a}={}){let o=new Z(BX24.callBatch),f=this.logger.start({type:"batch",data:{commandList:e,updateList:n}});a&&(o.limitCommandSerial=a);try{let c=await o.batch(e,A);if(Object.keys(o.errors).length){let i=Object.entries(o.errors).map(([d,y])=>{var u;return{key:d,error:`${y==null?void 0:y.method} ${(u=y==null?void 0:y.error)==null?void 0:u.toString()}`.trim()}});r&&r(o.errors),this.logger.stop({key:f,status:"fail",errorList:i,answer:o.answerData})}else this.logger.stop({key:f,status:"success",answer:o.answerData});return c}catch(c){let i=c==null?void 0:c.toString();return this.logger.stop({key:f,status:"fail-runtime",errorList:[i],answer:o.answerData}),console.error(c),!1}}async batchUpdateField(e,A,{updateList:n,errorCall:r,limitCommandSerial:a}={}){let o=new Z(BX24.callMethod),f=this.logger.start({type:"callMethod-batch",data:{commandList:e,updateList:n}});a&&(o.limitCommandSerial=a);try{let c=await o.batchUpdateField(e,A);if(Object.keys(o.errors).length){let i=Object.entries(o.errors).map(([d,y])=>{var u;return{key:d,error:`${y==null?void 0:y.method} ${(u=y==null?void 0:y.error)==null?void 0:u.toString()}`.trim()}});r&&r(o.errors),this.logger.stop({key:f,status:"fail",errorList:i,answer:o.answerData})}else this.logger.stop({key:f,status:"success",answer:o.answerData});return c}catch(c){let i=c==null?void 0:c.toString();return this.logger.stop({key:f,status:"fail-runtime",errorList:[i],answer:o.answerData}),console.error(c),!1}}async batchTotalCount(e,A){let n=new Z(BX24.callBatch),r=this.logger.start({type:"batch",data:{commandList:e}});try{let a=await n.batchTotalCount(e,A);if(Object.keys(n.errors).length){let o=Object.entries(n.errors).map(([f,c])=>({key:f,error:c.toString()}));this.logger.stop({key:r,status:"fail",errorList:o})}else this.logger.stop({key:r,status:"success"});return a}catch(a){return this.logger.stop({key:r,status:"fail",errorList:[a.toString()]}),console.error(a),!1}}getPlacement(){return this.call({method:"placement.get"}).then(e=>(this.placeData||(this.placeData=e),e))}async placementBind(e){this.placeData||(this.placeData=await this.getPlacement());const{appName:A,pathApp:n}=this.appConst,r=this.placeData.map(o=>o.placement);let a=this.placeData.find(o=>o.placement==e);r.includes(e)?a.handler!=n&&(window.placementUnBind||(window.placementUnBind={}),window.placementUnBind[e]||this.placementUnBind(a).then(()=>{window.placementUnBind[e]||(window.placementUnBind[e]=!0,this.placementBind(e))})):this.call({method:"placement.bind",params:{PLACEMENT:e,HANDLER:n,LANG_ALL:{ru:{TITLE:A}}}}).then(o=>{o?console.info("Приложение успешно встроено в",e):console.warn("Приложение не может быть встроено в",e)})}placementUnBind(e){const{pathApp:A,appName:n}=this.appConst;return this.call({method:"placement.unbind",params:{PLACEMENT:e,HANDLER:A,LANG_ALL:{ru:{TITLE:n}}}}).then(r=>(console.log("Встройка отвязана",e),r))}getBotList(){return this.call({method:"imbot.bot.list",params:{}}).then(e=>{let A=Object.values(e);return console.log("chat-bot list:",A),A})}regBot({code:e,type:A,name:n}){const{appName:r,pathApp:a,chatBotLogo:o}=this.appConst,f=this.appInfo.ID;return this.call({method:"imbot.register",params:{CODE:e??this.appInfo.CODE,TYPE:A??"O",EVENT_HANDLER:a,OPENLINE:"Y",CLIENT_ID:"",PROPERTIES:{NAME:`${n??r} - бот #${f}`,LAST_NAME:"",COLOR:"GREEN",EMAIL:"",PERSONAL_BIRTHDAY:Tt().format("%Y-%m-%d"),WORK_POSITION:"Почтальон",PERSONAL_WWW:"",PERSONAL_GENDER:"M",PERSONAL_PHOTO:o??""}}}).then(c=>(console.log("Чат-бот добавлен",c),c))}unRegBot(e){return this.call({method:"imbot.unregister",params:{BOT_ID:e}}).then(A=>(console.log("чат-бот удален",A),A))}getLoggerList(e){return this.logger.getEntityList(e)}}Qt=new WeakSet,ge=function(){return this.call({method:"app.info"})},Zt=new WeakSet,Ee=function(){return this.call({method:"user.current"})},T.Batch=Z,T.BxBoot=Re,T.BxHelper=te,T.BxLogger=ce,T.tempus=Tt,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types/batch.d.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
type TCommand = {
|
|
2
|
-
method: string,
|
|
3
|
-
params: Record<string, unknown> | {
|
|
4
|
-
select?: string[],
|
|
5
|
-
filter?: Record<string, string | string[]>,
|
|
6
|
-
} | {
|
|
7
|
-
id?: string,
|
|
8
|
-
params?: Record<string, string>,
|
|
9
|
-
fields?: Record<string, unknown>,
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare class Batch{
|
|
14
|
-
/**
|
|
15
|
-
* @constructor
|
|
16
|
-
* @param {()=>void} callBatch - пробрасываем метод BX24.callBatch
|
|
17
|
-
*/
|
|
18
|
-
constructor(callBatch: ()=>void);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Флаг режима передачи
|
|
22
|
-
*/
|
|
23
|
-
get serial(): boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* лимит команд при котором происходит переключение батча в последовательный режим по дефолту 50
|
|
27
|
-
*/
|
|
28
|
-
limitCommandSerial: number
|
|
29
|
-
|
|
30
|
-
/** Объект ошибок key-value, где key - ключ чанка пакета, value - описание ошибки */
|
|
31
|
-
errors: Record<string, string>;
|
|
32
|
-
|
|
33
|
-
/** Объект служебной информации отработавшего запроса*/
|
|
34
|
-
answerData: Record<string, any>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Установить последовательный режим
|
|
38
|
-
*/
|
|
39
|
-
setSerial(): void;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Установить параллельный режим режим
|
|
43
|
-
*/
|
|
44
|
-
setParallel(): void;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Принудительно остановить выгрузку данных
|
|
48
|
-
*/
|
|
49
|
-
stop(): void;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Пакетный запрос данных
|
|
53
|
-
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
54
|
-
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
55
|
-
*/
|
|
56
|
-
batch(
|
|
57
|
-
commandList: Record<string, TCommand>,
|
|
58
|
-
progressCall?: (data:{ percent: number })=>void
|
|
59
|
-
): Awaited<Record<string, unknown[]> | boolean>;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Пакетный запрос количества элементов по запрощенным сущностям
|
|
63
|
-
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
64
|
-
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
65
|
-
*/
|
|
66
|
-
batchTotalCount(
|
|
67
|
-
commandList: Record<string, TCommand>,
|
|
68
|
-
progressCall?: (data:{ percent: number })=>void
|
|
69
|
-
): Awaited<Record<string, unknown[]> | boolean>;
|
|
70
|
-
}
|
|
71
|
-
|
|
1
|
+
type TCommand = {
|
|
2
|
+
method: string,
|
|
3
|
+
params: Record<string, unknown> | {
|
|
4
|
+
select?: string[],
|
|
5
|
+
filter?: Record<string, string | string[]>,
|
|
6
|
+
} | {
|
|
7
|
+
id?: string,
|
|
8
|
+
params?: Record<string, string>,
|
|
9
|
+
fields?: Record<string, unknown>,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class Batch{
|
|
14
|
+
/**
|
|
15
|
+
* @constructor
|
|
16
|
+
* @param {()=>void} callBatch - пробрасываем метод BX24.callBatch
|
|
17
|
+
*/
|
|
18
|
+
constructor(callBatch: ()=>void);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Флаг режима передачи
|
|
22
|
+
*/
|
|
23
|
+
get serial(): boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* лимит команд при котором происходит переключение батча в последовательный режим по дефолту 50
|
|
27
|
+
*/
|
|
28
|
+
limitCommandSerial: number
|
|
29
|
+
|
|
30
|
+
/** Объект ошибок key-value, где key - ключ чанка пакета, value - описание ошибки */
|
|
31
|
+
errors: Record<string, string>;
|
|
32
|
+
|
|
33
|
+
/** Объект служебной информации отработавшего запроса*/
|
|
34
|
+
answerData: Record<string, any>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Установить последовательный режим
|
|
38
|
+
*/
|
|
39
|
+
setSerial(): void;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Установить параллельный режим режим
|
|
43
|
+
*/
|
|
44
|
+
setParallel(): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Принудительно остановить выгрузку данных
|
|
48
|
+
*/
|
|
49
|
+
stop(): void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Пакетный запрос данных
|
|
53
|
+
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
54
|
+
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
55
|
+
*/
|
|
56
|
+
batch(
|
|
57
|
+
commandList: Record<string, TCommand>,
|
|
58
|
+
progressCall?: (data:{ percent: number })=>void
|
|
59
|
+
): Awaited<Record<string, unknown[]> | boolean>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Пакетный запрос количества элементов по запрощенным сущностям
|
|
63
|
+
* @param commandList - лист команд можно передавать как в виде объекта, так и в виде массива команд
|
|
64
|
+
* @param progressCall - принимает callback в который передается статус загрузки данных в процентах
|
|
65
|
+
*/
|
|
66
|
+
batchTotalCount(
|
|
67
|
+
commandList: Record<string, TCommand>,
|
|
68
|
+
progressCall?: (data:{ percent: number })=>void
|
|
69
|
+
): Awaited<Record<string, unknown[]> | boolean>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
72
|
export default Batch;
|