@easydata/crud 1.4.11 → 1.4.13

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.
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see easydata.crud.min.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("easydataCRUD",[],e):"object"==typeof exports?exports.easydataCRUD=e():t.easydataCRUD=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(module,__webpack_exports__,__webpack_require__){"use strict";var browserUtils;__webpack_require__.d(__webpack_exports__,"a",(function(){return browserUtils})),function(browserUtils){var _isFirefox=null,_isIE=null;function IsIE(){if(null===_isIE){var t=navigator.userAgent;_isIE=t.indexOf("MSIE ")>-1||t.indexOf("Trident/")>-1}return _isIE}function IsEdge(){return!IsIE()&&eval("!!window.StyleMedia")}function IsFirefox(){if(null===_isFirefox){var t=navigator.userAgent;_isFirefox=t.toLowerCase().indexOf("firefox")>-1}return _isFirefox}browserUtils.IsIE=IsIE,browserUtils.IsEdge=IsEdge,browserUtils.IsFirefox=IsFirefox;var _detectedIsMobileMode=!1,_isMobileMode=void 0,detectIsMobileMode=function(){var t=isMobileMode();_detectedIsMobileMode=window.matchMedia("only screen and (max-width: 840px)").matches||window.matchMedia("only screen and (max-height: 420px)").matches;var e=isMobileMode();e!==t&&mobileModeChangeHandler&&mobileModeChangeHandler(e)},mobileModeChangeHandler;function isMobileMode(){return void 0!==_isMobileMode?_isMobileMode:_detectedIsMobileMode}function setIsMobileMode(t){var e=isMobileMode();_isMobileMode=t;var n=isMobileMode();n!==e&&mobileModeChangeHandler&&mobileModeChangeHandler(n)}function onMobileModeChanged(t){mobileModeChangeHandler=t}function getMobileCssClass(){return isMobileMode()?"k-mobile":null}detectIsMobileMode(),window.addEventListener("resize",(function(){return detectIsMobileMode()})),browserUtils.isMobileMode=isMobileMode,browserUtils.setIsMobileMode=setIsMobileMode,browserUtils.onMobileModeChanged=onMobileModeChanged,browserUtils.getMobileCssClass=getMobileCssClass}(browserUtils||(browserUtils={}))},function(t,e,n){"use strict";var i,o;n.r(e),n.d(e,"TextDataFilter",(function(){return F})),n.d(e,"EntityEditForm",(function(){return Ft})),n.d(e,"EntityEditFormBuilder",(function(){return Vt})),n.d(e,"TextFilterWidget",(function(){return _t})),n.d(e,"ProgressBar",(function(){return jt})),n.d(e,"DataContext",(function(){return qt})),n.d(e,"EasyDataServerLoader",(function(){return Gt})),n.d(e,"Validator",(function(){return At})),n.d(e,"TypeValidator",(function(){return Wt})),n.d(e,"RequiredValidator",(function(){return Kt})),n.d(e,"EasyDataViewDispatcher",(function(){return Zt})),n.d(e,"RootDataView",(function(){return Jt})),n.d(e,"EntityDataView",(function(){return Xt})),function(t){t[t.Unknown=0]="Unknown",t[t.String=1]="String",t[t.Byte=2]="Byte",t[t.Word=3]="Word",t[t.Int32=4]="Int32",t[t.Int64=5]="Int64",t[t.Bool=6]="Bool",t[t.Float=7]="Float",t[t.Currency=8]="Currency",t[t.BCD=9]="BCD",t[t.Date=10]="Date",t[t.Time=11]="Time",t[t.DateTime=12]="DateTime",t[t.Autoinc=13]="Autoinc",t[t.Memo=14]="Memo",t[t.Blob=15]="Blob",t[t.FixedChar=16]="FixedChar",t[t.Guid=17]="Guid",t[t.Geometry=18]="Geometry",t[t.Geography=19]="Geography"}(i||(i={})),function(t){t[t.Data=0]="Data",t[t.Virtual=1]="Virtual",t[t.Lookup=2]="Lookup"}(o||(o={}));var r,s="Unknown",a="EDIT",l="DATETIME",u="LIST",d="FILE";!function(t){t.Trace="TRACE",t.Options="OPTIONS",t.Get="GET",t.Put="PUT",t.Post="POST",t.Delete="DELETE"}(r||(r={}));var c,h,p=function(){function t(t,e){this.xhr=t,this.method=e.method,this.url=e.url,this.headers=e.headers,this.queryParams=e.queryParams,this.data=e.data}return t.prototype.setHeader=function(t,e){this.headers[t]=e},t.prototype.setQueryParam=function(t,e){this.queryParams[t]=e},t.prototype.getXMLHttpRequest=function(){return this.xhr},t.prototype.getResponseHeaders=function(){if(this.xhr.readyState==this.xhr.HEADERS_RECEIVED){for(var t={},e=0,n=this.xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);e<n.length;e++){var i=n[e].split(": "),o=i.shift(),r=i.join(": ");t[o]=r}return t}return{}},t.prototype.open=function(){var t=this;if(this.xhr.readyState===this.xhr.UNSENT){var e=this.url;for(var n in this.queryParams&&Object.keys(this.queryParams).length>0&&(e+=encodeURI("?"+Object.keys(this.queryParams).map((function(e){return e+"="+t.queryParams[e]})).join("&"))),this.xhr.open(this.method,e,!0),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),this.headers)this.xhr.setRequestHeader(n,this.headers[n])}},t.prototype.abort=function(){this.xhr.abort()},t}();function f(t,e){for(var n="",i=0;i<e;i++)n+=t;return n}function g(t,e){var n=t;return null!=n&&n.length>0?("/"!=n.charAt(n.length-1)&&(n+="/"),n+=e):n=e,n}!function(t){var e,n={shortDateFormat:"MM/dd/yyyy",longDateFormat:"dd MMM, yyyy",editDateFormat:"MM/dd/yyyy",shortTimeFormat:"HH:mm",editTimeFormat:"HH:mm",longTimeFormat:"HH:mm:ss",shortMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longMonthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],shortWeekDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longWeekDayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],decimalSeparator:".",currency:"USD"},o={localeId:"en-US",englishName:"English",displayName:"English",texts:{ButtonOK:"OK",ButtonCancel:"Cancel",Yes:"Yes",No:"No",True:"True",False:"False"},settings:n},r={"en-US":o},s=[];function a(t){for(var e=0,n=s;e<n.length;e++){(0,n[e])(t)}}function l(){return e.localeId}function u(t){var n=r[t];n?h.assignDeep(e,n):(e.englishName=t,e.displayName=t,e.texts=h.assignDeep({},o.texts)),e.localeId=t}function d(){return e.settings}function c(t){e.settings||(e.settings=h.assignDeep({},n)),e.settings=h.assignDeep(e.settings,t)}function p(t,n){a(n);var i=e;t&&(n.localeId||(n.localeId=t),(i=r[t])||(i=h.assignDeep({},o),r[t]=i)),h.assignDeep(i,n)}function f(){var t,n,i,o,r,s,a="object"==typeof navigator?navigator.language:void 0;t=a,n=new Date(2020,5,7,19,34,56,88),i=n.toLocaleDateString(t,{year:"numeric",month:"numeric",day:"numeric"}),o=n.toLocaleTimeString(t,{hour:"numeric",minute:"numeric",second:"numeric"}),r=i.replace("07","dd").replace("7","d").replace("06","MM").replace("6","M").replace("2020","yyyy").replace("20","yy"),s=o.replace("19","HH").replace("07","hh").replace("7","h").replace("34","mm").replace("56","ss").replace("PM","tt"),e.settings||(e.settings={}),c({shortDateFormat:r,shortTimeFormat:s})}function g(t){var e,n=d();switch(t){case i.Date:e=n.shortDateFormat;break;case i.Time:e=n.shortTimeFormat;break;default:e=n.shortDateFormat+" "+n.shortTimeFormat}return e}function m(t){var e,n=d();switch(t){case i.Date:e=n.longDateFormat;break;case i.Time:e=n.longTimeFormat;break;default:e=n.longDateFormat+" "+n.longTimeFormat}return e}t.addMapper=function(t){s.push(t)},t.getLocales=function(){var t=[];for(var e in r)t.push({locale:e,englishName:r[e].englishName,displayName:r[e].displayName});return t.sort((function(t,e){return t.englishName>e.englishName?1:t.englishName===e.englishName?0:-1}))},t.getCurrentLocale=l,t.setLocale=function(t){console.warn("This method is deprecated. Use setCurrentLocale instead"),u(t)},t.setCurrentLocale=u,t.getText=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var i=e.texts,o="";if(t&&t.length)for(var r=t.length,s=0;s<r&&"object"==typeof(o=i[t[s]]);s++)i=o;return o},t.getLocaleSettings=d,t.getOneLocaleSetting=function(t){return e.settings[t]},t.getShortMonthName=function(t){var e=d();if(t>0&&t<13)return e.shortMonthNames[t-1];throw"Wrong month number: "+t},t.getLongMonthName=function(t){var e=d();if(t>0&&t<13)return e.longMonthNames[t-1];throw"Wrong month number: "+t},t.getShortWeekDayName=function(t){var e=d();if(t>0&&t<8)return e.shortWeekDayNames.length>=t?e.shortWeekDayNames[t-1]:t.toString();throw"Wrong month number: "+t},t.getLongWeekDayName=function(t){var e=d();if(t>0&&t<8)return e.longWeekDayNames.length>=t?e.longWeekDayNames[t-1]:t.toString();throw"Wrong month number: "+t},t.updateLocaleSettings=c,t.updateLocaleTexts=function(t){"object"==typeof t?(a({localeId:e.localeId,texts:t}),h.assignDeep(e.texts,t)):console.error("Wrong parameter type in updateLocaleTexts function call.The first parameter (localeId) is not necessary. Use updateLocaleTexts(texts) instead")},t.updateDefaultTexts=function(t){for(var n in r){var i=r[n];i.texts=h.assignDeep({},t,i.texts)}e.texts=h.assignDeep({},t,e.texts)},t.updateLocaleInfo=p,t.addLocale=function(t,e){p(t,e)},t.resetLocales=function(){e||(e=h.assignDeep({},o),f())},t.dateTimeToStr=function(t,e,n){return n?"d"==n?n=g(i.Date):"D"==n?n=m(i.Date):"f"==n?n=g(i.DateTime):"F"==n&&(n=m(i.DateTime)):n=g(e),h.dateTimeToStr(t,n)},t.numberToStr=function(e,n){if(n&&n.length>0){var i=n.charAt(0).toUpperCase();if("S"===i)return function(e,n){if(!y[n]){var i=n.split("|").filter((function(t){return t.length>0})).map((function(t){return t.split("=")}));if(y[n]={},i.length>0)if(i[0].length>1)for(var o=0,r=i;o<r.length;o++){var s=r[o];y[n][Number.parseInt(s[1])]=s[0]}else i.forEach((function(t,e){y[n][e]=t[0]}))}var a=y[n];if(void 0!==a[e]){s=a[e];return t.getText(s)||s}return e.toString()}(e,n.slice(1));if(["D","F","C"].indexOf(i)>=0){var o=l();return e.toLocaleString(o,function(t){var e=d(),n=t[0].toUpperCase(),i=t.length>1?Number.parseInt(t.slice(1)):"D"==n?1:2;switch(n){case"D":return{style:"decimal",useGrouping:!1,minimumIntegerDigits:i};case"C":return{style:"currency",currency:e.currency,minimumFractionDigits:i};default:return{style:"decimal",minimumFractionDigits:i,maximumFractionDigits:i}}}(n))}return function(t,e){for(var n=t.toString(),i="",o=n.length-1,r=e.length-1;r>=0;r--){var s=e.charAt(r);"#"===s||"0"===s?o>=0?(i+=n.charAt(o),o--):"0"===s&&(i+=0):i+=s}return i.split("").reverse().join("")}(Math.trunc(e),n)}var r=d();return h.numberToStr(e,r.decimalSeparator)},t.booleanToStr=function(e,n){if(n&&n.length>0&&"S"===n.charAt(0).toUpperCase()){var i=n.slice(1).split("|");if(i.length>1){var o=i[e?1:0];return t.getText(o)||o}}return""+e};var y={}}(c||(c={})),function(t){t.getAllDataTypes=function(){return Object.values(i).filter((function(t){return"number"==typeof t}))},t.getDateDataTypes=function(){return[i.Time,i.Date,i.DateTime]},t.getStringDataTypes=function(){return[i.String,i.Memo,i.FixedChar]};var e=[i.Byte,i.Word,i.Int32,i.Int64,i.Float,i.Currency,i.Autoinc];t.getNumericDataTypes=function(){return e};var n=[i.Byte,i.Word,i.Int32,i.Int64,i.Autoinc];function o(t,e,n){e||(e={});for(var i=0,s=n;i<s.length;i++){var a=s[i];if(a)for(var l in a)if(a.hasOwnProperty(l)){var u=a[l];null!==u&&"object"==typeof u?t.has(u)?e[l]=t.get(u):Array.isArray(u)?(e[l]=r(u),t.set(u,e[l])):(void 0!==e[l]&&null!=e[l]||(e[l]=Object.create(Object.getPrototypeOf(u))),t.set(u,e[l]),o(t,e[l],[u])):e[l]=u}}return e}function r(t){for(var e=[],n=0,i=t;n<i.length;n++){var o=i[n];e.push(o)}return e}t.assign=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var i=0;i<e.length;i++){var o=e[i];if(o)for(var r in o)o.hasOwnProperty(r)&&(t[r]=o[r])}return t},t.assignDeep=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return o(new WeakMap,t,e)},t.getIfDefined=function(t,e){return void 0!==t?t:e},t.IsDefinedAndNotNull=function(t){return null!=t},t.copyArrayTo=function(t,e){for(var n=t.length,i=e.length,o=0;o<n&&o<i;o++)e[o]=t[o]},t.createArrayFrom=r,t.findItemById=function(t,e){for(var n=t.length,i=0;i<n;i++)if(t[i].id===e)return t[i];return null},t.findItemIndexById=function(t,e){for(var n=t.length,i=0;i<n;i++)if(t[i].id===e)return i;return-1},t.indexOfArrayItem=function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=t.length,i=0;i<n;i++)if(e==t[i])return i;return-1},t.moveArrayItem=function(t,e,n){if(e>=t.length)throw"Index out of bounds: "+e;n>=t.length&&(n=t.length-1);var i=t.splice(e,1)[0];t.splice(n,0,i)},t.removeArrayItem=function(t,e){var n=t.indexOf(e);if(-1!=n)return t.splice(n,1)[0]},t.insertArrayItem=function(t,e,n){t.splice(e,0,n)},t.fillArray=function(t,e,n,i){void 0===n&&(n=0);for(var o=t.length>>>0,r=n>>0,s=r<0?Math.max(o+r,0):Math.min(r,o),a=void 0===i?o:i>>0,l=a<0?Math.max(o+a,0):Math.min(a,o);s<l;)t[s]=e,s++;return t},t.shiftToFitWindow=function(t,e){var n=document.getElementsByTagName("body")[0],i=window.innerWidth||document.documentElement.clientWidth||n.clientWidth,o=t+e,r=0;return o>i&&t+(r=i-o-10)<0&&(r=10-t),r},t.isObject=function(t){return null!==t&&("function"==typeof t||"object"==typeof t)},t.isNumericType=function(t){return e.indexOf(t)>=0},t.isIntType=function(t){return n.indexOf(t)>=0},t.isNumeric=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},t.areCompatibleDataTypes=function(t,e){return void 0===t||void 0===e||t==i.Unknown||e==i.Unknown||t==e||t==i.Date&&e==i.DateTime||t==i.DateTime&&e==i.Date},t.isPropSet=function(t,e){return t[e]||t[e.toLowerCase()]||t[e.toUpperCase()]};var s="0123456789abcdefghijklmnopqrstuvwxyz";function a(t,e){var n=t.length;if(n>e){var i=n/e,o="";o+=t[0];for(var r=i,s=void 0,a=1;a<n;a++)s=t[a],a+1>r&&(o+=s,r+=i);return o}return t}function l(t,e,n){return t.substr(0,e)+n+t.substr(e+n.length)}function u(t,e){return Math.floor(Math.random()*(e-t))+t}function d(t){var e=parseInt(t);if(isNaN(e))throw'"'+t+'" is not a valid number';return e}t.generateId=function(t){t||(t="easy");var e=t.length>4?function(t,e){var n=t.split("-"),i=1,o=e;n.length<e&&(i=e/n.length,o=n.length);for(var r="",s=0;s<o;s++)r+=a(n[s],i);return r}(t,4):t;e&&e.length>0&&(e+="-");var n=f("",2),i=s.length-1;return n=l(n,0,s[u(0,i)]),e+(n=l(n,1,s[u(0,i)]))+function(t){var e=36,n=14,i=f("",n),o=t;do{i=l(i,n--,s[o%e]),o=Math.floor(o/=e)}while(o>0);return r=i.trim(),r.split("").reverse().join("");var r}(621355968e9+1e4*(new Date).getTime()-0x8d60e562e627800)},t.strToDateTime=function(t,e){if(!t||0==t.length)return new Date;var n=t.replace(/[^a-zA-Z0-9_]/g,"-"),i=e.replace(/[^a-zA-Z0-9_]/g,"-").split("-"),o=n.split("-"),r=i.indexOf("MM"),s=i.indexOf("dd"),a=i.indexOf("yyyy"),l=i.indexOf("HH"),u=i.indexOf("mm"),c=i.indexOf("ss"),h=new Date;try{var p=a>-1&&a<o.length?d(o[a]):h.getFullYear(),f=r>-1&&r<o.length?d(o[r])-1:h.getMonth()-1;if(f>11)throw"";var g=s>-1&&s<o.length?d(o[s]):h.getDate();if(g>function(t,e){return new Date(e,t+1,0).getDate()}(f,p))throw"";var m=l>-1&&l<o.length?d(o[l]):0;if(m>23)throw"";var y=u>-1&&u<o.length?d(o[u]):0;if(y>59)throw"";var v=c>-1&&c<o.length?d(o[c]):0;if(v>59)throw"";return new Date(p,f,g,m,y,v)}catch(e){throw t+" is not a valid date."}},t.strToTime=function(t){var e=t.split(":");try{var n=e.length>0?d(e[0]):0;if(n>23)throw"";var i=e.length>1?d(e[1]):0;if(i>59)throw"";var o=e.length>1?d(e[1]):0;if(o>59)throw"";return new Date(0,0,0,n,i,o)}catch(e){throw t+" is not a valid time."}};var h=/\[([^\]]+)]|y{2,4}|M{1,4}|d{1,2}|H{1,2}|h{1,2}|m{2}|s{2}|t{2}/g;t.dateTimeToStr=function(t,e){var n=t.getFullYear().toString(),i=t.getMonth()+1,o=t.getDate(),r=t.getHours(),s=t.getMinutes(),a=t.getSeconds(),l=r%12||12,u=r>11,d={yyyy:n,yy:n.substring(n.length-2),MMMM:c.getLongMonthName(i),MMM:c.getShortMonthName(i),MM:i<10?"0"+i:i.toString(),M:i.toString(),dd:o<10?"0"+o:o.toString(),d:o.toString(),HH:r<10?"0"+r:r.toString(),H:r.toString(),hh:l<10?"0"+l:l.toString(),h:l.toString(),tt:u?"PM":"AM",mm:s<10?"0"+s:s.toString(),ss:a<10?"0"+a:a.toString()};return e.replace(h,(function(t,e){return e||d[t]}))},t.numberToStr=function(t,e){return e=e||c.getLocaleSettings().decimalSeparator,t.toString().replace(".",e)}}(h||(h={}));var m,y,v=function(){function t(t,e){this.request=t,this.promise=e}return t.prototype.getPromise=function(){return this.promise},t.prototype.getRequest=function(){return this.request},t.prototype.then=function(t,e){return this.promise.then(t,e)},t.prototype.catch=function(t){return this.promise.catch(t)},t.prototype.finally=function(t){return this.promise.finally(t)},t}(),b=(m=function(t,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},m(t,e)},function(t,e){function n(){this.constructor=t}m(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),C=function(){return C=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},C.apply(this,arguments)},w=function(t){function e(e,n){var i=t.call(this,n)||this;return i.status=e,i}return b(e,t),e}(Error),D=function(){function t(){this.defaultHeaders={},this.customPayload=void 0}return Object.defineProperty(t.prototype,"responseBody",{get:function(){return this._responseBody},enumerable:!0,configurable:!0}),t.prototype.get=function(t,e){return this.send(r.Get,t,null,e)},t.prototype.post=function(t,e,n){return this.send(r.Post,t,e,n)},t.prototype.put=function(t,e,n){return this.send(r.Put,t,e,n)},t.prototype.delete=function(t,e,n){return this.send(r.Delete,t,e,n)},t.prototype.send=function(e,n,i,o){var r=this,s=(o=o||{}).dataType||"json",a=o.contentType||"form-data"!==s?"application/json":null;i&&"form-data"!=s&&this.customPayload&&(i.data=h.assignDeep(i.data||{},this.customPayload));var l=new("onload"in new XMLHttpRequest?XMLHttpRequest:window.XDomainRequest),u={method:e,url:n,headers:C(C({},this.defaultHeaders),o.headers||{}),queryParams:o.queryParams||{},data:i};a&&(u.headers["Content-Type"]=a);var d=new p(l,u);this.beforeEachRequest&&(console.warn("HttpClient: 'beforeEachRequest' is deprecated and will be removed in future updates.\n Use 'onRequest' instead"),this.beforeEachRequest(d)),this.onRequest&&this.onRequest(d);var c=d.data&&"string"!=typeof d.data&&"json"==s?JSON.stringify(d.data):d.data;return d.open(),new v(d,new Promise((function(e,i){o.responseType&&(l.responseType=o.responseType),l.onerror=function(t){i(new w(l.status,l.responseText))},l.onreadystatechange=function(){if(4==l.readyState){var o=l.getResponseHeader("Content-Type")||"",s=l.status;if(0===s)i(new w(s,"Network error or the request was aborted"));else if(s>=200&&s<400){var a="arraybuffer"===l.responseType||"blob"===l.responseType?l.response:0==o.indexOf("application/json")?JSON.parse(l.responseText):l.responseText;r._responseBody=a,r.onResponse&&r.onResponse(l),e(a)}else{("arraybuffer"===l.responseType||"blob"===l.responseType?t.decodeArrayBuffer(l.response):Promise.resolve(l.responseText)).then((function(t){var e=0==o.indexOf("application/json")?JSON.parse(t):t;r._responseBody=e;var a=e.message||(404==s?"No such endpoint: "+n:e);i(new w(s,a))}))}}},l.send(c)})))},t.decodeArrayBuffer=function(t){var e=new FileReader;return new Promise((function(n){e.onloadend=function(){e.readyState==FileReader.DONE&&n(e.result)},e.readAsText(new Blob([t]))}))},t}(),T=function(){function t(t){this.isEditable=!0,this.name="",this.caption="",this.description="",this.parent=t,this.attributes=new Array,this.subEntities=new Array}return t.prototype.loadFromData=function(t,e){if(e){if(this.id=e.id,this.name=e.name,this.captionPlural=e.namePlur,this.caption=e.name,this.description=e.desc,void 0!==e.ied&&(this.isEditable=e.ied),this.subEntities=new Array,e.ents)for(var n=0;n<e.ents.length;n++){var i=t.createEntity(this);i.loadFromData(t,e.ents[n]),this.subEntities.push(i)}if(this.attributes=new Array,e.attrs)for(n=0;n<e.attrs.length;n++){var o=t.createEntityAttr(this);o.loadFromData(t,e.attrs[n]),this.attributes.push(o)}}},t.prototype.scan=function(t,e){var n={stop:!1},i=function(o){if(e&&e(o,n),o.attributes)for(var r=o.attributes.length,s=0;s<r&&!n.stop;s++){var a=o.attributes[s];if(t&&t(a,n),n.stop)return}if(o.subEntities){var l=o.subEntities.length;for(s=0;s<l&&!n.stop;s++)i(o.subEntities[s])}};i(this)},t.prototype.getFirstPrimaryAttr=function(){return this.getPrimaryAttrs()[0]},t.prototype.getPrimaryAttrs=function(){return this.attributes.filter((function(t){return t.isPrimaryKey}))},t}(),x=function(){function t(t){this.id="",this.caption="{Unrecognized attribute}",this.dataType=i.String,this.size=0,this.isPrimaryKey=!1,this.isForeignKey=!1,this.isNullable=!0,this.showOnView=!0,this.isEditable=!0,this.showOnCreate=!0,this.showOnEdit=!0,this.showInLookup=!1,this.lookupAttr="",this.expr="",this.entity=t,this.kind=o.Data}return t.prototype.loadFromData=function(t,e){if(e){this.id=e.id,this.description=e.desc,this.caption=e.cptn,this.dataType=e.dtype,this.isPrimaryKey=e.ipk,this.isForeignKey=e.ifk,this.size=e.size,this.lookupAttr=e.lattr,this.lookupEntity=e.lent,this.dataAttr=e.dattr,this.lookupDataAttr=e.ldattr;var n=h.getDateDataTypes().indexOf(this.dataType);this.defaultValue=e.defVal&&n?new Date(e.defVal):e.defVal,this.isNullable=h.getIfDefined(e.nul,this.isNullable),this.isEditable=h.getIfDefined(e.ied,this.isEditable),this.showOnView=h.getIfDefined(e.ivis||e.sov,this.showOnView),this.showOnCreate=h.getIfDefined(e.soc,this.showOnCreate),this.showOnEdit=h.getIfDefined(e.soe,this.showOnEdit),this.showInLookup=h.getIfDefined(e.sil,this.showInLookup),this.kind=e.kind,this.displayFormat=e.dfmt,e.udata&&(this.userData=e.udata),e.edtr&&(this.defaultEditor=t.getEditorById(e.edtr)||t.createValueEditor())}},t}(),E=function(){function t(){this.id="",this.tag=s,this.resType=i.Unknown,this.defValue=""}return t.prototype.loadFromData=function(t){t&&(this.id=t.id,this.tag=t.tag,this.defValue=t.defval,this.resType=t.rtype,this.accept=t.accept,this.multiline=t.multiline,t.subType&&(this.resType=t.subType),t.name&&(this.name=t.name),t.values&&(this.values=t.values))},t.prototype.getValueText=function(t){var e="";if(!this.values)return e;if(Array.isArray(t))for(var n=0,i=this.values;n<i.length;n++){var o=i[n];t.indexOf(o.id)>=0&&(e+=o.text+",")}else for(var r=0,s=this.values;r<s.length;r++){(o=s[r]).id===t&&(e+=o.text+",")}return e&&(e=e.substring(0,e.length-1)),e},t}(),I=function(){function t(){this.mainEntity=null,this.id="__none",this.name="Empty model",this.rootEntity=this.createEntity(),this.displayFormats=new Map}return t.prototype.getMainEntity=function(){return this.mainEntity},t.prototype.createEntity=function(t){return new T(t)},t.prototype.createEntityAttr=function(t){return new x(t)},t.prototype.createValueEditor=function(){return new E},t.prototype.loadFromJSON=function(t){var e=JSON.parse(t);this.loadFromData(e)},t.prototype.loadFromData=function(t){if(this.id=t.id,this.name=t.name,this.version=t.vers,this.editors=new Array,t.editors)for(var e=0;e<t.editors.length;e++){var n=this.createValueEditor();n.loadFromData(t.editors[e]),this.editors.push(n)}if(this.rootEntity.loadFromData(this,t.entroot),this.displayFormats=new Map,t.displayFormats)for(var o in t.displayFormats){var r=i[o],s=t.displayFormats[o]||new Array;this.displayFormats.set(r,s)}},t.prototype.getDisplayFormats=function(){return this.displayFormats},t.prototype.getDisplayFormatsForType=function(t){return this.displayFormats.has(t)?this.displayFormats.get(t):[]},t.prototype.getDefaultFormat=function(t){return this.displayFormats.has(t)?this.displayFormats.get(t).filter((function(t){return t.isdef}))[0]:null},t.prototype.setData=function(t){"string"==typeof t?this.loadFromJSON(t):this.loadFromData(t)},t.prototype.isEmpty=function(){return 0===this.rootEntity.subEntities.length&&0===this.rootEntity.attributes.length},t.prototype.getId=function(){return this.id},t.prototype.getName=function(){return this.name},t.prototype.getRootEntity=function(){return this.rootEntity},t.prototype.getEditorById=function(t){for(var e=0,n=this.editors;e<n.length;e++){var i=n[e];if(i.id===t)return i}return null},t.prototype.getAttributeById=function(t){var e=this.getEntityAttrById(this.getRootEntity(),t);return e||null},t.prototype.checkAttrProperty=function(t,e){var n=this.getAttributeById(t);if(n){if(void 0===n[e])throw"No such property: "+e;return!!n[e]||!!n.lookupAttr&&(t=n.lookupAttr,(n=this.getAttributeById(t))&&n[e])}return!1},t.prototype.getEntityAttrById=function(t,e){var n,i;if(t.attributes){var o=t.attributes.length;for(n=0;n<o;n++)if(t.attributes[n].id==e)return t.attributes[n]}if(t.subEntities){var r=t.subEntities.length;for(n=0;n<r;n++)if(i=this.getEntityAttrById(t.subEntities[n],e))return i}return null},t.prototype.listByEntityWithFilter=function(t,e){var n,i=new Array,o=null;if(t.subEntities)for(var r=t.subEntities.length,s=0;s<r;s++){if(o=t.subEntities[s],!e||e(o,null))(n=c.getText("Entities",o.name))||(n=o.caption),(d=h.assign(this.createEntity(),{id:o.name,text:n,items:[],isEntity:!0})).items=this.listByEntityWithFilter(o,e),d.items.length>0&&i.push(d)}var a=null;if(t.attributes)for(var l=t.attributes.length,u=0;u<l;u++)if(a=t.attributes[u],!e||e(t,a)){(n=c.getText("Attributes",a.id))||(n=a.caption);var d=h.assign(this.createEntity(),{id:a.id,text:n,dataType:a.dataType});i.push(d)}return i},t.prototype.listByEntity=function(t,e,n){e=e||{};var i,o=[],r=[],s=null;if(t.subEntities)for(var a=t.subEntities.length,l=0;l<a;l++)if(s=t.subEntities[l],!n||n(s,null)){i=c.getText("Entities",s.name)||s.caption;var u=h.assign(this.createEntity(),{id:s.name,text:i,items:[],isEntity:!0,description:s.description}),d=h.assign({},e);d.includeRootData=!1,u.items=this.listByEntity(s,d,n),u.items.length>0&&o.push(u)}var p=null;if(t.attributes)for(var f=t.attributes.length,g=0;g<f;g++)p=t.attributes[g],n&&!n(t,p)||(i=c.getText("Attributes",p.id)||p.caption,r.push(h.assign(this.createEntityAttr(t),{id:p.id,text:i,dataType:p.dataType,lookupAttr:p.lookupAttr,description:p.description})));var m,y=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(o.sort(y),r.sort(y)),m=e.attrPlacement&&0!=e.attrPlacement?r.concat(o):o.concat(r),2==e.attrPlacement&&m.sort(y),e.includeRootData?((i=c.getText("Entities",t.name))||(i=t.caption),{id:t.name,text:i,items:m}):m},t.prototype.clear=function(){this.rootEntity=this.createEntity(),this.editors=[],this.version=""},t.prototype.addDefaultValueEditors=function(){this.addOrUpdateValueEditor("_DTE",a,i.String).defValue="",this.addOrUpdateValueEditor("_DPDE",l,i.DateTime),this.addOrUpdateValueEditor("_DPTE",l,i.DateTime)},t.prototype.addOrUpdateValueEditor=function(t,e,n){var i=h.findItemById(this.editors,t);return i||((i=this.createValueEditor()).id=t,this.editors.push(i)),i.tag=e,i.resType=n,i},t.prototype.getEntitiesTree=function(t,e){return this.listByEntity(this.getRootEntity(),t,e)},t.prototype.getEntitiesTreeWithFilter=function(t){return this.listByEntityWithFilter(this.getRootEntity(),t)},t.prototype.getFullEntityPathByAttr=function(t,e){return e=e||" ",this.getEntityPathByAttr(this.getRootEntity(),t,e,!0)},t.prototype.getEntityPathByAttr=function(t,e,n,i){if(!t)return"";n=n||" ";var o="";if(t.caption&&!i){var r=c.getText("Entities",t.caption);o=r||t.caption}if(t.attributes)for(var s=t.attributes.length,a=0;a<s;a++)if(t.attributes[a].id==e)return o;if(t.subEntities){var l=t.subEntities.length;for(a=0;a<l;a++){var u=t.subEntities[a],d=this.getEntityPathByAttr(u,e,n,!1);if(""!==d)return""!==o&&(d=o+n+d),d}}return""},t.prototype.getAttributeText=function(t,e){var n=c.getText("Attributes",t.id);if(n||(n=t.caption),!e)return n;var i=this.getFullEntityPathByAttr(t.id," ");return(i?e.replace(new RegExp("{attr}","g"),n).replace(new RegExp("{entity}","g"),i):n).trim()},t.prototype.runThroughEntities=function(t,e){this.getRootEntity().scan(t,e)},t.prototype.getFirstAttributeByFilter=function(t){var e=null;return this.runThroughEntities((function(n,i){t(n)&&(i.stop=!0,e=n)}),null),e},t}(),S=function(){return S=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},S.apply(this,arguments)};!function(){function t(t){this.colStore=t,this.aggregates=[],this.groups=[],this.useGrandTotals=!1,this.useRecordCount=!1,this._caseSensitiveGroups=!1,this.COUNT_FIELD_NAME="GRPRECCNT"}Object.defineProperty(t.prototype,"caseSensitiveGroups",{get:function(){return this._caseSensitiveGroups},set:function(t){this._caseSensitiveGroups=t,this.updateCompareProc()},enumerable:!0,configurable:!0}),t.prototype.updateCompareProc=function(){this.compareValues=this._caseSensitiveGroups?this.strictCompare:this.caseInsensitiveCompare},t.prototype.addGroup=function(t){var e=t.columns||this.colStore.getColumnIds(t.from,t.to);if(!this.colStore.validateColumns(e))throw"Invalid columns: "+e;if(this.hasColumnsInUse(e))throw"Can't add same columns to different groups/aggregates";return this.groups.push(S({columns:e},t)),this},t.prototype.addAggregateColumn=function(t,e){var n="string"==typeof t?t:this.colStore.getColumnIds(t,t)[0];if(this.hasColumnsInUse([n])||!this.colStore.validateAggregate(n,e))throw"Invalid aggregation function for the column: "+n;return this.aggregates.push({colId:n,funcId:e}),this},t.prototype.addGrandTotals=function(){return this.useGrandTotals=!0,this},t.prototype.addCounts=function(){return this.useRecordCount=!0,this},t.prototype.getGroups=function(){var t=this,e=[];return this.groups.map((function(n){return e=e.concat(n.columns),S(S({},n),{columns:Array.from(e),aggregates:Array.from(t.aggregates)})}))},t.prototype.getInternalGroups=function(){return this.groups},t.prototype.lastGroup=function(){var t=this.getGroups();return t[t.length-1]},t.prototype.getAggregates=function(){return this.aggregates},t.prototype.hasAggregates=function(){return this.aggregates.length>0},t.prototype.hasGroups=function(){return this.groups.length>0},t.prototype.hasGrandTotals=function(){return this.useGrandTotals},t.prototype.hasRecordCount=function(){return this.useRecordCount},t.prototype.isEmpty=function(){return!(this.hasAggregates()||this.hasGroups()||this.hasAggregates()||this.hasRecordCount())},t.prototype.drop=function(){console.warn('"drop()" method is obsolete. Use "clear()" instead'),this.clear()},t.prototype.clear=function(){return this.groups=[],this.aggregates=[],this.useGrandTotals=!1,this.useRecordCount=!1,this.caseSensitiveGroups=!1,this},t.prototype.hasColumnsInUse=function(t){for(var e=0,n=this.groups;e<n.length;e++){if(n[e].columns.filter((function(e){return t.indexOf(e)>=0})).length>0)return!0}for(var i=0,o=this.aggregates;i<o.length;i++){var r=o[i];if(t.indexOf(r.colId)>=0)return!0}return!1},t.prototype.needAggrCalculation=function(){return(this.hasAggregates()||this.hasRecordCount())&&(this.hasGrandTotals()||this.hasGroups())},t.prototype.saveToData=function(){return{groups:Array.from(this.groups),ugt:this.useGrandTotals,urc:this.useRecordCount,csg:this.caseSensitiveGroups,aggregates:Array.from(this.aggregates)}},t.prototype.loadFromData=function(t){t&&(void 0!==t.ugt&&(this.useGrandTotals=t.ugt),void 0!==t.urc&&(this.useRecordCount=t.urc),void 0!==t.csg&&(this.caseSensitiveGroups=t.csg),t.groups&&(this.groups=Array.from(t.groups)),t.aggregates&&(this.aggregates=Array.from(t.aggregates)))},t.prototype.buildGroupKey=function(t,e){var n=!this.caseSensitiveGroups,i={};if(t)for(var o=0,r=t.columns;o<r.length;o++){var s=r[o],a=e.getValue(s);n&&"string"==typeof a&&(a=a.toLowerCase()),i[s]=a}return i},t.prototype.strictCompare=function(t,e){return t===e},t.prototype.caseInsensitiveCompare=function(t,e){return("string"==typeof t?t.toLowerCase():t)===("string"==typeof e?e.toLowerCase():e)}}();!function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Center=2]="Center",t[t.Right=3]="Right"}(y||(y={}));var M,P=function(t){if(!t)throw Error("Options are required");if(!t.id)throw Error("Field Id is required");if(!t.label)throw Error("Label is required");this.id=t.id,this.type=h.getIfDefined(t.type,i.String),this.label=t.label,this.originAttrId=t.originAttrId,this.isAggr=t.isAggr||!1,this.displayFormat=t.dfmt,this.groupFooterColumnTemplate=t.gfct,this.style=t.style||{},this.description=t.description,this.calculatedWidth=0},R=function(){function t(){this.items=[],this.mapper={},this._dateColumnIdx=[]}return Object.defineProperty(t.prototype,"count",{get:function(){return this.items.length},enumerable:!0,configurable:!0}),t.prototype.add=function(t){var e;e=t instanceof P?t:new P(t);var n=this.items.length;return this.items.push(e),this.mapper[e.id]=n,[i.Date,i.DateTime,i.Time].indexOf(e.type)>=0&&this._dateColumnIdx.push(n),n},t.prototype.updateDateColumnIdx=function(){this._dateColumnIdx=this.getItems().filter((function(t){return[i.Date,i.DateTime,i.Time].indexOf(t.type)>=0})).map((function(t,e){return e}))},t.prototype.put=function(t,e){t>=0&&t<this.count&&(this.items[t]=e,this.updateDateColumnIdx())},t.prototype.move=function(t,e){var n=this.items.indexOf(t);n>=0&&n!=e&&(h.moveArrayItem(this.items,n,e),this.updateDateColumnIdx())},t.prototype.get=function(t){return t>=0&&t<this.count?this.items[t]:null},t.prototype.getIndex=function(t){return this.mapper[t]},t.prototype.getItems=function(){return this.items},t.prototype.getDateColumnIndexes=function(){return this._dateColumnIdx},t.prototype.removeAt=function(t){var e=this.get(t);this.items.splice(t,1);var n=this._dateColumnIdx.indexOf(t);n>=0&&this._dateColumnIdx.splice(n,1),delete this.mapper[e.id]},t.prototype.clear=function(){this.items=[],this._dateColumnIdx=[],this.mapper={}},t}(),k=function(){function t(t,e){this.columns=t,this.values=e}return t.prototype.toArray=function(){return Array.from(this.values)},t.prototype.size=function(){return this.values.length},t.prototype.getValue=function(t){var e;if("string"==typeof t){if(void 0===(e=this.columns.getIndex(t)))throw new RangeError("No column with id '"+t+"'")}else e=t;if(e>=this.values.length)throw new RangeError("Out of range: "+e);return this.values[e]},t.prototype.setValue=function(t,e){var n;if("string"==typeof t){if(void 0===(n=this.columns.getIndex(t)))throw new RangeError("No column with id '"+t+"'")}else n=t;if(n>=this.values.length)throw new RangeError("Out of range: "+n);this.values[n]=e},t}(),O=function(){function t(t){if(this._chunkSize=1e3,this._elasticChunks=!1,this.cachedRows=[],this.total=0,this.loader=null,this.needTotal=!0,this.isInMemory=!1,t=t||{},this._chunkSize=t.chunkSize||this._chunkSize,this._elasticChunks=t.elasticChunks||this._elasticChunks,this.loader=t.loader,void 0!==t.inMemory&&(this.isInMemory=t.inMemory),this.isInMemory&&(this.needTotal=!1),this._columns=new R,this.onUpdate=t.onUpdate,t.columns)for(var e=0,n=t.columns;e<n.length;e++){var i=n[e];this._columns.add(i)}if(t.rows)for(var o=0,r=t.rows;o<r.length;o++){var s=r[o],a=this.createRow(s);this.addRow(a)}this.needTotal=!this._elasticChunks}return Object.defineProperty(t.prototype,"columns",{get:function(){return this._columns},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"chunkSize",{get:function(){return this._chunkSize},set:function(t){this._chunkSize=t,this.total=0,this.needTotal=!this.elasticChunks,this.cachedRows=[]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"elasticChunks",{get:function(){return this._elasticChunks},set:function(t){this._elasticChunks=t,this.total=0,this.needTotal=!this.elasticChunks,this.cachedRows=[]},enumerable:!0,configurable:!0}),t.prototype.getRows=function(t){var e=this,n=0,i=this._chunkSize;t&&("page"in t?(n=t.pageSize*(t.page-1),i=t.pageSize):(n=t.offset,i=t.limit));var o=n+i;if(!this.needTotal&&!this.elasticChunks){if(n>=this.total)return Promise.resolve([]);o>this.total&&(o=this.total)}if(this.isInMemory&&o>this.cachedRows.length&&(o=this.cachedRows.length),o<=this.cachedRows.length)return Promise.resolve(this.cachedRows.slice(n,o));if(!this.loader)throw"Loader is not defined. Can't get the rows from "+n+" to "+o;var r=this.needTotal;this.needTotal&&(this.needTotal=!1);var s=this.cachedRows.length,a=o-s;return a<this._chunkSize&&(a=this._chunkSize),this.loader.loadChunk({offset:s,limit:a,needTotal:r}).then((function(t){(r&&(e.total=t.total),Array.prototype.push.apply(e.cachedRows,t.table.getCachedRows()),o>e.cachedRows.length&&(o=e.cachedRows.length),e.elasticChunks)&&(t.table.getCachedCount()<a&&(e.total=e.cachedRows.length));return e.fireUpdated(),e.cachedRows.slice(n,o)}))},t.prototype.getRow=function(t){return this.getRows({offset:t,limit:1}).then((function(t){return t.length>0?t[0]:null}))},t.prototype.getTotal=function(){return this.total},t.prototype.setTotal=function(t){this.total=t,this.needTotal=!1},t.prototype.getCachedCount=function(){return this.cachedRows.length},t.prototype.clear=function(){this.columns.clear(),this.cachedRows=[],this.total=0,this.needTotal=!this._elasticChunks,this.fireUpdated()},t.prototype.createRow=function(t){var e=this,n=this._columns.getDateColumnIndexes(),i=new Array(this._columns.count),o=t instanceof k?function(e){return t.getValue(e)}:function(e){return t[e]};return t&&this.columns.getItems().forEach((function(t){var r=o(t.id),s=e.columns.getIndex(t.id);i[s]=n.indexOf(s)>=0?e.mapDate(r,t.type):r})),new k(this._columns,i)},t.prototype.mapDate=function(t,e){if(t){var n=new Date(t);return isNaN(n.getTime())&&e==i.Time&&(n=h.strToTime(t)),n}return null},t.prototype.addRow=function(t){var e;if(Array.isArray(t)){var n=t,i=this._columns.getDateColumnIndexes();if(i.length>0)for(var o=0,r=i;o<r.length;o++){var s=r[o];n[s]&&(n[s]=this.mapDate(n[s],this._columns.get(s).type))}e=new k(this._columns,n)}else e=this.createRow(t);this.cachedRows.push(e);var a=this.getCachedCount();return a>this.total&&(this.total=a),e},t.prototype.getCachedRows=function(){return this.cachedRows},t.prototype.totalIsKnown=function(){return this.elasticChunks?this.getCachedCount()===this.total:!this.needTotal},t.prototype.fireUpdated=function(){this.onUpdate&&this.onUpdate(this)},t}(),A=function(){function t(){}return t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))},t}(),L=function(){function t(t){this.silentMode=0,this.events=new Array,this.source=t}return t.prototype.subscribe=function(t,e){var n=this.getEventRecByType(t),i={id:A.newGuid(),callback:e};return n?n.eventCallbacks.push(i):(n={type:t,eventCallbacks:new Array(i)},this.events.push(n)),i.id},t.prototype.unsubscribe=function(t,e){var n=this.getEventRecByType(t);if(n){var i=-1;for(i=0;i<n.eventCallbacks.length&&n.eventCallbacks[i].id!==e;i++);i>=0&&n.eventCallbacks.splice(i,1)}},t.prototype.fire=function(t,e,n,i){if(void 0===n&&(n=0),void 0===i&&(i=!1),!this.silentMode||i){var o=this.getEventRecByType(t);if(o){var r={type:t,source:this.source,data:e},s=function(){for(var t=0,e=o.eventCallbacks;t<e.length;t++){e[t].callback(r)}};n>0?setTimeout(s,n):s()}}},t.prototype.enterSilentMode=function(){this.silentMode++},t.prototype.exitSilentMode=function(){this.silentMode&&this.silentMode--},t.prototype.isSilent=function(){return this.silentMode>0},t.prototype.getEventRecByType=function(t){for(var e=0,n=this.events;e<n.length;e++){var i=n[e];if(i.type==t)return i}return null},t}();!function(t){t.renderLiquidTemplate=function(t,e){var n=t;if(e)for(var i in e){var o=new RegExp("{{"+i+"}}","g");n=n.replace(o,e[i])}return n}}(M||(M={})),c.resetLocales(),"function"!=typeof Object.values&&(Object.values=function(t){return Object.keys(t).map((function(e){return t[e]}))}),"function"!=typeof Math.trunc&&(Math.trunc=function(t){return isNaN(t)?NaN:t>0?Math.floor(t):Math.ceil(t)});var N=function(){return N=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},N.apply(this,arguments)},F=function(){function t(t,e,n,i){void 0===i&&(i=!1),this.loader=t,this.sourceTable=e,this.sourceId=n,this.isLookup=i,this.filterValue="",this.justServerSide=!1}return t.prototype.getValue=function(){return this.filterValue},t.prototype.apply=function(t){return this.filterValue=t,this.filterValue?this.applyCore():this.clear()},t.prototype.clear=function(){return this.filterValue="",Promise.resolve(this.sourceTable)},t.prototype.applyCore=function(){var t=this;if(this.sourceTable.getTotal()!=this.sourceTable.getCachedCount()||this.justServerSide){var e=[{class:"__substring",value:this.filterValue}];return this.loader.loadChunk({offset:0,limit:this.sourceTable.chunkSize,needTotal:!0,filters:e,sourceId:this.sourceId,lookup:this.isLookup}).then((function(n){for(var i=new O({chunkSize:t.sourceTable.chunkSize,loader:{loadChunk:function(n){return t.loader.loadChunk(N(N({},n),{filters:e,sourceId:t.sourceId,lookup:t.isLookup}))}}}),o=0,r=t.sourceTable.columns.getItems();o<r.length;o++){var s=r[o];i.columns.add(s)}i.setTotal(n.total);for(var a=0,l=n.table.getCachedRows();a<l.length;a++){var u=l[a];i.addRow(u)}return i}))}return this.applyInMemoryFilter()},t.prototype.applyInMemoryFilter=function(){var t=this;return new Promise((function(e,n){for(var i=new O({chunkSize:t.sourceTable.chunkSize,inMemory:!0}),o=0,r=t.sourceTable.columns.getItems();o<r.length;o++){var s=r[o];i.columns.add(s)}for(var a=t.filterValue.split("||").map((function(t){return t.trim().toLowerCase()})),l=t.sourceTable.columns.getItems().filter((function(t){return h.isNumericType(t.type)||h.getStringDataTypes().indexOf(t.type)>=0})),u=function(t){for(var e=0,n=l;e<n.length;e++){var i=n[e],o=t.getValue(i.id);if(o)for(var r=o.toString().toLowerCase(),s=0,u=a;s<u.length;s++){var d=u[s];if(r.indexOf(d)>=0)return!0}}return!1},d=0,c=t.sourceTable.getCachedRows();d<c.length;d++){var p=c[d];u(p)&&i.addRow(p)}i.setTotal(i.getCachedCount()),e(i)}))},t}(),_=n(0);function B(t){var e={x:0,y:0};if(null!==t){var n=function(t){var e,n={top:0,right:0,bottom:0,left:0,width:0,height:0};try{e=t.getBoundingClientRect()}catch(t){e=n}var i=document.body,o=document.documentElement,r=function(){var t=document.body,e=document.documentElement;return{top:window.pageYOffset||e.scrollTop||t.scrollTop,left:window.pageXOffset||e.scrollLeft||t.scrollLeft}}(),s=r.top,a=r.left,l=o.clientTop||i.clientTop||0,u=o.clientLeft||i.clientLeft||0,d=e.top+s-l,c=e.left+a-u;return{top:Math.round(d),left:Math.round(c)}}(t);e={x:n.left,y:n.top}}return e}var H="eqjs";var V=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),j=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var i=Array(t),o=0;for(e=0;e<n;e++)for(var r=arguments[e],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i},G=function(){function t(t,e){this.element="string"==typeof t?document.createElement(t):t,e&&this.element.parentElement!==e&&e.appendChild(this.element)}return t.prototype.addChild=function(t,e){var n=W(t,this.element);return e&&e(n),this},t.prototype.addChildElement=function(t){return t&&this.element.appendChild(t),this},t.prototype.attr=function(t,e){return this.element.setAttribute(t,e),this},t.prototype.id=function(t){return this.attr("id",t)},t.prototype.focus=function(){return this.element.focus(),this},t.prototype.title=function(t){return this.attr("title",t)},t.prototype.data=function(t,e){return void 0===e&&(e=null),null===e?(this.element.removeAttribute("data-"+t),this):this.attr("data-"+t,e)},t.prototype.show=function(){return this.removeStyle("display")},t.prototype.hide=function(t){return void 0===t&&(t=!0),t?this.setStyle("display","none"):this},t.prototype.visible=function(t){return void 0===t&&(t=!0),t?this.setStyle("visibility","visible"):this.setStyle("visibility","hidden")},t.prototype.isVisible=function(){return!!(this.element.offsetWidth||this.element.offsetHeight||this.element.getClientRects().length)},t.prototype.addClass=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t)for(var i=j(t.trim().split(" "),e),o=0;o<i.length;o++)this.element.classList.add(i[o]);return this},t.prototype.removeClass=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t)for(var i=j(t.trim().split(" "),e),o=0;o<i.length;o++)this.element.classList.remove(i[o]);return this},t.prototype.toggleClass=function(t,e){return void 0===e&&(e=void 0),t&&this.element.classList.toggle(t,e),this},t.prototype.on=function(t,e){for(var n=t.split(" "),i=0;i<n.length;i++)this.element.addEventListener(n[i],e);return this},t.prototype.off=function(t,e){for(var n=t.split(" "),i=0;i<n.length;i++)this.element.removeEventListener(n[i],e);return this},t.prototype.setStyle=function(t,e){return this.element.style.setProperty(t,e),this},t.prototype.removeStyle=function(t){return this.element.style.removeProperty(t),this},t.prototype.text=function(t){return this.element.innerText=t,this},t.prototype.html=function(t){return this.element.innerHTML=t,this},t.prototype.clear=function(){var t=this.element;this.element=document.createElement(this.element.tagName),t.replaceWith(this.element)},t.prototype.addText=function(t){var e=document.createTextNode(t);return this.element.appendChild(e),this},t.prototype.addHtml=function(t){return this.element.innerHTML+=t,this},t.prototype.toDOM=function(){return this.element},t.prototype.appendTo=function(t){return t&&t.appendChild(this.element),this},t}(),z=function(t){function e(e,n){return e?t.call(this,e,n)||this:t.call(this,"textarea",n)||this}return V(e,t),e.prototype.name=function(t){return this.element.name=t,this},e.prototype.rows=function(t){return this.element.rows=t,this},e.prototype.cols=function(t){return this.element.cols=t,this},e.prototype.value=function(t){return this.element.value=t,this},e}(G),q=function(t){function e(e,n){return e?t.call(this,e,n)||this:t.call(this,"input",n)||this}return V(e,t),e.prototype.name=function(t){return this.element.name=t,this},e.prototype.type=function(t){return this.element.type=t,this},e.prototype.size=function(t){return this.element.size=t,this},e.prototype.value=function(t){return t instanceof Date?this.element.valueAsDate=t:"number"==typeof t?this.element.valueAsNumber=t:this.element.value=t,this},e.prototype.mask=function(t){return function(t,e){var n={9:"[0-9]",a:"[a-z]"},i=e.split(""),o=function(e){if("focus"!==e.type||""===t.value){var o=[],r=t.selectionStart;i.forEach((function(e,i){if(n[e]){var r=new RegExp(n[e],"i").test(t.value.charAt(i));o.push(r?t.value.charAt(i):"_")}else o.push(e)})),t.value=o.join(""),t.selectionStart=t.selectionEnd=r}};t.addEventListener("keydown",(function(e){if(8===e.keyCode||46===e.keyCode){e.preventDefault();var o=[],r=t.selectionStart;if(0==r)return;for(var s=r,a=!0,l=i.length-1;l>=0;l--){var u=i[l];if(n[u]){var d=new RegExp(n[u],"i").test(t.value.charAt(l));d&&l!=r-1&&(a=!1),l===r-1&&s--,o.push(d&&l!=r-1?t.value.charAt(l):"_")}else l===s-1&&s--,r-1===l&&r--,o.push(u)}t.value=a?"":o.reverse().join(""),t.selectionStart=t.selectionEnd=s<0?0:s;var c=document.createEvent("Event");c.initEvent("input",!0,!0),t.dispatchEvent(c)}})),t.addEventListener("keypress",(function(e){var o=String.fromCharCode(e.charCode);if(o){e.preventDefault();var r=[],s=t.selectionStart,a=s;i.forEach((function(e,i){if(n[e]){var l=i!=s?t.value.charAt(i):o,u=new RegExp(n[e],"i").test(l);r.push(u?l:"_"),u&&s===i&&a++}else r.push(e),a===i&&a++,s===i&&s++})),t.value=r.join(""),t.selectionStart=t.selectionEnd=a;var l=document.createEvent("Event");l.initEvent("input",!0,!0),t.dispatchEvent(l)}})),t.addEventListener("input",o),t.addEventListener("focus",o)}(this.element,t),this},e}(G),U=function(t){function e(e,n){return e?t.call(this,e,n)||this:t.call(this,"select",n)||this}return V(e,t),e.prototype.addOption=function(t){var e=document.createElement("option");return"string"==typeof t?(e.value=t,e.innerHTML=t):(e.value=t.value,e.innerHTML=t.title||t.value,e.selected=t.selected||!1),this.element.appendChild(e),this},e.prototype.value=function(t){return this.element.value=t,this},e}(G);function W(t,e){return"div"===t||t instanceof HTMLDivElement||"span"===t||t instanceof HTMLSpanElement||"a"===t||t instanceof HTMLAnchorElement||"button"===t||t instanceof HTMLButtonElement||"img"===t||t instanceof HTMLImageElement?new G(t,e):"input"===t||t instanceof HTMLInputElement?new q(t instanceof HTMLInputElement?t:null,e):"textarea"===t||t instanceof HTMLTextAreaElement?new z(t instanceof HTMLTextAreaElement?t:null,e):"select"===t||t instanceof HTMLSelectElement?new U(t instanceof HTMLSelectElement?t:null,e):new G(t,e)}var Y,K="undefined"!=typeof TouchEvent;!function(t){t.None="none",t.Allow="allow",t.Forbid="forbid"}(Y||(Y={}));var X,J=function(t,e,n){this.dropEffect=Y.Allow,this.pageX=0,this.pageY=0,this.item=t,this.dragImage=e,this.data=t.data,this.sourceEvent=n,n&&n instanceof MouseEvent&&(this.pageX=n.pageX,this.pageY=n.pageY),n&&K&&n instanceof TouchEvent&&n.touches[0]&&(this.pageX=n.touches[0].pageX,this.pageY=n.touches[0].pageY)},Z=function(t){t&&t instanceof MouseEvent&&(this.x=t.pageX,this.y=t.pageY),t&&K&&t instanceof TouchEvent&&t.touches[0]&&(this.x=t.touches[0].pageX,this.y=t.touches[0].pageY)},Q=new(function(){function t(){this.delta=5,this.draggableItem=null,this.dragImage=null,this.finishedSuccessfully=!1,this.mouseDownPosition=null,this.containerDescriptors=[],this.containerDescriptorIndex=-1,this.dropEffect=Y.None,this.classPrefix="eqjs-drop",this.DRAG_DISABLED_ATTR="drag-disabled"}return t.prototype.registerDraggableItem=function(t){var e=this,n=t.element;if(!n)throw Error("Element in draggle item is null or undefined");n.ondragstart=function(){return!1};var i=function(t){if(!n.hasAttribute(e.DRAG_DISABLED_ATTR)){t.preventDefault(),t instanceof MouseEvent&&t.stopPropagation();var i=new Z(t);(Math.abs(i.x-e.mouseDownPosition.x)>e.delta||Math.abs(i.y-e.mouseDownPosition.y)>e.delta)&&r(t)}},o=function(t){e.mouseMoveDragListener(t)},r=function(r){r.preventDefault(),r.stopPropagation(),n.removeEventListener("mousemove",i),n.removeEventListener("touchmove",i),e.finishedSuccessfully=!1,t.beforeDragStart&&t.beforeDragStart(),e.dragImage=W("div").setStyle("position","absolute").setStyle("z-index","65530").toDOM(),document.body.appendChild(e.dragImage),e.dragImage.appendChild(n.cloneNode(!0)),t.renderer&&t.renderer(e.dragImage),e.dropEffect=Y.None,e.updateCusror(e.dropEffect),e.updateImageClass(e.dropEffect),e.draggableItem={element:n,scope:t.scope,data:t.data},e.updateDragItemPosition(r);var s=new J(e.draggableItem,e.dragImage,r);s.dropEffect=e.dropEffect,t.onDragStart&&t.onDragStart(s),e.dropEffect!==s.dropEffect&&(e.dropEffect=s.dropEffect,e.updateImageClass(e.dropEffect)),document.addEventListener("mousemove",o,!0),document.addEventListener("touchmove",o,!0)},s=function(t){K&&t instanceof TouchEvent&&t.preventDefault(),e.mouseDownPosition=new Z(t),n.addEventListener("mousemove",i),n.addEventListener("touchmove",i),document.addEventListener("mouseup",a),document.addEventListener("touchend",a)};n.addEventListener("mousedown",s),n.addEventListener("touchstart",s);var a=function(t){e.mouseDownPosition=null,n.removeEventListener("mousemove",i),n.removeEventListener("touchmove",i),document.removeEventListener("mousemove",o,!0),document.removeEventListener("touchmove",o,!0),e.draggableItem&&l(t)},l=function(n){try{if(e.containerDescriptorIndex>=0){var i=e.containerDescriptors[e.containerDescriptorIndex],o={element:i.element,scopes:i.scopes,data:i.data},r=new J(e.draggableItem,e.dragImage,n);try{o.scopes.indexOf(e.draggableItem.scope)>=0&&e.dropEffect===Y.Allow&&(e.finishedSuccessfully=!0,i.onDrop&&i.onDrop(o,r))}finally{i.onDragLeave&&i.onDragLeave(o,r)}}}finally{try{var s=new J(e.draggableItem,e.dragImage,n);s.data.finishedSuccessfully=e.finishedSuccessfully,t.onDragEnd&&t.onDragEnd(s)}finally{e.draggableItem=null,e.dragImage&&e.dragImage.parentElement&&e.dragImage.parentElement.removeChild(e.dragImage),e.dragImage=null,e.finishedSuccessfully=!1,document.removeEventListener("mouseup",a),document.removeEventListener("touchend",a)}}}},t.prototype.registerDropContainer=function(t){if(!t.element)throw Error("Element in drop container is null or undefined");this.containerDescriptors.push(t)},t.prototype.removeDropContainer=function(t){var e=this.containerDescriptors.filter((function(e){return e===t||e.element==t}));if(e)for(var n=0,i=e;n<i.length;n++){var o=i[n];h.removeArrayItem(this.containerDescriptors,o)}},t.prototype.mouseMoveDragListener=function(t){if(t instanceof MouseEvent&&t.preventDefault(),t.stopPropagation(),this.updateDragItemPosition(t),-1==this.containerDescriptorIndex){for(var e=0;e<this.containerDescriptors.length;e++){var n=this.containerDescriptors[e];if(this.detectDragEnterEvent(n.element,t)){this.containerDescriptorIndex=e;break}}this.containerDescriptorIndex>=0&&this.dragEnterEvent(t)}else{n=this.containerDescriptors[this.containerDescriptorIndex];this.detectDragLeaveEvent(n.element,t)&&(this.dragLeaveEvent(t),this.containerDescriptorIndex=-1)}if(this.containerDescriptorIndex>=0){var i={element:(n=this.containerDescriptors[this.containerDescriptorIndex]).element,scopes:n.scopes,data:n.data};if(i.scopes.indexOf(this.draggableItem.scope)>=0){var o=new J(this.draggableItem,this.dragImage,t);o.dropEffect=this.dropEffect,n.onDragOver&&n.onDragOver(i,o)}}},t.prototype.updateCusror=function(t){switch(t){case Y.Allow:this.setCursorStyle(this.dragImage,"grabbing");break;case Y.Forbid:this.setCursorStyle(this.dragImage,"no-drop");break;default:this.setCursorStyle(this.dragImage,"grabbing")}},t.prototype.updateImageClass=function(t){switch(this.dragImage.classList.remove(this.classPrefix+"-allow"),this.dragImage.classList.remove(this.classPrefix+"-forbid"),this.dragImage.classList.remove(this.classPrefix+"-none"),t){case Y.Allow:this.dragImage.classList.add(this.classPrefix+"-allow");break;case Y.None:this.dragImage.classList.add(this.classPrefix+"-none");break;case Y.Forbid:this.dragImage.classList.add(this.classPrefix+"-forbid");break;default:this.dragImage.classList.add(this.classPrefix+"-none")}},t.prototype.setCursorStyle=function(t,e){if(t){t.style.cursor=e;for(var n=0;n<t.children.length;n++)this.setCursorStyle(t.children[n],e)}},t.prototype.updateDragItemPosition=function(t){if(this.dragImage){var e=new Z(t);this.dragImage.style.top=e.y-this.dragImage.offsetHeight/2+"px",this.dragImage.style.left=e.x-this.dragImage.offsetWidth/2+"px"}},t.prototype.dragEnterEvent=function(t){var e=this.containerDescriptors[this.containerDescriptorIndex],n={element:e.element,scopes:e.scopes,data:e.data};if(n.scopes.indexOf(this.draggableItem.scope)>=0){var i=new J(this.draggableItem,this.dragImage,t);i.dropEffect=Y.Allow,e.onDragEnter&&e.onDragEnter(n,i),this.dropEffect=i.dropEffect,this.updateCusror(this.dropEffect),this.updateImageClass(this.dropEffect)}else this.dropEffect!==Y.Forbid&&(this.dropEffect=Y.None,this.updateCusror(this.dropEffect),this.updateImageClass(this.dropEffect))},t.prototype.dragLeaveEvent=function(t){var e=this.containerDescriptors[this.containerDescriptorIndex],n={element:e.element,scopes:e.scopes,data:e.data};if(n.scopes.indexOf(this.draggableItem.scope)>=0){var i=new J(this.draggableItem,this.dragImage,t);i.dropEffect=Y.None,e.onDragLeave&&e.onDragLeave(n,i),this.dropEffect=i.dropEffect,this.updateCusror(this.dropEffect),this.updateImageClass(this.dropEffect)}},t.prototype.detectDragEnterEvent=function(t,e){var n=B(t),i=new Z(e);return!(i.y<n.y||i.y>n.y+t.offsetHeight)&&!(i.x<n.x||i.x>n.x+t.offsetWidth)},t.prototype.detectDragLeaveEvent=function(t,e){var n=B(t),i=new Z(e);return!(i.y>n.y&&i.y<n.y+t.offsetHeight&&i.x>n.x&&i.x<n.x+t.offsetWidth)},t}());!function(t){t[t.Always=0]="Always",t[t.Once=1]="Once",t[t.Never=2]="Never"}(X||(X={}));var $,tt="keg",et=/{0:(.*?)}/g;!function(t){t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.DATETIME=3]="DATETIME",t[t.BOOL=4]="BOOL"}($||($={}));var nt,it=function(t,e,n,i){var o=t?t.toString().replace(/\n/g,"↵ "):"";n.innerText=o,n.title=o,e.align==nt.NONE&&n.classList.add(tt+"-cell-value-align-left")},ot=function(t,e,n,i){var o=(t||"").toString();"number"==typeof t&&(o=e.dataColumn&&e.dataColumn.displayFormat&&et.test(e.dataColumn.displayFormat)?e.dataColumn.displayFormat.replace(et,(function(e,n){return c.numberToStr(t,n)})):t.toLocaleString()),n.innerText=o,n.title=o,e.align==nt.NONE&&n.classList.add(tt+"-cell-value-align-right")},rt=function(t,e,n,o){var r="[object Date]"===Object.prototype.toString.call(t),s=(t||"").toString();if(r)if(e.dataColumn&&e.dataColumn.displayFormat&&et.test(e.dataColumn.displayFormat))s=e.dataColumn.displayFormat.replace(et,(function(n,i){return c.dateTimeToStr(t,e.type,i)}));else{var a=c.getCurrentLocale(),l={hour:"numeric",minute:"numeric",second:"numeric"};switch(e.type){case i.Date:s=t.toLocaleDateString(a);break;case i.Time:s=t.toLocaleTimeString(a,l);break;case i.DateTime:s=t.toLocaleDateString(a)+" "+t.toLocaleTimeString(a,l)}}n.innerText=s,n.title=s,e.align==nt.NONE&&n.classList.add(tt+"-cell-value-align-right")},st=function(t,e,n,i){if(e.dataColumn&&e.dataColumn.displayFormat&&et.test(e.dataColumn.displayFormat)){var o=e.dataColumn.displayFormat.replace(et,(function(e,n){return c.booleanToStr(t,n)}));return it(o,e,n)}n.classList.add(tt+"-cell-value-bool"),n.classList.add(tt+"-"+(t?"cell-value-true":"cell-value-false"))},at=function(){function t(t){this.renderers={},this.defaultRenderers={},this.registerRenderer("StringDefault",it),this.setDefaultRenderer($.STRING,it),this.registerRenderer("NumberDefault",ot),this.setDefaultRenderer($.NUMBER,ot),this.registerRenderer("DateTimeDefault",rt),this.setDefaultRenderer($.DATETIME,rt),this.registerRenderer("BoolDefault",st),this.setDefaultRenderer($.BOOL,st)}return t.prototype.getDefaultRenderer=function(t){var e=this.getCellType(t);return this.defaultRenderers[$[e]]},t.prototype.getDefaultRendererByType=function(t){return this.defaultRenderers[$[t]]},t.prototype.setDefaultRenderer=function(t,e){e&&(this.defaultRenderers[$[t]]=e)},t.prototype.getRenderer=function(t){return this.renderers[t]},t.prototype.registerRenderer=function(t,e){this.renderers[t]=e},t.prototype.getCellType=function(t){switch(t){case i.Autoinc:case i.Byte:case i.Word:case i.Currency:case i.Float:case i.Int32:case i.Int64:return $.NUMBER;case i.Date:case i.DateTime:case i.Time:return $.DATETIME;case i.Bool:return $.BOOL;default:return $.STRING}},t}();!function(t){t[t.NONE=1]="NONE",t[t.LEFT=2]="LEFT",t[t.CENTER=3]="CENTER",t[t.RIGHT=4]="RIGHT"}(nt||(nt={}));var lt,ut=function(){function t(t,e,n){void 0===n&&(n=!1),this._label=null,this._description=null,this.align=nt.NONE,this.isVisible=!0,this.isRowNum=!1,this.dataColumn=t,this.grid=e;var i=e.options.columnWidths||{};t?(t.style.alignment&&(this.align=function(t){switch(t){case y.Left:return nt.LEFT;case y.Center:return nt.CENTER;case y.Right:return nt.RIGHT;default:return nt.NONE}}(t.style.alignment)),this.width=i&&i[this.type]?i[this.type].default:250,this.cellRenderer=this.grid.cellRendererStore.getDefaultRenderer(t.type),this._description=t.description):n&&(this.isRowNum=!0,this.width=i&&i.rowNumColumn?i.rowNumColumn.default:60,this._label="",this.cellRenderer=this.grid.cellRendererStore.getDefaultRendererByType($.NUMBER)),e&&e.options&&e.options.onGetCellRenderer&&(this.cellRenderer=e.options.onGetCellRenderer(this,this.cellRenderer)||this.cellRenderer)}return Object.defineProperty(t.prototype,"label",{get:function(){return this._label?this._label:this.isRowNum?"":this.dataColumn.label},set:function(t){this._label=this.label},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"description",{get:function(){return this._description},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this.dataColumn?this.dataColumn.type:null},enumerable:!0,configurable:!0}),t}(),dt=function(){function t(t,e){this.items=[],this.grid=e,this.sync(t)}return t.prototype.sync=function(t,e){void 0===e&&(e=!0),this.clear();var n=new ut(null,this.grid,!0);if(this.add(n),e||(n.isVisible=!1),t)for(var i=0,o=t.getItems();i<o.length;i++){var r=o[i],s=new ut(r,this.grid);this.grid.options.onSyncGridColumn&&this.grid.options.onSyncGridColumn(s),this.add(s)}},Object.defineProperty(t.prototype,"count",{get:function(){return this.items.length},enumerable:!0,configurable:!0}),t.prototype.add=function(t){var e=this.items.length;return this.items.push(t),e},t.prototype.put=function(t,e){t>=0&&t<this.items.length&&(this.items[t]=e)},t.prototype.move=function(t,e){var n=this.items.indexOf(t);n>=0&&n!=e&&h.moveArrayItem(this.items,n,e)},t.prototype.get=function(t){return t>=0&&t<this.items.length?this.items[t]:null},t.prototype.getItems=function(){return this.items},t.prototype.removeAt=function(t){this.get(t);this.items.splice(t,1)},t.prototype.clear=function(){this.items=[]},t}(),ct=function(){return ct=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ct.apply(this,arguments)},ht=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var i=Array(t),o=0;for(e=0;e<n;e++)for(var r=arguments[e],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i},pt=function(){function t(t){if(this.cssPrefix="keg",this.pagination={page:1,pageSize:30,total:0},this.paginationOptions={maxButtonCount:10,useBootstrap:!1},this.defaultDataGridOptions={slot:null,dataTable:null,fixHeightOnFirstRender:!1,syncGridColumns:!0,useRowNumeration:!0,allowDragDrop:!1,aggregates:{settings:null,calculator:null},paging:{enabled:!0,pageSize:30,pageSizeItems:[20,30,50,100,200]},columnWidths:{autoResize:X.Always,stringColumns:{min:100,max:500,default:250},numberColumns:{min:60,default:120},boolColumns:{min:50,default:80},dateColumns:{min:80,default:200},otherColumns:{min:100,max:500,default:250},rowNumColumn:{min:40,default:60}},showPlusButton:!1,viewportRowsCount:null,showActiveRow:!0},this.rowsOnPagePromise=null,this.containerInitialHeight=0,this.firstRender=!0,this.prevRowTotals=null,this.landingIndex=-1,this.landingSlot=W("div").addClass(this.cssPrefix+"-col-landing-slot").addChildElement(W("div").toDOM()).toDOM(),this._activeRowIndex=-1,t&&t.paging&&(t.paging=h.assign(this.defaultDataGridOptions.paging,t.paging)),this.options=this.mergeOptions(t),this.processColumnWidthsOptions(),!this.options.slot)throw Error('"slot" parameter is required to initialize EasyDataGrid');if(!this.options.dataTable)throw Error('"dataTable" parameter is required to initialize EasyDataGrid');this.dataTable=t.dataTable,this.eventEmitter=new L(this),this.cellRendererStore=new at(t),this.columns=new dt(this.dataTable.columns,this),this.setSlot(this.options.slot),this.init(this.options)}return t.prototype.mergeOptions=function(t){var e=h.assignDeep({},this.defaultDataGridOptions.columnWidths,t.columnWidths),n=h.assignDeep({},this.defaultDataGridOptions.paging,t.paging),i=h.assign({},this.defaultDataGridOptions,t);return i.columnWidths=e,i.paging=n,i},t.prototype.processColumnWidthsOptions=function(){var t=this.options.columnWidths;if(t){h.getStringDataTypes().forEach((function(e){t[e]=ct(ct({},t.stringColumns),t[e])})),h.getNumericDataTypes().forEach((function(e){t[e]=ct(ct({},t.numberColumns),t[e])})),t[i.Bool]=ct(ct({},t.boolColumns),t[i.Bool]),h.getDateDataTypes().forEach((function(e){t[e]=ct(ct({},t.dateColumns),t[e])}));var e=ht(h.getStringDataTypes(),h.getNumericDataTypes(),h.getDateDataTypes(),[i.Bool]);h.getAllDataTypes().forEach((function(n){n in e||(t[n]=ct(ct({},t.otherColumns),t[n]))})),t[i.Unknown]=t.otherColumns}},t.prototype.setSlot=function(t){if("string"==typeof t){if(t.length)if("#"===t[0])this.slot=document.getElementById(t.substring(1));else{if("."!==t[0])throw Error("Unrecognized slot parameter (Must be id, class or HTMLElement): "+t);var e=document.getElementsByClassName(t.substring(1));e.length&&(this.slot=e[0])}}else this.slot=t},t.prototype.init=function(t){var e=this;t.onInit&&this.addEventListener("init",t.onInit),t.onRowClick&&this.addEventListener("rowClick",t.onRowClick),t.onRowDbClick&&this.addEventListener("rowDbClick",t.onRowDbClick),t.onPlusButtonClick&&this.addEventListener("plusButtonClick",t.onPlusButtonClick),t.onColumnChanged&&this.addEventListener("columnChanged",t.onColumnChanged),t.onColumnDeleted&&this.addEventListener("columnDeleted",t.onColumnDeleted),t.onColumnMoved&&this.addEventListener("columnMoved",t.onColumnMoved),t.onPageChanged&&this.addEventListener("pageChanged",t.onPageChanged),t.onActiveRowChanged&&this.addEventListener("activeRowChanged",t.onActiveRowChanged),this.addEventListener("pageChanged",(function(t){return e.activeRowIndex=-1})),h.assignDeep(this.paginationOptions,t.pagination),this.pagination.pageSize=this.options.paging.pageSize||this.pagination.pageSize,this.options.allowDragDrop&&Q.registerDropContainer({element:this.slot,scopes:["gridColumnMove"],onDragEnter:function(t,n){e.slot.classList.add(H+"-drophover"),e.showLandingSlot(n.pageX,n.pageY)},onDragOver:function(t,n){e.showLandingSlot(n.pageX,n.pageY)},onDragLeave:function(t,n){n.dropEffect=Y.Forbid,e.slot.classList.remove(H+"-drophover"),e.hideLandingSlot()},onDrop:function(t,n){e.dataTable.columns.move(n.data.column,e.landingIndex),e.refresh(),e.fireEvent({type:"columnMoved",columnId:n.data.column.id,newIndex:e.landingIndex})}}),this.refresh(),this.fireEvent("init")},t.prototype.fireEvent=function(t){"string"==typeof t?this.eventEmitter.fire(t):this.eventEmitter.fire(t.type,t)},t.prototype.setData=function(t){this.dataTable=t,this.clear(),this.refresh()},t.prototype.getData=function(){return this.dataTable},t.prototype.getColumns=function(){return this.columns},t.prototype.destroy=function(){this.slot.innerHTML=""},t.prototype.refresh=function(){this.clearDOM(),this.render()},t.prototype.clearDOM=function(){this.slot.innerHTML=""},t.prototype.clear=function(){this.pagination.page=1,this.clearDOM()},t.prototype.render=function(){var t=this;if(this.hasData()||this.options.showPlusButton){this.containerInitialHeight=this.slot.clientHeight,this.rootDiv=document.createElement("div"),this.rootDiv.style.width="100%",this.rootDiv.classList.add(this.cssPrefix+"-root"),this.columns.sync(this.dataTable.columns,this.options.useRowNumeration),this.renderHeader(),this.rootDiv.appendChild(this.headerDiv),this.renderBody(),this.rootDiv.appendChild(this.bodyDiv),this.renderFooter(),this.rootDiv.appendChild(this.footerDiv);var e=document.createElement("div");e.classList.add(this.cssPrefix+"-container"),e.appendChild(this.rootDiv),this.slot.appendChild(e);var n=this.options.columnWidths.autoResize!==X.Never;this.rowsOnPagePromise?this.rowsOnPagePromise.then((function(){return t.updateHeight()})).then((function(){t.firstRender=!1,t.rowsOnPagePromise=null})):setTimeout((function(){t.updateHeight().then((function(){t.firstRender=!1,n&&t.resizeColumns()}))}),100)}},t.prototype.updateHeight=function(){var t=this;return new Promise((function(e){if(t.options.viewportRowsCount){var n=t.bodyCellContainerDiv.firstElementChild,i=(n?n.offsetHeight:36)*t.options.viewportRowsCount;return W(t.bodyViewportDiv).setStyle("height",i+"px"),void setTimeout((function(){var n=t.bodyViewportDiv.offsetHeight-t.bodyViewportDiv.clientHeight;i+=n,W(t.bodyViewportDiv).setStyle("height",i+"px"),e()}),100)}t.containerInitialHeight,e()})).then((function(){t.options.fixHeightOnFirstRender&&t.firstRender&&(t.slot.style.height=t.slot.offsetHeight+"px")}))},t.prototype.getContainerWidth=function(){return this.columns.getItems().filter((function(t){return t.isVisible})).map((function(t){return t.width})).reduce((function(t,e){return t+e}))},t.prototype.renderHeader=function(){var t=this;this.headerDiv=W("div").addClass(this.cssPrefix+"-header").toDOM(),this.headerViewportDiv=W("div",this.headerDiv).addClass(this.cssPrefix+"-header-viewport").toDOM(),this.headerCellContainerDiv=W("div",this.headerViewportDiv).addClass(this.cssPrefix+"-header-cell-container").toDOM(),this.headerRowDiv=W("div",this.headerCellContainerDiv).addClass(this.cssPrefix+"-header-row").toDOM(),this.columns.getItems().forEach((function(e,n){if(e.isVisible){var i=t.renderColumnHeader(e,n);t.headerRowDiv.appendChild(i),e.isRowNum&&W(i).addChildElement(t.renderHeaderButtons())}}));var e=this.getContainerWidth();W(this.headerCellContainerDiv).setStyle("width",e+"px")},t.prototype.hasData=function(){return this.dataTable.columns.count>0},t.prototype.renderColumnHeader=function(t,e){var n=this,i=W("div").addClass(this.cssPrefix+"-header-cell").data("col-idx",""+e).setStyle("width",t.width+"px");t.dataColumn&&i.data("col-id",""+t.dataColumn.id);var o=i.toDOM();return W("div",o).addClass(this.cssPrefix+"-header-cell-resize"),t.isRowNum||W("div",o).addClass(this.cssPrefix+"-header-cell-label").text(t.label),t.description&&W("div",o).addClass("question-mark").title(t.description),this.options.allowDragDrop&&Q.registerDraggableItem({element:o,scope:"gridColumnMove",data:{column:t},renderer:function(e){e.innerHTML="";var i=document.createElement("div");i.innerText=t.label,e.classList.add(n.cssPrefix+"-sortable-helper"),e.appendChild(i)},onDragStart:function(t){t.dropEffect=Y.Allow}}),o},t.prototype.renderBody=function(){var t=this;this.bodyDiv=W("div").addClass(this.cssPrefix+"-body").toDOM(),this.bodyViewportDiv=W("div",this.bodyDiv).addClass(this.cssPrefix+"-body-viewport").attr("tabIndex","0").toDOM(),this.bodyCellContainerDiv=W("div",this.bodyViewportDiv).addClass(this.cssPrefix+"-cell-container").toDOM();var e=this.canShowAggregates();this.dataTable&&(this.showProgress(),this.rowsOnPagePromise=this.getRowsToRender().then((function(n){t.pagination.total=t.dataTable.getTotal(),t.hideProgress(),t.bodyCellContainerDiv.innerHTML="",t.prevRowTotals=null;var i=0;if(n.length){var o=e?t.options.aggregates.settings.getGroups():[];i=n.length<t.pagination.pageSize?n.length:t.pagination.pageSize,n.forEach((function(n,r){if(e&&t.updateTotalsState(o,n),r<i){var s=t.renderRow(n,r);t.bodyCellContainerDiv.appendChild(s)}}));var r=t.options.aggregates&&t.options.aggregates.showGrandTotalsOnEachPage;if(e&&(t.isLastPage()||r)){var s=new k(t.dataTable.columns,new Array(t.dataTable.columns.count));t.updateTotalsState(o,s,!0)}}if(t.options.columnWidths.autoResize!==X.Never)t.resizeColumns();else{var a=t.getContainerWidth();W(t.bodyCellContainerDiv).setStyle("width",a+"px")}return i})).catch((function(t){return console.error(t),0}))),this.bodyViewportDiv.addEventListener("scroll",(function(e){W(t.headerViewportDiv).setStyle("margin-left","-"+t.bodyViewportDiv.scrollLeft+"px")})),this.bodyViewportDiv.addEventListener("keydown",this.onViewportKeydown.bind(this))},t.prototype.isLastPage=function(){return this.dataTable.elasticChunks?this.dataTable.totalIsKnown()&&this.pagination.page*this.pagination.pageSize>=this.pagination.total:this.pagination.page*this.pagination.pageSize>=this.pagination.total},t.prototype.canShowAggregates=function(){if(!this.options||!this.options.aggregates||!this.options.aggregates.settings)return!1;var t=this.options.aggregates.settings;return(t.hasAggregates()||t.hasRecordCount())&&(t.hasGroups()||t.hasGrandTotals())},t.prototype.updateTotalsState=function(t,e,n){void 0===n&&(n=!1);var i=this.options.aggregates.settings;if(this.prevRowTotals&&i.hasGroups()){for(var o=-1,r=1;r<=t.length;r++){for(var s=0,a=t[r-1].columns;s<a.length;s++){var l=a[s];if(!i.compareValues(this.prevRowTotals.getValue(l),e.getValue(l))){o=r;break}}if(-1!==o)break}if(-1!==o)for(r=t.length;r>=o;r--){var u=new k(this.dataTable.columns,this.prevRowTotals.toArray()),d=this.renderTotalsRow(r,u);this.bodyCellContainerDiv.appendChild(d)}}if(n&&i.hasGrandTotals()&&i.hasAggregates()){d=this.renderTotalsRow(0,e);this.bodyCellContainerDiv.appendChild(d)}this.prevRowTotals=e},t.prototype.applyGroupColumnTemplate=function(t,e,n){var i=t.replace(/{{\s*GroupValue\s*}}/g,e?"<span>"+e+"</span>":"-");return i=i.replace(/{{\s*GroupCount\s*}}/g,n?"<span>"+n+"</span>":"-")},t.prototype.renderTotalsRow=function(t,e){var n=this,i=this.options.aggregates.settings,o=t>0?i.getGroups()[t-1]:{columns:[],aggregates:i.getAggregates()},r=W("div").addClass(this.cssPrefix+"-row").addClass(this.cssPrefix+"-row-totals").addClass(this.cssPrefix+"-totals-lv"+t).data("totals-level",""+t).attr("tabindex","-1").toDOM();this.columns.getItems().forEach((function(t,i){if(t.isVisible){var s="",a=t.isRowNum?-1:n.dataTable.columns.getIndex(t.dataColumn.id);!t.isRowNum&&t.dataColumn&&o.columns.indexOf(t.dataColumn.id)>=0&&(s=e.getValue(a)),a==n.dataTable.columns.count-1&&(s=". . . . . ."),r.appendChild(n.renderCell(t,i,s,r))}}));var s=this.options.aggregates.calculator.getAggrContainer(),a=i.getAggregates().map((function(t){return t.colId})),l=i.buildGroupKey(o,e);return s.getAggregateData(t,l).then((function(s){for(var l=0,u=a;l<u.length;l++){var d=u[l];e.setValue(d,s[d])}r.innerHTML="",n.columns.getItems().forEach((function(l,u){if(l.isVisible){var d="",c=l.isRowNum?-1:n.dataTable.columns.getIndex(l.dataColumn.id);if(!l.isRowNum){var h=!1;if(l.dataColumn){var p=o.columns.indexOf(l.dataColumn.id),f=a.indexOf(l.dataColumn.id);h=t>0?p==o.columns.length-1:0==c,(p>=0||f>=0)&&(d=e.getValue(c))}var g="";if(t>0&&!(g=l.dataColumn.groupFooterColumnTemplate)&&i.hasRecordCount()&&h&&(g="{{GroupValue}} ({{GroupCount}})"),g)d=n.renderCell(l,u,d,r).firstChild.innerHTML,d=n.applyGroupColumnTemplate(g,d,s[i.COUNT_FIELD_NAME])}var m=n.renderCell(l,u,d,r);r.appendChild(m)}}))})).catch((function(t){return console.error(t)})),r},t.prototype.onViewportKeydown=function(t){if(this.options.showActiveRow){var e=this.bodyCellContainerDiv.querySelectorAll("."+this.cssPrefix+"-row").length,n=void 0;switch(t.key){case"ArrowLeft":case"ArrowRight":break;case"ArrowUp":t.preventDefault(),n=this.activeRowIndex<0||this.activeRowIndex>=e?e-1:this.activeRowIndex-1,this.activeRowIndex=n>=0?n:0;break;case"ArrowDown":t.preventDefault(),n=this.activeRowIndex<0||this.activeRowIndex>=e?0:this.activeRowIndex+1,this.activeRowIndex=n<e?n:e-1}}},t.prototype.ensureRowVisibility=function(t){var e="number"==typeof t?this.getDataRow(t):t;if(e){var n=e.getBoundingClientRect(),i=this.bodyViewportDiv.getBoundingClientRect(),o=n.top-i.top,r=n.bottom-i.top,s=this.bodyViewportDiv.clientHeight,a=window.innerHeight||document.documentElement.clientHeight;if(o>0&&r<=s&&n.top>0&&n.bottom<a)return;o<0?this.bodyViewportDiv.scrollTop=this.bodyViewportDiv.scrollTop+o:r>s&&(this.bodyViewportDiv.scrollTop=this.bodyViewportDiv.scrollTop+r-s),(n=e.getBoundingClientRect()).top<0?document.documentElement.scrollTop=document.documentElement.scrollTop+n.top:n.bottom>a&&(document.documentElement.scrollTop=document.documentElement.scrollTop+n.bottom-a)}},t.prototype.getRowsToRender=function(){return!1===this.options.paging.enabled?Promise.resolve(this.dataTable.getCachedRows()):this.dataTable.getRows({offset:(this.pagination.page-1)*this.pagination.pageSize,limit:this.pagination.pageSize+1}).catch((function(t){return console.error(t),[]}))},t.prototype.renderFooter=function(){var t=this;this.footerDiv=W("div").addClass(this.cssPrefix+"-footer").toDOM(),this.rowsOnPagePromise&&this.rowsOnPagePromise.then((function(e){t.footerDiv.innerHTML="",t.footerPaginateDiv=t.renderPageNavigator(),t.footerDiv.appendChild(t.footerPaginateDiv);var n=t.renderPageInfoBlock(e);t.footerDiv.appendChild(n)}))},t.prototype.renderPageInfoBlock=function(t){var e=W("div").addClass(this.cssPrefix+"-page-info").toDOM();if(this.dataTable.getTotal()>0){var n=t?(this.pagination.page-1)*this.pagination.pageSize+1:0,i=t?n+t-1:0,o=this.dataTable.getTotal().toString();if(this.dataTable.elasticChunks)this.dataTable.getCachedCount()!==this.dataTable.getTotal()&&(o="?");e.innerHTML=c.getText("GridPageInfo").replace("{FirstPageRecordNum}","<span>"+n.toString()+"</span>").replace("{LastPageRecordNum}","<span>"+i.toString()+"</span>").replace("{Total}","<span>"+o+"</span>")}return e},t.prototype.showProgress=function(){},t.prototype.hideProgress=function(){},t.prototype.getLocalIndexByGlobal=function(t){return this.pagination?t%this.pagination.pageSize:t},t.prototype.getGlobalIndexByLocal=function(t){return this.pagination?(this.pagination.page-1)*this.pagination.pageSize+t:t},t.prototype.renderRow=function(t,e){var n=this,i=this.getGlobalIndexByLocal(e),o=W("div").addClass(this.cssPrefix+"-row").addClass(this.cssPrefix+"-row-"+(e%2==1?"odd":"even")).data("row-idx",""+i).attr("tabindex","-1").on("click",(function(i){n.activeRowIndex=e,n.fireEvent({type:"rowClick",row:t,rowIndex:e,sourceEvent:i})})).on("dblclick",(function(i){n.fireEvent({type:"rowDbClick",row:t,rowIndex:e,sourceEvent:i})}));0==e&&o.addClass(this.cssPrefix+"-row-first");var r=o.toDOM();return this.options.showActiveRow&&e==this.activeRowIndex&&o.addClass(this.cssPrefix+"-row-active"),this.columns.getItems().forEach((function(e,o){if(e.isVisible){var s=e.isRowNum?-1:n.dataTable.columns.getIndex(e.dataColumn.id),a=e.isRowNum?i+1:t.getValue(s);r.appendChild(n.renderCell(e,o,a,r))}})),r},t.prototype.renderCell=function(t,e,n,i){var o=W("div").addClass(this.cssPrefix+"-cell").data("col-idx",""+e).attr("tabindex","-1").setStyle("width",t.width+"px");t.align==nt.LEFT?o.addClass(this.cssPrefix+"-cell-align-left"):t.align==nt.RIGHT?o.addClass(this.cssPrefix+"-cell-align-right"):t.align==nt.CENTER&&o.addClass(this.cssPrefix+"-cell-align-center");var r=o.toDOM(),s=r.appendChild(W("div").addClass(this.cssPrefix+"-cell-value").toDOM());return t.cellRenderer&&t.cellRenderer(n,t,s,i),r},t.prototype.setPage=function(t){this.pagination.page=t,this.fireEvent({type:"pageChanged",page:t}),this.refresh(),this.bodyViewportDiv.focus()},t.prototype.renderPageNavigator=function(){var t=this,e=document.createElement("div");e.className=this.cssPrefix+"-pagination-wrapper";var n=this.dataTable.getTotal();if(this.options.paging&&this.options.paging.enabled&&n>0){var i=this.paginationOptions.useBootstrap?"":this.cssPrefix+"-",o=function(e){var n=e.target;if(n.hasAttribute("data-page")){var i=parseInt(n.getAttribute("data-page"));t.setPage(i)}},r=function(e,n,r,s,a){var l=document.createElement("li");if(l.className=i+"page-item",!s){a&&(l.className+=" active");var u=document.createElement("a");return u.setAttribute("href","javascript:void(0)"),u.innerHTML=n||e.toString(),u.setAttribute("data-page",""+e),u.className=i+"page-link",u.addEventListener("click",o),l.appendChild(u),l}var d=document.createElement("span");if(d.setAttribute("aria-hidden","true"),d.className=i+"page-link",r)l.className+=" disabled";else{if(t.paginationOptions.useBootstrap)(d=document.createElement("a")).setAttribute("href","javascript:void(0)"),d.setAttribute("data-page",""+e);else{var c=document.createElement("a");c.setAttribute("href","javascript:void(0)"),c.setAttribute("data-page",""+e),d=c}d.className=i+"page-link",d.addEventListener("click",o)}return d.innerHTML=n,l.appendChild(d),l};if(this.dataTable.elasticChunks){var s=this.pagination.page||1;(l=document.createElement("ul")).className=i+"pagination";var a=r(s-1,"&laquo;",1==s,!0,!1);l.appendChild(a),a=r(s+1,"&raquo;",this.isLastPage(),!0,!1),l.appendChild(a),e.appendChild(l)}else if(this.pagination.total>this.pagination.pageSize){s=this.pagination.page||1;var l,u=Math.ceil(this.pagination.total/this.pagination.pageSize)||1,d=this.paginationOptions.maxButtonCount||10,h=s-1,p=h-h%d+1,f=p+d-1;f>u&&(f=u),(l=document.createElement("ul")).className=i+"pagination";a=r(p-1,"&laquo;",1==p,!0,!1);l.appendChild(a);for(var g=p;g<=f;g++)a=r(g,g.toString(),!1,!1,g==s),l.appendChild(a);a=r(f+1,"&raquo;",f==u,!0,!1),l.appendChild(a),e.appendChild(l)}if(this.options.paging.allowPageSizeChange){var m=document.createElement("div");m.className=this.cssPrefix+"-page-sizes";var y=document.createElement("div");y.className="kfrm-select "+this.cssPrefix+"-page-sizes-select",m.appendChild(y);var v=document.createElement("select"),b=this.options.paging.pageSizeItems||[],C=new Set(b);C.add(this.options.paging.pageSize||20),Array.from(C).forEach((function(t){var e=document.createElement("option");e.value=t.toString(),e.text=t.toString(),v.appendChild(e)})),v.value=(this.pagination.pageSize||20).toString(),y.appendChild(v),v.addEventListener("change",(function(e){var n=parseInt(e.target.value);t.pagination.pageSize=n,t.pagination.page=1,t.refresh()}));var w=document.createElement("div");w.className=this.cssPrefix+"-page-sizes-label",m.appendChild(w);var D=document.createElement("span");D.innerText=c.getText("GridItemsPerPage"),w.appendChild(D),e.appendChild(m)}}return e},t.prototype.addEventListener=function(t,e){return this.eventEmitter.subscribe(t,(function(t){return e(t.data)}))},t.prototype.removeEventListener=function(t,e){this.eventEmitter.unsubscribe(t,e)},t.prototype.renderHeaderButtons=function(){var t=this;return this.options.showPlusButton?W("div").addClass(this.cssPrefix+"-header-btn-plus").title(this.options.plusButtonTitle||"Add").addChild("a",(function(e){return e.attr("href","javascript:void(0)").on("click",(function(e){e.preventDefault(),t.fireEvent({type:"plusButtonClick",sourceEvent:e})}))})).toDOM():W("span").addText("#").toDOM()},t.prototype.showLandingSlot=function(t,e){for(var n=this.headerRowDiv.querySelectorAll("[class*="+this.cssPrefix+"-table-col]"),i=[],o=1;o<n.length;o++){var r=n[o];"none"!==r.style.display&&i.push(r)}if(0===i.length)return this.landingIndex=0,void this.headerRowDiv.appendChild(this.landingSlot);var s=B(this.landingSlot);if(!(t>=s.x&&t<=s.x+this.landingSlot.offsetWidth)){for(var a=this.landingIndex,l=0,u=i;l<u.length;l++){var d=u[l],c=B(d),h=d.offsetWidth;t>c.x&&t<c.x+h&&(a=parseInt(d.getAttribute("data-col-idx"))-1)}a!=this.landingIndex&&(this.landingIndex=a,this.landingIndex<i.length?this.headerRowDiv.insertBefore(this.landingSlot,i[this.landingIndex]):this.headerRowDiv.appendChild(this.landingSlot))}},t.prototype.hideLandingSlot=function(){var t=this;this.landingIndex=-1,setTimeout((function(){t.landingSlot.parentElement&&t.landingSlot.parentElement.removeChild(t.landingSlot)}),10)},Object.defineProperty(t.prototype,"activeRowIndex",{get:function(){return this._activeRowIndex},set:function(t){if(t!==this._activeRowIndex){var e=this._activeRowIndex;this._activeRowIndex=t,this.updateActiveRow(),this.fireEvent({type:"activeRowChanged",oldValue:e,newValue:this.activeRowIndex,rowIndex:this.getGlobalIndexByLocal(this.activeRowIndex)})}},enumerable:!0,configurable:!0}),t.prototype.updateActiveRow=function(){var t=this;if(this.options.showActiveRow){this.bodyCellContainerDiv.querySelectorAll("[class*="+this.cssPrefix+"-row-active]").forEach((function(e){e.classList.remove(t.cssPrefix+"-row-active")}));var e=this.getActiveRow();e&&(e.classList.add(this.cssPrefix+"-row-active"),this.ensureRowVisibility(this.activeRowIndex))}},t.prototype.getActiveRow=function(){return this.getDataRow(this.activeRowIndex)},t.prototype.getDataRow=function(t){var e=Array.from(this.bodyCellContainerDiv.querySelectorAll("."+this.cssPrefix+"-row:not(."+this.cssPrefix+"-row-totals)"));return t>=0&&t<e.length?e[t]:null},t.prototype.focus=function(){this.bodyViewportDiv.focus()},t.prototype.resizeColumns=function(){if(this.options.columnWidths.autoResize!==X.Never){var t=this.bodyCellContainerDiv.style.width;this.bodyCellContainerDiv.style.visibility="hidden",this.bodyCellContainerDiv.style.width="1px",this.headerRowDiv.style.width="1px";for(var e=0,n=this.columns.getItems(),i=this.headerCellContainerDiv.querySelectorAll("."+this.cssPrefix+"-header-cell"),o=0,r=function(t){var r=n[t];if(!r.isVisible)return"continue";var a=s.options.columnWidths.autoResize!==X.Always&&r.dataColumn?r.dataColumn.calculatedWidth:0,l=s.bodyCellContainerDiv.querySelectorAll("."+s.cssPrefix+'-cell[data-col-idx="'+t+'"] > .'+s.cssPrefix+"-cell-value"),u=0;if(a>0)e+=a,r.width=a,l.forEach((function(t){t.parentElement.style.width=a+"px"})),i[o].style.width=a+"px";else if(0==l.length&&(i[o].style.width=null,i[o].style.whiteSpace="nowrap"),u=i[o].offsetWidth,l.length>0){l.forEach((function(t){t.parentElement.style.width=null;var e=t.parentElement.offsetWidth;e>u&&(u=e)})),u+=3;var d=r.isRowNum?s.options.columnWidths.rowNumColumn.max||500:s.options.columnWidths[r.dataColumn.type].max||2e3,c=r.isRowNum?s.options.columnWidths.rowNumColumn.min||0:s.options.columnWidths[r.dataColumn.type].min||20;u>d&&(u=d),u<c&&(u=c),h.isNumericType(r.type)&&(u=Math.round(1.3*u)),e+=u,r.width=u,l.forEach((function(t){t.parentElement.style.width=u+"px"})),i[o].style.width=u+"px",r.dataColumn&&(r.dataColumn.calculatedWidth=u)}else e+=u;o++},s=this,a=0;a<this.columns.count;a++)r(a);e>0?(this.bodyCellContainerDiv.style.width=e+"px",this.headerCellContainerDiv.style.width=e+"px"):(this.bodyCellContainerDiv.style.width=t,this.headerCellContainerDiv.style.width=t),this.bodyCellContainerDiv.style.visibility=null,this.headerRowDiv.removeAttribute("style")}},t}(),ft=function(){function t(t,e){this.slot=t,this.options=e||{},this.options.yearRange||(this.options.yearRange="c-10:c+10")}return Object.defineProperty(t.prototype,"cssPrefix",{get:function(){return"kdtp-cal"},enumerable:!0,configurable:!0}),t.prototype.setDate=function(t){this.currentDate=new Date(t)},t.prototype.getDate=function(){return new Date(this.currentDate)},t.prototype.dateChanged=function(t){this.options.onDateChanged&&this.options.onDateChanged(this.currentDate,t)},t}(),gt=function(){function t(t){this.calendar=null,this.timePicker=null,this.options=t,this.render()}return Object.defineProperty(t.prototype,"cssPrefix",{get:function(){return"kdtp"},enumerable:!0,configurable:!0}),t.prototype.setDateTime=function(t){this.currentDateTime=new Date(t),this.calendar&&this.calendar.setDate(this.currentDateTime),this.timePicker&&this.timePicker.setTime(this.currentDateTime)},t.prototype.getDateTime=function(){return new Date(this.currentDateTime)},t.prototype.render=function(){var t=this;this.options.showCalendar&&(this.calendar=this.createCalendar({yearRange:this.options.yearRange,showDateTimeInput:this.options.showDateTimeInput,timePickerIsUsed:this.options.showTimePicker,oneClickDateSelection:this.options.oneClickDateSelection,onDateChanged:function(e,n){t.currentDateTime=e,t.timePicker&&t.timePicker.setTime(t.currentDateTime),t.options.showTimePicker&&t.dateTimeChanged(),n&&t.apply(t.currentDateTime)}}),this.calendar&&this.calendar.render()),this.options.showTimePicker&&(this.timePicker=this.createTimePicker({onTimeChanged:function(e){t.currentDateTime.setHours(e.getHours()),t.currentDateTime.setMinutes(e.getMinutes()),t.calendar&&t.calendar.setDate(t.currentDateTime),t.dateTimeChanged()}}),this.timePicker&&this.timePicker.render()),this.setDateTime(new Date)},t.prototype.createCalendar=function(t){return null},t.prototype.createTimePicker=function(t){return null},t.prototype.show=function(t){this.options.beforeShow&&this.options.beforeShow();var e=B(t||document.body);this.slot.style.top=e.y+t.clientHeight+"px",this.slot.style.left=e.x+"px"},t.prototype.apply=function(t){this.options.onApply&&this.options.onApply(t),this.destroy()},t.prototype.cancel=function(){this.options.onCancel&&this.options.onCancel(),this.destroy()},t.prototype.destroy=function(){this.slot&&this.slot.parentElement&&this.slot.parentElement.removeChild(this.slot)},t.prototype.dateTimeChanged=function(){this.options.onDateTimeChanged&&this.options.onDateTimeChanged(this.currentDateTime)},t}(),mt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),yt=function(t){function e(e,n){var i=t.call(this,e,n)||this;i.daysOfWeek=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i.calendarBody=null,i.isManualInputChanging=!1;for(var o=0;o<i.daysOfWeek.length;o++)i.daysOfWeek[o]=c.getShortWeekDayName(o+1);for(o=0;o<i.months.length;o++)i.months[o]=c.getLongMonthName(o+1);return i}return mt(e,t),e.prototype.setDate=function(e){t.prototype.setDate.call(this,e),this.selectedMonth=this.currentDate.getMonth(),this.selectedYear=this.currentDate.getFullYear(),this.rerenderMonth()},e.prototype.render=function(){var t=this,e=W("div",this.slot).addClass(this.cssPrefix+"-header");this.options.showDateTimeInput?e.addChildElement(this.renderManualDateInput()):e.addChild("span",(function(e){return t.headerTextElem=e.toDOM()})),W(this.slot).addChildElement(this.renderCalendarButtons()),this.calendarBody=W("div",this.slot).addClass(this.cssPrefix+"-body").toDOM()},e.prototype.getInputDateFormat=function(){var t=c.getLocaleSettings();return this.options.timePickerIsUsed?t.editDateFormat+" "+t.editTimeFormat:t.editDateFormat},e.prototype.renderManualDateInput=function(){var t=this,e=this.getInputDateFormat(),n=W("input").attr("placeholder",e).addClass(this.cssPrefix+"-header-input");return n.mask(e.replace("yyyy","9999").replace("MM","99").replace("dd","99").replace("HH","99").replace("mm","99").replace("ss","99")).on("input",(function(i){n.removeClass("error");try{t.isManualInputChanging=!0;var o=h.strToDateTime(t.manualInputElem.value,e);t.currentDate=o,t.jump(t.currentDate.getFullYear(),t.currentDate.getMonth()),t.dateChanged(!1)}catch(t){n.addClass("error")}finally{t.isManualInputChanging=!1}})).on("keydown",(function(e){13===e.keyCode&&(e.preventDefault(),e.stopPropagation(),t.manualInputElem.className.indexOf("error")<0&&!t.isManualInputChanging&&t.dateChanged(!0))})).on("focus",(function(){setTimeout((function(){t.manualInputElem.selectionStart=0,t.manualInputElem.selectionEnd=0}),50)})),this.manualInputElem=n.toDOM(),this.manualInputElem},e.prototype.updateDisplayedDateValue=function(){if(this.manualInputElem){if(!this.isManualInputChanging){var t=this.getInputDateFormat();this.manualInputElem.value=h.dateTimeToStr(this.currentDate,t),this.manualInputElem.focus()}}else if(this.headerTextElem){var e=c.getCurrentLocale();this.headerTextElem.innerText=this.currentDate.toLocaleString("en"==e?void 0:e,{year:"numeric",month:"long",day:"numeric"})}},e.prototype.renderCalendarButtons=function(){var t=this;return W("nav").addClass(this.cssPrefix+"-nav").addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-prev").on("click",(function(){t.prev()})).addChild("span",(function(t){return t.html("&lsaquo;")}))})).addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-selectors").addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-month").addChild("select",(function(e){e.on("change",(function(){t.jump(t.selectedYear,parseInt(t.selectMonthElem.value))}));for(var n=function(n){e.addChild("option",(function(e){return e.attr("value",n.toString()).text(t.months[n])}))},i=0;i<t.months.length;i++)n(i);t.selectMonthElem=e.toDOM()}))})).addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-year").addChild("select",(function(e){return t.selectYearElem=e.on("change",(function(){t.jump(parseInt(t.selectYearElem.value),t.selectedMonth)})).toDOM()}))}))})).addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-next").on("click",(function(){t.next()})).addChild("span",(function(t){return t.html("&rsaquo;")}))})).toDOM()},e.prototype.prev=function(){this.selectedYear=0===this.selectedMonth?this.selectedYear-1:this.selectedYear,this.selectedMonth=0===this.selectedMonth?11:this.selectedMonth-1,this.rerenderMonth()},e.prototype.next=function(){this.selectedYear=11===this.selectedMonth?this.selectedYear+1:this.selectedYear,this.selectedMonth=(this.selectedMonth+1)%12,this.rerenderMonth()},e.prototype.rerenderSelectYear=function(){var t=/c-(\d*):c\+(\d*)/g.exec(this.options.yearRange),e=0,n=1;null!==t&&(e=parseInt(t[1]),n=parseInt(t[2])),this.selectYearElem.innerHTML="";for(var i=0;i<=e+n;i++){var o=document.createElement("option"),r=this.selectedYear-e+i;o.value=r.toString(),o.innerText=r.toString(),this.selectYearElem.appendChild(o)}},e.prototype.jump=function(t,e){this.selectedYear=t,this.selectedMonth=e,this.rerenderMonth()},e.prototype.rerenderMonth=function(){var t=this;this.updateDisplayedDateValue(),this.rerenderSelectYear();var e=new Date(this.selectedYear,this.selectedMonth).getDay(),n=new Date(this.selectedYear,this.selectedMonth+1,0).getDate();this.calendarBody.innerHTML="",this.selectYearElem.value=this.selectedYear.toString(),this.selectMonthElem.value=this.selectedMonth.toString(),this.daysOfWeek.forEach((function(e,n){W("div",t.calendarBody).addClass(t.cssPrefix+"-weekday").addClass(0==n||6==n?t.cssPrefix+"-weekend":"").text(e)}));for(var i=0;i<e;i++)W("div",this.calendarBody).addClass(this.cssPrefix+"-day-empty");for(var o=new Date,r=1;r<=n;r++){var s=W("div",this.calendarBody).addClass(this.cssPrefix+"-day").attr("data-date",r.toString()).text(r.toString()).on("click",(function(e){t.currentDate.setFullYear(t.selectedYear),t.currentDate.setMonth(t.selectedMonth),t.currentDate.setDate(parseInt(e.target.getAttribute("data-date"))),t.dateChanged(t.options.oneClickDateSelection)}));r===o.getDate()&&this.selectedYear===o.getFullYear()&&this.selectedMonth===o.getMonth()&&s.addClass(this.cssPrefix+"-day-current"),r===this.currentDate.getDate()&&this.selectedYear===this.currentDate.getFullYear()&&this.selectedMonth===this.currentDate.getMonth()&&s.addClass(this.cssPrefix+"-day-selected");var a=(e+r-1)%7;0!=a&&6!=a||s.addClass(this.cssPrefix+"-weekend")}var l=(e+n)%7,u=0==l?0:7-l;for(i=0;i<u;i++)W("div",this.calendarBody).addClass(this.cssPrefix+"-day-empty")},e.prototype.dateChanged=function(e){t.prototype.dateChanged.call(this,e),this.rerenderMonth()},e}(ft),vt=function(){function t(t,e){this.slot=t,this.options=e||{}}return Object.defineProperty(t.prototype,"cssPrefix",{get:function(){return"kdtp-tp"},enumerable:!0,configurable:!0}),t.prototype.setTime=function(t){this.currentTime=new Date(t)},t.prototype.getTime=function(){return new Date(this.currentTime)},t.prototype.timeChanged=function(){this.options.onTimeChanged&&this.options.onTimeChanged(this.currentTime)},t}(),bt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return bt(e,t),e.prototype.setTime=function(e){t.prototype.setTime.call(this,e),this.updateDisplayedTime(),this.hoursInput.valueAsNumber=e.getHours(),this.minutesInput.valueAsNumber=e.getMinutes()},e.prototype.render=function(){var t=this;W("div",this.slot).addClass(this.cssPrefix+"-time").addChild("span",(function(e){return t.timeText=e.toDOM()})).toDOM();var e=W("div",this.slot).addClass(this.cssPrefix+"-sliders");return e.addChild("div",(function(e){return e.addClass(t.cssPrefix+"-time-row").title("Hours").addChild("input",(function(e){return t.hoursInput=e.addClass(t.cssPrefix+"-input-hours").type("range").attr("min","0").attr("max","23").attr("step","1").on("input",(function(e){t.currentTime.setHours(t.hoursInput.valueAsNumber),t.updateDisplayedTime(),t.timeChanged()})).toDOM()}))})),e.addChild("div",(function(e){return e.addClass(t.cssPrefix+"-time-row").title("Minutes").addChild("input",(function(e){return t.minutesInput=e.addClass(t.cssPrefix+"-input-minutes").type("range").attr("min","0").attr("max","59").attr("step","1").on("input",(function(e){t.currentTime.setMinutes(t.minutesInput.valueAsNumber),t.updateDisplayedTime(),t.timeChanged()})).toDOM()}))})),this.slot},e.prototype.updateDisplayedTime=function(){var t=c.getCurrentLocale(),e=this.currentTime.toLocaleString("en"==t?void 0:t,{hour:"numeric",minute:"numeric"});this.timeText.innerText=e},e}(vt),wt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return wt(e,t),e.prototype.render=function(){var e=this,n=W("div",document.body).addClass(""+this.cssPrefix).attr("tabIndex","0").setStyle("position","absolute").setStyle("top","-1000px").setStyle("left","-1000px").on("keydown",(function(t){return 27===t.keyCode?e.cancel():13===t.keyCode&&e.apply(e.getDateTime()),!1}));this.options.zIndex&&n.setStyle("z-index",""+this.options.zIndex),this.slot=n.toDOM(),t.prototype.render.call(this),this.renderButtons(),this.globalMouseDownHandler=function(t){var n=window.event||t;n.srcElement||n.target;return!e.slot.contains(n.target)&&(document.removeEventListener("mousedown",e.globalMouseDownHandler,!0),e.cancel()),!0}},e.prototype.renderButtons=function(){var t=this,e=W("div",this.slot).addClass(this.cssPrefix+"-buttons").addChild("button",(function(e){return t.nowButton=e.addClass(t.cssPrefix+"-button "+t.cssPrefix+"-button-now").text(c.getText("ButtonNow")).on("click",(function(){return t.setDateTime(new Date),t.dateTimeChanged(),!1})).toDOM()}));!this.options.showTimePicker&&this.options.oneClickDateSelection||e.addChild("button",(function(e){return t.submitButton=e.addClass(t.cssPrefix+"-button "+t.cssPrefix+"-button-apply").text(c.getText("ButtonApply")).on("click",(function(){return t.apply(t.getDateTime()),!1})).toDOM()})),e.addChild("button",(function(e){return t.submitButton=e.addClass(t.cssPrefix+"-button "+t.cssPrefix+"-button-cancel").text(c.getText("ButtonCancel")).on("click",(function(){return t.cancel(),!1})).toDOM()}))},e.prototype.createCalendar=function(t){return this.calendarSlot=W("div",this.slot).addClass(this.cssPrefix+"-cal").toDOM(),new yt(this.calendarSlot,t)},e.prototype.createTimePicker=function(t){return this.timePickerSlot=W("div",this.slot).addClass(this.cssPrefix+"-tp").toDOM(),new Ct(this.timePickerSlot,t)},e.prototype.show=function(e){var n=this;if(this.options.showDateTimeInput){this.options.beforeShow&&this.options.beforeShow();var i=B(e||document.body),o=B(e?e.parentElement||e:document.body);this.slot.style.top=o.y+"px",this.slot.style.left=i.x+"px"}else t.prototype.show.call(this,e),this.slot.focus();setTimeout((function(){document.addEventListener("mousedown",n.globalMouseDownHandler,!0)}),1)},e}(gt);!function(t){t[t.Left=1]="Left",t[t.Center=2]="Center",t[t.Right=3]="Right"}(lt||(lt={}));var Tt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),xt="kdlg",Et=function(){function t(){}return t.prototype.openConfirm=function(t,e,n){var i=this,o={title:t,closable:!1,submitable:!0,cancelable:!0,body:'<div id="kdlg-dialog-confirm">'+e+"</div>"};return n?(o.onSubmit=function(){n(!0)},o.onCancel=function(){n(!1)},void this.open(o)):new Promise((function(t){o.onSubmit=function(){t(!0)},o.onCancel=function(){t(!1)},i.open(o)}))},t.prototype.openPrompt=function(t,e,n,i){var o=this,r={title:t,submitable:!0,closable:!0,cancelable:!0,submitOnEnter:!0,body:'<div id="kdlg-dialog-form" class="kfrm-form">\n <div class="kfrm-fields label-above">\n <label for="kdlg-dialog-form-input" id="kdlg-dialog-form-content">'+e+'</label>\n <input type="text" name="'+xt+'-dialog-form-input" id="'+xt+'-dialog-form-input" />\n </div>\n </div>',arrangeParents:!1,beforeOpen:function(){var t=document.getElementById(xt+"-dialog-form-input");n&&(t.value=n),t.focus()}},s=function(t){var e=document.getElementById(xt+"-dialog-form-input"),n=e.value;return n&&n.replace(/\s/g,"").length>0?(t(n),!0):(e.classList.add("eqjs-invalid"),!1)};return i?(r.onSubmit=function(){return s(i)},r.onCancel=function(){i("")},void this.open(r)):new Promise((function(t){r.onSubmit=function(){return s(t)},r.onCancel=function(){t("")},o.open(r)}))},t.prototype.open=function(t,e){var n=this,i=new It(t,e),o=t.onDestroy;return t.onDestroy=function(t){n.untrack(t),o&&o(t)},i.open(),this.track(i),i},t.prototype.createSet=function(t){return new Mt(t,this)},t.prototype.untrack=function(e){var n=t.openDialogs.indexOf(e);n>=0&&t.openDialogs.splice(n,1)},t.prototype.track=function(e){t.openDialogs.push(e)},t.prototype.openProgress=function(t){var e=this,n=new St(t),i=t.onDestroy;return t.onDestroy=function(t){e.untrack(t),i&&i(t)},n.open(),this.track(n),n},t.prototype.getAllDialogs=function(){return Array.from(t.openDialogs)},t.prototype.closeAllDialogs=function(){for(var e=0,n=Array.from(t.openDialogs);e<n.length;e++){n[e].close()}},t.openDialogs=[],t}(),It=function(){function t(t,e){var n=this;this.options=t,this.submitHandler=function(t){return(!n.options.onSubmit||!1!==n.options.onSubmit(n,t))&&(n.destroy(),!0)},this.cancelHandler=function(){n.options.onCancel&&n.options.onCancel(n),n.destroy()},this.keydownHandler=function(t){return 13!=t.keyCode||!n.isActiveDialog()||(t.preventDefault(),t.stopPropagation(),!n.submitHandler())||(window.removeEventListener("keydown",n.keydownHandler,!1),!1)},this.dialogId=h.generateId("dlg"),this.data=e,this.slot=W("div",document.body).attr("tab-index","-1").data("dialog-id",this.dialogId).addClass(xt+"-modal","is-active").focus().addChild("div",(function(t){return t.addClass("kdlg-modal-background")})).addChild("div",(function(i){return n.windowElement=i.addClass(xt+"-modal-window").addChild("header",(function(e){n.headerElement=e.addClass(xt+"-header").addChild("p",(function(e){return e.addClass(xt+"-header-title").addText(t.title)})).toDOM(),!1!==t.closable&&e.addChild("button",(function(t){return t.addClass(xt+"-modal-close").on("click",(function(){n.cancelHandler()})).focus()}))})).addChild("div",(function(t){t.addClass(xt+"-alert-container"),n.alertElement=t.toDOM()})).addChild("section",(function(i){if(n.bodyElement=i.addClass(xt+"-body").toDOM(),"string"==typeof t.body){var o=M.renderLiquidTemplate(t.body,e);i.addHtml(o)}else i.addChildElement(t.body)})).addChild("footer",(function(e){var i=null;i=t.footerAlignment&&t.footerAlignment==lt.Center?"align-center":"align-right",n.footerElement=e.addClass(xt+"-footer").toDOM(),e.addClass(i),!1!==t.submitable&&(e.addChild("button",(function(e){e.id(n.dialogId+"-btn-submit").addClass("kfrm-button","is-info").addText(t.submitButtonText||c.getText("ButtonOK")),t.recaptchaSiteKey?(e.data("sitekey",t.recaptchaSiteKey),e.addClass("g-recaptcha"),e.on("click",(function(e){grecaptcha?grecaptcha.ready((function(){grecaptcha.execute(t.recaptchaSiteKey,{action:"submit"}).then((function(t){n.submitHandler(t)}))})):n.submitHandler()}))):e.on("click",(function(t){n.submitHandler()})),e.focus()})),!1!==t.cancelable&&e.addChild("button",(function(e){return e.id(n.dialogId+"-btn-cancel").addClass("kfrm-button").addText(t.cancelButtonText||c.getText("ButtonCancel")).on("click",(function(t){n.cancelHandler()}))})))})).toDOM()})).toDOM()}return t.prototype.getData=function(){return this.data},t.prototype.getRootElement=function(){return this.slot},t.prototype.getSubmitButtonElement=function(){return document.getElementById(this.dialogId+"-btn-submit")},t.prototype.getCancelButtonElement=function(){return document.getElementById(this.dialogId+"-btn-cancel")},t.prototype.open=function(){var t=this;this.options.beforeOpen&&this.options.beforeOpen(this),W(this.slot).show(),this.options.arrangeParents&&this.arrangeParents(!0);var e=this.slot.querySelector(".kdlg-modal-window");this.options.height&&(e.style.height="string"==typeof this.options.height?this.options.height:this.options.height+"px"),this.options.width&&(e.style.width="string"==typeof this.options.width?this.options.width:this.options.width+"px"),this.options.submitOnEnter&&window.addEventListener("keydown",this.keydownHandler,!1),this.slot.querySelectorAll("input").forEach((function(e){return e.addEventListener("input",(function(){t.clearAlert(),t.options.onInput&&t.options.onInput(t)}))})),this.options.onShow&&this.options.onShow(this)},t.prototype.submit=function(){this.submitHandler()},t.prototype.cancel=function(){this.cancelHandler()},t.prototype.close=function(){this.destroy()},t.prototype.disableButtons=function(){this.slot.querySelectorAll("button").forEach((function(t){return t.disabled=!0}))},t.prototype.enableButtons=function(){this.slot.querySelectorAll("button").forEach((function(t){return t.disabled=!1}))},t.prototype.showAlert=function(t,e,n){var i=W("div").addClass(xt+"-alert "+(e||"")).addChild("span",(function(t){return t.addClass(xt+"-alert-closebtn").text("×").on("click",(function(t){var e=t.target.parentElement;e.parentElement.removeChild(e)}))})).addText(t).toDOM();!0===n&&this.clearAlert(),this.alertElement.appendChild(i)},t.prototype.clearAlert=function(){this.alertElement.innerHTML=""},t.prototype.destroy=function(){document.querySelectorAll('[data-dialog-id="'+this.dialogId+'"]').length<=0||(this.options.arrangeParents&&this.arrangeParents(!1),document.body.removeChild(this.slot),this.options.submitOnEnter&&window.removeEventListener("keydown",this.keydownHandler,!1),this.options.onDestroy&&this.options.onDestroy(this))},t.prototype.isActiveDialog=function(){var t=document.documentElement.querySelectorAll(".kdlg-modal");return t[t.length-1]===this.slot},t.prototype.arrangeParents=function(t){for(var e=document.documentElement.querySelectorAll(".kdlg-modal-window"),n=0;n<e.length-1;n++)if(t){var i=0==n?20:40*n+20;W(e[n]).setStyle("margin-top",i+"px").setStyle("margin-left",i+"px")}else W(e[n]).removeStyle("margin-top").removeStyle("margin-left")},t}(),St=function(t){function e(e,n){var i,o,r=this,s=W("div").addChild("div",(function(t){return i=t.text(e.content||"").toDOM()})).addChild("div",(function(t){t.addClass(xt+"-progress-line").addChild("div",(function(t){o=t.addClass("fill").toDOM(),e.determinated?t.setStyle("width","0%"):t.addClass("indeterminate")}))})).toDOM();return(r=t.call(this,{title:e.title,body:s,beforeOpen:e.beforeOpen,onSubmit:e.onSubmit,width:e.width,height:e.height,submitable:!1,cancelable:!1,closable:!1,onDestroy:e.onDestroy},n)||this).contentElement=i,r.progressElement=o,r}return Tt(e,t),e.prototype.updateContent=function(t){this.contentElement.innerText=t},e.prototype.updateProgress=function(t){var e=this;t=this.in01(t),this.progressElement.style.width=100*t+"%",1===t&&setTimeout((function(){e.submit()}),500)},e.prototype.in01=function(t){return t>1?1:t<0?0:t},e}(It),Mt=function(){function t(t,e){this.options=t,this.dialogService=e,this.currentDialog=null,this.currentIndex=0,this.options=t,this.dialogService=e}return t.prototype.getCurrent=function(){return this.currentDialog},t.prototype.openNext=function(t){return this.open(this.currentIndex+1,t)},t.prototype.openPrev=function(t){return this.open(this.currentIndex-1,t)},t.prototype.open=function(t,e){if(t<0?this.currentIndex=0:t>=this.options.length?this.currentIndex=this.options.length-1:this.currentIndex=t,this.currentDialog)try{this.currentDialog.close()}catch(t){}var n=this.options[this.currentIndex];return this.currentDialog=this.dialogService.open(n,e),this.currentDialog},t.prototype.close=function(){this.currentDialog&&(this.currentDialog.close(),this.currentDialog=null)},t}();c.updateDefaultTexts({GridPageInfo:"{FirstPageRecordNum} - {LastPageRecordNum} of {Total} records",GridItemsPerPage:"items per page",ButtonOK:"OK",ButtonCancel:"Cancel",ButtonApply:"Apply",ButtonNow:"Now",LblTotal:"Total"});new Et;var Pt="yyyy-MM-dd",Rt="HH:mm",kt=function(t){var e=c.getLocaleSettings();return t==i.Date?e.editDateFormat:t==i.Time?e.editTimeFormat:e.editDateFormat+" "+e.editTimeFormat},Ot=function(t){var e=window.history.state;history.pushState(e,document.title,t),window.dispatchEvent(new Event("ed_set_location"))},At=function(){},Lt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Nt=function(t){function e(){var e=t.call(this)||this;return e.name="DateTime",e}return Lt(e,t),e.prototype.validate=function(t,e){if(!h.IsDefinedAndNotNull(e)||""==e)return{successed:!0};if(h.getDateDataTypes().indexOf(t.dataType)>=0)try{var n=kt(t.dataType);h.strToDateTime(e,n)}catch(t){return{successed:!1,messages:[c.getText("DateTimeError")]}}return{successed:!0}},e}(At),Ft=function(){function t(t){this.context=t,this.validators=[new Nt]}return t.prototype.getHtml=function(){return this.html},t.prototype.setHtmlInt=function(t){this.html=t,this.errorsDiv=this.html.querySelector(".errors-block")},t.prototype.validate=function(){this.clearErrors();for(var t=!0,e=0,n=Array.from(this.html.querySelectorAll("input, select"));e<n.length;e++){var i=n[e],o=this.context.getMetaData().getAttributeById(i.name);if("checkbox"!==i.type){var r=this.validateValue(o,i.value);if(!r.successed){t&&W(this.errorsDiv).addChild("ul"),t=!1;for(var s=0,a=r.messages;s<a.length;s++){var l=a[s];this.errorsDiv.firstElementChild.innerHTML+="<li>"+o.caption+": "+l+"</li>"}}this.markInputValid(i,r.successed)}}return t},t.prototype.getData=function(){var t=this;return new Promise((function(e,n){for(var i=[],o=Array.from(t.html.querySelectorAll("input, select, textarea")),r={},s=function(e){var n=e.name.substring(e.name.lastIndexOf(".")+1),o=t.context.getMetaData().getAttributeById(e.name);"checkbox"===e.type?r[n]=e.checked:"file"===e.type?i.push(t.fileToBase64(e.files[0]).then((function(t){return r[n]=t}))):r[n]=t.mapValue(o.dataType,e.value)},a=0,l=o;a<l.length;a++){s(l[a])}Promise.all(i).then((function(){return e(r)})).catch((function(t){return n(t)}))}))},t.prototype.fileToBase64=function(t){return new Promise((function(e,n){var i=new FileReader;i.readAsDataURL(t),i.onload=function(){var t=i.result.toString();e(t.substring(t.indexOf(",")+1))},i.onerror=function(t){return n(t)}}))},t.prototype.useValidator=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.useValidators(t)},t.prototype.useValidators=function(t){this.validators=this.validators.concat(t)},t.prototype.mapValue=function(t,e){if(h.getDateDataTypes().indexOf(t)>=0){if(t!==i.Time&&e&&e.length){var n=kt(t),o=(s=t)==i.Date?Pt:s==i.Time?Rt:Pt+"T"+Rt,r=h.strToDateTime(e,n);return h.dateTimeToStr(r,o)}return e&&e.length?e:null}var s;return h.isIntType(t)?parseInt(e):h.isNumericType(t)?parseFloat(e):e},t.prototype.clearErrors=function(){this.errorsDiv.innerHTML="",this.html.querySelectorAll("input, select").forEach((function(t){t.classList.remove("is-valid"),t.classList.remove("is-invalid")}))},t.prototype.markInputValid=function(t,e){t.classList.add(e?"is-valid":"is-invalid")},t.prototype.validateValue=function(t,e){for(var n={successed:!0,messages:[]},i=0,o=this.validators;i<o.length;i++){var r=o[i].validate(t,e);r.successed||(n.successed=!1,n.messages=n.messages.concat(r.messages))}return n},t}(),_t=function(){function t(t,e,n,i){var o=this;this.slot=t,this.grid=e,this.filter=n,this.options={focus:!1,instantMode:!1,instantTimeout:1e3},this.options=h.assignDeep(this.options,i||{});var r=this.grid.cellRendererStore.getDefaultRendererByType($.STRING);this.grid.cellRendererStore.setDefaultRenderer($.STRING,(function(t,e,n,i){return o.highlightCellRenderer(r,t,e,n,i)}));var s=this.grid.cellRendererStore.getDefaultRendererByType($.NUMBER);this.grid.cellRendererStore.setDefaultRenderer($.NUMBER,(function(t,e,n,i){return o.highlightCellRenderer(s,t,e,n,i)})),this.render()}return t.prototype.render=function(){var t=this,e=_.a.IsIE()?"kfrm-fields-ie is-horizontal":"kfrm-fields is-horizontal",n=_.a.IsIE()||_.a.IsEdge();W(this.slot).addClass(e).addChild("div",(function(e){e.addClass("control").addChild("input",(function(e){t.filterInput=e.toDOM(),e.attr("placeholder",c.getText("SearchInputPlaceholder")).type("text"),e.on("keydown",t.inputKeydownHandler.bind(t)),t.options.instantMode&&e.on("keyup",t.inputKeyupHandler.bind(t))})),n||e.addClass("has-icons-right").addChild("span",(function(e){e.addClass("icon").addClass("is-right").addClass("is-clickable").html("&#x1F5D9;").on("click",t.clearButtonClickHander.bind(t))}))})),this.options.instantMode||W(this.slot).addChild("button",(function(e){return e.addClass("kfrm-button").addText(c.getText("SearchBtn")).on("click",t.searchButtonClickHandler.bind(t))})),this.options.focus&&this.filterInput.focus()},t.prototype.inputKeydownHandler=function(t){13==t.keyCode&&this.applyFilter(!0)},t.prototype.inputKeyupHandler=function(){var t=this;this.applyFilterTimeout&&clearTimeout(this.applyFilterTimeout),this.applyFilterTimeout=setTimeout((function(){t.applyFilter(!0)}),this.options.instantTimeout)},t.prototype.clearButtonClickHander=function(){this.filterInput.value="",this.filterInput.focus(),this.applyFilter(!0)},t.prototype.searchButtonClickHandler=function(){this.applyFilter(!0)},t.prototype.applyFilter=function(t){var e=this;this.applyFilterTimeout&&clearTimeout(this.applyFilterTimeout);var n=this.filter.getValue();return(!t||n!=this.filterInput.value)&&(this.filter.apply(this.filterInput.value).then((function(t){e.grid.setData(t)})),!0)},t.prototype.highlightCellRenderer=function(t,e,n,i,o){if((h.isNumericType(n.type)||h.getStringDataTypes().indexOf(n.type)>=0)&&e){e=n.dataColumn&&n.dataColumn.displayFormat&&et.test(n.dataColumn.displayFormat)?n.dataColumn.displayFormat.replace(et,(function(t,n){return c.numberToStr(e,n)})):e.toLocaleString();var r=this.highlightText(e.toString());if(r instanceof HTMLElement)return i.title=e,void i.appendChild(r)}t(e,n,i,o)},t.prototype.highlightText=function(t){var e=t.toLowerCase(),n=this.filter.getValue().toString();if(n&&n.length>0&&t&&t.length>0){for(var i=[],o=n.split("||").map((function(t){return t.trim().toLowerCase()})),r=0;r<o.length;r++){var s=0,a=o[r];if(a.length){if(a===e)return(p=document.createElement("span")).style.backgroundColor="yellow",p.innerText=t,p;for(;s<t.length-1;){var l=e.indexOf(a,s);l>=0?(i.push({index:l,length:o[r].length}),s=l+a.length):s++}}}if(i.length>0){i.sort((function(t,e){return t.index>e.index?1:t.index==e.index2?0:-1}));for(r=0;r<i.length-1;){var u=i[r+1].index-(i[r].index+i[r].length);if(u<0){var d=i[r+1].length+u;d>0&&(i[r].length+=d),i.splice(r+1,1)}else r++}var c=document.createElement("div");for(r=0;r<i.length;r++){if(0===r){var h=document.createTextNode(t.substring(0,i[r].index));c.appendChild(h)}var p;(p=document.createElement("span")).style.backgroundColor="yellow",p.innerText=t.substring(i[r].index,i[r].index+i[r].length),c.appendChild(p);var f=r<i.length-1?document.createTextNode(t.substring(i[r].index+i[r].length,i[r+1].index)):document.createTextNode(t.substring(i[r].index+i[r].length));c.appendChild(f)}return c}}return t},t}(),Bt=function(){return Bt=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Bt.apply(this,arguments)},Ht=_.a.IsIE(),Vt=function(){function t(t,e){this.context=t,this.params=e,this.params=e||{},this.reset()}return t.prototype.reset=function(){this.form=new Ft(this.context)},t.prototype.setupLookupField=function(t,e,n,i){var o=this,r=this.context.getMetaData().getRootEntity().subEntities.filter((function(t){return t.id==e.lookupEntity}))[0],s=this.context.getMetaData().getAttributeById(e.dataAttr);if(s){n=n||!s.isEditable,i=this.params.values?this.params.values.getValue(s.id):void 0;var a,l=Ht?"kfrm-fields-ie is-horizontal":"kfrm-fields is-horizontal";W(t).addChild("div",(function(t){t.addClass(l).addChild("input",(function(t){a=t.toDOM(),t.attr("readonly",""),t.name(s.id),t.type(o.resolveInputType(s.dataType)),t.value(h.IsDefinedAndNotNull(i)?i.toString():"")})),n||t.addChild("button",(function(t){return t.addClass("kfrm-button").attr("title",c.getText("NavigationBtnTitle")).addText("...").on("click",(function(n){var i=new O({loader:{loadChunk:function(t){return o.context.getDataLoader().loadChunk(Bt(Bt({},t),{id:r.id}))}}});o.context.getDataLoader().loadChunk({offset:0,limit:1e3,needTotal:!0,sourceId:r.id}).then((function(n){for(var s,l=function(t){var e=r.attributes.filter((function(e){return e.id==t.id&&(e.isPrimaryKey||e.showInLookup)}));e.length&&i.columns.add(t)},u=0,d=n.table.columns.getItems();u<d.length;u++){l(d[u])}i.setTotal(n.total);for(var h=0,p=n.table.getCachedRows();h<p.length;h++){var f=p[h];i.addRow(f)}var g,m=new Et,y=null,v=null,b=W("div").addClass("kfrm-form").addChild("div",(function(t){return t.addClass("kfrm-field").addChild("label",(function(t){return t.addText(c.getText("LookupSelectedItem")).toDOM()})).addChild("div",(function(t){return v=t.addText("None").toDOM()}))})).addChild("div",(function(t){return g=t.toDOM()})).addChild("div",(function(t){return t.addClass("kfrm-control").addChild("div",(function(t){return y=t.toDOM()}))})).toDOM(),C=a.value,w=function(t){v.innerHTML=i.columns.getItems().map((function(e){return"<b>"+e.label+":</b> "+function(t,e){return t instanceof k?t.getValue(e):t[e.substring(e.lastIndexOf(".")+1)]}(t,e.id)})).join(", ")};if(C){var D=r.getFirstPrimaryAttr(),T=D.id.substring(D.id.lastIndexOf(".")+1);o.context.fetchRecord((s={},s[T]=C,s),r.id).then((function(t){t.entity&&w(t.entity)})).catch((function(t){console.error(t)}))}var x=new pt({slot:y,dataTable:i,fixHeightOnFirstRender:!0,paging:{pageSize:10},onActiveRowChanged:function(t){x.getData().getRow(t.rowIndex).then((function(t){C=t.getValue(e.lookupDataAttr),w(t)}))}});m.open({title:c.getText("LookupDlgCaption").replace("{entity}",r.caption),body:b,arrangeParents:!0,beforeOpen:function(){var t=o.context.createFilter(r.id,x.getData(),!0);new _t(g,x,t,{instantMode:!0,focus:!0})},onSubmit:function(){return a.value=C,!0},onDestroy:function(){x.destroy(),t.toDOM().focus()}})}))}))}))}))}},t.prototype.setupDateTimeField=function(t,e,n,o,r){var s,a=this,l=Ht?"kfrm-fields-ie is-horizontal":"kfrm-fields is-horizontal",u=kt(e.dataType),d=u.replace("yyyy","9999").replace("MM","99").replace("dd","99").replace("HH","99").replace("mm","99").replace("ss","99");W(t).addChild("div",(function(t){t.addClass(l).addChild("input",(function(t){s=t.toDOM(),t.name(e.id),t.type(r?"hidden":a.resolveInputType(e.dataType)),o?t.attr("readonly",""):(t.mask(d),t.on("keypress",(function(t){return a.applySumbit(t)})).on("input",(function(e){t.removeClass("is-invalid");try{h.strToDateTime(s.value,u)}catch(e){t.addClass("is-invalid")}})).on("blur",(function(t){s.value===d.replace(/[9]/g,"_")&&(s.value="")}))),t.value(h.IsDefinedAndNotNull(n)?h.dateTimeToStr(n,u):"")})),o||t.addChild("button",(function(t){return t.addClass("kfrm-button").attr("title",c.getText(e.dataType!==i.Time?"CalendarBtnTitle":"TimerBtnTitle")).addChild("i",(function(t){return t.addClass(e.dataType!==i.Time?"ed-calendar-icon":"ed-timer-icon")})).on("click",(function(t){var n;try{n=s.value.length?e.dataType!==i.Time?h.strToDateTime(s.value,u):h.strToTime(s.value):new Date((new Date).setSeconds(0))}catch(t){n=new Date((new Date).setSeconds(0))}var o={zIndex:9999999999,showCalendar:e.dataType!==i.Time,showTimePicker:e.dataType!==i.Date,onApply:function(t){t.setSeconds(0),t.setMilliseconds(0),s.value=h.dateTimeToStr(t,u)}},r=new Dt(o);r.setDateTime(n),r.show(t.target)})).toDOM()}))}))},t.prototype.setupListField=function(t,e,n,i,o){var r=this;W(t).addChild("div",(function(t){return t.addClass("kfrm-select full-width").addChild("select",(function(t){if(o&&t.attr("readonly",""),t.attr("name",e.id),t.on("keypress",(function(t){return r.applySumbit(t)})),i)for(var s=0;s<i.length;s++){var a=i[s];t.addOption({value:a.id,title:a.text,selected:0===s})}t.value(n)}))}))},t.prototype.setupFileField=function(t,e,n,i){var o=this;W(t).addChild("input",(function(t){n&&t.attr("readonly",""),t.name(e.id).type(o.resolveInputType(e.dataType)),t.attr("accept",i)}))},t.prototype.setupTextField=function(t,e,n,o,r){var s=this;W(t).addChild("input",(function(t){o&&t.attr("readonly",""),t.type(r?"hidden":s.resolveInputType(e.dataType)),t.name(e.id).type(s.resolveInputType(e.dataType)),e.dataType==i.Bool?n&&t.attr("checked",""):t.on("keypress",(function(t){return s.applySumbit(t)})).value(h.IsDefinedAndNotNull(n)?n.toString():"")}))},t.prototype.setupTextArea=function(t,e,n,i){W(t).addChild("textarea",(function(t){i&&t.attr("readonly",""),t.attr("name",e.id),t.setStyle("height","120px"),t.value(h.IsDefinedAndNotNull(n)?n.toString():"")}))},t.prototype.addFormField=function(t,e){var n=this.params.values&&e.kind!==o.Lookup?this.params.values.getValue(e.id):this.params.isEditForm?void 0:e.defaultValue,i=this.resolveEditor(e),r=this.params.isEditForm&&(e.isPrimaryKey||!e.isEditable),s=!e.isNullable;Ht&&(t=W("div",t).addClass("kfrm-field-ie").toDOM()),W(t).addChild("label",(function(t){t.attr("for",e.id),t.addHtml(e.caption+" "+(s?'<sup style="color: red">*</sup>':"")+": "),e.description&&t.addChild("div",(function(t){return t.attr("title",e.description).addClass("question-mark").setStyle("vertical-align","middle").setStyle("display","inline-block")}))}));var a=e.isPrimaryKey;if(e.kind!==o.Lookup)switch(i.tag){case l:this.setupDateTimeField(t,e,n,r,a);break;case u:this.setupListField(t,e,n,i.values,r);break;case d:this.setupFileField(t,e,r,i.accept);break;default:i.multiline?this.setupTextArea(t,e,n,r):this.setupTextField(t,e,n,r,a)}else this.setupLookupField(t,e,r,n)},t.prototype.resolveInputType=function(t){return t===i.Bool?"checkbox":t===i.Blob?"file":"text"},t.prototype.resolveEditor=function(t){var e=t.defaultEditor||new E;return e.tag==s&&(h.getDateDataTypes().indexOf(t.dataType)>=0?e.tag=l:e.tag=a),e},t.prototype.applySumbit=function(t){return 13===t.keyCode&&(this.sumbitCallback&&this.sumbitCallback(),!1)},t.prototype.onSubmit=function(t){return this.sumbitCallback=t,this},t.prototype.build=function(){var t,e=W("div").addClass("kfrm-form").addChild("div",(function(t){return t.addClass("errors-block").toDOM()})).addChild("div",(function(e){e.addClass(Ht?"kfrm-fields-ie col-ie-1-4 label-align-right":"kfrm-fields col-a-1 label-align-right"),t=e})).toDOM();this.form.setHtmlInt(e);for(var n=0,i=this.context.getActiveEntity().attributes;n<i.length;n++){var o=i[n];(this.params.isEditForm||o.showOnCreate)&&((o.isPrimaryKey||!this.params.isEditForm||o.showOnEdit)&&this.addFormField(t.toDOM(),o))}return this.form},t}(),jt=function(){function t(t){this.slot=t,this.hide(),this.slot.classList.add("ed-progress-bar")}return t.prototype.show=function(){this.slot.style.removeProperty("display")},t.prototype.hide=function(){this.slot.style.display="none"},t}(),Gt=function(){function t(t){this.context=t}return t.prototype.loadChunk=function(t){var e=this,n=this.context.resolveEndpoint("FetchDataset",{sourceId:t.sourceId||this.context.getActiveEntity().id});return delete t.sourceId,this.context.startProcess(),this.context.getHttpClient().post(n,t).then((function(e){for(var n=new O({chunkSize:1e3}),i=e.resultSet,o=0,r=i.cols;o<r.length;o++){var s=r[o];n.columns.add(s)}for(var a=0,l=i.rows;a<l.length;a++){var u=l[a];n.addRow(u)}var d=0;return e.meta&&e.meta.totalRecords&&(d=e.meta.totalRecords),{table:n,total:d,hasNext:!t.needTotal||t.offset+t.limit<d}})).finally((function(){e.context.endProcess()}))},t}(),zt=function(){return zt=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},zt.apply(this,arguments)},qt=function(){function t(t){this.endpoints=new Map,this.endpointVarsRegex=/\{.*?\}/g,this.options=t||{},this.http=new D,this.model=new I,this.model.id=t.metaDataId||"__default",this.dataLoader=new Gt(this);var e=zt({loader:this.dataLoader},t.dataTable);this.data=new O(e),this.setDefaultEndpoints(this.options.endpoint||"/api/easydata")}return t.prototype.getActiveEntity=function(){return this.activeEntity},t.prototype.setActiveSource=function(t){this.activeEntity=this.model.getRootEntity().subEntities.filter((function(e){return e.id==t}))[0]},t.prototype.getMetaData=function(){return this.model},t.prototype.getData=function(){return this.data},t.prototype.getDataLoader=function(){return this.dataLoader},t.prototype.createFilter=function(t,e,n){return new F(this.dataLoader,e||this.getData(),t||this.activeEntity.id,n)},t.prototype.loadMetaData=function(){var t=this,e=this.resolveEndpoint("GetMetaData");return this.startProcess(),this.http.get(e).then((function(e){return e.model&&t.model.loadFromData(e.model),t.model})).catch((function(t){return console.error("Error: "+t.message+". Source: "+t.sourceError),null})).finally((function(){t.endProcess()}))},t.prototype.getHttpClient=function(){return this.http},t.prototype.fetchDataset=function(){var t=this;return this.data.clear(),this.dataLoader.loadChunk({offset:0,limit:this.data.chunkSize,needTotal:!0}).then((function(e){for(var n=0,i=e.table.columns.getItems();n<i.length;n++){var o=i[n];t.data.columns.add(o)}t.data.setTotal(e.total);for(var r=0,s=e.table.getCachedRows();r<s.length;r++){var a=s[r];t.data.addRow(a)}return t.data}))},t.prototype.fetchRecord=function(t,e){var n=this,i=this.resolveEndpoint("FetchRecord",{sourceId:e||this.activeEntity.id});return this.startProcess(),this.http.get(i,{queryParams:t}).finally((function(){return n.endProcess()}))},t.prototype.createRecord=function(t,e){var n=this,i=this.resolveEndpoint("CreateRecord",{sourceId:e||this.activeEntity.id});return this.startProcess(),this.http.post(i,t,{dataType:"json"}).finally((function(){return n.endProcess()}))},t.prototype.updateRecord=function(t,e){var n=this,i=this.resolveEndpoint("UpdateRecord",{sourceId:e||this.activeEntity.id});return this.startProcess(),this.http.post(i,t,{dataType:"json"}).finally((function(){return n.endProcess()}))},t.prototype.deleteRecord=function(t,e){var n=this,i=this.resolveEndpoint("DeleteRecord",{sourceId:e||this.activeEntity.id});return this.startProcess(),this.http.post(i,t,{dataType:"json"}).finally((function(){return n.endProcess()}))},t.prototype.setEndpoint=function(t,e){this.endpoints.set(t,e)},t.prototype.setEnpointIfNotExist=function(t,e){this.endpoints.has(t)||this.endpoints.set(t,e)},t.prototype.resolveEndpoint=function(t,e){e=e||{};var n=this.endpoints.get(t);if(!n)throw t+" endpoint is not defined";var i=n.match(this.endpointVarsRegex);if(i)for(var o=0,r=i;o<r.length;o++){var s=r[o],a=s.substring(1,s.length-1),l=e[a];if(!l)if("modelId"==a)l=this.model.getId();else{if("sourceId"!=a)throw"Parameter ["+a+"] is not defined";l=this.activeEntity.id}n=n.replace(s,l)}return n},t.prototype.startProcess=function(){this.options.onProcessStart&&this.options.onProcessStart()},t.prototype.endProcess=function(){this.options.onProcessEnd&&this.options.onProcessEnd()},t.prototype.setDefaultEndpoints=function(t){this.setEnpointIfNotExist("GetMetaData",g(t,"models/{modelId}")),this.setEnpointIfNotExist("FetchDataset",g(t,"models/{modelId}/sources/{sourceId}/fetch")),this.setEnpointIfNotExist("FetchRecord",g(t,"models/{modelId}/sources/{sourceId}/fetch")),this.setEnpointIfNotExist("CreateRecord",g(t,"models/{modelId}/sources/{sourceId}/create")),this.setEnpointIfNotExist("UpdateRecord",g(t,"models/{modelId}/sources/{sourceId}/update")),this.setEnpointIfNotExist("DeleteRecord",g(t,"models/{modelId}/sources/{sourceId}/delete"))},t}(),Ut=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Wt=function(t){function e(){var e=t.call(this)||this;return e.name="Type",e}return Ut(e,t),e.prototype.validate=function(t,e){if(!h.IsDefinedAndNotNull(e)||""==e)return{successed:!0};if(h.isNumericType(t.dataType)){if(!h.isNumeric(e))return{successed:!1,messages:[c.getText("NumberError")]};if(h.isIntType(t.dataType)&&!Number.isInteger(Number.parseFloat(e)))return{successed:!1,messages:[c.getText("IntNumberError")]}}return{successed:!0}},e}(At),Yt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Kt=function(t){function e(){var e=t.call(this)||this;return e.name="Required",e}return Yt(e,t),e.prototype.validate=function(t,e){return t.isNullable||h.IsDefinedAndNotNull(e)&&""!==e?{successed:!0}:{successed:!1,messages:[c.getText("RequiredError")]}},e}(At),Xt=function(){function t(t,e,n,i){var o=this;this.slot=t,this.context=e,this.basePath=n,this.options={showFilterBox:!0,showBackToEntities:!0},this.defaultValidators=[new Kt,new Wt],this.options=h.assignDeep(this.options,i||{}),this.dlg=new Et;var r=this.context.getActiveEntity();if(!r)throw"Can't find active entity for "+window.location.pathname;this.slot.innerHTML+="<h1>"+(r.captionPlural||r.caption)+"</h1>",this.options.showBackToEntities&&W(this.slot).addChild("a",(function(t){return t.attr("href","javascript:void(0)").text("← "+c.getText("BackToEntities")).on("click",(function(t){t.preventDefault(),Ot(o.basePath)}))})),this.renderGrid()}return t.prototype.syncGridColumnHandler=function(t){if(t.dataColumn){var e=this.context.getMetaData().getAttributeById(t.dataColumn.id);e&&(t.isVisible=e.showOnView)}},t.prototype.renderGrid=function(){var t=this;this.context.fetchDataset().then((function(e){var n=document.createElement("div");if(t.slot.appendChild(n),n.id="Grid",t.grid=new pt(h.assignDeep({slot:n,dataTable:e,paging:{pageSize:15,allowPageSizeChange:!0,pageSizeItems:[15,30,50,100,200]},showPlusButton:t.context.getActiveEntity().isEditable,plusButtonTitle:c.getText("AddRecordBtnTitle"),showActiveRow:!1,onPlusButtonClick:t.addClickHandler.bind(t),onGetCellRenderer:t.manageCellRenderer.bind(t),onRowDbClick:t.rowDbClickHandler.bind(t),onSyncGridColumn:t.syncGridColumnHandler.bind(t)},t.options.grid||{})),t.options.showFilterBox){var i,o=W("div").addClass("kfrm-form").setStyle("margin","10px 0px").addChild("div",(function(t){return i=t.toDOM()})).toDOM();t.slot.insertBefore(o,n);var r=t.context.createFilter();t.filterWidget=new _t(i,t.grid,r)}}))},t.prototype.manageCellRenderer=function(t,e){var n=this;if(t.isRowNum)return t.width=110,function(t,e,i,o){var r=W("div",i).addClass("keg-cell-value");n.context.getActiveEntity().isEditable&&r.addChild("a",(function(t){return t.attr("href","javascript:void(0)").text(c.getText("EditBtn")).on("click",(function(t){return n.editClickHandler(t,parseInt(o.getAttribute("data-row-idx")))}))})).addChild("span",(function(t){return t.text(" | ")})).addChild("a",(function(t){return t.attr("href","javascript:void(0)").text(c.getText("DeleteBtn")).on("click",(function(t){return n.deleteClickHandler(t,parseInt(o.getAttribute("data-row-idx")))}))}))}},t.prototype.addClickHandler=function(){var t=this,e=this.context.getActiveEntity(),n=new Vt(this.context).onSubmit((function(){return i.submit()})).build();n.useValidators(this.defaultValidators);var i=this.dlg.open({title:c.getText("AddDlgCaption").replace("{entity}",e.caption),body:n.getHtml(),onSubmit:function(){if(!n.validate())return!1;n.getData().then((function(e){return t.context.createRecord(e)})).then((function(){return t.refreshData()})).catch((function(e){t.processError(e)}))}})},t.prototype.editClickHandler=function(t,e){var n=this;this.grid.getData().getRow(e).then((function(t){t&&n.showEditForm(t)}))},t.prototype.showEditForm=function(t){var e=this,n=this.context.getActiveEntity(),i=new Vt(this.context,{isEditForm:!0,values:t}).onSubmit((function(){return o.submit()})).build();i.useValidators(this.defaultValidators);var o=this.dlg.open({title:c.getText("EditDlgCaption").replace("{entity}",n.caption),body:i.getHtml(),onSubmit:function(){if(!i.validate())return!1;i.getData().then((function(t){return e.context.updateRecord(t)})).then((function(){return e.refreshData()})).catch((function(t){e.processError(t)}))}})},t.prototype.rowDbClickHandler=function(t){this.context.getActiveEntity().isEditable&&this.showEditForm(t.row)},t.prototype.deleteClickHandler=function(t,e){var n=this;this.grid.getData().getRow(e).then((function(t){if(t){var e=n.context.getActiveEntity(),i=e.getPrimaryAttrs(),o=i.map((function(e){return t.getValue(e.id)})),r=i.reduce((function(t,e,n){return t[e.id.substring(e.id.lastIndexOf(".")+1)]=o[n],t}),{});n.dlg.openConfirm(c.getText("DeleteDlgCaption").replace("{entity}",e.caption),c.getText("DeleteDlgMessage").replace("{recordId}",Object.keys(r).map((function(t){return t+":"+r[t]})).join(";"))).then((function(t){t&&n.context.deleteRecord(r).then((function(){return n.refreshData()})).catch((function(t){n.processError(t)}))}))}}))},t.prototype.processError=function(t){this.dlg.open({title:"Ooops, something went wrong",body:t.message,closable:!0,cancelable:!1})},t.prototype.refreshData=function(){var t=this;return this.context.fetchDataset().then((function(){var e=!1;t.filterWidget&&(e=t.filterWidget.applyFilter(!1)),e||t.grid.refresh()}))},t}(),Jt=function(){function t(t,e,n){this.slot=t,this.context=e,this.basePath=n,this.metaData=this.context.getMetaData(),this.slot.innerHTML+="<h1>"+c.getText("RootViewTitle")+"</h1>",this.renderEntitySelector()}return t.prototype.renderEntitySelector=function(){var t=this,e=this.metaData.getRootEntity().subEntities;this.slot&&W(this.slot).addChild("div",(function(n){return n.addClass("ed-root").addChild("div",(function(e){return e.addClass("ed-menu-description").addText(c.getText(t.metaData.isEmpty()?"ModelIsEmpty":"EntityMenuDesc"))})).addChild("ul",(function(n){n.addClass("ed-entity-menu"),e.forEach((function(e){n.addChild("li",(function(n){n.addClass("ed-entity-item").on("click",(function(){Ot(t.basePath+"/"+decodeURIComponent(e.id))})).addChild("div",(function(t){t.addClass("ed-entity-item-caption").addText(e.captionPlural||e.caption)})),e.description&&n.addChild("div",(function(t){t.addClass("ed-entity-item-descr").addText(""+e.description)}))}))}))}))}))},t}(),Zt=function(){function t(t){var e=this;this.options={container:"#EasyDataContainer",basePath:"easydata"},this.onSetLocation=function(){e.setActiveView()},this.attach=function(){window.addEventListener("ed_set_location",e.onSetLocation),window.addEventListener("popstate",e.onSetLocation)},this.options=h.assign(this.options,t||{}),this.options.rootEntity?(this.options.showBackToEntities=!1,this.basePath="/"):this.basePath=this.normalizeBasePath(this.options.basePath),this.setContainer(this.options.container);var n=document.createElement("div"),i=new jt(n),o=this.container.parentElement;o.insertBefore(n,o.firstElementChild),this.context=new qt({endpoint:this.options.endpoint,dataTable:this.options.dataTable,onProcessStart:function(){return i.show()},onProcessEnd:function(){return i.hide()}})}return t.prototype.normalizeBasePath=function(t){t=this.trimSlashes(t);var e=decodeURIComponent(window.location.pathname),n=e.toLocaleLowerCase().indexOf(t);return n>=0?e.substring(0,n+t.length):"/"},t.prototype.trimSlashes=function(t){return t.replace(/^\/|\/$/g,"")},t.prototype.setContainer=function(t){if(!t)throw"Container is undefined";if("string"==typeof t){if(t.length){if("."===t[0]){var e=document.getElementsByClassName(t.substring(1));e.length&&(this.container=e[0])}else"#"===t[0]&&(t=t.substring(1)),this.container=document.getElementById(t);if(!this.container)throw Error("Unrecognized `container` parameter: "+t+"\nIt must be an element ID, a class name (starting with .) or an HTMLElement object itself.")}}else this.container=t},t.prototype.getActiveSourceId=function(){if(this.options.rootEntity)return this.options.rootEntity;var t=decodeURIComponent(window.location.pathname),e=this.basePath.length+1;return e<t.length?t.substring(e):null},t.prototype.run=function(){var t=this;return this.attach(),this.context.loadMetaData().then((function(){t.setActiveView()})).catch((function(t){return console.error(t)}))},t.prototype.setActiveView=function(){this.clear();var t=this.getActiveSourceId();t?(this.context.setActiveSource(t),window.EDView=new Xt(this.container,this.context,this.basePath,this.options)):window.EDView=new Jt(this.container,this.context,this.basePath)},t.prototype.clear=function(){this.container.innerHTML="",this.context.getData().clear()},t.prototype.detach=function(){window.removeEventListener("ed_set_location",this.onSetLocation),window.removeEventListener("popstate",this.onSetLocation)},t}();c.updateDefaultTexts({RequiredError:"Value is required.",NumberError:"Value should be a number",IntNumberError:"Value should be an integer number",DateTimeError:"Invalid date or time value",LookupSelectedItem:"Selected item: ",LookupDlgCaption:"Select {entity}",None:"None",NavigationBtnTitle:"Navigation values",CalendarBtnTitle:"Open calendar",TimerBtnTitle:"Open timer",AddBtnTitle:"Add",AddRecordBtnTitle:"Add record",EditBtn:"Edit",DeleteBtn:"Delete",SelectLink:"[ select ]",AddDlgCaption:"Create {entity}",EditDlgCaption:"Edit {entity}",DeleteDlgCaption:"Delete {entity}",DeleteDlgMessage:"Are you sure you want to remove this record: {{recordId}}?",EntityMenuDesc:"Click on an entity to view/edit its content",BackToEntities:"Back to entities",SearchBtn:"Search",SearchInputPlaceholder:"Search...",RootViewTitle:"Entities",ModelIsEmpty:"No entity was found."})}])}));
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("easydataCRUD",[],e):"object"==typeof exports?exports.easydataCRUD=e():t.easydataCRUD=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(module,__webpack_exports__,__webpack_require__){"use strict";var browserUtils;__webpack_require__.d(__webpack_exports__,"a",(function(){return browserUtils})),function(browserUtils){var _isFirefox=null,_isIE=null;function IsIE(){if(null===_isIE){var t=navigator.userAgent;_isIE=t.indexOf("MSIE ")>-1||t.indexOf("Trident/")>-1}return _isIE}function IsEdge(){return!IsIE()&&eval("!!window.StyleMedia")}function IsFirefox(){if(null===_isFirefox){var t=navigator.userAgent;_isFirefox=t.toLowerCase().indexOf("firefox")>-1}return _isFirefox}browserUtils.IsIE=IsIE,browserUtils.IsEdge=IsEdge,browserUtils.IsFirefox=IsFirefox;var _detectedIsMobileMode=!1,_isMobileMode=void 0,detectIsMobileMode=function(){var t=isMobileMode();_detectedIsMobileMode=window.matchMedia("only screen and (max-width: 840px)").matches||window.matchMedia("only screen and (max-height: 420px)").matches;var e=isMobileMode();e!==t&&mobileModeChangeHandler&&mobileModeChangeHandler(e)},mobileModeChangeHandler;function isMobileMode(){return void 0!==_isMobileMode?_isMobileMode:_detectedIsMobileMode}function setIsMobileMode(t){var e=isMobileMode();_isMobileMode=t;var n=isMobileMode();n!==e&&mobileModeChangeHandler&&mobileModeChangeHandler(n)}function onMobileModeChanged(t){mobileModeChangeHandler=t}function getMobileCssClass(){return isMobileMode()?"k-mobile":null}detectIsMobileMode(),window.addEventListener("resize",(function(){return detectIsMobileMode()})),browserUtils.isMobileMode=isMobileMode,browserUtils.setIsMobileMode=setIsMobileMode,browserUtils.onMobileModeChanged=onMobileModeChanged,browserUtils.getMobileCssClass=getMobileCssClass}(browserUtils||(browserUtils={}))},function(t,e,n){"use strict";var i,o;n.r(e),n.d(e,"TextDataFilter",(function(){return F})),n.d(e,"EntityEditForm",(function(){return Ft})),n.d(e,"EntityEditFormBuilder",(function(){return Vt})),n.d(e,"TextFilterWidget",(function(){return _t})),n.d(e,"ProgressBar",(function(){return jt})),n.d(e,"DataContext",(function(){return qt})),n.d(e,"EasyDataServerLoader",(function(){return Gt})),n.d(e,"Validator",(function(){return At})),n.d(e,"TypeValidator",(function(){return Wt})),n.d(e,"RequiredValidator",(function(){return Kt})),n.d(e,"EasyDataViewDispatcher",(function(){return Zt})),n.d(e,"RootDataView",(function(){return Jt})),n.d(e,"EntityDataView",(function(){return Xt})),function(t){t[t.Unknown=0]="Unknown",t[t.String=1]="String",t[t.Byte=2]="Byte",t[t.Word=3]="Word",t[t.Int32=4]="Int32",t[t.Int64=5]="Int64",t[t.Bool=6]="Bool",t[t.Float=7]="Float",t[t.Currency=8]="Currency",t[t.BCD=9]="BCD",t[t.Date=10]="Date",t[t.Time=11]="Time",t[t.DateTime=12]="DateTime",t[t.Autoinc=13]="Autoinc",t[t.Memo=14]="Memo",t[t.Blob=15]="Blob",t[t.FixedChar=16]="FixedChar",t[t.Guid=17]="Guid",t[t.Geometry=18]="Geometry",t[t.Geography=19]="Geography"}(i||(i={})),function(t){t[t.Data=0]="Data",t[t.Virtual=1]="Virtual",t[t.Lookup=2]="Lookup"}(o||(o={}));var r,s="Unknown",a="EDIT",l="DATETIME",u="LIST",d="FILE";!function(t){t.Trace="TRACE",t.Options="OPTIONS",t.Get="GET",t.Put="PUT",t.Post="POST",t.Delete="DELETE"}(r||(r={}));var c,h,p=function(){function t(t,e){this.xhr=t,this.method=e.method,this.url=e.url,this.headers=e.headers,this.queryParams=e.queryParams,this.data=e.data}return t.prototype.setHeader=function(t,e){this.headers[t]=e},t.prototype.setQueryParam=function(t,e){this.queryParams[t]=e},t.prototype.getXMLHttpRequest=function(){return this.xhr},t.prototype.getResponseHeaders=function(){if(this.xhr.readyState==this.xhr.HEADERS_RECEIVED){for(var t={},e=0,n=this.xhr.getAllResponseHeaders().trim().split(/[\r\n]+/);e<n.length;e++){var i=n[e].split(": "),o=i.shift(),r=i.join(": ");t[o]=r}return t}return{}},t.prototype.open=function(){var t=this;if(this.xhr.readyState===this.xhr.UNSENT){var e=this.url;for(var n in this.queryParams&&Object.keys(this.queryParams).length>0&&(e+=encodeURI("?"+Object.keys(this.queryParams).map((function(e){return e+"="+t.queryParams[e]})).join("&"))),this.xhr.open(this.method,e,!0),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),this.headers)this.xhr.setRequestHeader(n,this.headers[n])}},t.prototype.abort=function(){this.xhr.abort()},t}();function f(t,e){for(var n="",i=0;i<e;i++)n+=t;return n}function g(t,e){var n=t;return null!=n&&n.length>0?("/"!=n.charAt(n.length-1)&&(n+="/"),n+=e):n=e,n}!function(t){var e,n={shortDateFormat:"MM/dd/yyyy",longDateFormat:"dd MMM, yyyy",editDateFormat:"MM/dd/yyyy",shortTimeFormat:"HH:mm",editTimeFormat:"HH:mm",longTimeFormat:"HH:mm:ss",shortMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longMonthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],shortWeekDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longWeekDayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],decimalSeparator:".",currency:"USD"},o={localeId:"en-US",englishName:"English",displayName:"English",texts:{ButtonOK:"OK",ButtonCancel:"Cancel",Yes:"Yes",No:"No",True:"True",False:"False"},settings:n},r={"en-US":o},s=[];function a(t){for(var e=0,n=s;e<n.length;e++){(0,n[e])(t)}}function l(){return e.localeId}function u(t){var n=r[t];n?h.assignDeep(e,n):(e.englishName=t,e.displayName=t,e.texts=h.assignDeep({},o.texts)),e.localeId=t}function d(){return e.settings}function c(t){e.settings||(e.settings=h.assignDeep({},n)),e.settings=h.assignDeep(e.settings,t)}function p(t,n){a(n);var i=e;t&&(n.localeId||(n.localeId=t),(i=r[t])||(i=h.assignDeep({},o),r[t]=i)),h.assignDeep(i,n)}function f(){var t,n,i,o,r,s,a="object"==typeof navigator?navigator.language:void 0;t=a,n=new Date(2020,5,7,19,34,56,88),i=n.toLocaleDateString(t,{year:"numeric",month:"numeric",day:"numeric"}),o=n.toLocaleTimeString(t,{hour:"numeric",minute:"numeric",second:"numeric"}),r=i.replace("07","dd").replace("7","d").replace("06","MM").replace("6","M").replace("2020","yyyy").replace("20","yy"),s=o.replace("19","HH").replace("07","hh").replace("7","h").replace("34","mm").replace("56","ss").replace("PM","tt"),e.settings||(e.settings={}),c({shortDateFormat:r,shortTimeFormat:s})}function g(t){var e,n=d();switch(t){case i.Date:e=n.shortDateFormat;break;case i.Time:e=n.shortTimeFormat;break;default:e=n.shortDateFormat+" "+n.shortTimeFormat}return e}function m(t){var e,n=d();switch(t){case i.Date:e=n.longDateFormat;break;case i.Time:e=n.longTimeFormat;break;default:e=n.longDateFormat+" "+n.longTimeFormat}return e}t.addMapper=function(t){s.push(t)},t.getLocales=function(){var t=[];for(var e in r)t.push({locale:e,englishName:r[e].englishName,displayName:r[e].displayName});return t.sort((function(t,e){return t.englishName>e.englishName?1:t.englishName===e.englishName?0:-1}))},t.getCurrentLocale=l,t.setLocale=function(t){console.warn("This method is deprecated. Use setCurrentLocale instead"),u(t)},t.setCurrentLocale=u,t.getText=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var i=e.texts,o="";if(t&&t.length)for(var r=t.length,s=0;s<r&&"object"==typeof(o=i[t[s]]);s++)i=o;return o},t.getLocaleSettings=d,t.getOneLocaleSetting=function(t){return e.settings[t]},t.getShortMonthName=function(t){var e=d();if(t>0&&t<13)return e.shortMonthNames[t-1];throw"Wrong month number: "+t},t.getLongMonthName=function(t){var e=d();if(t>0&&t<13)return e.longMonthNames[t-1];throw"Wrong month number: "+t},t.getShortWeekDayName=function(t){var e=d();if(t>0&&t<8)return e.shortWeekDayNames.length>=t?e.shortWeekDayNames[t-1]:t.toString();throw"Wrong month number: "+t},t.getLongWeekDayName=function(t){var e=d();if(t>0&&t<8)return e.longWeekDayNames.length>=t?e.longWeekDayNames[t-1]:t.toString();throw"Wrong month number: "+t},t.updateLocaleSettings=c,t.updateLocaleTexts=function(t){"object"==typeof t?(a({localeId:e.localeId,texts:t}),h.assignDeep(e.texts,t)):console.error("Wrong parameter type in updateLocaleTexts function call.The first parameter (localeId) is not necessary. Use updateLocaleTexts(texts) instead")},t.updateDefaultTexts=function(t){for(var n in r){var i=r[n];i.texts=h.assignDeep({},t,i.texts)}e.texts=h.assignDeep({},t,e.texts)},t.updateLocaleInfo=p,t.addLocale=function(t,e){p(t,e)},t.resetLocales=function(){e||(e=h.assignDeep({},o),f())},t.dateTimeToStr=function(t,e,n){return n?"d"==n?n=g(i.Date):"D"==n?n=m(i.Date):"f"==n?n=g(i.DateTime):"F"==n&&(n=m(i.DateTime)):n=g(e),h.dateTimeToStr(t,n)},t.numberToStr=function(e,n){if(n&&n.length>0){var i=n.charAt(0).toUpperCase();if("S"===i)return function(e,n){if(!y[n]){var i=n.split("|").filter((function(t){return t.length>0})).map((function(t){return t.split("=")}));if(y[n]={},i.length>0)if(i[0].length>1)for(var o=0,r=i;o<r.length;o++){var s=r[o];y[n][Number.parseInt(s[1])]=s[0]}else i.forEach((function(t,e){y[n][e]=t[0]}))}var a=y[n];if(void 0!==a[e]){s=a[e];return t.getText(s)||s}return e.toString()}(e,n.slice(1));if(["D","F","C"].indexOf(i)>=0){var o=l();return e.toLocaleString(o,function(t){var e=d(),n=t[0].toUpperCase(),i=t.length>1?Number.parseInt(t.slice(1)):"D"==n?1:2;switch(n){case"D":return{style:"decimal",useGrouping:!1,minimumIntegerDigits:i};case"C":return{style:"currency",currency:e.currency,minimumFractionDigits:i};default:return{style:"decimal",minimumFractionDigits:i,maximumFractionDigits:i}}}(n))}return function(t,e){for(var n=t.toString(),i="",o=n.length-1,r=e.length-1;r>=0;r--){var s=e.charAt(r);"#"===s||"0"===s?o>=0?(i+=n.charAt(o),o--):"0"===s&&(i+=0):i+=s}return i.split("").reverse().join("")}(Math.trunc(e),n)}var r=d();return h.numberToStr(e,r.decimalSeparator)},t.booleanToStr=function(e,n){if(n&&n.length>0&&"S"===n.charAt(0).toUpperCase()){var i=n.slice(1).split("|");if(i.length>1){var o=i[e?1:0];return t.getText(o)||o}}return""+e};var y={}}(c||(c={})),function(t){t.getAllDataTypes=function(){return Object.values(i).filter((function(t){return"number"==typeof t}))},t.getDateDataTypes=function(){return[i.Time,i.Date,i.DateTime]},t.getStringDataTypes=function(){return[i.String,i.Memo,i.FixedChar]};var e=[i.Byte,i.Word,i.Int32,i.Int64,i.Float,i.Currency,i.Autoinc];t.getNumericDataTypes=function(){return e};var n=[i.Byte,i.Word,i.Int32,i.Int64,i.Autoinc];function o(t,e,n){e||(e={});for(var i=0,s=n;i<s.length;i++){var a=s[i];if(a)for(var l in a)if(a.hasOwnProperty(l)){var u=a[l];null!==u&&"object"==typeof u?t.has(u)?e[l]=t.get(u):Array.isArray(u)?(e[l]=r(u),t.set(u,e[l])):(void 0!==e[l]&&null!=e[l]||(e[l]=Object.create(Object.getPrototypeOf(u))),t.set(u,e[l]),o(t,e[l],[u])):e[l]=u}}return e}function r(t){for(var e=[],n=0,i=t;n<i.length;n++){var o=i[n];e.push(o)}return e}t.assign=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var i=0;i<e.length;i++){var o=e[i];if(o)for(var r in o)o.hasOwnProperty(r)&&(t[r]=o[r])}return t},t.assignDeep=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return o(new WeakMap,t,e)},t.getIfDefined=function(t,e){return void 0!==t?t:e},t.IsDefinedAndNotNull=function(t){return null!=t},t.copyArrayTo=function(t,e){for(var n=t.length,i=e.length,o=0;o<n&&o<i;o++)e[o]=t[o]},t.createArrayFrom=r,t.findItemById=function(t,e){for(var n=t.length,i=0;i<n;i++)if(t[i].id===e)return t[i];return null},t.findItemIndexById=function(t,e){for(var n=t.length,i=0;i<n;i++)if(t[i].id===e)return i;return-1},t.indexOfArrayItem=function(t,e){if(t.indexOf)return t.indexOf(e);for(var n=t.length,i=0;i<n;i++)if(e==t[i])return i;return-1},t.moveArrayItem=function(t,e,n){if(e>=t.length)throw"Index out of bounds: "+e;n>=t.length&&(n=t.length-1);var i=t.splice(e,1)[0];t.splice(n,0,i)},t.removeArrayItem=function(t,e){var n=t.indexOf(e);if(-1!=n)return t.splice(n,1)[0]},t.insertArrayItem=function(t,e,n){t.splice(e,0,n)},t.fillArray=function(t,e,n,i){void 0===n&&(n=0);for(var o=t.length>>>0,r=n>>0,s=r<0?Math.max(o+r,0):Math.min(r,o),a=void 0===i?o:i>>0,l=a<0?Math.max(o+a,0):Math.min(a,o);s<l;)t[s]=e,s++;return t},t.shiftToFitWindow=function(t,e){var n=document.getElementsByTagName("body")[0],i=window.innerWidth||document.documentElement.clientWidth||n.clientWidth,o=t+e,r=0;return o>i&&t+(r=i-o-10)<0&&(r=10-t),r},t.isObject=function(t){return null!==t&&("function"==typeof t||"object"==typeof t)},t.isNumericType=function(t){return e.indexOf(t)>=0},t.isIntType=function(t){return n.indexOf(t)>=0},t.isNumeric=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},t.areCompatibleDataTypes=function(t,e){return void 0===t||void 0===e||t==i.Unknown||e==i.Unknown||t==e||t==i.Date&&e==i.DateTime||t==i.DateTime&&e==i.Date},t.isPropSet=function(t,e){return t[e]||t[e.toLowerCase()]||t[e.toUpperCase()]};var s=4,a="0123456789abcdefghijklmnopqrstuvwxyz",l=0x8d60e562e627800;function u(t,e){var n=t.length;if(n>e){var i=n/e,o="";o+=t[0];for(var r=i,s=void 0,a=1;a<n;a++)s=t[a],a+1>r&&(o+=s,r+=i);return o}return t}function d(t,e,n){return t.substr(0,e)+n+t.substr(e+n.length)}function h(t,e){return Math.floor(Math.random()*(e-t))+t}function p(t){var e=parseInt(t);if(isNaN(e))throw'"'+t+'" is not a valid number';return e}t.generateId=function(t){t||(t="easy");var e=t.length>s?function(t,e){var n=t.split("-"),i=1,o=e;n.length<e&&(i=e/n.length,o=n.length);for(var r="",s=0;s<o;s++)r+=u(n[s],i);return r}(t,s):t;e&&e.length>0&&(e+="-");var n=f("",2),i=a.length-1;return n=d(n,0,a[h(0,i)]),e+(n=d(n,1,a[h(0,i)]))+function(t){var e=36,n=14,i=f("",n),o=t;do{i=d(i,n--,a[o%e]),o=Math.floor(o/=e)}while(o>0);return r=i.trim(),r.split("").reverse().join("");var r}(621355968e9+1e4*(new Date).getTime()-l)},t.strToDateTime=function(t,e){if(!t||0==t.length)return new Date;var n=t.replace(/[^a-zA-Z0-9_]/g,"-"),i=e.replace(/[^a-zA-Z0-9_]/g,"-").split("-"),o=n.split("-"),r=i.indexOf("MM"),s=i.indexOf("dd"),a=i.indexOf("yyyy"),l=i.indexOf("HH"),u=i.indexOf("mm"),d=i.indexOf("ss"),c=new Date;try{var h=a>-1&&a<o.length?p(o[a]):c.getFullYear(),f=r>-1&&r<o.length?p(o[r])-1:c.getMonth()-1;if(f>11)throw"";var g=s>-1&&s<o.length?p(o[s]):c.getDate();if(g>function(t,e){return new Date(e,t+1,0).getDate()}(f,h))throw"";var m=l>-1&&l<o.length?p(o[l]):0;if(m>23)throw"";var y=u>-1&&u<o.length?p(o[u]):0;if(y>59)throw"";var v=d>-1&&d<o.length?p(o[d]):0;if(v>59)throw"";return new Date(h,f,g,m,y,v)}catch(e){throw t+" is not a valid date."}},t.strToTime=function(t){var e=t.split(":");try{var n=e.length>0?p(e[0]):0;if(n>23)throw"";var i=e.length>1?p(e[1]):0;if(i>59)throw"";var o=e.length>1?p(e[1]):0;if(o>59)throw"";return new Date(0,0,0,n,i,o)}catch(e){throw t+" is not a valid time."}};var g=/\[([^\]]+)]|y{2,4}|M{1,4}|d{1,2}|H{1,2}|h{1,2}|m{2}|s{2}|t{2}/g;t.dateTimeToStr=function(t,e){var n=t.getFullYear().toString(),i=t.getMonth()+1,o=t.getDate(),r=t.getHours(),s=t.getMinutes(),a=t.getSeconds(),l=r%12||12,u=r>11,d={yyyy:n,yy:n.substring(n.length-2),MMMM:c.getLongMonthName(i),MMM:c.getShortMonthName(i),MM:i<10?"0"+i:i.toString(),M:i.toString(),dd:o<10?"0"+o:o.toString(),d:o.toString(),HH:r<10?"0"+r:r.toString(),H:r.toString(),hh:l<10?"0"+l:l.toString(),h:l.toString(),tt:u?"PM":"AM",mm:s<10?"0"+s:s.toString(),ss:a<10?"0"+a:a.toString()};return e.replace(g,(function(t,e){return e||d[t]}))},t.numberToStr=function(t,e){return e=e||c.getLocaleSettings().decimalSeparator,t.toString().replace(".",e)}}(h||(h={}));var m,y,v=function(){function t(t,e){this.request=t,this.promise=e}return t.prototype.getPromise=function(){return this.promise},t.prototype.getRequest=function(){return this.request},t.prototype.then=function(t,e){return this.promise.then(t,e)},t.prototype.catch=function(t){return this.promise.catch(t)},t.prototype.finally=function(t){return this.promise.finally(t)},t}(),b=(m=function(t,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},m(t,e)},function(t,e){function n(){this.constructor=t}m(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),C=function(){return C=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},C.apply(this,arguments)},w=function(t){function e(e,n){var i=t.call(this,n)||this;return i.status=e,i}return b(e,t),e}(Error),D=function(){function t(){this.defaultHeaders={},this.customPayload=void 0}return Object.defineProperty(t.prototype,"responseBody",{get:function(){return this._responseBody},enumerable:!0,configurable:!0}),t.prototype.get=function(t,e){return this.send(r.Get,t,null,e)},t.prototype.post=function(t,e,n){return this.send(r.Post,t,e,n)},t.prototype.put=function(t,e,n){return this.send(r.Put,t,e,n)},t.prototype.delete=function(t,e,n){return this.send(r.Delete,t,e,n)},t.prototype.send=function(e,n,i,o){var r=this,s=(o=o||{}).dataType||"json",a=o.contentType||"form-data"!==s?"application/json":null;i&&"form-data"!=s&&this.customPayload&&(i.data=h.assignDeep(i.data||{},this.customPayload));var l=new("onload"in new XMLHttpRequest?XMLHttpRequest:window.XDomainRequest),u={method:e,url:n,headers:C(C({},this.defaultHeaders),o.headers||{}),queryParams:o.queryParams||{},data:i};a&&(u.headers["Content-Type"]=a);var d=new p(l,u);this.beforeEachRequest&&(console.warn("HttpClient: 'beforeEachRequest' is deprecated and will be removed in future updates.\n Use 'onRequest' instead"),this.beforeEachRequest(d)),this.onRequest&&this.onRequest(d);var c=d.data&&"string"!=typeof d.data&&"json"==s?JSON.stringify(d.data):d.data;return d.open(),new v(d,new Promise((function(e,i){o.responseType&&(l.responseType=o.responseType),l.onerror=function(t){i(new w(l.status,l.responseText))},l.onreadystatechange=function(){if(4==l.readyState){var o=l.getResponseHeader("Content-Type")||"",s=l.status;if(0===s)i(new w(s,"Network error or the request was aborted"));else if(s>=200&&s<400){var a="arraybuffer"===l.responseType||"blob"===l.responseType?l.response:0==o.indexOf("application/json")?JSON.parse(l.responseText):l.responseText;r._responseBody=a,r.onResponse&&r.onResponse(l),e(a)}else{("arraybuffer"===l.responseType||"blob"===l.responseType?t.decodeArrayBuffer(l.response):Promise.resolve(l.responseText)).then((function(t){var e=0==o.indexOf("application/json")?JSON.parse(t):t;r._responseBody=e;var a=e.message||(404==s?"No such endpoint: "+n:e);i(new w(s,a))}))}}},l.send(c)})))},t.decodeArrayBuffer=function(t){var e=new FileReader;return new Promise((function(n){e.onloadend=function(){e.readyState==FileReader.DONE&&n(e.result)},e.readAsText(new Blob([t]))}))},t}(),T=function(){function t(t){this.isEditable=!0,this.name="",this.caption="",this.description="",this.parent=t,this.attributes=new Array,this.subEntities=new Array}return t.prototype.loadFromData=function(t,e){if(e){if(this.id=e.id,this.name=e.name,this.captionPlural=e.namePlur,this.caption=e.name,this.description=e.desc,void 0!==e.ied&&(this.isEditable=e.ied),this.subEntities=new Array,e.ents)for(var n=0;n<e.ents.length;n++){var i=t.createEntity(this);i.loadFromData(t,e.ents[n]),this.subEntities.push(i)}if(this.attributes=new Array,e.attrs)for(n=0;n<e.attrs.length;n++){var o=t.createEntityAttr(this);o.loadFromData(t,e.attrs[n]),this.attributes.push(o)}}},t.prototype.scan=function(t,e){var n={stop:!1},i=function(o){if(e&&e(o,n),o.attributes)for(var r=o.attributes.length,s=0;s<r&&!n.stop;s++){var a=o.attributes[s];if(t&&t(a,n),n.stop)return}if(o.subEntities){var l=o.subEntities.length;for(s=0;s<l&&!n.stop;s++)i(o.subEntities[s])}};i(this)},t.prototype.getFirstPrimaryAttr=function(){return this.getPrimaryAttrs()[0]},t.prototype.getPrimaryAttrs=function(){return this.attributes.filter((function(t){return t.isPrimaryKey}))},t}(),x=function(){function t(t){this.id="",this.caption="{Unrecognized attribute}",this.dataType=i.String,this.size=0,this.isPrimaryKey=!1,this.isForeignKey=!1,this.isNullable=!0,this.showOnView=!0,this.isEditable=!0,this.showOnCreate=!0,this.showOnEdit=!0,this.showInLookup=!1,this.lookupAttr="",this.expr="",this.entity=t,this.kind=o.Data}return t.prototype.loadFromData=function(t,e){if(e){this.id=e.id,this.description=e.desc,this.caption=e.cptn,this.dataType=e.dtype,this.isPrimaryKey=e.ipk,this.isForeignKey=e.ifk,this.size=e.size,this.lookupAttr=e.lattr,this.lookupEntity=e.lent,this.dataAttr=e.dattr,this.lookupDataAttr=e.ldattr;var n=h.getDateDataTypes().indexOf(this.dataType);this.defaultValue=e.defVal&&n?new Date(e.defVal):e.defVal,this.isNullable=h.getIfDefined(e.nul,this.isNullable),this.isEditable=h.getIfDefined(e.ied,this.isEditable),this.showOnView=h.getIfDefined(e.ivis||e.sov,this.showOnView),this.showOnCreate=h.getIfDefined(e.soc,this.showOnCreate),this.showOnEdit=h.getIfDefined(e.soe,this.showOnEdit),this.showInLookup=h.getIfDefined(e.sil,this.showInLookup),this.kind=e.kind,this.displayFormat=e.dfmt,e.udata&&(this.userData=e.udata),e.edtr&&(this.defaultEditor=t.getEditorById(e.edtr)||t.createValueEditor())}},t}(),E=function(){function t(){this.id="",this.tag=s,this.resType=i.Unknown,this.defValue=""}return t.prototype.loadFromData=function(t){t&&(this.id=t.id,this.tag=t.tag,this.defValue=t.defval,this.resType=t.rtype,this.accept=t.accept,this.multiline=t.multiline,t.subType&&(this.resType=t.subType),t.name&&(this.name=t.name),t.values&&(this.values=t.values))},t.prototype.getValueText=function(t){var e="";if(!this.values)return e;if(Array.isArray(t))for(var n=0,i=this.values;n<i.length;n++){var o=i[n];t.indexOf(o.id)>=0&&(e+=o.text+",")}else for(var r=0,s=this.values;r<s.length;r++){(o=s[r]).id===t&&(e+=o.text+",")}return e&&(e=e.substring(0,e.length-1)),e},t}(),I=function(){function t(){this.mainEntity=null,this.id="__none",this.name="Empty model",this.rootEntity=this.createEntity(),this.displayFormats=new Map}return t.prototype.getMainEntity=function(){return this.mainEntity},t.prototype.createEntity=function(t){return new T(t)},t.prototype.createEntityAttr=function(t){return new x(t)},t.prototype.createValueEditor=function(){return new E},t.prototype.loadFromJSON=function(t){var e=JSON.parse(t);this.loadFromData(e)},t.prototype.loadFromData=function(t){if(this.id=t.id,this.name=t.name,this.version=t.vers,this.editors=new Array,t.editors)for(var e=0;e<t.editors.length;e++){var n=this.createValueEditor();n.loadFromData(t.editors[e]),this.editors.push(n)}if(this.rootEntity.loadFromData(this,t.entroot),this.displayFormats=new Map,t.displayFormats)for(var o in t.displayFormats){var r=i[o],s=t.displayFormats[o]||new Array;this.displayFormats.set(r,s)}},t.prototype.getDisplayFormats=function(){return this.displayFormats},t.prototype.getDisplayFormatsForType=function(t){return this.displayFormats.has(t)?this.displayFormats.get(t):[]},t.prototype.getDefaultFormat=function(t){return this.displayFormats.has(t)?this.displayFormats.get(t).filter((function(t){return t.isdef}))[0]:null},t.prototype.setData=function(t){"string"==typeof t?this.loadFromJSON(t):this.loadFromData(t)},t.prototype.isEmpty=function(){return 0===this.rootEntity.subEntities.length&&0===this.rootEntity.attributes.length},t.prototype.getId=function(){return this.id},t.prototype.getName=function(){return this.name},t.prototype.getRootEntity=function(){return this.rootEntity},t.prototype.getEditorById=function(t){for(var e=0,n=this.editors;e<n.length;e++){var i=n[e];if(i.id===t)return i}return null},t.prototype.getAttributeById=function(t){var e=this.getEntityAttrById(this.getRootEntity(),t);return e||null},t.prototype.checkAttrProperty=function(t,e){var n=this.getAttributeById(t);if(n){if(void 0===n[e])throw"No such property: "+e;return!!n[e]||!!n.lookupAttr&&(t=n.lookupAttr,(n=this.getAttributeById(t))&&n[e])}return!1},t.prototype.getEntityAttrById=function(t,e){var n,i;if(t.attributes){var o=t.attributes.length;for(n=0;n<o;n++)if(t.attributes[n].id==e)return t.attributes[n]}if(t.subEntities){var r=t.subEntities.length;for(n=0;n<r;n++)if(i=this.getEntityAttrById(t.subEntities[n],e))return i}return null},t.prototype.listByEntityWithFilter=function(t,e){var n,i=new Array,o=null;if(t.subEntities)for(var r=t.subEntities.length,s=0;s<r;s++){if(o=t.subEntities[s],!e||e(o,null))(n=c.getText("Entities",o.name))||(n=o.caption),(d=h.assign(this.createEntity(),{id:o.name,text:n,items:[],isEntity:!0})).items=this.listByEntityWithFilter(o,e),d.items.length>0&&i.push(d)}var a=null;if(t.attributes)for(var l=t.attributes.length,u=0;u<l;u++)if(a=t.attributes[u],!e||e(t,a)){(n=c.getText("Attributes",a.id))||(n=a.caption);var d=h.assign(this.createEntity(),{id:a.id,text:n,dataType:a.dataType});i.push(d)}return i},t.prototype.listByEntity=function(t,e,n){e=e||{};var i,o=[],r=[],s=null;if(t.subEntities)for(var a=t.subEntities.length,l=0;l<a;l++)if(s=t.subEntities[l],!n||n(s,null)){i=c.getText("Entities",s.name)||s.caption;var u=h.assign(this.createEntity(),{id:s.name,text:i,items:[],isEntity:!0,description:s.description}),d=h.assign({},e);d.includeRootData=!1,u.items=this.listByEntity(s,d,n),u.items.length>0&&o.push(u)}var p=null;if(t.attributes)for(var f=t.attributes.length,g=0;g<f;g++)p=t.attributes[g],n&&!n(t,p)||(i=c.getText("Attributes",p.id)||p.caption,r.push(h.assign(this.createEntityAttr(t),{id:p.id,text:i,dataType:p.dataType,lookupAttr:p.lookupAttr,description:p.description})));var m,y=function(t,e){return t.text.toLowerCase()==e.text.toLowerCase()?0:t.text.toLowerCase()>e.text.toLowerCase()?1:-1};return e.sortEntities&&(o.sort(y),r.sort(y)),m=e.attrPlacement&&0!=e.attrPlacement?r.concat(o):o.concat(r),2==e.attrPlacement&&m.sort(y),e.includeRootData?((i=c.getText("Entities",t.name))||(i=t.caption),{id:t.name,text:i,items:m}):m},t.prototype.clear=function(){this.rootEntity=this.createEntity(),this.editors=[],this.version=""},t.prototype.addDefaultValueEditors=function(){this.addOrUpdateValueEditor("_DTE",a,i.String).defValue="",this.addOrUpdateValueEditor("_DPDE",l,i.DateTime),this.addOrUpdateValueEditor("_DPTE",l,i.DateTime)},t.prototype.addOrUpdateValueEditor=function(t,e,n){var i=h.findItemById(this.editors,t);return i||((i=this.createValueEditor()).id=t,this.editors.push(i)),i.tag=e,i.resType=n,i},t.prototype.getEntitiesTree=function(t,e){return this.listByEntity(this.getRootEntity(),t,e)},t.prototype.getEntitiesTreeWithFilter=function(t){return this.listByEntityWithFilter(this.getRootEntity(),t)},t.prototype.getFullEntityPathByAttr=function(t,e){return e=e||" ",this.getEntityPathByAttr(this.getRootEntity(),t,e,!0)},t.prototype.getEntityPathByAttr=function(t,e,n,i){if(!t)return"";n=n||" ";var o="";if(t.caption&&!i){var r=c.getText("Entities",t.caption);o=r||t.caption}if(t.attributes)for(var s=t.attributes.length,a=0;a<s;a++)if(t.attributes[a].id==e)return o;if(t.subEntities){var l=t.subEntities.length;for(a=0;a<l;a++){var u=t.subEntities[a],d=this.getEntityPathByAttr(u,e,n,!1);if(""!==d)return""!==o&&(d=o+n+d),d}}return""},t.prototype.getAttributeText=function(t,e){var n=c.getText("Attributes",t.id);if(n||(n=t.caption),!e)return n;var i=this.getFullEntityPathByAttr(t.id," ");return(i?e.replace(new RegExp("{attr}","g"),n).replace(new RegExp("{entity}","g"),i):n).trim()},t.prototype.runThroughEntities=function(t,e){this.getRootEntity().scan(t,e)},t.prototype.getFirstAttributeByFilter=function(t){var e=null;return this.runThroughEntities((function(n,i){t(n)&&(i.stop=!0,e=n)}),null),e},t}(),S=function(){return S=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},S.apply(this,arguments)};!function(){function t(t){this.colStore=t,this.aggregates=[],this.groups=[],this.useGrandTotals=!1,this.useRecordCount=!1,this._caseSensitiveGroups=!1,this.COUNT_FIELD_NAME="GRPRECCNT"}Object.defineProperty(t.prototype,"caseSensitiveGroups",{get:function(){return this._caseSensitiveGroups},set:function(t){this._caseSensitiveGroups=t,this.updateCompareProc()},enumerable:!0,configurable:!0}),t.prototype.updateCompareProc=function(){this.compareValues=this._caseSensitiveGroups?this.strictCompare:this.caseInsensitiveCompare},t.prototype.addGroup=function(t){var e=t.columns||this.colStore.getColumnIds(t.from,t.to);if(!this.colStore.validateColumns(e))throw"Invalid columns: "+e;if(this.hasColumnsInUse(e))throw"Can't add same columns to different groups/aggregates";return this.groups.push(S({columns:e},t)),this},t.prototype.addAggregateColumn=function(t,e){var n="string"==typeof t?t:this.colStore.getColumnIds(t,t)[0];if(this.hasColumnsInUse([n])||!this.colStore.validateAggregate(n,e))throw"Invalid aggregation function for the column: "+n;return this.aggregates.push({colId:n,funcId:e}),this},t.prototype.addGrandTotals=function(){return this.useGrandTotals=!0,this},t.prototype.addCounts=function(){return this.useRecordCount=!0,this},t.prototype.getGroups=function(){var t=this,e=[];return this.groups.map((function(n){return e=e.concat(n.columns),S(S({},n),{columns:Array.from(e),aggregates:Array.from(t.aggregates)})}))},t.prototype.getInternalGroups=function(){return this.groups},t.prototype.lastGroup=function(){var t=this.getGroups();return t[t.length-1]},t.prototype.getAggregates=function(){return this.aggregates},t.prototype.hasAggregates=function(){return this.aggregates.length>0},t.prototype.hasGroups=function(){return this.groups.length>0},t.prototype.hasGrandTotals=function(){return this.useGrandTotals},t.prototype.hasRecordCount=function(){return this.useRecordCount},t.prototype.isEmpty=function(){return!(this.hasAggregates()||this.hasGroups()||this.hasAggregates()||this.hasRecordCount())},t.prototype.drop=function(){console.warn('"drop()" method is obsolete. Use "clear()" instead'),this.clear()},t.prototype.clear=function(){return this.groups=[],this.aggregates=[],this.useGrandTotals=!1,this.useRecordCount=!1,this.caseSensitiveGroups=!1,this},t.prototype.hasColumnsInUse=function(t){for(var e=0,n=this.groups;e<n.length;e++){if(n[e].columns.filter((function(e){return t.indexOf(e)>=0})).length>0)return!0}for(var i=0,o=this.aggregates;i<o.length;i++){var r=o[i];if(t.indexOf(r.colId)>=0)return!0}return!1},t.prototype.needAggrCalculation=function(){return(this.hasAggregates()||this.hasRecordCount())&&(this.hasGrandTotals()||this.hasGroups())},t.prototype.saveToData=function(){return{groups:Array.from(this.groups),ugt:this.useGrandTotals,urc:this.useRecordCount,csg:this.caseSensitiveGroups,aggregates:Array.from(this.aggregates)}},t.prototype.loadFromData=function(t){t&&(void 0!==t.ugt&&(this.useGrandTotals=t.ugt),void 0!==t.urc&&(this.useRecordCount=t.urc),void 0!==t.csg&&(this.caseSensitiveGroups=t.csg),t.groups&&(this.groups=Array.from(t.groups)),t.aggregates&&(this.aggregates=Array.from(t.aggregates)))},t.prototype.buildGroupKey=function(t,e){var n=!this.caseSensitiveGroups,i={};if(t)for(var o=0,r=t.columns;o<r.length;o++){var s=r[o],a=e.getValue(s);n&&"string"==typeof a&&(a=a.toLowerCase()),i[s]=a}return i},t.prototype.strictCompare=function(t,e){return t instanceof Date?t.getTime()===e.getTime():t===e},t.prototype.caseInsensitiveCompare=function(t,e){return t instanceof Date?t.getTime()===e.getTime():("string"==typeof t?t.toLowerCase():t)===("string"==typeof e?e.toLowerCase():e)}}();!function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Center=2]="Center",t[t.Right=3]="Right"}(y||(y={}));var M,P=function(t){if(!t)throw Error("Options are required");if(!t.id)throw Error("Field Id is required");if(!t.label)throw Error("Label is required");this.id=t.id,this.type=h.getIfDefined(t.type,i.String),this.label=t.label,this.originAttrId=t.originAttrId,this.isAggr=t.isAggr||!1,this.displayFormat=t.dfmt,this.groupFooterColumnTemplate=t.gfct,this.style=t.style||{},this.description=t.description,this.calculatedWidth=0},R=function(){function t(){this.items=[],this.mapper={},this._dateColumnIdx=[]}return Object.defineProperty(t.prototype,"count",{get:function(){return this.items.length},enumerable:!0,configurable:!0}),t.prototype.add=function(t){var e;e=t instanceof P?t:new P(t);var n=this.items.length;return this.items.push(e),this.mapper[e.id]=n,[i.Date,i.DateTime,i.Time].indexOf(e.type)>=0&&this._dateColumnIdx.push(n),n},t.prototype.updateDateColumnIdx=function(){this._dateColumnIdx=this.getItems().filter((function(t){return[i.Date,i.DateTime,i.Time].indexOf(t.type)>=0})).map((function(t,e){return e}))},t.prototype.put=function(t,e){t>=0&&t<this.count&&(this.items[t]=e,this.updateDateColumnIdx())},t.prototype.move=function(t,e){var n=this.items.indexOf(t);n>=0&&n!=e&&(h.moveArrayItem(this.items,n,e),this.updateDateColumnIdx())},t.prototype.get=function(t){return t>=0&&t<this.count?this.items[t]:null},t.prototype.getIndex=function(t){return this.mapper[t]},t.prototype.getItems=function(){return this.items},t.prototype.getDateColumnIndexes=function(){return this._dateColumnIdx},t.prototype.removeAt=function(t){var e=this.get(t);this.items.splice(t,1);var n=this._dateColumnIdx.indexOf(t);n>=0&&this._dateColumnIdx.splice(n,1),delete this.mapper[e.id]},t.prototype.clear=function(){this.items=[],this._dateColumnIdx=[],this.mapper={}},t}(),k=function(){function t(t,e){this.columns=t,this.values=e}return t.prototype.toArray=function(){return Array.from(this.values)},t.prototype.size=function(){return this.values.length},t.prototype.getValue=function(t){var e;if("string"==typeof t){if(void 0===(e=this.columns.getIndex(t)))throw new RangeError("No column with id '"+t+"'")}else e=t;if(e>=this.values.length)throw new RangeError("Out of range: "+e);return this.values[e]},t.prototype.setValue=function(t,e){var n;if("string"==typeof t){if(void 0===(n=this.columns.getIndex(t)))throw new RangeError("No column with id '"+t+"'")}else n=t;if(n>=this.values.length)throw new RangeError("Out of range: "+n);this.values[n]=e},t}(),O=function(){function t(t){if(this._chunkSize=1e3,this._elasticChunks=!1,this.cachedRows=[],this.total=0,this.loader=null,this.needTotal=!0,this.isInMemory=!1,t=t||{},this._chunkSize=t.chunkSize||this._chunkSize,this._elasticChunks=t.elasticChunks||this._elasticChunks,this.loader=t.loader,void 0!==t.inMemory&&(this.isInMemory=t.inMemory),this.isInMemory&&(this.needTotal=!1),this._columns=new R,this.onUpdate=t.onUpdate,t.columns)for(var e=0,n=t.columns;e<n.length;e++){var i=n[e];this._columns.add(i)}if(t.rows)for(var o=0,r=t.rows;o<r.length;o++){var s=r[o],a=this.createRow(s);this.addRow(a)}this.needTotal=!this._elasticChunks}return Object.defineProperty(t.prototype,"columns",{get:function(){return this._columns},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"chunkSize",{get:function(){return this._chunkSize},set:function(t){this._chunkSize=t,this.total=0,this.needTotal=!this.elasticChunks,this.cachedRows=[]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"elasticChunks",{get:function(){return this._elasticChunks},set:function(t){this._elasticChunks=t,this.total=0,this.needTotal=!this.elasticChunks,this.cachedRows=[]},enumerable:!0,configurable:!0}),t.prototype.getRows=function(t){var e=this,n=0,i=this._chunkSize;t&&("page"in t?(n=t.pageSize*(t.page-1),i=t.pageSize):(n=t.offset,i=t.limit));var o=n+i;if(!this.needTotal&&!this.elasticChunks){if(n>=this.total)return Promise.resolve([]);o>this.total&&(o=this.total)}if(this.isInMemory&&o>this.cachedRows.length&&(o=this.cachedRows.length),o<=this.cachedRows.length)return Promise.resolve(this.cachedRows.slice(n,o));if(!this.loader)throw"Loader is not defined. Can't get the rows from "+n+" to "+o;var r=this.needTotal;this.needTotal&&(this.needTotal=!1);var s=this.cachedRows.length,a=o-s;return a<this._chunkSize&&(a=this._chunkSize),this.loader.loadChunk({offset:s,limit:a,needTotal:r}).then((function(t){(r&&(e.total=t.total),Array.prototype.push.apply(e.cachedRows,t.table.getCachedRows()),o>e.cachedRows.length&&(o=e.cachedRows.length),e.elasticChunks)&&(t.table.getCachedCount()<a&&(e.total=e.cachedRows.length));return e.fireUpdated(),e.cachedRows.slice(n,o)}))},t.prototype.getRow=function(t){return this.getRows({offset:t,limit:1}).then((function(t){return t.length>0?t[0]:null}))},t.prototype.getTotal=function(){return this.total},t.prototype.setTotal=function(t){this.total=t,this.needTotal=!1},t.prototype.getCachedCount=function(){return this.cachedRows.length},t.prototype.clear=function(){this.columns.clear(),this.cachedRows=[],this.total=0,this.needTotal=!this._elasticChunks,this.fireUpdated()},t.prototype.createRow=function(t){var e=this,n=this._columns.getDateColumnIndexes(),i=new Array(this._columns.count),o=t instanceof k?function(e){return t.getValue(e)}:function(e){return t[e]};return t&&this.columns.getItems().forEach((function(t){var r=o(t.id),s=e.columns.getIndex(t.id);i[s]=n.indexOf(s)>=0?e.mapDate(r,t.type):r})),new k(this._columns,i)},t.prototype.mapDate=function(t,e){if(t){var n=new Date(t);return isNaN(n.getTime())&&e==i.Time&&(n=h.strToTime(t)),n}return null},t.prototype.addRow=function(t){var e;if(Array.isArray(t)){var n=t,i=this._columns.getDateColumnIndexes();if(i.length>0)for(var o=0,r=i;o<r.length;o++){var s=r[o];n[s]&&(n[s]=this.mapDate(n[s],this._columns.get(s).type))}e=new k(this._columns,n)}else e=this.createRow(t);this.cachedRows.push(e);var a=this.getCachedCount();return a>this.total&&(this.total=a),e},t.prototype.getCachedRows=function(){return this.cachedRows},t.prototype.totalIsKnown=function(){return this.elasticChunks?this.getCachedCount()===this.total:!this.needTotal},t.prototype.fireUpdated=function(){this.onUpdate&&this.onUpdate(this)},t}(),A=function(){function t(){}return t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))},t}(),L=function(){function t(t){this.silentMode=0,this.events=new Array,this.source=t}return t.prototype.subscribe=function(t,e){var n=this.getEventRecByType(t),i={id:A.newGuid(),callback:e};return n?n.eventCallbacks.push(i):(n={type:t,eventCallbacks:new Array(i)},this.events.push(n)),i.id},t.prototype.unsubscribe=function(t,e){var n=this.getEventRecByType(t);if(n){var i=-1;for(i=0;i<n.eventCallbacks.length&&n.eventCallbacks[i].id!==e;i++);i>=0&&n.eventCallbacks.splice(i,1)}},t.prototype.fire=function(t,e,n,i){if(void 0===n&&(n=0),void 0===i&&(i=!1),!this.silentMode||i){var o=this.getEventRecByType(t);if(o){var r={type:t,source:this.source,data:e},s=function(){for(var t=0,e=o.eventCallbacks;t<e.length;t++){e[t].callback(r)}};n>0?setTimeout(s,n):s()}}},t.prototype.enterSilentMode=function(){this.silentMode++},t.prototype.exitSilentMode=function(){this.silentMode&&this.silentMode--},t.prototype.isSilent=function(){return this.silentMode>0},t.prototype.getEventRecByType=function(t){for(var e=0,n=this.events;e<n.length;e++){var i=n[e];if(i.type==t)return i}return null},t}();!function(t){t.renderLiquidTemplate=function(t,e){var n=t;if(e)for(var i in e){var o=new RegExp("{{"+i+"}}","g");n=n.replace(o,e[i])}return n}}(M||(M={})),c.resetLocales(),"function"!=typeof Object.values&&(Object.values=function(t){return Object.keys(t).map((function(e){return t[e]}))}),"function"!=typeof Math.trunc&&(Math.trunc=function(t){return isNaN(t)?NaN:t>0?Math.floor(t):Math.ceil(t)});var N=function(){return N=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},N.apply(this,arguments)},F=function(){function t(t,e,n,i){void 0===i&&(i=!1),this.loader=t,this.sourceTable=e,this.sourceId=n,this.isLookup=i,this.filterValue="",this.justServerSide=!1}return t.prototype.getValue=function(){return this.filterValue},t.prototype.apply=function(t){return this.filterValue=t,this.filterValue?this.applyCore():this.clear()},t.prototype.clear=function(){return this.filterValue="",Promise.resolve(this.sourceTable)},t.prototype.applyCore=function(){var t=this;if(this.sourceTable.getTotal()!=this.sourceTable.getCachedCount()||this.justServerSide){var e=[{class:"__substring",value:this.filterValue}];return this.loader.loadChunk({offset:0,limit:this.sourceTable.chunkSize,needTotal:!0,filters:e,sourceId:this.sourceId,lookup:this.isLookup}).then((function(n){for(var i=new O({chunkSize:t.sourceTable.chunkSize,loader:{loadChunk:function(n){return t.loader.loadChunk(N(N({},n),{filters:e,sourceId:t.sourceId,lookup:t.isLookup}))}}}),o=0,r=t.sourceTable.columns.getItems();o<r.length;o++){var s=r[o];i.columns.add(s)}i.setTotal(n.total);for(var a=0,l=n.table.getCachedRows();a<l.length;a++){var u=l[a];i.addRow(u)}return i}))}return this.applyInMemoryFilter()},t.prototype.applyInMemoryFilter=function(){var t=this;return new Promise((function(e,n){for(var i=new O({chunkSize:t.sourceTable.chunkSize,inMemory:!0}),o=0,r=t.sourceTable.columns.getItems();o<r.length;o++){var s=r[o];i.columns.add(s)}for(var a=t.filterValue.split("||").map((function(t){return t.trim().toLowerCase()})),l=t.sourceTable.columns.getItems().filter((function(t){return h.isNumericType(t.type)||h.getStringDataTypes().indexOf(t.type)>=0})),u=function(t){for(var e=0,n=l;e<n.length;e++){var i=n[e],o=t.getValue(i.id);if(o)for(var r=o.toString().toLowerCase(),s=0,u=a;s<u.length;s++){var d=u[s];if(r.indexOf(d)>=0)return!0}}return!1},d=0,c=t.sourceTable.getCachedRows();d<c.length;d++){var p=c[d];u(p)&&i.addRow(p)}i.setTotal(i.getCachedCount()),e(i)}))},t}(),_=n(0);function B(t){var e={x:0,y:0};if(null!==t){var n=function(t){var e,n={top:0,right:0,bottom:0,left:0,width:0,height:0};try{e=t.getBoundingClientRect()}catch(t){e=n}var i=document.body,o=document.documentElement,r=function(){var t=document.body,e=document.documentElement;return{top:window.pageYOffset||e.scrollTop||t.scrollTop,left:window.pageXOffset||e.scrollLeft||t.scrollLeft}}(),s=r.top,a=r.left,l=o.clientTop||i.clientTop||0,u=o.clientLeft||i.clientLeft||0,d=e.top+s-l,c=e.left+a-u;return{top:Math.round(d),left:Math.round(c)}}(t);e={x:n.left,y:n.top}}return e}var H="eqjs";var V=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),j=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var i=Array(t),o=0;for(e=0;e<n;e++)for(var r=arguments[e],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i},G=function(){function t(t,e){this.element="string"==typeof t?document.createElement(t):t,e&&this.element.parentElement!==e&&e.appendChild(this.element)}return t.prototype.addChild=function(t,e){var n=W(t,this.element);return e&&e(n),this},t.prototype.addChildElement=function(t){return t&&this.element.appendChild(t),this},t.prototype.attr=function(t,e){return this.element.setAttribute(t,e),this},t.prototype.id=function(t){return this.attr("id",t)},t.prototype.focus=function(){return this.element.focus(),this},t.prototype.title=function(t){return this.attr("title",t)},t.prototype.data=function(t,e){return void 0===e&&(e=null),null===e?(this.element.removeAttribute("data-"+t),this):this.attr("data-"+t,e)},t.prototype.show=function(){return this.removeStyle("display")},t.prototype.hide=function(t){return void 0===t&&(t=!0),t?this.setStyle("display","none"):this},t.prototype.visible=function(t){return void 0===t&&(t=!0),t?this.setStyle("visibility","visible"):this.setStyle("visibility","hidden")},t.prototype.isVisible=function(){return!!(this.element.offsetWidth||this.element.offsetHeight||this.element.getClientRects().length)},t.prototype.addClass=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t)for(var i=j(t.trim().split(" "),e),o=0;o<i.length;o++)this.element.classList.add(i[o]);return this},t.prototype.removeClass=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t)for(var i=j(t.trim().split(" "),e),o=0;o<i.length;o++)this.element.classList.remove(i[o]);return this},t.prototype.toggleClass=function(t,e){return void 0===e&&(e=void 0),t&&this.element.classList.toggle(t,e),this},t.prototype.on=function(t,e){for(var n=t.split(" "),i=0;i<n.length;i++)this.element.addEventListener(n[i],e);return this},t.prototype.off=function(t,e){for(var n=t.split(" "),i=0;i<n.length;i++)this.element.removeEventListener(n[i],e);return this},t.prototype.setStyle=function(t,e){return this.element.style.setProperty(t,e),this},t.prototype.removeStyle=function(t){return this.element.style.removeProperty(t),this},t.prototype.text=function(t){return this.element.innerText=t,this},t.prototype.html=function(t){return this.element.innerHTML=t,this},t.prototype.clear=function(){var t=this.element;this.element=document.createElement(this.element.tagName),t.replaceWith(this.element)},t.prototype.addText=function(t){var e=document.createTextNode(t);return this.element.appendChild(e),this},t.prototype.addHtml=function(t){return this.element.innerHTML+=t,this},t.prototype.toDOM=function(){return this.element},t.prototype.appendTo=function(t){return t&&t.appendChild(this.element),this},t}(),z=function(t){function e(e,n){return e?t.call(this,e,n)||this:t.call(this,"textarea",n)||this}return V(e,t),e.prototype.name=function(t){return this.element.name=t,this},e.prototype.rows=function(t){return this.element.rows=t,this},e.prototype.cols=function(t){return this.element.cols=t,this},e.prototype.value=function(t){return this.element.value=t,this},e}(G),q=function(t){function e(e,n){return e?t.call(this,e,n)||this:t.call(this,"input",n)||this}return V(e,t),e.prototype.name=function(t){return this.element.name=t,this},e.prototype.type=function(t){return this.element.type=t,this},e.prototype.size=function(t){return this.element.size=t,this},e.prototype.value=function(t){return t instanceof Date?this.element.valueAsDate=t:"number"==typeof t?this.element.valueAsNumber=t:this.element.value=t,this},e.prototype.mask=function(t){return function(t,e){var n={9:"[0-9]",a:"[a-z]"},i=e.split(""),o=function(e){if("focus"!==e.type||""===t.value){var o=[],r=t.selectionStart;i.forEach((function(e,i){if(n[e]){var r=new RegExp(n[e],"i").test(t.value.charAt(i));o.push(r?t.value.charAt(i):"_")}else o.push(e)})),t.value=o.join(""),t.selectionStart=t.selectionEnd=r}};t.addEventListener("keydown",(function(e){if(8===e.keyCode||46===e.keyCode){e.preventDefault();var o=[],r=t.selectionStart;if(0==r)return;for(var s=r,a=!0,l=i.length-1;l>=0;l--){var u=i[l];if(n[u]){var d=new RegExp(n[u],"i").test(t.value.charAt(l));d&&l!=r-1&&(a=!1),l===r-1&&s--,o.push(d&&l!=r-1?t.value.charAt(l):"_")}else l===s-1&&s--,r-1===l&&r--,o.push(u)}t.value=a?"":o.reverse().join(""),t.selectionStart=t.selectionEnd=s<0?0:s;var c=document.createEvent("Event");c.initEvent("input",!0,!0),t.dispatchEvent(c)}})),t.addEventListener("keypress",(function(e){var o=String.fromCharCode(e.charCode);if(o){e.preventDefault();var r=[],s=t.selectionStart,a=s;i.forEach((function(e,i){if(n[e]){var l=i!=s?t.value.charAt(i):o,u=new RegExp(n[e],"i").test(l);r.push(u?l:"_"),u&&s===i&&a++}else r.push(e),a===i&&a++,s===i&&s++})),t.value=r.join(""),t.selectionStart=t.selectionEnd=a;var l=document.createEvent("Event");l.initEvent("input",!0,!0),t.dispatchEvent(l)}})),t.addEventListener("input",o),t.addEventListener("focus",o)}(this.element,t),this},e}(G),U=function(t){function e(e,n){return e?t.call(this,e,n)||this:t.call(this,"select",n)||this}return V(e,t),e.prototype.addOption=function(t){var e=document.createElement("option");return"string"==typeof t?(e.value=t,e.innerHTML=t):(e.value=t.value,e.innerHTML=t.title||t.value,e.selected=t.selected||!1),this.element.appendChild(e),this},e.prototype.value=function(t){return this.element.value=t,this},e}(G);function W(t,e){return"div"===t||t instanceof HTMLDivElement||"span"===t||t instanceof HTMLSpanElement||"a"===t||t instanceof HTMLAnchorElement||"button"===t||t instanceof HTMLButtonElement||"img"===t||t instanceof HTMLImageElement?new G(t,e):"input"===t||t instanceof HTMLInputElement?new q(t instanceof HTMLInputElement?t:null,e):"textarea"===t||t instanceof HTMLTextAreaElement?new z(t instanceof HTMLTextAreaElement?t:null,e):"select"===t||t instanceof HTMLSelectElement?new U(t instanceof HTMLSelectElement?t:null,e):new G(t,e)}var Y,K="undefined"!=typeof TouchEvent;!function(t){t.None="none",t.Allow="allow",t.Forbid="forbid"}(Y||(Y={}));var X,J=function(t,e,n){this.dropEffect=Y.Allow,this.pageX=0,this.pageY=0,this.item=t,this.dragImage=e,this.data=t.data,this.sourceEvent=n,n&&n instanceof MouseEvent&&(this.pageX=n.pageX,this.pageY=n.pageY),n&&K&&n instanceof TouchEvent&&n.touches[0]&&(this.pageX=n.touches[0].pageX,this.pageY=n.touches[0].pageY)},Z=function(t){t&&t instanceof MouseEvent&&(this.x=t.pageX,this.y=t.pageY),t&&K&&t instanceof TouchEvent&&t.touches[0]&&(this.x=t.touches[0].pageX,this.y=t.touches[0].pageY)},Q=new(function(){function t(){this.delta=5,this.draggableItem=null,this.dragImage=null,this.finishedSuccessfully=!1,this.mouseDownPosition=null,this.containerDescriptors=[],this.containerDescriptorIndex=-1,this.dropEffect=Y.None,this.classPrefix="eqjs-drop",this.DRAG_DISABLED_ATTR="drag-disabled"}return t.prototype.registerDraggableItem=function(t){var e=this,n=t.element;if(!n)throw Error("Element in draggle item is null or undefined");n.ondragstart=function(){return!1};var i=function(t){if(!n.hasAttribute(e.DRAG_DISABLED_ATTR)){t.preventDefault(),t instanceof MouseEvent&&t.stopPropagation();var i=new Z(t);(Math.abs(i.x-e.mouseDownPosition.x)>e.delta||Math.abs(i.y-e.mouseDownPosition.y)>e.delta)&&r(t)}},o=function(t){e.mouseMoveDragListener(t)},r=function(r){r.preventDefault(),r.stopPropagation(),n.removeEventListener("mousemove",i),n.removeEventListener("touchmove",i),e.finishedSuccessfully=!1,t.beforeDragStart&&t.beforeDragStart(),e.dragImage=W("div").setStyle("position","absolute").setStyle("z-index","65530").toDOM(),document.body.appendChild(e.dragImage),e.dragImage.appendChild(n.cloneNode(!0)),t.renderer&&t.renderer(e.dragImage),e.dropEffect=Y.None,e.updateCusror(e.dropEffect),e.updateImageClass(e.dropEffect),e.draggableItem={element:n,scope:t.scope,data:t.data},e.updateDragItemPosition(r);var s=new J(e.draggableItem,e.dragImage,r);s.dropEffect=e.dropEffect,t.onDragStart&&t.onDragStart(s),e.dropEffect!==s.dropEffect&&(e.dropEffect=s.dropEffect,e.updateImageClass(e.dropEffect)),document.addEventListener("mousemove",o,!0),document.addEventListener("touchmove",o,!0)},s=function(t){K&&t instanceof TouchEvent&&t.preventDefault(),e.mouseDownPosition=new Z(t),n.addEventListener("mousemove",i),n.addEventListener("touchmove",i),document.addEventListener("mouseup",a),document.addEventListener("touchend",a)};n.addEventListener("mousedown",s),n.addEventListener("touchstart",s);var a=function(t){e.mouseDownPosition=null,n.removeEventListener("mousemove",i),n.removeEventListener("touchmove",i),document.removeEventListener("mousemove",o,!0),document.removeEventListener("touchmove",o,!0),e.draggableItem&&l(t)},l=function(n){try{if(e.containerDescriptorIndex>=0){var i=e.containerDescriptors[e.containerDescriptorIndex],o={element:i.element,scopes:i.scopes,data:i.data},r=new J(e.draggableItem,e.dragImage,n);try{o.scopes.indexOf(e.draggableItem.scope)>=0&&e.dropEffect===Y.Allow&&(e.finishedSuccessfully=!0,i.onDrop&&i.onDrop(o,r))}finally{i.onDragLeave&&i.onDragLeave(o,r)}}}finally{try{var s=new J(e.draggableItem,e.dragImage,n);s.data.finishedSuccessfully=e.finishedSuccessfully,t.onDragEnd&&t.onDragEnd(s)}finally{e.draggableItem=null,e.dragImage&&e.dragImage.parentElement&&e.dragImage.parentElement.removeChild(e.dragImage),e.dragImage=null,e.finishedSuccessfully=!1,document.removeEventListener("mouseup",a),document.removeEventListener("touchend",a)}}}},t.prototype.registerDropContainer=function(t){if(!t.element)throw Error("Element in drop container is null or undefined");this.containerDescriptors.push(t)},t.prototype.removeDropContainer=function(t){var e=this.containerDescriptors.filter((function(e){return e===t||e.element==t}));if(e)for(var n=0,i=e;n<i.length;n++){var o=i[n];h.removeArrayItem(this.containerDescriptors,o)}},t.prototype.mouseMoveDragListener=function(t){if(t instanceof MouseEvent&&t.preventDefault(),t.stopPropagation(),this.updateDragItemPosition(t),-1==this.containerDescriptorIndex){for(var e=0;e<this.containerDescriptors.length;e++){var n=this.containerDescriptors[e];if(this.detectDragEnterEvent(n.element,t)){this.containerDescriptorIndex=e;break}}this.containerDescriptorIndex>=0&&this.dragEnterEvent(t)}else{n=this.containerDescriptors[this.containerDescriptorIndex];this.detectDragLeaveEvent(n.element,t)&&(this.dragLeaveEvent(t),this.containerDescriptorIndex=-1)}if(this.containerDescriptorIndex>=0){var i={element:(n=this.containerDescriptors[this.containerDescriptorIndex]).element,scopes:n.scopes,data:n.data};if(i.scopes.indexOf(this.draggableItem.scope)>=0){var o=new J(this.draggableItem,this.dragImage,t);o.dropEffect=this.dropEffect,n.onDragOver&&n.onDragOver(i,o)}}},t.prototype.updateCusror=function(t){switch(t){case Y.Allow:this.setCursorStyle(this.dragImage,"grabbing");break;case Y.Forbid:this.setCursorStyle(this.dragImage,"no-drop");break;default:this.setCursorStyle(this.dragImage,"grabbing")}},t.prototype.updateImageClass=function(t){switch(this.dragImage.classList.remove(this.classPrefix+"-allow"),this.dragImage.classList.remove(this.classPrefix+"-forbid"),this.dragImage.classList.remove(this.classPrefix+"-none"),t){case Y.Allow:this.dragImage.classList.add(this.classPrefix+"-allow");break;case Y.None:this.dragImage.classList.add(this.classPrefix+"-none");break;case Y.Forbid:this.dragImage.classList.add(this.classPrefix+"-forbid");break;default:this.dragImage.classList.add(this.classPrefix+"-none")}},t.prototype.setCursorStyle=function(t,e){if(t){t.style.cursor=e;for(var n=0;n<t.children.length;n++)this.setCursorStyle(t.children[n],e)}},t.prototype.updateDragItemPosition=function(t){if(this.dragImage){var e=new Z(t);this.dragImage.style.top=e.y-this.dragImage.offsetHeight/2+"px",this.dragImage.style.left=e.x-this.dragImage.offsetWidth/2+"px"}},t.prototype.dragEnterEvent=function(t){var e=this.containerDescriptors[this.containerDescriptorIndex],n={element:e.element,scopes:e.scopes,data:e.data};if(n.scopes.indexOf(this.draggableItem.scope)>=0){var i=new J(this.draggableItem,this.dragImage,t);i.dropEffect=Y.Allow,e.onDragEnter&&e.onDragEnter(n,i),this.dropEffect=i.dropEffect,this.updateCusror(this.dropEffect),this.updateImageClass(this.dropEffect)}else this.dropEffect!==Y.Forbid&&(this.dropEffect=Y.None,this.updateCusror(this.dropEffect),this.updateImageClass(this.dropEffect))},t.prototype.dragLeaveEvent=function(t){var e=this.containerDescriptors[this.containerDescriptorIndex],n={element:e.element,scopes:e.scopes,data:e.data};if(n.scopes.indexOf(this.draggableItem.scope)>=0){var i=new J(this.draggableItem,this.dragImage,t);i.dropEffect=Y.None,e.onDragLeave&&e.onDragLeave(n,i),this.dropEffect=i.dropEffect,this.updateCusror(this.dropEffect),this.updateImageClass(this.dropEffect)}},t.prototype.detectDragEnterEvent=function(t,e){var n=B(t),i=new Z(e);return!(i.y<n.y||i.y>n.y+t.offsetHeight)&&!(i.x<n.x||i.x>n.x+t.offsetWidth)},t.prototype.detectDragLeaveEvent=function(t,e){var n=B(t),i=new Z(e);return!(i.y>n.y&&i.y<n.y+t.offsetHeight&&i.x>n.x&&i.x<n.x+t.offsetWidth)},t}());!function(t){t[t.Always=0]="Always",t[t.Once=1]="Once",t[t.Never=2]="Never"}(X||(X={}));var $,tt="keg",et=/{0:(.*?)}/g;!function(t){t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.DATETIME=3]="DATETIME",t[t.BOOL=4]="BOOL"}($||($={}));var nt,it=function(t,e,n,i){var o=t?t.toString().replace(/\n/g,"↵ "):"";n.innerText=o,n.title=o,e.align==nt.NONE&&n.classList.add(tt+"-cell-value-align-left")},ot=function(t,e,n,i){var o=(t||"").toString();"number"==typeof t&&(o=e.dataColumn&&e.dataColumn.displayFormat&&et.test(e.dataColumn.displayFormat)?e.dataColumn.displayFormat.replace(et,(function(e,n){return c.numberToStr(t,n)})):t.toLocaleString()),n.innerText=o,n.title=o,e.align==nt.NONE&&n.classList.add(tt+"-cell-value-align-right")},rt=function(t,e,n,o){var r="[object Date]"===Object.prototype.toString.call(t),s=(t||"").toString();if(r)if(e.dataColumn&&e.dataColumn.displayFormat&&et.test(e.dataColumn.displayFormat))s=e.dataColumn.displayFormat.replace(et,(function(n,i){return c.dateTimeToStr(t,e.type,i)}));else{var a=c.getCurrentLocale(),l={hour:"numeric",minute:"numeric",second:"numeric"};switch(e.type){case i.Date:s=t.toLocaleDateString(a);break;case i.Time:s=t.toLocaleTimeString(a,l);break;case i.DateTime:s=t.toLocaleDateString(a)+" "+t.toLocaleTimeString(a,l)}}n.innerText=s,n.title=s,e.align==nt.NONE&&n.classList.add(tt+"-cell-value-align-right")},st=function(t,e,n,i){if(e.dataColumn&&e.dataColumn.displayFormat&&et.test(e.dataColumn.displayFormat)){var o=e.dataColumn.displayFormat.replace(et,(function(e,n){return c.booleanToStr(t,n)}));return it(o,e,n)}n.classList.add(tt+"-cell-value-bool"),n.classList.add(tt+"-"+(t?"cell-value-true":"cell-value-false"))},at=function(){function t(t){this.renderers={},this.defaultRenderers={},this.registerRenderer("StringDefault",it),this.setDefaultRenderer($.STRING,it),this.registerRenderer("NumberDefault",ot),this.setDefaultRenderer($.NUMBER,ot),this.registerRenderer("DateTimeDefault",rt),this.setDefaultRenderer($.DATETIME,rt),this.registerRenderer("BoolDefault",st),this.setDefaultRenderer($.BOOL,st)}return t.prototype.getDefaultRenderer=function(t){var e=this.getCellType(t);return this.defaultRenderers[$[e]]},t.prototype.getDefaultRendererByType=function(t){return this.defaultRenderers[$[t]]},t.prototype.setDefaultRenderer=function(t,e){e&&(this.defaultRenderers[$[t]]=e)},t.prototype.getRenderer=function(t){return this.renderers[t]},t.prototype.registerRenderer=function(t,e){this.renderers[t]=e},t.prototype.getCellType=function(t){switch(t){case i.Autoinc:case i.Byte:case i.Word:case i.Currency:case i.Float:case i.Int32:case i.Int64:return $.NUMBER;case i.Date:case i.DateTime:case i.Time:return $.DATETIME;case i.Bool:return $.BOOL;default:return $.STRING}},t}();!function(t){t[t.NONE=1]="NONE",t[t.LEFT=2]="LEFT",t[t.CENTER=3]="CENTER",t[t.RIGHT=4]="RIGHT"}(nt||(nt={}));var lt,ut=function(){function t(t,e,n){void 0===n&&(n=!1),this._label=null,this._description=null,this.align=nt.NONE,this.isVisible=!0,this.isRowNum=!1,this.dataColumn=t,this.grid=e;var i=e.options.columnWidths||{};t?(t.style.alignment&&(this.align=function(t){switch(t){case y.Left:return nt.LEFT;case y.Center:return nt.CENTER;case y.Right:return nt.RIGHT;default:return nt.NONE}}(t.style.alignment)),this.width=i&&i[this.type]?i[this.type].default:250,this.cellRenderer=this.grid.cellRendererStore.getDefaultRenderer(t.type),this._description=t.description):n&&(this.isRowNum=!0,this.width=i&&i.rowNumColumn?i.rowNumColumn.default:60,this._label="",this.cellRenderer=this.grid.cellRendererStore.getDefaultRendererByType($.NUMBER)),e&&e.options&&e.options.onGetCellRenderer&&(this.cellRenderer=e.options.onGetCellRenderer(this,this.cellRenderer)||this.cellRenderer)}return Object.defineProperty(t.prototype,"label",{get:function(){return this._label?this._label:this.isRowNum?"":this.dataColumn.label},set:function(t){this._label=this.label},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"description",{get:function(){return this._description},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this.dataColumn?this.dataColumn.type:null},enumerable:!0,configurable:!0}),t}(),dt=function(){function t(t,e){this.items=[],this.grid=e,this.sync(t)}return t.prototype.sync=function(t,e){void 0===e&&(e=!0),this.clear();var n=new ut(null,this.grid,!0);if(this.add(n),e||(n.isVisible=!1),t)for(var i=0,o=t.getItems();i<o.length;i++){var r=o[i],s=new ut(r,this.grid);this.grid.options.onSyncGridColumn&&this.grid.options.onSyncGridColumn(s),this.add(s)}},Object.defineProperty(t.prototype,"count",{get:function(){return this.items.length},enumerable:!0,configurable:!0}),t.prototype.add=function(t){var e=this.items.length;return this.items.push(t),e},t.prototype.put=function(t,e){t>=0&&t<this.items.length&&(this.items[t]=e)},t.prototype.move=function(t,e){var n=this.items.indexOf(t);n>=0&&n!=e&&h.moveArrayItem(this.items,n,e)},t.prototype.get=function(t){return t>=0&&t<this.items.length?this.items[t]:null},t.prototype.getItems=function(){return this.items},t.prototype.removeAt=function(t){this.get(t);this.items.splice(t,1)},t.prototype.clear=function(){this.items=[]},t}(),ct=function(){return ct=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ct.apply(this,arguments)},ht=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var i=Array(t),o=0;for(e=0;e<n;e++)for(var r=arguments[e],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i},pt=function(){function t(t){if(this.cssPrefix="keg",this.pagination={page:1,pageSize:30,total:0},this.paginationOptions={maxButtonCount:10,useBootstrap:!1},this.defaultDataGridOptions={slot:null,dataTable:null,fixHeightOnFirstRender:!1,syncGridColumns:!0,useRowNumeration:!0,allowDragDrop:!1,aggregates:{settings:null,calculator:null},paging:{enabled:!0,pageSize:30,pageSizeItems:[20,30,50,100,200]},columnWidths:{autoResize:X.Always,stringColumns:{min:100,max:500,default:250},numberColumns:{min:60,default:120},boolColumns:{min:50,default:80},dateColumns:{min:80,default:200},otherColumns:{min:100,max:500,default:250},rowNumColumn:{min:40,default:60}},showPlusButton:!1,viewportRowsCount:null,showActiveRow:!0},this.rowsOnPagePromise=null,this.containerInitialHeight=0,this.firstRender=!0,this.prevRowTotals=null,this.landingIndex=-1,this.landingSlot=W("div").addClass(this.cssPrefix+"-col-landing-slot").addChildElement(W("div").toDOM()).toDOM(),this._activeRowIndex=-1,t&&t.paging&&(t.paging=h.assign(this.defaultDataGridOptions.paging,t.paging)),this.options=this.mergeOptions(t),this.processColumnWidthsOptions(),!this.options.slot)throw Error('"slot" parameter is required to initialize EasyDataGrid');if(!this.options.dataTable)throw Error('"dataTable" parameter is required to initialize EasyDataGrid');this.dataTable=t.dataTable,this.eventEmitter=new L(this),this.cellRendererStore=new at(t),this.columns=new dt(this.dataTable.columns,this),this.setSlot(this.options.slot),this.init(this.options)}return t.prototype.mergeOptions=function(t){var e=h.assignDeep({},this.defaultDataGridOptions.columnWidths,t.columnWidths),n=h.assignDeep({},this.defaultDataGridOptions.paging,t.paging),i=h.assign({},this.defaultDataGridOptions,t);return i.columnWidths=e,i.paging=n,i},t.prototype.processColumnWidthsOptions=function(){var t=this.options.columnWidths;if(t){h.getStringDataTypes().forEach((function(e){t[e]=ct(ct({},t.stringColumns),t[e])})),h.getNumericDataTypes().forEach((function(e){t[e]=ct(ct({},t.numberColumns),t[e])})),t[i.Bool]=ct(ct({},t.boolColumns),t[i.Bool]),h.getDateDataTypes().forEach((function(e){t[e]=ct(ct({},t.dateColumns),t[e])}));var e=ht(h.getStringDataTypes(),h.getNumericDataTypes(),h.getDateDataTypes(),[i.Bool]);h.getAllDataTypes().forEach((function(n){n in e||(t[n]=ct(ct({},t.otherColumns),t[n]))})),t[i.Unknown]=t.otherColumns}},t.prototype.setSlot=function(t){if("string"==typeof t){if(t.length)if("#"===t[0])this.slot=document.getElementById(t.substring(1));else{if("."!==t[0])throw Error("Unrecognized slot parameter (Must be id, class or HTMLElement): "+t);var e=document.getElementsByClassName(t.substring(1));e.length&&(this.slot=e[0])}}else this.slot=t},t.prototype.init=function(t){var e=this;t.onInit&&this.addEventListener("init",t.onInit),t.onRowClick&&this.addEventListener("rowClick",t.onRowClick),t.onRowDbClick&&this.addEventListener("rowDbClick",t.onRowDbClick),t.onPlusButtonClick&&this.addEventListener("plusButtonClick",t.onPlusButtonClick),t.onColumnChanged&&this.addEventListener("columnChanged",t.onColumnChanged),t.onColumnDeleted&&this.addEventListener("columnDeleted",t.onColumnDeleted),t.onColumnMoved&&this.addEventListener("columnMoved",t.onColumnMoved),t.onPageChanged&&this.addEventListener("pageChanged",t.onPageChanged),t.onActiveRowChanged&&this.addEventListener("activeRowChanged",t.onActiveRowChanged),this.addEventListener("pageChanged",(function(t){return e.activeRowIndex=-1})),h.assignDeep(this.paginationOptions,t.pagination),this.pagination.pageSize=this.options.paging.pageSize||this.pagination.pageSize,this.options.allowDragDrop&&Q.registerDropContainer({element:this.slot,scopes:["gridColumnMove"],onDragEnter:function(t,n){e.slot.classList.add(H+"-drophover"),e.showLandingSlot(n.pageX,n.pageY)},onDragOver:function(t,n){e.showLandingSlot(n.pageX,n.pageY)},onDragLeave:function(t,n){n.dropEffect=Y.Forbid,e.slot.classList.remove(H+"-drophover"),e.hideLandingSlot()},onDrop:function(t,n){e.dataTable.columns.move(n.data.column,e.landingIndex),e.refresh(),e.fireEvent({type:"columnMoved",columnId:n.data.column.id,newIndex:e.landingIndex})}}),this.refresh(),this.fireEvent("init")},t.prototype.fireEvent=function(t){"string"==typeof t?this.eventEmitter.fire(t):this.eventEmitter.fire(t.type,t)},t.prototype.setData=function(t){this.dataTable=t,this.clear(),this.refresh()},t.prototype.getData=function(){return this.dataTable},t.prototype.getColumns=function(){return this.columns},t.prototype.destroy=function(){this.slot.innerHTML=""},t.prototype.refresh=function(){this.clearDOM(),this.render()},t.prototype.clearDOM=function(){this.slot.innerHTML=""},t.prototype.clear=function(){this.pagination.page=1,this.clearDOM()},t.prototype.render=function(){var t=this;if(this.hasData()||this.options.showPlusButton){this.containerInitialHeight=this.slot.clientHeight,this.rootDiv=document.createElement("div"),this.rootDiv.style.width="100%",this.rootDiv.classList.add(this.cssPrefix+"-root"),this.columns.sync(this.dataTable.columns,this.options.useRowNumeration),this.renderHeader(),this.rootDiv.appendChild(this.headerDiv),this.renderBody(),this.rootDiv.appendChild(this.bodyDiv),this.renderFooter(),this.rootDiv.appendChild(this.footerDiv);var e=document.createElement("div");e.classList.add(this.cssPrefix+"-container"),e.appendChild(this.rootDiv),this.slot.appendChild(e);var n=this.options.columnWidths.autoResize!==X.Never;this.rowsOnPagePromise?this.rowsOnPagePromise.then((function(){return t.updateHeight()})).then((function(){t.firstRender=!1,t.rowsOnPagePromise=null})):setTimeout((function(){t.updateHeight().then((function(){t.firstRender=!1,n&&t.resizeColumns()}))}),100)}},t.prototype.updateHeight=function(){var t=this;return new Promise((function(e){if(t.options.viewportRowsCount){var n=t.bodyCellContainerDiv.firstElementChild,i=(n?n.offsetHeight:36)*t.options.viewportRowsCount;return W(t.bodyViewportDiv).setStyle("height",i+"px"),void setTimeout((function(){var n=t.bodyViewportDiv.offsetHeight-t.bodyViewportDiv.clientHeight;i+=n,W(t.bodyViewportDiv).setStyle("height",i+"px"),e()}),100)}t.containerInitialHeight,e()})).then((function(){t.options.fixHeightOnFirstRender&&t.firstRender&&(t.slot.style.height=t.slot.offsetHeight+"px")}))},t.prototype.getContainerWidth=function(){return this.columns.getItems().filter((function(t){return t.isVisible})).map((function(t){return t.width})).reduce((function(t,e){return t+e}))},t.prototype.renderHeader=function(){var t=this;this.headerDiv=W("div").addClass(this.cssPrefix+"-header").toDOM(),this.headerViewportDiv=W("div",this.headerDiv).addClass(this.cssPrefix+"-header-viewport").toDOM(),this.headerCellContainerDiv=W("div",this.headerViewportDiv).addClass(this.cssPrefix+"-header-cell-container").toDOM(),this.headerRowDiv=W("div",this.headerCellContainerDiv).addClass(this.cssPrefix+"-header-row").toDOM(),this.columns.getItems().forEach((function(e,n){if(e.isVisible){var i=t.renderColumnHeader(e,n);t.headerRowDiv.appendChild(i),e.isRowNum&&W(i).addChildElement(t.renderHeaderButtons())}}));var e=this.getContainerWidth();W(this.headerCellContainerDiv).setStyle("width",e+"px")},t.prototype.hasData=function(){return this.dataTable.columns.count>0},t.prototype.renderColumnHeader=function(t,e){var n=this,i=W("div").addClass(this.cssPrefix+"-header-cell").data("col-idx",""+e).setStyle("width",t.width+"px");t.dataColumn&&i.data("col-id",""+t.dataColumn.id);var o=i.toDOM();return W("div",o).addClass(this.cssPrefix+"-header-cell-resize"),t.isRowNum||W("div",o).addClass(this.cssPrefix+"-header-cell-label").text(t.label),t.description&&W("div",o).addClass("question-mark").title(t.description),this.options.allowDragDrop&&Q.registerDraggableItem({element:o,scope:"gridColumnMove",data:{column:t},renderer:function(e){e.innerHTML="";var i=document.createElement("div");i.innerText=t.label,e.classList.add(n.cssPrefix+"-sortable-helper"),e.appendChild(i)},onDragStart:function(t){t.dropEffect=Y.Allow}}),o},t.prototype.renderBody=function(){var t=this;this.bodyDiv=W("div").addClass(this.cssPrefix+"-body").toDOM(),this.bodyViewportDiv=W("div",this.bodyDiv).addClass(this.cssPrefix+"-body-viewport").attr("tabIndex","0").toDOM(),this.bodyCellContainerDiv=W("div",this.bodyViewportDiv).addClass(this.cssPrefix+"-cell-container").toDOM();var e=this.canShowAggregates();this.dataTable&&(this.showProgress(),this.rowsOnPagePromise=this.getRowsToRender().then((function(n){t.pagination.total=t.dataTable.getTotal(),t.hideProgress(),t.bodyCellContainerDiv.innerHTML="",t.prevRowTotals=null;var i=0;if(n.length){var o=e?t.options.aggregates.settings.getGroups():[];i=n.length<t.pagination.pageSize?n.length:t.pagination.pageSize,n.forEach((function(n,r){if(e&&t.updateTotalsState(o,n),r<i){var s=t.renderRow(n,r);t.bodyCellContainerDiv.appendChild(s)}}));var r=t.options.aggregates&&t.options.aggregates.showGrandTotalsOnEachPage;if(e&&(t.isLastPage()||r)){var s=new k(t.dataTable.columns,new Array(t.dataTable.columns.count));t.updateTotalsState(o,s,!0)}}if(t.options.columnWidths.autoResize!==X.Never)t.resizeColumns();else{var a=t.getContainerWidth();W(t.bodyCellContainerDiv).setStyle("width",a+"px")}return i})).catch((function(t){return console.error(t),0}))),this.bodyViewportDiv.addEventListener("scroll",(function(e){W(t.headerViewportDiv).setStyle("margin-left","-"+t.bodyViewportDiv.scrollLeft+"px")})),this.bodyViewportDiv.addEventListener("keydown",this.onViewportKeydown.bind(this))},t.prototype.isLastPage=function(){return this.dataTable.elasticChunks?this.dataTable.totalIsKnown()&&this.pagination.page*this.pagination.pageSize>=this.pagination.total:this.pagination.page*this.pagination.pageSize>=this.pagination.total},t.prototype.canShowAggregates=function(){if(!this.options||!this.options.aggregates||!this.options.aggregates.settings)return!1;var t=this.options.aggregates.settings;return(t.hasAggregates()||t.hasRecordCount())&&(t.hasGroups()||t.hasGrandTotals())},t.prototype.updateTotalsState=function(t,e,n){void 0===n&&(n=!1);var i=this.options.aggregates.settings;if(this.prevRowTotals&&i.hasGroups()){for(var o=-1,r=1;r<=t.length;r++){for(var s=0,a=t[r-1].columns;s<a.length;s++){var l=a[s];if(!i.compareValues(this.prevRowTotals.getValue(l),e.getValue(l))){o=r;break}}if(-1!==o)break}if(-1!==o)for(r=t.length;r>=o;r--){var u=new k(this.dataTable.columns,this.prevRowTotals.toArray()),d=this.renderTotalsRow(r,u);this.bodyCellContainerDiv.appendChild(d)}}if(n&&i.hasGrandTotals()&&i.hasAggregates()){d=this.renderTotalsRow(0,e);this.bodyCellContainerDiv.appendChild(d)}this.prevRowTotals=e},t.prototype.applyGroupColumnTemplate=function(t,e,n){var i=t.replace(/{{\s*GroupValue\s*}}/g,e?""+e:"-");return i=i.replace(/{{\s*GroupCount\s*}}/g,n?""+n:"-")},t.prototype.renderTotalsRow=function(t,e){var n=this,i=this.options.aggregates.settings,o=t>0?i.getGroups()[t-1]:{columns:[],aggregates:i.getAggregates()},r=W("div").addClass(this.cssPrefix+"-row").addClass(this.cssPrefix+"-row-totals").addClass(this.cssPrefix+"-totals-lv"+t).data("totals-level",""+t).attr("tabindex","-1").toDOM();this.columns.getItems().forEach((function(t,i){if(t.isVisible){var s="",a=t.isRowNum?-1:n.dataTable.columns.getIndex(t.dataColumn.id);!t.isRowNum&&t.dataColumn&&o.columns.indexOf(t.dataColumn.id)>=0&&(s=e.getValue(a)),a==n.dataTable.columns.count-1&&(s=". . . . . ."),r.appendChild(n.renderCell(t,i,s,r))}}));var s=this.options.aggregates.calculator.getAggrContainer(),a=i.getAggregates().map((function(t){return t.colId})),l=i.buildGroupKey(o,e);return s.getAggregateData(t,l).then((function(s){for(var l=0,u=a;l<u.length;l++){var d=u[l];e.setValue(d,s[d])}r.innerHTML="",n.columns.getItems().forEach((function(l,u){if(l.isVisible){var d="",c=l.isRowNum?-1:n.dataTable.columns.getIndex(l.dataColumn.id);if(!l.isRowNum){var h=!1;if(l.dataColumn){var p=o.columns.indexOf(l.dataColumn.id),f=a.indexOf(l.dataColumn.id);h=t>0?p==o.columns.length-1:0==c,(p>=0||f>=0)&&(d=e.getValue(c))}var g="";if(t>0&&!(g=l.dataColumn.groupFooterColumnTemplate)&&i.hasRecordCount()&&h&&(g="{{GroupValue}} ({{GroupCount}})"),g)d=n.renderCell(l,u,d,r).firstChild.innerHTML,d=n.applyGroupColumnTemplate(g,d,s[i.COUNT_FIELD_NAME])}var m=n.renderCell(l,u,d,r);r.appendChild(m)}}))})).catch((function(t){return console.error(t)})),r},t.prototype.onViewportKeydown=function(t){if(this.options.showActiveRow){var e=this.bodyCellContainerDiv.querySelectorAll("."+this.cssPrefix+"-row").length,n=void 0;switch(t.key){case"ArrowLeft":case"ArrowRight":break;case"ArrowUp":t.preventDefault(),n=this.activeRowIndex<0||this.activeRowIndex>=e?e-1:this.activeRowIndex-1,this.activeRowIndex=n>=0?n:0;break;case"ArrowDown":t.preventDefault(),n=this.activeRowIndex<0||this.activeRowIndex>=e?0:this.activeRowIndex+1,this.activeRowIndex=n<e?n:e-1}}},t.prototype.ensureRowVisibility=function(t){var e="number"==typeof t?this.getDataRow(t):t;if(e){var n=e.getBoundingClientRect(),i=this.bodyViewportDiv.getBoundingClientRect(),o=n.top-i.top,r=n.bottom-i.top,s=this.bodyViewportDiv.clientHeight,a=window.innerHeight||document.documentElement.clientHeight;if(o>0&&r<=s&&n.top>0&&n.bottom<a)return;o<0?this.bodyViewportDiv.scrollTop=this.bodyViewportDiv.scrollTop+o:r>s&&(this.bodyViewportDiv.scrollTop=this.bodyViewportDiv.scrollTop+r-s),(n=e.getBoundingClientRect()).top<0?document.documentElement.scrollTop=document.documentElement.scrollTop+n.top:n.bottom>a&&(document.documentElement.scrollTop=document.documentElement.scrollTop+n.bottom-a)}},t.prototype.getRowsToRender=function(){return!1===this.options.paging.enabled?Promise.resolve(this.dataTable.getCachedRows()):this.dataTable.getRows({offset:(this.pagination.page-1)*this.pagination.pageSize,limit:this.pagination.pageSize+1}).catch((function(t){return console.error(t),[]}))},t.prototype.renderFooter=function(){var t=this;this.footerDiv=W("div").addClass(this.cssPrefix+"-footer").toDOM(),this.rowsOnPagePromise&&this.rowsOnPagePromise.then((function(e){t.footerDiv.innerHTML="",t.footerPaginateDiv=t.renderPageNavigator(),t.footerDiv.appendChild(t.footerPaginateDiv);var n=t.renderPageInfoBlock(e);t.footerDiv.appendChild(n)}))},t.prototype.renderPageInfoBlock=function(t){var e=W("div").addClass(this.cssPrefix+"-page-info").toDOM();if(this.dataTable.getTotal()>0){var n=t?(this.pagination.page-1)*this.pagination.pageSize+1:0,i=t?n+t-1:0,o=this.dataTable.getTotal().toString();if(this.dataTable.elasticChunks)this.dataTable.getCachedCount()!==this.dataTable.getTotal()&&(o="?");e.innerHTML=c.getText("GridPageInfo").replace("{FirstPageRecordNum}","<span>"+n.toString()+"</span>").replace("{LastPageRecordNum}","<span>"+i.toString()+"</span>").replace("{Total}","<span>"+o+"</span>")}return e},t.prototype.showProgress=function(){},t.prototype.hideProgress=function(){},t.prototype.getLocalIndexByGlobal=function(t){return this.pagination?t%this.pagination.pageSize:t},t.prototype.getGlobalIndexByLocal=function(t){return this.pagination?(this.pagination.page-1)*this.pagination.pageSize+t:t},t.prototype.renderRow=function(t,e){var n=this,i=this.getGlobalIndexByLocal(e),o=W("div").addClass(this.cssPrefix+"-row").addClass(this.cssPrefix+"-row-"+(e%2==1?"odd":"even")).data("row-idx",""+i).attr("tabindex","-1").on("click",(function(i){n.activeRowIndex=e,n.fireEvent({type:"rowClick",row:t,rowIndex:e,sourceEvent:i})})).on("dblclick",(function(i){n.fireEvent({type:"rowDbClick",row:t,rowIndex:e,sourceEvent:i})}));0==e&&o.addClass(this.cssPrefix+"-row-first");var r=o.toDOM();return this.options.showActiveRow&&e==this.activeRowIndex&&o.addClass(this.cssPrefix+"-row-active"),this.columns.getItems().forEach((function(e,o){if(e.isVisible){var s=e.isRowNum?-1:n.dataTable.columns.getIndex(e.dataColumn.id),a=e.isRowNum?i+1:t.getValue(s);r.appendChild(n.renderCell(e,o,a,r))}})),r},t.prototype.renderCell=function(t,e,n,i){var o=W("div").addClass(this.cssPrefix+"-cell").data("col-idx",""+e).attr("tabindex","-1").setStyle("width",t.width+"px");t.align==nt.LEFT?o.addClass(this.cssPrefix+"-cell-align-left"):t.align==nt.RIGHT?o.addClass(this.cssPrefix+"-cell-align-right"):t.align==nt.CENTER&&o.addClass(this.cssPrefix+"-cell-align-center");var r=o.toDOM(),s=r.appendChild(W("div").addClass(this.cssPrefix+"-cell-value").toDOM());return t.cellRenderer&&t.cellRenderer(n,t,s,i),r},t.prototype.setPage=function(t){this.pagination.page=t,this.fireEvent({type:"pageChanged",page:t}),this.refresh(),this.bodyViewportDiv.focus()},t.prototype.renderPageNavigator=function(){var t=this,e=document.createElement("div");e.className=this.cssPrefix+"-pagination-wrapper";var n=this.dataTable.getTotal();if(this.options.paging&&this.options.paging.enabled&&n>0){var i=this.paginationOptions.useBootstrap?"":this.cssPrefix+"-",o=function(e){var n=e.target;if(n.hasAttribute("data-page")){var i=parseInt(n.getAttribute("data-page"));t.setPage(i)}},r=function(e,n,r,s,a){var l=document.createElement("li");if(l.className=i+"page-item",!s){a&&(l.className+=" active");var u=document.createElement("a");return u.setAttribute("href","javascript:void(0)"),u.innerHTML=n||e.toString(),u.setAttribute("data-page",""+e),u.className=i+"page-link",u.addEventListener("click",o),l.appendChild(u),l}var d=document.createElement("span");if(d.setAttribute("aria-hidden","true"),d.className=i+"page-link",r)l.className+=" disabled";else{if(t.paginationOptions.useBootstrap)(d=document.createElement("a")).setAttribute("href","javascript:void(0)"),d.setAttribute("data-page",""+e);else{var c=document.createElement("a");c.setAttribute("href","javascript:void(0)"),c.setAttribute("data-page",""+e),d=c}d.className=i+"page-link",d.addEventListener("click",o)}return d.innerHTML=n,l.appendChild(d),l};if(this.dataTable.elasticChunks){var s=this.pagination.page||1;(l=document.createElement("ul")).className=i+"pagination";var a=r(s-1,"&laquo;",1==s,!0,!1);l.appendChild(a),a=r(s+1,"&raquo;",this.isLastPage(),!0,!1),l.appendChild(a),e.appendChild(l)}else if(this.pagination.total>this.pagination.pageSize){s=this.pagination.page||1;var l,u=Math.ceil(this.pagination.total/this.pagination.pageSize)||1,d=this.paginationOptions.maxButtonCount||10,h=s-1,p=h-h%d+1,f=p+d-1;f>u&&(f=u),(l=document.createElement("ul")).className=i+"pagination";a=r(p-1,"&laquo;",1==p,!0,!1);l.appendChild(a);for(var g=p;g<=f;g++)a=r(g,g.toString(),!1,!1,g==s),l.appendChild(a);a=r(f+1,"&raquo;",f==u,!0,!1),l.appendChild(a),e.appendChild(l)}if(this.options.paging.allowPageSizeChange){var m=document.createElement("div");m.className=this.cssPrefix+"-page-sizes";var y=document.createElement("div");y.className="kfrm-select "+this.cssPrefix+"-page-sizes-select",m.appendChild(y);var v=document.createElement("select"),b=this.options.paging.pageSizeItems||[],C=new Set(b);C.add(this.options.paging.pageSize||20),Array.from(C).forEach((function(t){var e=document.createElement("option");e.value=t.toString(),e.text=t.toString(),v.appendChild(e)})),v.value=(this.pagination.pageSize||20).toString(),y.appendChild(v),v.addEventListener("change",(function(e){var n=parseInt(e.target.value);t.pagination.pageSize=n,t.pagination.page=1,t.refresh()}));var w=document.createElement("div");w.className=this.cssPrefix+"-page-sizes-label",m.appendChild(w);var D=document.createElement("span");D.innerText=c.getText("GridItemsPerPage"),w.appendChild(D),e.appendChild(m)}}return e},t.prototype.addEventListener=function(t,e){return this.eventEmitter.subscribe(t,(function(t){return e(t.data)}))},t.prototype.removeEventListener=function(t,e){this.eventEmitter.unsubscribe(t,e)},t.prototype.renderHeaderButtons=function(){var t=this;return this.options.showPlusButton?W("div").addClass(this.cssPrefix+"-header-btn-plus").title(this.options.plusButtonTitle||"Add").addChild("a",(function(e){return e.attr("href","javascript:void(0)").on("click",(function(e){e.preventDefault(),t.fireEvent({type:"plusButtonClick",sourceEvent:e})}))})).toDOM():W("span").addText("#").toDOM()},t.prototype.showLandingSlot=function(t,e){for(var n=this.headerRowDiv.querySelectorAll("[class*="+this.cssPrefix+"-table-col]"),i=[],o=1;o<n.length;o++){var r=n[o];"none"!==r.style.display&&i.push(r)}if(0===i.length)return this.landingIndex=0,void this.headerRowDiv.appendChild(this.landingSlot);var s=B(this.landingSlot);if(!(t>=s.x&&t<=s.x+this.landingSlot.offsetWidth)){for(var a=this.landingIndex,l=0,u=i;l<u.length;l++){var d=u[l],c=B(d),h=d.offsetWidth;t>c.x&&t<c.x+h&&(a=parseInt(d.getAttribute("data-col-idx"))-1)}a!=this.landingIndex&&(this.landingIndex=a,this.landingIndex<i.length?this.headerRowDiv.insertBefore(this.landingSlot,i[this.landingIndex]):this.headerRowDiv.appendChild(this.landingSlot))}},t.prototype.hideLandingSlot=function(){var t=this;this.landingIndex=-1,setTimeout((function(){t.landingSlot.parentElement&&t.landingSlot.parentElement.removeChild(t.landingSlot)}),10)},Object.defineProperty(t.prototype,"activeRowIndex",{get:function(){return this._activeRowIndex},set:function(t){if(t!==this._activeRowIndex){var e=this._activeRowIndex;this._activeRowIndex=t,this.updateActiveRow(),this.fireEvent({type:"activeRowChanged",oldValue:e,newValue:this.activeRowIndex,rowIndex:this.getGlobalIndexByLocal(this.activeRowIndex)})}},enumerable:!0,configurable:!0}),t.prototype.updateActiveRow=function(){var t=this;if(this.options.showActiveRow){this.bodyCellContainerDiv.querySelectorAll("[class*="+this.cssPrefix+"-row-active]").forEach((function(e){e.classList.remove(t.cssPrefix+"-row-active")}));var e=this.getActiveRow();e&&(e.classList.add(this.cssPrefix+"-row-active"),this.ensureRowVisibility(this.activeRowIndex))}},t.prototype.getActiveRow=function(){return this.getDataRow(this.activeRowIndex)},t.prototype.getDataRow=function(t){var e=Array.from(this.bodyCellContainerDiv.querySelectorAll("."+this.cssPrefix+"-row:not(."+this.cssPrefix+"-row-totals)"));return t>=0&&t<e.length?e[t]:null},t.prototype.focus=function(){this.bodyViewportDiv.focus()},t.prototype.resizeColumns=function(){if(this.options.columnWidths.autoResize!==X.Never){var t=this.bodyCellContainerDiv.style.width;this.bodyCellContainerDiv.style.visibility="hidden",this.bodyCellContainerDiv.style.width="1px",this.headerRowDiv.style.width="1px";for(var e=0,n=this.columns.getItems(),i=this.headerCellContainerDiv.querySelectorAll("."+this.cssPrefix+"-header-cell"),o=0,r=function(t){var r=n[t];if(!r.isVisible)return"continue";var a=s.options.columnWidths.autoResize!==X.Always&&r.dataColumn?r.dataColumn.calculatedWidth:0,l=s.bodyCellContainerDiv.querySelectorAll("."+s.cssPrefix+'-cell[data-col-idx="'+t+'"] > .'+s.cssPrefix+"-cell-value"),u=0;if(a>0)e+=a,r.width=a,l.forEach((function(t){t.parentElement.style.width=a+"px"})),i[o].style.width=a+"px";else if(0==l.length&&(i[o].style.width=null,i[o].style.whiteSpace="nowrap"),u=i[o].offsetWidth,l.length>0){l.forEach((function(t){t.parentElement.style.width=null;var e=t.parentElement.offsetWidth;e>u&&(u=e)})),u+=3;var d=r.isRowNum?s.options.columnWidths.rowNumColumn.max||500:s.options.columnWidths[r.dataColumn.type].max||2e3,c=r.isRowNum?s.options.columnWidths.rowNumColumn.min||0:s.options.columnWidths[r.dataColumn.type].min||20;u>d&&(u=d),u<c&&(u=c),h.isNumericType(r.type)&&(u=Math.round(1.3*u)),e+=u,r.width=u,l.forEach((function(t){t.parentElement.style.width=u+"px"})),i[o].style.width=u+"px",r.dataColumn&&(r.dataColumn.calculatedWidth=u)}else e+=u;o++},s=this,a=0;a<this.columns.count;a++)r(a);e>0?(this.bodyCellContainerDiv.style.width=e+"px",this.headerCellContainerDiv.style.width=e+"px"):(this.bodyCellContainerDiv.style.width=t,this.headerCellContainerDiv.style.width=t),this.bodyCellContainerDiv.style.visibility=null,this.headerRowDiv.removeAttribute("style")}},t}(),ft=function(){function t(t,e){this.slot=t,this.options=e||{},this.options.yearRange||(this.options.yearRange="c-10:c+10")}return Object.defineProperty(t.prototype,"cssPrefix",{get:function(){return"kdtp-cal"},enumerable:!0,configurable:!0}),t.prototype.setDate=function(t){this.currentDate=new Date(t)},t.prototype.getDate=function(){return new Date(this.currentDate)},t.prototype.dateChanged=function(t){this.options.onDateChanged&&this.options.onDateChanged(this.currentDate,t)},t}(),gt=function(){function t(t){this.calendar=null,this.timePicker=null,this.options=t,this.render()}return Object.defineProperty(t.prototype,"cssPrefix",{get:function(){return"kdtp"},enumerable:!0,configurable:!0}),t.prototype.setDateTime=function(t){this.currentDateTime=new Date(t),this.calendar&&this.calendar.setDate(this.currentDateTime),this.timePicker&&this.timePicker.setTime(this.currentDateTime)},t.prototype.getDateTime=function(){return new Date(this.currentDateTime)},t.prototype.render=function(){var t=this;this.options.showCalendar&&(this.calendar=this.createCalendar({yearRange:this.options.yearRange,showDateTimeInput:this.options.showDateTimeInput,timePickerIsUsed:this.options.showTimePicker,oneClickDateSelection:this.options.oneClickDateSelection,onDateChanged:function(e,n){t.currentDateTime=e,t.timePicker&&t.timePicker.setTime(t.currentDateTime),t.options.showTimePicker&&t.dateTimeChanged(),n&&t.apply(t.currentDateTime)}}),this.calendar&&this.calendar.render()),this.options.showTimePicker&&(this.timePicker=this.createTimePicker({onTimeChanged:function(e){t.currentDateTime.setHours(e.getHours()),t.currentDateTime.setMinutes(e.getMinutes()),t.calendar&&t.calendar.setDate(t.currentDateTime),t.dateTimeChanged()}}),this.timePicker&&this.timePicker.render()),this.setDateTime(new Date)},t.prototype.createCalendar=function(t){return null},t.prototype.createTimePicker=function(t){return null},t.prototype.show=function(t){this.options.beforeShow&&this.options.beforeShow();var e=B(t||document.body);this.slot.style.top=e.y+t.clientHeight+"px",this.slot.style.left=e.x+"px"},t.prototype.apply=function(t){this.options.onApply&&this.options.onApply(t),this.destroy()},t.prototype.cancel=function(){this.options.onCancel&&this.options.onCancel(),this.destroy()},t.prototype.destroy=function(){this.slot&&this.slot.parentElement&&this.slot.parentElement.removeChild(this.slot)},t.prototype.dateTimeChanged=function(){this.options.onDateTimeChanged&&this.options.onDateTimeChanged(this.currentDateTime)},t}(),mt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),yt=function(t){function e(e,n){var i=t.call(this,e,n)||this;i.daysOfWeek=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i.calendarBody=null,i.isManualInputChanging=!1;for(var o=0;o<i.daysOfWeek.length;o++)i.daysOfWeek[o]=c.getShortWeekDayName(o+1);for(o=0;o<i.months.length;o++)i.months[o]=c.getLongMonthName(o+1);return i}return mt(e,t),e.prototype.setDate=function(e){t.prototype.setDate.call(this,e),this.selectedMonth=this.currentDate.getMonth(),this.selectedYear=this.currentDate.getFullYear(),this.rerenderMonth()},e.prototype.render=function(){var t=this,e=W("div",this.slot).addClass(this.cssPrefix+"-header");this.options.showDateTimeInput?e.addChildElement(this.renderManualDateInput()):e.addChild("span",(function(e){return t.headerTextElem=e.toDOM()})),W(this.slot).addChildElement(this.renderCalendarButtons()),this.calendarBody=W("div",this.slot).addClass(this.cssPrefix+"-body").toDOM()},e.prototype.getInputDateFormat=function(){var t=c.getLocaleSettings();return this.options.timePickerIsUsed?t.editDateFormat+" "+t.editTimeFormat:t.editDateFormat},e.prototype.renderManualDateInput=function(){var t=this,e=this.getInputDateFormat(),n=W("input").attr("placeholder",e).addClass(this.cssPrefix+"-header-input");return n.mask(e.replace("yyyy","9999").replace("MM","99").replace("dd","99").replace("HH","99").replace("mm","99").replace("ss","99")).on("input",(function(i){n.removeClass("error");try{t.isManualInputChanging=!0;var o=h.strToDateTime(t.manualInputElem.value,e);t.currentDate=o,t.jump(t.currentDate.getFullYear(),t.currentDate.getMonth()),t.dateChanged(!1)}catch(t){n.addClass("error")}finally{t.isManualInputChanging=!1}})).on("keydown",(function(e){13===e.keyCode&&(e.preventDefault(),e.stopPropagation(),t.manualInputElem.className.indexOf("error")<0&&!t.isManualInputChanging&&t.dateChanged(!0))})).on("focus",(function(){setTimeout((function(){t.manualInputElem.selectionStart=0,t.manualInputElem.selectionEnd=0}),50)})),this.manualInputElem=n.toDOM(),this.manualInputElem},e.prototype.updateDisplayedDateValue=function(){if(this.manualInputElem){if(!this.isManualInputChanging){var t=this.getInputDateFormat();this.manualInputElem.value=h.dateTimeToStr(this.currentDate,t),this.manualInputElem.focus()}}else if(this.headerTextElem){var e=c.getCurrentLocale();this.headerTextElem.innerText=this.currentDate.toLocaleString("en"==e?void 0:e,{year:"numeric",month:"long",day:"numeric"})}},e.prototype.renderCalendarButtons=function(){var t=this;return W("nav").addClass(this.cssPrefix+"-nav").addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-prev").on("click",(function(){t.prev()})).addChild("span",(function(t){return t.html("&lsaquo;")}))})).addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-selectors").addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-month").addChild("select",(function(e){e.on("change",(function(){t.jump(t.selectedYear,parseInt(t.selectMonthElem.value))}));for(var n=function(n){e.addChild("option",(function(e){return e.attr("value",n.toString()).text(t.months[n])}))},i=0;i<t.months.length;i++)n(i);t.selectMonthElem=e.toDOM()}))})).addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-year").addChild("select",(function(e){return t.selectYearElem=e.on("change",(function(){t.jump(parseInt(t.selectYearElem.value),t.selectedMonth)})).toDOM()}))}))})).addChild("div",(function(e){return e.addClass(t.cssPrefix+"-nav-next").on("click",(function(){t.next()})).addChild("span",(function(t){return t.html("&rsaquo;")}))})).toDOM()},e.prototype.prev=function(){this.selectedYear=0===this.selectedMonth?this.selectedYear-1:this.selectedYear,this.selectedMonth=0===this.selectedMonth?11:this.selectedMonth-1,this.rerenderMonth()},e.prototype.next=function(){this.selectedYear=11===this.selectedMonth?this.selectedYear+1:this.selectedYear,this.selectedMonth=(this.selectedMonth+1)%12,this.rerenderMonth()},e.prototype.rerenderSelectYear=function(){var t=/c-(\d*):c\+(\d*)/g.exec(this.options.yearRange),e=0,n=1;null!==t&&(e=parseInt(t[1]),n=parseInt(t[2])),this.selectYearElem.innerHTML="";for(var i=0;i<=e+n;i++){var o=document.createElement("option"),r=this.selectedYear-e+i;o.value=r.toString(),o.innerText=r.toString(),this.selectYearElem.appendChild(o)}},e.prototype.jump=function(t,e){this.selectedYear=t,this.selectedMonth=e,this.rerenderMonth()},e.prototype.rerenderMonth=function(){var t=this;this.updateDisplayedDateValue(),this.rerenderSelectYear();var e=new Date(this.selectedYear,this.selectedMonth).getDay(),n=new Date(this.selectedYear,this.selectedMonth+1,0).getDate();this.calendarBody.innerHTML="",this.selectYearElem.value=this.selectedYear.toString(),this.selectMonthElem.value=this.selectedMonth.toString(),this.daysOfWeek.forEach((function(e,n){W("div",t.calendarBody).addClass(t.cssPrefix+"-weekday").addClass(0==n||6==n?t.cssPrefix+"-weekend":"").text(e)}));for(var i=0;i<e;i++)W("div",this.calendarBody).addClass(this.cssPrefix+"-day-empty");for(var o=new Date,r=1;r<=n;r++){var s=W("div",this.calendarBody).addClass(this.cssPrefix+"-day").attr("data-date",r.toString()).text(r.toString()).on("click",(function(e){t.currentDate.setFullYear(t.selectedYear),t.currentDate.setMonth(t.selectedMonth),t.currentDate.setDate(parseInt(e.target.getAttribute("data-date"))),t.dateChanged(t.options.oneClickDateSelection)}));r===o.getDate()&&this.selectedYear===o.getFullYear()&&this.selectedMonth===o.getMonth()&&s.addClass(this.cssPrefix+"-day-current"),r===this.currentDate.getDate()&&this.selectedYear===this.currentDate.getFullYear()&&this.selectedMonth===this.currentDate.getMonth()&&s.addClass(this.cssPrefix+"-day-selected");var a=(e+r-1)%7;0!=a&&6!=a||s.addClass(this.cssPrefix+"-weekend")}var l=(e+n)%7,u=0==l?0:7-l;for(i=0;i<u;i++)W("div",this.calendarBody).addClass(this.cssPrefix+"-day-empty")},e.prototype.dateChanged=function(e){t.prototype.dateChanged.call(this,e),this.rerenderMonth()},e}(ft),vt=function(){function t(t,e){this.slot=t,this.options=e||{}}return Object.defineProperty(t.prototype,"cssPrefix",{get:function(){return"kdtp-tp"},enumerable:!0,configurable:!0}),t.prototype.setTime=function(t){this.currentTime=new Date(t)},t.prototype.getTime=function(){return new Date(this.currentTime)},t.prototype.timeChanged=function(){this.options.onTimeChanged&&this.options.onTimeChanged(this.currentTime)},t}(),bt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return bt(e,t),e.prototype.setTime=function(e){t.prototype.setTime.call(this,e),this.updateDisplayedTime(),this.hoursInput.valueAsNumber=e.getHours(),this.minutesInput.valueAsNumber=e.getMinutes()},e.prototype.render=function(){var t=this;W("div",this.slot).addClass(this.cssPrefix+"-time").addChild("span",(function(e){return t.timeText=e.toDOM()})).toDOM();var e=W("div",this.slot).addClass(this.cssPrefix+"-sliders");return e.addChild("div",(function(e){return e.addClass(t.cssPrefix+"-time-row").title("Hours").addChild("input",(function(e){return t.hoursInput=e.addClass(t.cssPrefix+"-input-hours").type("range").attr("min","0").attr("max","23").attr("step","1").on("input",(function(e){t.currentTime.setHours(t.hoursInput.valueAsNumber),t.updateDisplayedTime(),t.timeChanged()})).toDOM()}))})),e.addChild("div",(function(e){return e.addClass(t.cssPrefix+"-time-row").title("Minutes").addChild("input",(function(e){return t.minutesInput=e.addClass(t.cssPrefix+"-input-minutes").type("range").attr("min","0").attr("max","59").attr("step","1").on("input",(function(e){t.currentTime.setMinutes(t.minutesInput.valueAsNumber),t.updateDisplayedTime(),t.timeChanged()})).toDOM()}))})),this.slot},e.prototype.updateDisplayedTime=function(){var t=c.getCurrentLocale(),e=this.currentTime.toLocaleString("en"==t?void 0:t,{hour:"numeric",minute:"numeric"});this.timeText.innerText=e},e}(vt),wt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return wt(e,t),e.prototype.render=function(){var e=this,n=W("div",document.body).addClass(""+this.cssPrefix).attr("tabIndex","0").setStyle("position","absolute").setStyle("top","-1000px").setStyle("left","-1000px").on("keydown",(function(t){return 27===t.keyCode?e.cancel():13===t.keyCode&&e.apply(e.getDateTime()),!1}));this.options.zIndex&&n.setStyle("z-index",""+this.options.zIndex),this.slot=n.toDOM(),t.prototype.render.call(this),this.renderButtons(),this.globalMouseDownHandler=function(t){var n=window.event||t;n.srcElement||n.target;return!e.slot.contains(n.target)&&(document.removeEventListener("mousedown",e.globalMouseDownHandler,!0),e.cancel()),!0}},e.prototype.renderButtons=function(){var t=this,e=W("div",this.slot).addClass(this.cssPrefix+"-buttons").addChild("button",(function(e){return t.nowButton=e.addClass(t.cssPrefix+"-button "+t.cssPrefix+"-button-now").text(c.getText("ButtonNow")).on("click",(function(){return t.setDateTime(new Date),t.dateTimeChanged(),!1})).toDOM()}));!this.options.showTimePicker&&this.options.oneClickDateSelection||e.addChild("button",(function(e){return t.submitButton=e.addClass(t.cssPrefix+"-button "+t.cssPrefix+"-button-apply").text(c.getText("ButtonApply")).on("click",(function(){return t.apply(t.getDateTime()),!1})).toDOM()})),e.addChild("button",(function(e){return t.submitButton=e.addClass(t.cssPrefix+"-button "+t.cssPrefix+"-button-cancel").text(c.getText("ButtonCancel")).on("click",(function(){return t.cancel(),!1})).toDOM()}))},e.prototype.createCalendar=function(t){return this.calendarSlot=W("div",this.slot).addClass(this.cssPrefix+"-cal").toDOM(),new yt(this.calendarSlot,t)},e.prototype.createTimePicker=function(t){return this.timePickerSlot=W("div",this.slot).addClass(this.cssPrefix+"-tp").toDOM(),new Ct(this.timePickerSlot,t)},e.prototype.show=function(e){var n=this;if(this.options.showDateTimeInput){this.options.beforeShow&&this.options.beforeShow();var i=B(e||document.body),o=B(e?e.parentElement||e:document.body);this.slot.style.top=o.y+"px",this.slot.style.left=i.x+"px"}else t.prototype.show.call(this,e),this.slot.focus();setTimeout((function(){document.addEventListener("mousedown",n.globalMouseDownHandler,!0)}),1)},e}(gt);!function(t){t[t.Left=1]="Left",t[t.Center=2]="Center",t[t.Right=3]="Right"}(lt||(lt={}));var Tt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),xt="kdlg",Et=function(){function t(){}return t.prototype.openConfirm=function(t,e,n){var i=this,o={title:t,closable:!1,submitable:!0,cancelable:!0,body:'<div id="kdlg-dialog-confirm">'+e+"</div>"};return n?(o.onSubmit=function(){n(!0)},o.onCancel=function(){n(!1)},void this.open(o)):new Promise((function(t){o.onSubmit=function(){t(!0)},o.onCancel=function(){t(!1)},i.open(o)}))},t.prototype.openPrompt=function(t,e,n,i){var o=this,r={title:t,submitable:!0,closable:!0,cancelable:!0,submitOnEnter:!0,body:'<div id="kdlg-dialog-form" class="kfrm-form">\n <div class="kfrm-fields label-above">\n <label for="kdlg-dialog-form-input" id="kdlg-dialog-form-content">'+e+'</label>\n <input type="text" name="'+xt+'-dialog-form-input" id="'+xt+'-dialog-form-input" />\n </div>\n </div>',arrangeParents:!1,beforeOpen:function(){var t=document.getElementById(xt+"-dialog-form-input");n&&(t.value=n),t.focus()}},s=function(t){var e=document.getElementById(xt+"-dialog-form-input"),n=e.value;return n&&n.replace(/\s/g,"").length>0?(t(n),!0):(e.classList.add("eqjs-invalid"),!1)};return i?(r.onSubmit=function(){return s(i)},r.onCancel=function(){i("")},void this.open(r)):new Promise((function(t){r.onSubmit=function(){return s(t)},r.onCancel=function(){t("")},o.open(r)}))},t.prototype.open=function(t,e){var n=this,i=new It(t,e),o=t.onDestroy;return t.onDestroy=function(t){n.untrack(t),o&&o(t)},i.open(),this.track(i),i},t.prototype.createSet=function(t){return new Mt(t,this)},t.prototype.untrack=function(e){var n=t.openDialogs.indexOf(e);n>=0&&t.openDialogs.splice(n,1)},t.prototype.track=function(e){t.openDialogs.push(e)},t.prototype.openProgress=function(t){var e=this,n=new St(t),i=t.onDestroy;return t.onDestroy=function(t){e.untrack(t),i&&i(t)},n.open(),this.track(n),n},t.prototype.getAllDialogs=function(){return Array.from(t.openDialogs)},t.prototype.closeAllDialogs=function(){for(var e=0,n=Array.from(t.openDialogs);e<n.length;e++){n[e].close()}},t.openDialogs=[],t}(),It=function(){function t(t,e){var n=this;this.options=t,this.submitHandler=function(t){return(!n.options.onSubmit||!1!==n.options.onSubmit(n,t))&&(n.destroy(),!0)},this.cancelHandler=function(){n.options.onCancel&&n.options.onCancel(n),n.destroy()},this.keydownHandler=function(t){return 13!=t.keyCode||!n.isActiveDialog()||(t.preventDefault(),t.stopPropagation(),!n.submitHandler())||(window.removeEventListener("keydown",n.keydownHandler,!1),!1)},this.dialogId=h.generateId("dlg"),this.data=e,this.slot=W("div",document.body).attr("tab-index","-1").data("dialog-id",this.dialogId).addClass(xt+"-modal","is-active").focus().addChild("div",(function(t){return t.addClass("kdlg-modal-background")})).addChild("div",(function(i){return n.windowElement=i.addClass(xt+"-modal-window").addChild("header",(function(e){n.headerElement=e.addClass(xt+"-header").addChild("p",(function(e){return e.addClass(xt+"-header-title").addText(t.title)})).toDOM(),!1!==t.closable&&e.addChild("button",(function(t){return t.addClass(xt+"-modal-close").on("click",(function(){n.cancelHandler()})).focus()}))})).addChild("div",(function(t){t.addClass(xt+"-alert-container"),n.alertElement=t.toDOM()})).addChild("section",(function(i){if(n.bodyElement=i.addClass(xt+"-body").toDOM(),"string"==typeof t.body){var o=M.renderLiquidTemplate(t.body,e);i.addHtml(o)}else i.addChildElement(t.body)})).addChild("footer",(function(e){var i=null;i=t.footerAlignment&&t.footerAlignment==lt.Center?"align-center":"align-right",n.footerElement=e.addClass(xt+"-footer").toDOM(),e.addClass(i),!1!==t.submitable&&(e.addChild("button",(function(e){e.id(n.dialogId+"-btn-submit").addClass("kfrm-button","is-info").addText(t.submitButtonText||c.getText("ButtonOK")),t.recaptchaSiteKey?(e.data("sitekey",t.recaptchaSiteKey),e.addClass("g-recaptcha"),e.on("click",(function(e){grecaptcha?grecaptcha.ready((function(){grecaptcha.execute(t.recaptchaSiteKey,{action:"submit"}).then((function(t){n.submitHandler(t)}))})):n.submitHandler()}))):e.on("click",(function(t){n.submitHandler()})),e.focus()})),!1!==t.cancelable&&e.addChild("button",(function(e){return e.id(n.dialogId+"-btn-cancel").addClass("kfrm-button").addText(t.cancelButtonText||c.getText("ButtonCancel")).on("click",(function(t){n.cancelHandler()}))})))})).toDOM()})).toDOM()}return t.prototype.getData=function(){return this.data},t.prototype.getRootElement=function(){return this.slot},t.prototype.getSubmitButtonElement=function(){return document.getElementById(this.dialogId+"-btn-submit")},t.prototype.getCancelButtonElement=function(){return document.getElementById(this.dialogId+"-btn-cancel")},t.prototype.open=function(){var t=this;this.options.beforeOpen&&this.options.beforeOpen(this),W(this.slot).show(),this.options.arrangeParents&&this.arrangeParents(!0);var e=this.slot.querySelector(".kdlg-modal-window");this.options.height&&(e.style.height="string"==typeof this.options.height?this.options.height:this.options.height+"px"),this.options.width&&(e.style.width="string"==typeof this.options.width?this.options.width:this.options.width+"px"),this.options.submitOnEnter&&window.addEventListener("keydown",this.keydownHandler,!1),this.slot.querySelectorAll("input").forEach((function(e){return e.addEventListener("input",(function(){t.clearAlert(),t.options.onInput&&t.options.onInput(t)}))})),this.options.onShow&&this.options.onShow(this)},t.prototype.submit=function(){this.submitHandler()},t.prototype.cancel=function(){this.cancelHandler()},t.prototype.close=function(){this.destroy()},t.prototype.disableButtons=function(){this.slot.querySelectorAll("button").forEach((function(t){return t.disabled=!0}))},t.prototype.enableButtons=function(){this.slot.querySelectorAll("button").forEach((function(t){return t.disabled=!1}))},t.prototype.showAlert=function(t,e,n){var i=W("div").addClass(xt+"-alert "+(e||"")).addChild("span",(function(t){return t.addClass(xt+"-alert-closebtn").text("×").on("click",(function(t){var e=t.target.parentElement;e.parentElement.removeChild(e)}))})).addText(t).toDOM();!0===n&&this.clearAlert(),this.alertElement.appendChild(i)},t.prototype.clearAlert=function(){this.alertElement.innerHTML=""},t.prototype.destroy=function(){document.querySelectorAll('[data-dialog-id="'+this.dialogId+'"]').length<=0||(this.options.arrangeParents&&this.arrangeParents(!1),document.body.removeChild(this.slot),this.options.submitOnEnter&&window.removeEventListener("keydown",this.keydownHandler,!1),this.options.onDestroy&&this.options.onDestroy(this))},t.prototype.isActiveDialog=function(){var t=document.documentElement.querySelectorAll(".kdlg-modal");return t[t.length-1]===this.slot},t.prototype.arrangeParents=function(t){for(var e=document.documentElement.querySelectorAll(".kdlg-modal-window"),n=0;n<e.length-1;n++)if(t){var i=0==n?20:40*n+20;W(e[n]).setStyle("margin-top",i+"px").setStyle("margin-left",i+"px")}else W(e[n]).removeStyle("margin-top").removeStyle("margin-left")},t}(),St=function(t){function e(e,n){var i,o,r=this,s=W("div").addChild("div",(function(t){return i=t.text(e.content||"").toDOM()})).addChild("div",(function(t){t.addClass(xt+"-progress-line").addChild("div",(function(t){o=t.addClass("fill").toDOM(),e.determinated?t.setStyle("width","0%"):t.addClass("indeterminate")}))})).toDOM();return(r=t.call(this,{title:e.title,body:s,beforeOpen:e.beforeOpen,onSubmit:e.onSubmit,width:e.width,height:e.height,submitable:!1,cancelable:!1,closable:!1,onDestroy:e.onDestroy},n)||this).contentElement=i,r.progressElement=o,r}return Tt(e,t),e.prototype.updateContent=function(t){this.contentElement.innerText=t},e.prototype.updateProgress=function(t){var e=this;t=this.in01(t),this.progressElement.style.width=100*t+"%",1===t&&setTimeout((function(){e.submit()}),500)},e.prototype.in01=function(t){return t>1?1:t<0?0:t},e}(It),Mt=function(){function t(t,e){this.options=t,this.dialogService=e,this.currentDialog=null,this.currentIndex=0,this.options=t,this.dialogService=e}return t.prototype.getCurrent=function(){return this.currentDialog},t.prototype.openNext=function(t){return this.open(this.currentIndex+1,t)},t.prototype.openPrev=function(t){return this.open(this.currentIndex-1,t)},t.prototype.open=function(t,e){if(t<0?this.currentIndex=0:t>=this.options.length?this.currentIndex=this.options.length-1:this.currentIndex=t,this.currentDialog)try{this.currentDialog.close()}catch(t){}var n=this.options[this.currentIndex];return this.currentDialog=this.dialogService.open(n,e),this.currentDialog},t.prototype.close=function(){this.currentDialog&&(this.currentDialog.close(),this.currentDialog=null)},t}();c.updateDefaultTexts({GridPageInfo:"{FirstPageRecordNum} - {LastPageRecordNum} of {Total} records",GridItemsPerPage:"items per page",ButtonOK:"OK",ButtonCancel:"Cancel",ButtonApply:"Apply",ButtonNow:"Now",LblTotal:"Total"});new Et;var Pt="yyyy-MM-dd",Rt="HH:mm",kt=function(t){var e=c.getLocaleSettings();return t==i.Date?e.editDateFormat:t==i.Time?e.editTimeFormat:e.editDateFormat+" "+e.editTimeFormat},Ot=function(t){var e=window.history.state;history.pushState(e,document.title,t),window.dispatchEvent(new Event("ed_set_location"))},At=function(){},Lt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Nt=function(t){function e(){var e=t.call(this)||this;return e.name="DateTime",e}return Lt(e,t),e.prototype.validate=function(t,e){if(!h.IsDefinedAndNotNull(e)||""==e)return{successed:!0};if(h.getDateDataTypes().indexOf(t.dataType)>=0)try{var n=kt(t.dataType);h.strToDateTime(e,n)}catch(t){return{successed:!1,messages:[c.getText("DateTimeError")]}}return{successed:!0}},e}(At),Ft=function(){function t(t){this.context=t,this.validators=[new Nt]}return t.prototype.getHtml=function(){return this.html},t.prototype.setHtmlInt=function(t){this.html=t,this.errorsDiv=this.html.querySelector(".errors-block")},t.prototype.validate=function(){this.clearErrors();for(var t=!0,e=0,n=Array.from(this.html.querySelectorAll("input, select"));e<n.length;e++){var i=n[e],o=this.context.getMetaData().getAttributeById(i.name);if("checkbox"!==i.type){var r=this.validateValue(o,i.value);if(!r.successed){t&&W(this.errorsDiv).addChild("ul"),t=!1;for(var s=0,a=r.messages;s<a.length;s++){var l=a[s];this.errorsDiv.firstElementChild.innerHTML+="<li>"+o.caption+": "+l+"</li>"}}this.markInputValid(i,r.successed)}}return t},t.prototype.getData=function(){var t=this;return new Promise((function(e,n){for(var i=[],o=Array.from(t.html.querySelectorAll("input, select, textarea")),r={},s=function(e){var n=e.name.substring(e.name.lastIndexOf(".")+1),o=t.context.getMetaData().getAttributeById(e.name);"checkbox"===e.type?r[n]=e.checked:"file"===e.type?i.push(t.fileToBase64(e.files[0]).then((function(t){return r[n]=t}))):r[n]=t.mapValue(o.dataType,e.value)},a=0,l=o;a<l.length;a++){s(l[a])}Promise.all(i).then((function(){return e(r)})).catch((function(t){return n(t)}))}))},t.prototype.fileToBase64=function(t){return new Promise((function(e,n){var i=new FileReader;i.readAsDataURL(t),i.onload=function(){var t=i.result.toString();e(t.substring(t.indexOf(",")+1))},i.onerror=function(t){return n(t)}}))},t.prototype.useValidator=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.useValidators(t)},t.prototype.useValidators=function(t){this.validators=this.validators.concat(t)},t.prototype.mapValue=function(t,e){if(h.getDateDataTypes().indexOf(t)>=0){if(t!==i.Time&&e&&e.length){var n=kt(t),o=(s=t)==i.Date?Pt:s==i.Time?Rt:Pt+"T"+Rt,r=h.strToDateTime(e,n);return h.dateTimeToStr(r,o)}return e&&e.length?e:null}var s;return h.isIntType(t)?parseInt(e):h.isNumericType(t)?parseFloat(e):e},t.prototype.clearErrors=function(){this.errorsDiv.innerHTML="",this.html.querySelectorAll("input, select").forEach((function(t){t.classList.remove("is-valid"),t.classList.remove("is-invalid")}))},t.prototype.markInputValid=function(t,e){t.classList.add(e?"is-valid":"is-invalid")},t.prototype.validateValue=function(t,e){for(var n={successed:!0,messages:[]},i=0,o=this.validators;i<o.length;i++){var r=o[i].validate(t,e);r.successed||(n.successed=!1,n.messages=n.messages.concat(r.messages))}return n},t}(),_t=function(){function t(t,e,n,i){var o=this;this.slot=t,this.grid=e,this.filter=n,this.options={focus:!1,instantMode:!1,instantTimeout:1e3},this.options=h.assignDeep(this.options,i||{});var r=this.grid.cellRendererStore.getDefaultRendererByType($.STRING);this.grid.cellRendererStore.setDefaultRenderer($.STRING,(function(t,e,n,i){return o.highlightCellRenderer(r,t,e,n,i)}));var s=this.grid.cellRendererStore.getDefaultRendererByType($.NUMBER);this.grid.cellRendererStore.setDefaultRenderer($.NUMBER,(function(t,e,n,i){return o.highlightCellRenderer(s,t,e,n,i)})),this.render()}return t.prototype.render=function(){var t=this,e=_.a.IsIE()?"kfrm-fields-ie is-horizontal":"kfrm-fields is-horizontal",n=_.a.IsIE()||_.a.IsEdge();W(this.slot).addClass(e).addChild("div",(function(e){e.addClass("control").addChild("input",(function(e){t.filterInput=e.toDOM(),e.attr("placeholder",c.getText("SearchInputPlaceholder")).type("text"),e.on("keydown",t.inputKeydownHandler.bind(t)),t.options.instantMode&&e.on("keyup",t.inputKeyupHandler.bind(t))})),n||e.addClass("has-icons-right").addChild("span",(function(e){e.addClass("icon").addClass("is-right").addClass("is-clickable").html("&#x1F5D9;").on("click",t.clearButtonClickHander.bind(t))}))})),this.options.instantMode||W(this.slot).addChild("button",(function(e){return e.addClass("kfrm-button").addText(c.getText("SearchBtn")).on("click",t.searchButtonClickHandler.bind(t))})),this.options.focus&&this.filterInput.focus()},t.prototype.inputKeydownHandler=function(t){13==t.keyCode&&this.applyFilter(!0)},t.prototype.inputKeyupHandler=function(){var t=this;this.applyFilterTimeout&&clearTimeout(this.applyFilterTimeout),this.applyFilterTimeout=setTimeout((function(){t.applyFilter(!0)}),this.options.instantTimeout)},t.prototype.clearButtonClickHander=function(){this.filterInput.value="",this.filterInput.focus(),this.applyFilter(!0)},t.prototype.searchButtonClickHandler=function(){this.applyFilter(!0)},t.prototype.applyFilter=function(t){var e=this;this.applyFilterTimeout&&clearTimeout(this.applyFilterTimeout);var n=this.filter.getValue();return(!t||n!=this.filterInput.value)&&(this.filter.apply(this.filterInput.value).then((function(t){e.grid.setData(t)})),!0)},t.prototype.highlightCellRenderer=function(t,e,n,i,o){if((h.isNumericType(n.type)||h.getStringDataTypes().indexOf(n.type)>=0)&&e){e=n.dataColumn&&n.dataColumn.displayFormat&&et.test(n.dataColumn.displayFormat)?n.dataColumn.displayFormat.replace(et,(function(t,n){return c.numberToStr(e,n)})):e.toLocaleString();var r=this.highlightText(e.toString());if(r instanceof HTMLElement)return i.title=e,void i.appendChild(r)}t(e,n,i,o)},t.prototype.highlightText=function(t){var e=t.toLowerCase(),n=this.filter.getValue().toString();if(n&&n.length>0&&t&&t.length>0){for(var i=[],o=n.split("||").map((function(t){return t.trim().toLowerCase()})),r=0;r<o.length;r++){var s=0,a=o[r];if(a.length){if(a===e)return(p=document.createElement("span")).style.backgroundColor="yellow",p.innerText=t,p;for(;s<t.length-1;){var l=e.indexOf(a,s);l>=0?(i.push({index:l,length:o[r].length}),s=l+a.length):s++}}}if(i.length>0){i.sort((function(t,e){return t.index>e.index?1:t.index==e.index2?0:-1}));for(r=0;r<i.length-1;){var u=i[r+1].index-(i[r].index+i[r].length);if(u<0){var d=i[r+1].length+u;d>0&&(i[r].length+=d),i.splice(r+1,1)}else r++}var c=document.createElement("div");for(r=0;r<i.length;r++){if(0===r){var h=document.createTextNode(t.substring(0,i[r].index));c.appendChild(h)}var p;(p=document.createElement("span")).style.backgroundColor="yellow",p.innerText=t.substring(i[r].index,i[r].index+i[r].length),c.appendChild(p);var f=r<i.length-1?document.createTextNode(t.substring(i[r].index+i[r].length,i[r+1].index)):document.createTextNode(t.substring(i[r].index+i[r].length));c.appendChild(f)}return c}}return t},t}(),Bt=function(){return Bt=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Bt.apply(this,arguments)},Ht=_.a.IsIE(),Vt=function(){function t(t,e){this.context=t,this.params=e,this.params=e||{},this.reset()}return t.prototype.reset=function(){this.form=new Ft(this.context)},t.prototype.setupLookupField=function(t,e,n,i){var o=this,r=this.context.getMetaData().getRootEntity().subEntities.filter((function(t){return t.id==e.lookupEntity}))[0],s=this.context.getMetaData().getAttributeById(e.dataAttr);if(s){n=n||!s.isEditable,i=this.params.values?this.params.values.getValue(s.id):void 0;var a,l=Ht?"kfrm-fields-ie is-horizontal":"kfrm-fields is-horizontal";W(t).addChild("div",(function(t){t.addClass(l).addChild("input",(function(t){a=t.toDOM(),t.attr("readonly",""),t.name(s.id),t.type(o.resolveInputType(s.dataType)),t.value(h.IsDefinedAndNotNull(i)?i.toString():"")})),n||t.addChild("button",(function(t){return t.addClass("kfrm-button").attr("title",c.getText("NavigationBtnTitle")).addText("...").on("click",(function(n){var i=new O({loader:{loadChunk:function(t){return o.context.getDataLoader().loadChunk(Bt(Bt({},t),{id:r.id}))}}});o.context.getDataLoader().loadChunk({offset:0,limit:1e3,needTotal:!0,sourceId:r.id}).then((function(n){for(var s,l=function(t){var e=r.attributes.filter((function(e){return e.id==t.id&&(e.isPrimaryKey||e.showInLookup)}));e.length&&i.columns.add(t)},u=0,d=n.table.columns.getItems();u<d.length;u++){l(d[u])}i.setTotal(n.total);for(var h=0,p=n.table.getCachedRows();h<p.length;h++){var f=p[h];i.addRow(f)}var g,m=new Et,y=null,v=null,b=W("div").addClass("kfrm-form").addChild("div",(function(t){return t.addClass("kfrm-field").addChild("label",(function(t){return t.addText(c.getText("LookupSelectedItem")).toDOM()})).addChild("div",(function(t){return v=t.addText("None").toDOM()}))})).addChild("div",(function(t){return g=t.toDOM()})).addChild("div",(function(t){return t.addClass("kfrm-control").addChild("div",(function(t){return y=t.toDOM()}))})).toDOM(),C=a.value,w=function(t){v.innerHTML=i.columns.getItems().map((function(e){return"<b>"+e.label+":</b> "+function(t,e){return t instanceof k?t.getValue(e):t[e.substring(e.lastIndexOf(".")+1)]}(t,e.id)})).join(", ")};if(C){var D=r.getFirstPrimaryAttr(),T=D.id.substring(D.id.lastIndexOf(".")+1);o.context.fetchRecord((s={},s[T]=C,s),r.id).then((function(t){t.entity&&w(t.entity)})).catch((function(t){console.error(t)}))}var x=new pt({slot:y,dataTable:i,fixHeightOnFirstRender:!0,paging:{pageSize:10},onActiveRowChanged:function(t){x.getData().getRow(t.rowIndex).then((function(t){C=t.getValue(e.lookupDataAttr),w(t)}))}});m.open({title:c.getText("LookupDlgCaption").replace("{entity}",r.caption),body:b,arrangeParents:!0,beforeOpen:function(){var t=o.context.createFilter(r.id,x.getData(),!0);new _t(g,x,t,{instantMode:!0,focus:!0})},onSubmit:function(){return a.value=C,!0},onDestroy:function(){x.destroy(),t.toDOM().focus()}})}))}))}))}))}},t.prototype.setupDateTimeField=function(t,e,n,o,r){var s,a=this,l=Ht?"kfrm-fields-ie is-horizontal":"kfrm-fields is-horizontal",u=kt(e.dataType),d=u.replace("yyyy","9999").replace("MM","99").replace("dd","99").replace("HH","99").replace("mm","99").replace("ss","99");W(t).addChild("div",(function(t){t.addClass(l).addChild("input",(function(t){s=t.toDOM(),t.name(e.id),t.type(r?"hidden":a.resolveInputType(e.dataType)),o?t.attr("readonly",""):(t.mask(d),t.on("keypress",(function(t){return a.applySumbit(t)})).on("input",(function(e){t.removeClass("is-invalid");try{h.strToDateTime(s.value,u)}catch(e){t.addClass("is-invalid")}})).on("blur",(function(t){s.value===d.replace(/[9]/g,"_")&&(s.value="")}))),t.value(h.IsDefinedAndNotNull(n)?h.dateTimeToStr(n,u):"")})),o||t.addChild("button",(function(t){return t.addClass("kfrm-button").attr("title",c.getText(e.dataType!==i.Time?"CalendarBtnTitle":"TimerBtnTitle")).addChild("i",(function(t){return t.addClass(e.dataType!==i.Time?"ed-calendar-icon":"ed-timer-icon")})).on("click",(function(t){var n;try{n=s.value.length?e.dataType!==i.Time?h.strToDateTime(s.value,u):h.strToTime(s.value):new Date((new Date).setSeconds(0))}catch(t){n=new Date((new Date).setSeconds(0))}var o={zIndex:9999999999,showCalendar:e.dataType!==i.Time,showTimePicker:e.dataType!==i.Date,onApply:function(t){t.setSeconds(0),t.setMilliseconds(0),s.value=h.dateTimeToStr(t,u)}},r=new Dt(o);r.setDateTime(n),r.show(t.target)})).toDOM()}))}))},t.prototype.setupListField=function(t,e,n,i,o){var r=this;W(t).addChild("div",(function(t){return t.addClass("kfrm-select full-width").addChild("select",(function(t){if(o&&t.attr("readonly",""),t.attr("name",e.id),t.on("keypress",(function(t){return r.applySumbit(t)})),i)for(var s=0;s<i.length;s++){var a=i[s];t.addOption({value:a.id,title:a.text,selected:0===s})}t.value(n)}))}))},t.prototype.setupFileField=function(t,e,n,i){var o=this;W(t).addChild("input",(function(t){n&&t.attr("readonly",""),t.name(e.id).type(o.resolveInputType(e.dataType)),t.attr("accept",i)}))},t.prototype.setupTextField=function(t,e,n,o,r){var s=this;W(t).addChild("input",(function(t){o&&t.attr("readonly",""),t.type(r?"hidden":s.resolveInputType(e.dataType)),t.name(e.id).type(s.resolveInputType(e.dataType)),e.dataType==i.Bool?n&&t.attr("checked",""):t.on("keypress",(function(t){return s.applySumbit(t)})).value(h.IsDefinedAndNotNull(n)?n.toString():"")}))},t.prototype.setupTextArea=function(t,e,n,i){W(t).addChild("textarea",(function(t){i&&t.attr("readonly",""),t.attr("name",e.id),t.setStyle("height","120px"),t.value(h.IsDefinedAndNotNull(n)?n.toString():"")}))},t.prototype.addFormField=function(t,e){var n=this.params.values&&e.kind!==o.Lookup?this.params.values.getValue(e.id):this.params.isEditForm?void 0:e.defaultValue,i=this.resolveEditor(e),r=this.params.isEditForm&&(e.isPrimaryKey||!e.isEditable),s=!e.isNullable;Ht&&(t=W("div",t).addClass("kfrm-field-ie").toDOM()),W(t).addChild("label",(function(t){t.attr("for",e.id),t.addHtml(e.caption+" "+(s?'<sup style="color: red">*</sup>':"")+": "),e.description&&t.addChild("div",(function(t){return t.attr("title",e.description).addClass("question-mark").setStyle("vertical-align","middle").setStyle("display","inline-block")}))}));var a=e.isPrimaryKey;if(e.kind!==o.Lookup)switch(i.tag){case l:this.setupDateTimeField(t,e,n,r,a);break;case u:this.setupListField(t,e,n,i.values,r);break;case d:this.setupFileField(t,e,r,i.accept);break;default:i.multiline?this.setupTextArea(t,e,n,r):this.setupTextField(t,e,n,r,a)}else this.setupLookupField(t,e,r,n)},t.prototype.resolveInputType=function(t){return t===i.Bool?"checkbox":t===i.Blob?"file":"text"},t.prototype.resolveEditor=function(t){var e=t.defaultEditor||new E;return e.tag==s&&(h.getDateDataTypes().indexOf(t.dataType)>=0?e.tag=l:e.tag=a),e},t.prototype.applySumbit=function(t){return 13===t.keyCode&&(this.sumbitCallback&&this.sumbitCallback(),!1)},t.prototype.onSubmit=function(t){return this.sumbitCallback=t,this},t.prototype.build=function(){var t,e=W("div").addClass("kfrm-form").addChild("div",(function(t){return t.addClass("errors-block").toDOM()})).addChild("div",(function(e){e.addClass(Ht?"kfrm-fields-ie col-ie-1-4 label-align-right":"kfrm-fields col-a-1 label-align-right"),t=e})).toDOM();this.form.setHtmlInt(e);for(var n=0,i=this.context.getActiveEntity().attributes;n<i.length;n++){var o=i[n];(this.params.isEditForm||o.showOnCreate)&&((o.isPrimaryKey||!this.params.isEditForm||o.showOnEdit)&&this.addFormField(t.toDOM(),o))}return this.form},t}(),jt=function(){function t(t){this.slot=t,this.hide(),this.slot.classList.add("ed-progress-bar")}return t.prototype.show=function(){this.slot.style.removeProperty("display")},t.prototype.hide=function(){this.slot.style.display="none"},t}(),Gt=function(){function t(t){this.context=t}return t.prototype.loadChunk=function(t){var e=this,n=this.context.resolveEndpoint("FetchDataset",{sourceId:t.sourceId||this.context.getActiveEntity().id});return delete t.sourceId,this.context.startProcess(),this.context.getHttpClient().post(n,t).then((function(e){for(var n=new O({chunkSize:1e3}),i=e.resultSet,o=0,r=i.cols;o<r.length;o++){var s=r[o];n.columns.add(s)}for(var a=0,l=i.rows;a<l.length;a++){var u=l[a];n.addRow(u)}var d=0;return e.meta&&e.meta.totalRecords&&(d=e.meta.totalRecords),{table:n,total:d,hasNext:!t.needTotal||t.offset+t.limit<d}})).finally((function(){e.context.endProcess()}))},t}(),zt=function(){return zt=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},zt.apply(this,arguments)},qt=function(){function t(t){this.endpoints=new Map,this.endpointVarsRegex=/\{.*?\}/g,this.options=t||{},this.http=new D,this.model=new I,this.model.id=t.metaDataId||"__default",this.dataLoader=new Gt(this);var e=zt({loader:this.dataLoader},t.dataTable);this.data=new O(e),this.setDefaultEndpoints(this.options.endpoint||"/api/easydata")}return t.prototype.getActiveEntity=function(){return this.activeEntity},t.prototype.setActiveSource=function(t){this.activeEntity=this.model.getRootEntity().subEntities.filter((function(e){return e.id==t}))[0]},t.prototype.getMetaData=function(){return this.model},t.prototype.getData=function(){return this.data},t.prototype.getDataLoader=function(){return this.dataLoader},t.prototype.createFilter=function(t,e,n){return new F(this.dataLoader,e||this.getData(),t||this.activeEntity.id,n)},t.prototype.loadMetaData=function(){var t=this,e=this.resolveEndpoint("GetMetaData");return this.startProcess(),this.http.get(e).then((function(e){return e.model&&t.model.loadFromData(e.model),t.model})).catch((function(t){return console.error("Error: "+t.message+". Source: "+t.sourceError),null})).finally((function(){t.endProcess()}))},t.prototype.getHttpClient=function(){return this.http},t.prototype.fetchDataset=function(){var t=this;return this.data.clear(),this.dataLoader.loadChunk({offset:0,limit:this.data.chunkSize,needTotal:!0}).then((function(e){for(var n=0,i=e.table.columns.getItems();n<i.length;n++){var o=i[n];t.data.columns.add(o)}t.data.setTotal(e.total);for(var r=0,s=e.table.getCachedRows();r<s.length;r++){var a=s[r];t.data.addRow(a)}return t.data}))},t.prototype.fetchRecord=function(t,e){var n=this,i=this.resolveEndpoint("FetchRecord",{sourceId:e||this.activeEntity.id});return this.startProcess(),this.http.get(i,{queryParams:t}).finally((function(){return n.endProcess()}))},t.prototype.createRecord=function(t,e){var n=this,i=this.resolveEndpoint("CreateRecord",{sourceId:e||this.activeEntity.id});return this.startProcess(),this.http.post(i,t,{dataType:"json"}).finally((function(){return n.endProcess()}))},t.prototype.updateRecord=function(t,e){var n=this,i=this.resolveEndpoint("UpdateRecord",{sourceId:e||this.activeEntity.id});return this.startProcess(),this.http.post(i,t,{dataType:"json"}).finally((function(){return n.endProcess()}))},t.prototype.deleteRecord=function(t,e){var n=this,i=this.resolveEndpoint("DeleteRecord",{sourceId:e||this.activeEntity.id});return this.startProcess(),this.http.post(i,t,{dataType:"json"}).finally((function(){return n.endProcess()}))},t.prototype.setEndpoint=function(t,e){this.endpoints.set(t,e)},t.prototype.setEnpointIfNotExist=function(t,e){this.endpoints.has(t)||this.endpoints.set(t,e)},t.prototype.resolveEndpoint=function(t,e){e=e||{};var n=this.endpoints.get(t);if(!n)throw t+" endpoint is not defined";var i=n.match(this.endpointVarsRegex);if(i)for(var o=0,r=i;o<r.length;o++){var s=r[o],a=s.substring(1,s.length-1),l=e[a];if(!l)if("modelId"==a)l=this.model.getId();else{if("sourceId"!=a)throw"Parameter ["+a+"] is not defined";l=this.activeEntity.id}n=n.replace(s,l)}return n},t.prototype.startProcess=function(){this.options.onProcessStart&&this.options.onProcessStart()},t.prototype.endProcess=function(){this.options.onProcessEnd&&this.options.onProcessEnd()},t.prototype.setDefaultEndpoints=function(t){this.setEnpointIfNotExist("GetMetaData",g(t,"models/{modelId}")),this.setEnpointIfNotExist("FetchDataset",g(t,"models/{modelId}/sources/{sourceId}/fetch")),this.setEnpointIfNotExist("FetchRecord",g(t,"models/{modelId}/sources/{sourceId}/fetch")),this.setEnpointIfNotExist("CreateRecord",g(t,"models/{modelId}/sources/{sourceId}/create")),this.setEnpointIfNotExist("UpdateRecord",g(t,"models/{modelId}/sources/{sourceId}/update")),this.setEnpointIfNotExist("DeleteRecord",g(t,"models/{modelId}/sources/{sourceId}/delete"))},t}(),Ut=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Wt=function(t){function e(){var e=t.call(this)||this;return e.name="Type",e}return Ut(e,t),e.prototype.validate=function(t,e){if(!h.IsDefinedAndNotNull(e)||""==e)return{successed:!0};if(h.isNumericType(t.dataType)){if(!h.isNumeric(e))return{successed:!1,messages:[c.getText("NumberError")]};if(h.isIntType(t.dataType)&&!Number.isInteger(Number.parseFloat(e)))return{successed:!1,messages:[c.getText("IntNumberError")]}}return{successed:!0}},e}(At),Yt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),Kt=function(t){function e(){var e=t.call(this)||this;return e.name="Required",e}return Yt(e,t),e.prototype.validate=function(t,e){return t.isNullable||h.IsDefinedAndNotNull(e)&&""!==e?{successed:!0}:{successed:!1,messages:[c.getText("RequiredError")]}},e}(At),Xt=function(){function t(t,e,n,i){var o=this;this.slot=t,this.context=e,this.basePath=n,this.options={showFilterBox:!0,showBackToEntities:!0},this.defaultValidators=[new Kt,new Wt],this.options=h.assignDeep(this.options,i||{}),this.dlg=new Et;var r=this.context.getActiveEntity();if(!r)throw"Can't find active entity for "+window.location.pathname;this.slot.innerHTML+="<h1>"+(r.captionPlural||r.caption)+"</h1>",this.options.showBackToEntities&&W(this.slot).addChild("a",(function(t){return t.attr("href","javascript:void(0)").text("← "+c.getText("BackToEntities")).on("click",(function(t){t.preventDefault(),Ot(o.basePath)}))})),this.renderGrid()}return t.prototype.syncGridColumnHandler=function(t){if(t.dataColumn){var e=this.context.getMetaData().getAttributeById(t.dataColumn.id);e&&(t.isVisible=e.showOnView)}},t.prototype.renderGrid=function(){var t=this;this.context.fetchDataset().then((function(e){var n=document.createElement("div");if(t.slot.appendChild(n),n.id="Grid",t.grid=new pt(h.assignDeep({slot:n,dataTable:e,paging:{pageSize:15,allowPageSizeChange:!0,pageSizeItems:[15,30,50,100,200]},showPlusButton:t.context.getActiveEntity().isEditable,plusButtonTitle:c.getText("AddRecordBtnTitle"),showActiveRow:!1,onPlusButtonClick:t.addClickHandler.bind(t),onGetCellRenderer:t.manageCellRenderer.bind(t),onRowDbClick:t.rowDbClickHandler.bind(t),onSyncGridColumn:t.syncGridColumnHandler.bind(t)},t.options.grid||{})),t.options.showFilterBox){var i,o=W("div").addClass("kfrm-form").setStyle("margin","10px 0px").addChild("div",(function(t){return i=t.toDOM()})).toDOM();t.slot.insertBefore(o,n);var r=t.context.createFilter();t.filterWidget=new _t(i,t.grid,r)}}))},t.prototype.manageCellRenderer=function(t,e){var n=this;if(t.isRowNum)return t.width=110,function(t,e,i,o){var r=W("div",i).addClass("keg-cell-value");n.context.getActiveEntity().isEditable&&r.addChild("a",(function(t){return t.attr("href","javascript:void(0)").text(c.getText("EditBtn")).on("click",(function(t){return n.editClickHandler(t,parseInt(o.getAttribute("data-row-idx")))}))})).addChild("span",(function(t){return t.text(" | ")})).addChild("a",(function(t){return t.attr("href","javascript:void(0)").text(c.getText("DeleteBtn")).on("click",(function(t){return n.deleteClickHandler(t,parseInt(o.getAttribute("data-row-idx")))}))}))}},t.prototype.addClickHandler=function(){var t=this,e=this.context.getActiveEntity(),n=new Vt(this.context).onSubmit((function(){return i.submit()})).build();n.useValidators(this.defaultValidators);var i=this.dlg.open({title:c.getText("AddDlgCaption").replace("{entity}",e.caption),body:n.getHtml(),onSubmit:function(){if(!n.validate())return!1;n.getData().then((function(e){return t.context.createRecord(e)})).then((function(){return t.refreshData()})).catch((function(e){t.processError(e)}))}})},t.prototype.editClickHandler=function(t,e){var n=this;this.grid.getData().getRow(e).then((function(t){t&&n.showEditForm(t)}))},t.prototype.showEditForm=function(t){var e=this,n=this.context.getActiveEntity(),i=new Vt(this.context,{isEditForm:!0,values:t}).onSubmit((function(){return o.submit()})).build();i.useValidators(this.defaultValidators);var o=this.dlg.open({title:c.getText("EditDlgCaption").replace("{entity}",n.caption),body:i.getHtml(),onSubmit:function(){if(!i.validate())return!1;i.getData().then((function(t){return e.context.updateRecord(t)})).then((function(){return e.refreshData()})).catch((function(t){e.processError(t)}))}})},t.prototype.rowDbClickHandler=function(t){this.context.getActiveEntity().isEditable&&this.showEditForm(t.row)},t.prototype.deleteClickHandler=function(t,e){var n=this;this.grid.getData().getRow(e).then((function(t){if(t){var e=n.context.getActiveEntity(),i=e.getPrimaryAttrs(),o=i.map((function(e){return t.getValue(e.id)})),r=i.reduce((function(t,e,n){return t[e.id.substring(e.id.lastIndexOf(".")+1)]=o[n],t}),{});n.dlg.openConfirm(c.getText("DeleteDlgCaption").replace("{entity}",e.caption),c.getText("DeleteDlgMessage").replace("{recordId}",Object.keys(r).map((function(t){return t+":"+r[t]})).join(";"))).then((function(t){t&&n.context.deleteRecord(r).then((function(){return n.refreshData()})).catch((function(t){n.processError(t)}))}))}}))},t.prototype.processError=function(t){this.dlg.open({title:"Ooops, something went wrong",body:t.message,closable:!0,cancelable:!1})},t.prototype.refreshData=function(){var t=this;return this.context.fetchDataset().then((function(){var e=!1;t.filterWidget&&(e=t.filterWidget.applyFilter(!1)),e||t.grid.refresh()}))},t}(),Jt=function(){function t(t,e,n){this.slot=t,this.context=e,this.basePath=n,this.metaData=this.context.getMetaData(),this.slot.innerHTML+="<h1>"+c.getText("RootViewTitle")+"</h1>",this.renderEntitySelector()}return t.prototype.renderEntitySelector=function(){var t=this,e=this.metaData.getRootEntity().subEntities;this.slot&&W(this.slot).addChild("div",(function(n){return n.addClass("ed-root").addChild("div",(function(e){return e.addClass("ed-menu-description").addText(c.getText(t.metaData.isEmpty()?"ModelIsEmpty":"EntityMenuDesc"))})).addChild("ul",(function(n){n.addClass("ed-entity-menu"),e.forEach((function(e){n.addChild("li",(function(n){n.addClass("ed-entity-item").on("click",(function(){Ot(t.basePath+"/"+decodeURIComponent(e.id))})).addChild("div",(function(t){t.addClass("ed-entity-item-caption").addText(e.captionPlural||e.caption)})),e.description&&n.addChild("div",(function(t){t.addClass("ed-entity-item-descr").addText(""+e.description)}))}))}))}))}))},t}(),Zt=function(){function t(t){var e=this;this.options={container:"#EasyDataContainer",basePath:"easydata"},this.onSetLocation=function(){e.setActiveView()},this.attach=function(){window.addEventListener("ed_set_location",e.onSetLocation),window.addEventListener("popstate",e.onSetLocation)},this.options=h.assign(this.options,t||{}),this.options.rootEntity?(this.options.showBackToEntities=!1,this.basePath="/"):this.basePath=this.normalizeBasePath(this.options.basePath),this.setContainer(this.options.container);var n=document.createElement("div"),i=new jt(n),o=this.container.parentElement;o.insertBefore(n,o.firstElementChild),this.context=new qt({endpoint:this.options.endpoint,dataTable:this.options.dataTable,onProcessStart:function(){return i.show()},onProcessEnd:function(){return i.hide()}})}return t.prototype.normalizeBasePath=function(t){t=this.trimSlashes(t);var e=decodeURIComponent(window.location.pathname),n=e.toLocaleLowerCase().indexOf(t);return n>=0?e.substring(0,n+t.length):"/"},t.prototype.trimSlashes=function(t){return t.replace(/^\/|\/$/g,"")},t.prototype.setContainer=function(t){if(!t)throw"Container is undefined";if("string"==typeof t){if(t.length){if("."===t[0]){var e=document.getElementsByClassName(t.substring(1));e.length&&(this.container=e[0])}else"#"===t[0]&&(t=t.substring(1)),this.container=document.getElementById(t);if(!this.container)throw Error("Unrecognized `container` parameter: "+t+"\nIt must be an element ID, a class name (starting with .) or an HTMLElement object itself.")}}else this.container=t},t.prototype.getActiveSourceId=function(){if(this.options.rootEntity)return this.options.rootEntity;var t=decodeURIComponent(window.location.pathname),e=this.basePath.length+1;return e<t.length?t.substring(e):null},t.prototype.run=function(){var t=this;return this.attach(),this.context.loadMetaData().then((function(){t.setActiveView()})).catch((function(t){return console.error(t)}))},t.prototype.setActiveView=function(){this.clear();var t=this.getActiveSourceId();t?(this.context.setActiveSource(t),window.EDView=new Xt(this.container,this.context,this.basePath,this.options)):window.EDView=new Jt(this.container,this.context,this.basePath)},t.prototype.clear=function(){this.container.innerHTML="",this.context.getData().clear()},t.prototype.detach=function(){window.removeEventListener("ed_set_location",this.onSetLocation),window.removeEventListener("popstate",this.onSetLocation)},t}();c.updateDefaultTexts({RequiredError:"Value is required.",NumberError:"Value should be a number",IntNumberError:"Value should be an integer number",DateTimeError:"Invalid date or time value",LookupSelectedItem:"Selected item: ",LookupDlgCaption:"Select {entity}",None:"None",NavigationBtnTitle:"Navigation values",CalendarBtnTitle:"Open calendar",TimerBtnTitle:"Open timer",AddBtnTitle:"Add",AddRecordBtnTitle:"Add record",EditBtn:"Edit",DeleteBtn:"Delete",SelectLink:"[ select ]",AddDlgCaption:"Create {entity}",EditDlgCaption:"Edit {entity}",DeleteDlgCaption:"Delete {entity}",DeleteDlgMessage:"Are you sure you want to remove this record: {{recordId}}?",EntityMenuDesc:"Click on an entity to view/edit its content",BackToEntities:"Back to entities",SearchBtn:"Search",SearchInputPlaceholder:"Search...",RootViewTitle:"Entities",ModelIsEmpty:"No entity was found."})}])}));
3
3
  //# sourceMappingURL=easydata.crud.min.js.map