smart-webcomponents-react 14.0.0 → 14.0.35

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.
Files changed (244) hide show
  1. package/alertwindow/alertwindow.umd.js +1 -1
  2. package/combobox/combobox.d.ts +5 -0
  3. package/combobox/combobox.esm.js +12 -1
  4. package/combobox/combobox.umd.js +12 -1
  5. package/dialogwindow/dialogwindow.umd.js +1 -1
  6. package/grid/grid.d.ts +74 -38
  7. package/grid/grid.esm.js +60 -26
  8. package/grid/grid.umd.js +60 -26
  9. package/index.d.ts +99 -30
  10. package/kanban/kanban.d.ts +10 -0
  11. package/kanban/kanban.esm.js +23 -1
  12. package/kanban/kanban.umd.js +23 -1
  13. package/multilinewindow/multilinewindow.umd.js +1 -1
  14. package/package.json +1 -1
  15. package/progresswindow/progresswindow.umd.js +1 -1
  16. package/promptwindow/promptwindow.umd.js +1 -1
  17. package/source/modules/smart.accordion.js +1 -1
  18. package/source/modules/smart.array.js +2 -2
  19. package/source/modules/smart.barcode.js +1 -1
  20. package/source/modules/smart.breadcrumb.js +1 -1
  21. package/source/modules/smart.button.js +1 -1
  22. package/source/modules/smart.buttongroup.js +1 -1
  23. package/source/modules/smart.calendar.js +1 -1
  24. package/source/modules/smart.card.js +1 -1
  25. package/source/modules/smart.cardview.js +2 -2
  26. package/source/modules/smart.carousel.js +1 -1
  27. package/source/modules/smart.chart.js +2 -2
  28. package/source/modules/smart.checkbox.js +1 -1
  29. package/source/modules/smart.checkinput.js +1 -1
  30. package/source/modules/smart.chip.js +1 -1
  31. package/source/modules/smart.colorinput.js +1 -1
  32. package/source/modules/smart.colorpanel.js +1 -1
  33. package/source/modules/smart.colorpicker.js +1 -1
  34. package/source/modules/smart.combobox.js +2 -2
  35. package/source/modules/smart.common.js +2 -2
  36. package/source/modules/smart.countryinput.js +1 -1
  37. package/source/modules/smart.dateinput.js +2 -2
  38. package/source/modules/smart.daterangeinput.js +2 -2
  39. package/source/modules/smart.datetimepicker.js +1 -1
  40. package/source/modules/smart.dockinglayout.js +1 -1
  41. package/source/modules/smart.dropdownbutton.js +1 -1
  42. package/source/modules/smart.dropdownlist.js +1 -1
  43. package/source/modules/smart.editor.js +1 -1
  44. package/source/modules/smart.element.js +1 -1
  45. package/source/modules/smart.fileupload.js +1 -1
  46. package/source/modules/smart.form.js +1 -1
  47. package/source/modules/smart.formulaparser.js +1 -1
  48. package/source/modules/smart.ganttchart.js +4 -4
  49. package/source/modules/smart.gauge.js +1 -1
  50. package/source/modules/smart.grid.js +15 -15
  51. package/source/modules/smart.gridpanel.js +3 -3
  52. package/source/modules/smart.input.js +1 -1
  53. package/source/modules/smart.kanban.js +4 -4
  54. package/source/modules/smart.layout.js +1 -1
  55. package/source/modules/smart.led.js +1 -1
  56. package/source/modules/smart.listbox.js +1 -1
  57. package/source/modules/smart.listmenu.js +1 -1
  58. package/source/modules/smart.map.js +1 -1
  59. package/source/modules/smart.maskedtextbox.js +1 -1
  60. package/source/modules/smart.menu.js +1 -1
  61. package/source/modules/smart.multicomboinput.js +1 -1
  62. package/source/modules/smart.multiinput.js +1 -1
  63. package/source/modules/smart.multilinetextbox.js +2 -2
  64. package/source/modules/smart.multisplitbutton.js +1 -1
  65. package/source/modules/smart.numberinput.js +1 -1
  66. package/source/modules/smart.numerictextbox.js +2 -2
  67. package/source/modules/smart.pager.js +1 -1
  68. package/source/modules/smart.passwordinput.js +1 -1
  69. package/source/modules/smart.passwordtextbox.js +1 -1
  70. package/source/modules/smart.path.js +1 -1
  71. package/source/modules/smart.phoneinput.js +1 -1
  72. package/source/modules/smart.pivottable.js +4 -4
  73. package/source/modules/smart.progressbar.js +1 -1
  74. package/source/modules/smart.qrcode.js +1 -1
  75. package/source/modules/smart.querybuilder.js +2 -2
  76. package/source/modules/smart.radiobutton.js +1 -1
  77. package/source/modules/smart.rating.js +1 -1
  78. package/source/modules/smart.router.js +2 -2
  79. package/source/modules/smart.scheduler.js +2 -2
  80. package/source/modules/smart.scrollbar.js +1 -1
  81. package/source/modules/smart.slider.js +1 -1
  82. package/source/modules/smart.sortable.js +1 -1
  83. package/source/modules/smart.splitter.js +1 -1
  84. package/source/modules/smart.switchbutton.js +1 -1
  85. package/source/modules/smart.table.js +3 -3
  86. package/source/modules/smart.tabs.js +1 -1
  87. package/source/modules/smart.tank.js +1 -1
  88. package/source/modules/smart.textarea.js +1 -1
  89. package/source/modules/smart.textbox.js +2 -2
  90. package/source/modules/smart.timeinput.js +1 -1
  91. package/source/modules/smart.timepicker.js +1 -1
  92. package/source/modules/smart.toast.js +1 -1
  93. package/source/modules/smart.tooltip.js +1 -1
  94. package/source/modules/smart.tree.js +2 -2
  95. package/source/modules/smart.validator.js +1 -1
  96. package/source/modules/smart.window.js +2 -2
  97. package/source/smart.accordion.js +1 -1
  98. package/source/smart.ajax.js +1 -1
  99. package/source/smart.array.js +1 -1
  100. package/source/smart.barcode.js +1 -1
  101. package/source/smart.bootstrap.js +1 -1
  102. package/source/smart.breadcrumb.js +1 -1
  103. package/source/smart.button.js +1 -1
  104. package/source/smart.buttongroup.js +1 -1
  105. package/source/smart.calendar.js +1 -1
  106. package/source/smart.card.js +1 -1
  107. package/source/smart.cardview.js +1 -1
  108. package/source/smart.carousel.js +1 -1
  109. package/source/smart.chart.annotations.js +1 -1
  110. package/source/smart.chart.api.js +1 -1
  111. package/source/smart.chart.core.js +1 -1
  112. package/source/smart.chart.js +1 -1
  113. package/source/smart.chart.rangeselector.js +1 -1
  114. package/source/smart.chart.waterfall.js +1 -1
  115. package/source/smart.checkbox.js +1 -1
  116. package/source/smart.checkinput.js +1 -1
  117. package/source/smart.chip.js +1 -1
  118. package/source/smart.colorinput.js +1 -1
  119. package/source/smart.colorpanel.js +1 -1
  120. package/source/smart.colorpicker.js +1 -1
  121. package/source/smart.combobox.js +2 -2
  122. package/source/smart.complex.js +1 -1
  123. package/source/smart.core.js +1 -1
  124. package/source/smart.countryinput.js +1 -1
  125. package/source/smart.data.js +2 -2
  126. package/source/smart.date.js +1 -1
  127. package/source/smart.dateformatpanel.js +1 -1
  128. package/source/smart.dateinput.js +2 -2
  129. package/source/smart.daterangeinput.js +1 -1
  130. package/source/smart.datetimepicker.js +1 -1
  131. package/source/smart.dockinglayout.js +1 -1
  132. package/source/smart.draw.js +1 -1
  133. package/source/smart.dropdownbutton.js +1 -1
  134. package/source/smart.dropdownlist.js +1 -1
  135. package/source/smart.editor.js +1 -1
  136. package/source/smart.element.js +1 -1
  137. package/source/smart.elements.js +18 -18
  138. package/source/smart.export.js +1 -1
  139. package/source/smart.fileupload.js +1 -1
  140. package/source/smart.filter.js +1 -1
  141. package/source/smart.filterbuilder.js +1 -1
  142. package/source/smart.filterpanel.js +1 -1
  143. package/source/smart.form.js +1 -1
  144. package/source/smart.format.js +1 -1
  145. package/source/smart.formulaparser.js +1 -1
  146. package/source/smart.ganttchart.js +2 -2
  147. package/source/smart.gauge.js +1 -1
  148. package/source/smart.grid.cell.js +2 -2
  149. package/source/smart.grid.chart.js +1 -1
  150. package/source/smart.grid.column.js +2 -2
  151. package/source/smart.grid.core.js +2 -2
  152. package/source/smart.grid.dialog.js +2 -2
  153. package/source/smart.grid.edit.js +2 -2
  154. package/source/smart.grid.export.js +1 -1
  155. package/source/smart.grid.filter.js +2 -2
  156. package/source/smart.grid.group.js +1 -1
  157. package/source/smart.grid.js +1 -1
  158. package/source/smart.grid.menu.js +2 -2
  159. package/source/smart.grid.pager.js +1 -1
  160. package/source/smart.grid.reorder.js +1 -1
  161. package/source/smart.grid.resize.js +1 -1
  162. package/source/smart.grid.row.js +2 -2
  163. package/source/smart.grid.select.js +2 -2
  164. package/source/smart.grid.sort.js +1 -1
  165. package/source/smart.grid.toolbar.js +2 -2
  166. package/source/smart.grid.tree.js +1 -1
  167. package/source/smart.grid.view.js +2 -2
  168. package/source/smart.gridpanel.js +1 -1
  169. package/source/smart.input.js +1 -1
  170. package/source/smart.kanban.js +2 -2
  171. package/source/smart.layout.js +1 -1
  172. package/source/smart.led.js +1 -1
  173. package/source/smart.listbox.js +1 -1
  174. package/source/smart.listmenu.js +1 -1
  175. package/source/smart.map.js +1 -1
  176. package/source/smart.maskedtextbox.js +1 -1
  177. package/source/smart.math.js +1 -1
  178. package/source/smart.menu.js +1 -1
  179. package/source/smart.multicomboinput.js +1 -1
  180. package/source/smart.multiinput.js +1 -1
  181. package/source/smart.multilinetextbox.js +1 -1
  182. package/source/smart.multisplitbutton.js +1 -1
  183. package/source/smart.numberformatpanel.js +1 -1
  184. package/source/smart.numberinput.js +1 -1
  185. package/source/smart.numeric.js +1 -1
  186. package/source/smart.numerictextbox.js +1 -1
  187. package/source/smart.pager.js +1 -1
  188. package/source/smart.passwordinput.js +1 -1
  189. package/source/smart.passwordtextbox.js +1 -1
  190. package/source/smart.path.js +1 -1
  191. package/source/smart.phoneinput.js +1 -1
  192. package/source/smart.pivottable.js +1 -1
  193. package/source/smart.powerbutton.js +1 -1
  194. package/source/smart.progressbar.js +1 -1
  195. package/source/smart.qrcode.js +1 -1
  196. package/source/smart.radiobutton.js +1 -1
  197. package/source/smart.rating.js +1 -1
  198. package/source/smart.router.js +1 -1
  199. package/source/smart.scheduler.js +1 -1
  200. package/source/smart.scrollbar.js +1 -1
  201. package/source/smart.slider.js +1 -1
  202. package/source/smart.sortable.js +1 -1
  203. package/source/smart.splitter.js +1 -1
  204. package/source/smart.switchbutton.js +1 -1
  205. package/source/smart.table.js +2 -2
  206. package/source/smart.tabs.js +1 -1
  207. package/source/smart.tank.js +1 -1
  208. package/source/smart.textarea.js +1 -1
  209. package/source/smart.textbox.js +1 -1
  210. package/source/smart.tickintervalhandler.js +1 -1
  211. package/source/smart.timeinput.js +1 -1
  212. package/source/smart.timepicker.js +1 -1
  213. package/source/smart.toast.js +1 -1
  214. package/source/smart.tooltip.js +1 -1
  215. package/source/smart.tree.js +2 -2
  216. package/source/smart.validationpanel.js +1 -1
  217. package/source/smart.validator.js +1 -1
  218. package/source/smart.window.js +1 -1
  219. package/source/styles/components/smart.ganttchart.css +1 -1
  220. package/source/styles/components/smart.kanban.css +1 -1
  221. package/source/styles/components/smart.pivottable.css +1 -1
  222. package/source/styles/components/smart.table.css +1 -1
  223. package/source/styles/default/scss/smart.kanban.scss +20 -3
  224. package/source/styles/default/scss/smart.table.scss +22 -4
  225. package/source/styles/default/scss/textbox/_check-input.scss +1 -0
  226. package/source/styles/default/scss/textbox/_multi-combo-input.scss +1 -1
  227. package/source/styles/default/smart.kanban.css +17 -1
  228. package/source/styles/default/smart.table.css +30 -12
  229. package/source/styles/smart.default.css +2 -2
  230. package/source/typescript/smart.combobox.d.ts +5 -0
  231. package/source/typescript/smart.elements.d.ts +99 -30
  232. package/source/typescript/smart.grid.d.ts +77 -28
  233. package/source/typescript/smart.kanban.d.ts +10 -0
  234. package/source/typescript/smart.scheduler.d.ts +1 -1
  235. package/source/typescript/smart.table.d.ts +1 -1
  236. package/source/typescript/smart.tree.d.ts +5 -0
  237. package/table/table.d.ts +1 -1
  238. package/table/table.esm.js +1 -1
  239. package/table/table.umd.js +1 -1
  240. package/tabswindow/tabswindow.umd.js +1 -1
  241. package/tree/tree.d.ts +5 -0
  242. package/tree/tree.esm.js +12 -1
  243. package/tree/tree.umd.js +12 -1
  244. package/waitwindow/waitwindow.umd.js +1 -1
@@ -24,7 +24,7 @@ Smart("smart-calendar",class extends Smart.BaseElement{static get properties(){r
24
24
  /***/ 6057:
25
25
  /***/ (() => {
26
26
 
27
- (()=>{Smart.DataAdapter=window.smartDataAdapter=class{constructor(e){e||(e={});const t=Object.assign(this,e);t.key=(65536*(1+Math.random())|0).toString(16).substring(1),t.$document=Smart.Utilities.Extend(document),t.boundSource=!1===t.observable||t.virtualDataSource?[]:new Smart.ObservableArray,t.dataItemById=[],void 0===t.allowAdd&&(t.allowAdd=!0),void 0===t.allowRemove&&(t.allowRemove=!0),void 0===t.allowUpdate&&(t.allowUpdate=!0),void 0===t.mapChar&&(t.mapChar="."),void 0!==e.observable||t.virtualDataSource?t.observable=!1:t.observable=!0,void 0===t.sanitizeHTML&&(t.sanitizeHTML="blackList"),t._expandedRowIds=[],e.dataSource||(t.dataSource=[]),e.dataFields||(t.dataFields=[]),e.dataSourceType||(t.dataSourceType="array"),e.id||(t.id=null),e.autoFetch||(t.autoFetch=!0),e.dataFields&&(t.dataFields=e.dataFields),Object.defineProperty(t,"groupBy",{configurable:!1,enumerable:!0,get:()=>t._groupBy?t._groupBy:[],set(e){const a=()=>{t.boundHierarchy=null,t.refreshHierarchy(),t.onGroup&&t.onGroup()};t._groupBy=new Smart.ObservableArray(e),t._groupBy.notify((function(){a()})),t.isInitialized&&a()}}),e.groupBy?e.groupBy.toArray?t.groupBy=e.groupBy.toArray():t.groupBy=e.groupBy:t.groupBy=[],e&&!1!==e.autoBind&&t.dataBind(),t.isInitialized=!0}beginUpdate(){this.isUpdating=!0}endUpdate(){const e=this;e.isUpdating=!1,e.refreshIndexes(),e.refreshHierarchy()}get expandHierarchy(){return void 0===this._expandHierarchy&&(this._expandHierarchy=!1),this._expandHierarchy}set expandHierarchy(e){const t=this;t._expandHierarchy=e,t.isInitialized&&t.refreshHierarchy()}_getDataField(e){switch(e.name){case"leaf":case"parent":case"expanded":case"checked":case"selected":case"level":case"icon":case"data":case"group":case"children":case"items":e.map?e.map=e.map.replace(e.name,"$"+e.name):e.map=e.name,e.name="$"+e.name}}get dataFields(){return this._dataFields}set dataFields(e){const t=this;return t._dataFields=t._getDataFieldObjects(e),t._dataFields}_getDataFieldObjects(e){const t=this;let a=[];if("number"==typeof e){const t="A".charCodeAt(0);let n="",r=0;for(let i=0;i<e;i++){const e=String.fromCharCode(t+r);r++;const i=n+e;a.push({name:i,dataType:"string"}),r>=26&&(r=0,n+="A")}}else if(Array.isArray(e)&&e.length>0)for(let n=0;n<e.length;n++){const r=e[n];if("string"==typeof r){const e=r.split(":"),t=e[0].trim(),n=e.length>1?e[1].trim():"string";a.push({name:t,dataType:n})}else a.push(r);t._getDataField(a[a.length-1])}return a}get dataSource(){const e=this;return e._dataSource||(e._dataSource=[]),e._dataSource}set dataSource(e){const t=this;t._dataSource=e,t.isInitialized&&(t.boundSource=!1===t.observable||t.virtualDataSource?[]:new Smart.ObservableArray,t.dataItemById=[],t.bindingCompleted=!1,t.dataBind(),t.refreshIndexes())}get canNotify(){const e=this;return void 0===e._canNotify&&(e._canNotify=!0),e._canNotify}set canNotify(e){this._canNotify=e}_notify(e){const t=this;t.canNotify&&t.notifyFn&&t.notifyFn(e)}notify(e){e&&(this.notifyFn=e)}toArray(){const e=this;return!1===e.observable?e.boundSource:e.boundSource.toArray()}dataBind(){const t=this;t.bindingCompleted=!1,t.clear();const a=()=>{t.observable&&(t.boundSource.notify||(t.boundSource=new Smart.ObservableArray),t.boundSource.notify((function(e){if("update"===e.action&&e.path&&e.path.indexOf(".")>=0&&-1===e.path.indexOf("children")&&-1===e.path.indexOf("loaded")&&-1===e.path.indexOf("level")&&-1===e.path.indexOf("leaf")&&-1===e.path.indexOf("expanded")){let a=!1;for(let n=0;n<t.dataFields.length;n++){const r=t.dataFields[n].name;e.path.indexOf(r)>=0&&(a=!0)}t._notify&&a&&t._notify({action:"update",data:e.target,index:e.index})}}))),t._onBindingComplete()};"string"==typeof t.dataSource&&(t.dataSource.indexOf(".json")>=0||"json"===t.dataSourceType)?(t.url=t.dataSource,t.dataSourceType="json",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&t.dataSource.indexOf(".xml")>=0?(t.url=t.dataSource,t.dataSourceType="xml",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&t.dataSource.indexOf(".xlsx")>=0?(t.url=t.dataSource,t.dataSourceType="xlsx",new e(t,(e=>{if(!e[0])return e=[],t._bindToArray(),void a();const n=Object.keys(e[0]),r={},i=[];if(!1!==t.exportHeader){let a=0;for(let e in n){r[n[e]]=t.dataFields[a++].name}for(let t=1;t<e.length;t++){const a=e[t],o={};for(let e in n){const t=n[e];o[r[t]]=a[t]}i.push(o)}t.dataSource=i}t._bindToArray(),a()}))):"string"==typeof t.dataSource&&t.dataSource.indexOf(".csv")>=0?(t.url=t.dataSource,t.dataSourceType="csv",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&t.dataSource.indexOf(".tsv")>=0?(t.url=t.dataSource,t.dataSourceType="tsv",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&(t.dataSource.indexOf(".ics")>=0||t.dataSource.indexOf(".php")>=0&&"ics"===t.dataSourceType||t.dataSource.indexOf(".txt")>=0&&"ics"===t.dataSourceType)?(t.url=t.dataSource,t.dataSourceType="ics",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&(t.dataSource.indexOf("BEGIN:VCALENDAR")>=0||"ics"===t.dataSourceType)?(t._bindToICS(),a()):"string"==typeof t.dataSource&&(t.dataSource.indexOf("<?xml")>=0||"xml"===t.dataSourceType)?(t._bindToXML(),a()):"string"==typeof t.dataSource&&(t.dataSource.indexOf(" ")>=0||t.dataSource.indexOf(",")>=0||"tsv"===t.dataSourceType||"csv"===t.dataSourceType||"tab"===t.dataSourceType)?(t._bindToCSV(),a()):"array"===t.dataSourceType?(t._bindToArray(),a()):"json"===t.dataSourceType&&(t._bindToJSON(),a())}_bindToXML(){const e=this;let t=null,a=null;window.DOMParser&&(t=new DOMParser,a=t.parseFromString(e.dataSource,"text/xml")),void 0===e.root&&(e.root=""),void 0===e.record&&(e.record="");const n=a.querySelectorAll(e.root+" "+e.record),r=n.length,i=[];let o=e.dataFields?e.dataFields.length:0;if(0===o){const t=n[0],a=new Array;for(let e in t){const t=e;a[a.length]={name:t}}e.dataFields=a,o=a.length}for(let t=0;t<r;t++){const a=n[t],r={};if(void 0===a)break;if(e.id){const t=a.querySelector(e.id);r[e.id]=t.textContent}for(let t=0;t<o;t++){const n=e.dataFields[t],i=a.querySelector(n.map||n.name);r[n.name]=i.textContent}i[t]=r}e.canNotify=!1,e.dataSource=i,e.canNotify=!0,e._bindToArray()}static BindToCSV(e,t=!1){const a=""+e,n=-1===a.indexOf(",")?"\t":",",r=a.split("\r"),i=new Array,o=[];let d=a.split("\n"),l=d.length;1===l&&r.length>1&&(d=r,l=d.length);const s=!0===t;for(let e=0;e<l;e++){const t={},a=d[e].split(n);for(let n=0;n<a.length;n++){let r=o[n],i=a[n];if(r||(o.push({name:i.trim()}),r=o[o.length-1]),i=i.trim(),1!==e||s)switch(r.dataType){case"boolean":i="false"!==i;break;case"number":i=parseFloat(i);break;case"date":i=new Date(i)}else{let e="string";"false"===i||"true"===i?(e="boolean",i="false"!==i):isNaN(parseInt(i)&&-1===i.indexOf("/"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}t[r.name]=i}(s||e>0)&&i.push(t)}return i}_bindToCSV(){const e=this,t=""+e.dataSource,a=-1===t.indexOf(",")?"\t":",",n=t.split("\r"),r=new Array;let i=t.split("\n"),o=i.length;1===o&&n.length>1&&(i=n,o=i.length);const d=e.dataFields.length>0;for(let t=0;t<o;t++){const n=i[t],o={},l=i[t].split(a);for(let a=0;a<l.length;a++){let r=e.dataFields[a],i=l[a];if(r||(e.dataFields.push({name:i.trim()}),r=e.dataFields[e.dataFields.length-1]),r.map&&(i=n[r.map]),i=i.trim(),1!==t||d)switch(r.dataType){case"boolean":i="false"!==i;break;case"number":i=parseFloat(i);break;case"date":i=new Date(i)}else{let e="string";"false"===i||"true"===i?(e="boolean",i="false"!==i):isNaN(parseInt(i)&&-1===i.indexOf("/"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}o[r.map||r.name||a.toString()]=i}(d||t>0)&&r.push(o)}e.canNotify=!1,e.dataSource=r,e.canNotify=!0,e._bindToArray()}_onBindingComplete(){const e=this;e._buildHierarchy(),e.onBindingComplete&&e.onBindingComplete({data:e.boundSource}),e._notify&&e._notify({action:"bindingComplete",data:e.boundSource}),e.bindingCompleted=!0}refreshHierarchy(){this.isUpdating||this._buildHierarchy()}find(){return this.boundSource.find.apply(this.boundSource,arguments)}onVirtualDataSourceRequested(e,t){const a=this;let n=t?t.first:1/0,r=t?t.last:1/0,i=t?t.row:null;if(void 0===n&&(n=1/0),void 0===r&&(r=1/0),a.virtualFirstIndex=n,a.virtualLastIndex=r,a.virtualDataSource){const o=function(r){void 0!==r.virtualDataSourceLength&&(a.virtualDataSourceLength=r.virtualDataSourceLength),new Smart.DataAdapter({dataSource:r.dataSource,dataFields:r.dataFields||a.dataFields,data:t,keyDataField:r.keyDataField,parentDataField:r.parentDataField,observable:!1,id:r.id||a.id,onBindingComplete(r){if(void 0===t.result&&(t.result=!0),a.virtualDataSourceOnExpand&&i)return a.groupBy.length>0?r.data&&r.data.length>0&&a.add(r.data):r.data&&r.data.length>0?a.add(r.data,i.$.id):i.leaf=!0,a.onFilter&&a.onFilter(),void e(t);n===1/0&&"scroll"===t.action?r.data&&r.data.length&&a.add(r.data):"filter"===t.action||"group"===t.action?(a.canNotify=!1,a.dataSource=r.data,a.canNotify=!0):("add"===t.action||"update"===t.action||t.action,a.canNotify=!1,a.dataSource=r.data,a.canNotify=!0),a.onFilter&&a.onFilter(),e(t)}})};let d={};if(t.sorting&&t.sorting.length>0){let e=[];for(let a in t.sorting)e.push(a+" "+t.sorting[a].sortOrder.toUpperCase());const a=" ORDER BY "+e.join(", ");d.orderBy=a}else d.orderBy="";if(void 0===n||void 0===r||0===n&&0===r)d.limit="";else{const e=r-n,t=" LIMIT "+e+" OFFSET "+n;d.limit=t,isNaN(e)&&(d.limit="")}if(t.grouping&&t.grouping.length>0){const e=" GROUP BY "+t.grouping[0];d.groupBy=e}else d.groupBy="";if(t.filtering&&t.filtering.length>0){const e=(e,t)=>{switch(t.condition){case"EMPTY":return e+" = ''";case"NOT_EMPTY":return e+" != ''";case"EQUAL":return e+" = '"+t.value+"'";case"NOT_EQUAL":return e+" != '"+t.value+"'";case"CONTAINS_CASE_SENSITIVE":case"CONTAINS":return e+" LIKE '%"+t.value+"%'";case"DOES_NOT_CONTAIN_CASE_SENSITIVE":case"DOES_NOT_CONTAIN":return e+" NOT LIKE '%"+t.value+"%'";case"STARTS_WITH_CASE_SENSITIVE":case"STARTS_WITH":return e+" LIKE '"+t.value+"%'";case"ENDS_WITH_CASE_SENSITIVE":case"ENDS_WITH":return e+" LIKE '%"+t.value+"'";case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL"}},a=(e,t)=>{switch(t.condition){case"EQUAL":return e+" = "+t.value;case"NOT_EQUAL":return e+" != "+t.value;case"GREATER_THAN":return e+" > "+t.value;case"GREATER_THAN_OR_EQUAL":return e+" >= "+t.value;case"LESS_THAN":return e+" < "+t.value;case"LESS_THAN_OR_EQUAL":return e+" <= "+t.value;case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL";case"RANGE":return"("+e+" >= "+t.value+" and "+e+" <= "+t.valueTo+")"}},n=(e,t,a)=>{if(a.operator){var n=e(t,a.condition1),r=e(t,a.condition2);return"("+n+" "+a.operator+" "+r+")"}return e(t,a)};let r=[];for(let i in t.filtering){const o=t.filtering[i];let d=o.filters,l=[],s=" AND ";for(let t=0;t<d.length;t++){const r=d[t];switch(r.type){case"stringFilter":l.push(n(e,i,r));break;case"numericFilter":case"dateFilter":case"booleanFilter":l.push(n(a,i,r))}1===o.logicalOperators[t]&&(s=" OR ")}r.push("("+l.join(s)+")")}if(r.length>0){let e=" AND ";t.filterOperator&&"or"===t.filterOperator.toLowerCase()&&(e=" OR "),d.where=" WHERE "+r.join(e)}else d.where=""}else d.where="";if("dataBind"===t.action&&a.virtualDataSourceOnExpand&&a.keyDataField&&a.parentDataField&&(d.where?d.where+=" AND "+a.parentDataField+" IS NULL":d.where=" WHERE "+a.parentDataField+" IS NULL"),"update"===t.action){const e=[];for(let n in t.edit.row)"$"!==n&&n!==a.id&&e.push(n+"='"+t.edit.row[n]+"'");d.update=" SET "+e.join(", ")+" WHERE "+a.id+"="+t.edit.row[a.id]}if("remove"===t.action){const e=[];for(let n in t.edit.row)"$"!==n&&n!==a.id&&e.push(n+" = '"+t.edit.row[n]+"'");d.remove=" WHERE "+a.id+"="+t.edit.row[a.id]}if("add"===t.action){const e=[],a=[];for(let n in t.edit.row)"$"!==n&&(a.push(n),e.push("'"+t.edit.row[n]+"'"));d.add=" ("+a.join(", ")+") VALUES ("+e.join(", ")+")"}"expand"===t.action?(a.groupDataField?d.where?d.where+=" AND "+a.groupDataField+" = '"+i[a.groupDataField]+"'":d.where=" WHERE "+a.groupDataField+" = '"+i[a.groupDataField]+"'":a.keyDataField&&a.parentDataField?d.where?d.where+=" AND "+a.parentDataField+" = "+i[a.keyDataField]:d.where=" WHERE "+a.parentDataField+" = "+i[a.keyDataField]:d.where?d.where+=" AND "+i.groupDataField+" = '"+i.label+"'":d.where=" WHERE "+i.groupDataField+" = '"+i.label+"'",d.limit="",d.groupBy="",a.virtualDataSourceOnExpand(o,{first:n,last:r,row:t.row,sorting:t.sorting,filtering:t.filtering,grouping:t.grouping,action:t.action,query:d})):a.virtualDataSource(o,{first:n,last:r,sorting:t.sorting,filtering:t.filtering,filterOperator:t.filterOperator||"and",grouping:t.grouping,action:t.action,query:d})}else e()}add(e,t){const a=this;if(!e)return;let n=!0;const r=function(e){const r=a._getDataItem(e,a.boundSource.length);if(a.dataItemById[r.$.id])return void 0!==t&&(r.$.parentId=t),null;a[a.boundSource.length]=r,a.dataItemById[r.$.id]=r;const i=a.boundSource.push(r);return void 0!==t&&(r.$.parentId=t),i||(n=!1),r};if(e.length){let t=[];for(let a=0;a<e.length;a++){const n=r(e[a]);n&&t.push(n)}a._notify({action:"add",data:t})}else{const t=r(e);a._notify({action:"add",data:t})}return a.refreshHierarchy(),n}refreshIndexes(){const e=this;for(let t=0;t<e.boundSource.length;t++)e[t]=e.boundSource[t],e[t].$.index=t,e.dataItemById[e[t].$.id]=e[t];let t=e.boundSource.length;for(;e[t];)delete e[t],t++}removeLast(){const e=this;delete e[e.boundSource.length-1];const t=e.boundSource.pop();return delete e.dataItemById[t.$.id],e._notify({action:"removeLast",data:t}),e.refreshHierarchy(),t}remove(e){const t=this;let a=t.indexOf(e);-1===a&&e&&e.$&&(a=t.indexOf(t.dataItemById[e.$.id])),t.removeAt(a)}removeAt(e){const t=this,a=t.boundSource[e];if(!a)throw new Error("Invalid Item Index");t.boundSource.splice(e,1),delete t.dataItemById[a.$.id],t.refreshIndexes(),t._notify({action:"remove",index:e,data:a}),t.refreshHierarchy()}update(e,t){const a=this;if(Smart.Utilities.Types.isArray(e)&&Smart.Utilities.Types.isArray(t)&&0===e.length&&0===t.length)return void a.refreshHierarchy();if(t.length&&e.length){let n=[];for(let r=0;r<e.length;r++){const i=a._getDataItem(t[r],e[r]),o=e[r];n.push(i),a.boundSource[o]=i,a[o]=a.boundSource[o],a.dataItemById[i.$.id]=a[o]}return a._notify({action:"update",index:e,data:n}),void a.refreshHierarchy()}const n=a._getDataItem(t,e),r=a.boundSource[e].$.id;return n.$.id=r,a.boundSource[e]=n,a[e]=a.boundSource[e],a.dataItemById[n.$.id]=a[e],a._notify({action:"update",index:e,data:n}),a.refreshHierarchy(),n}insert(e,t){const a=this;if(t.length){const n=[];for(let r=0;r<t.length;r++){const i=a._getDataItem(t[r],e+r);n.push(i)}t=n}else t=a._getDataItem(t,e);const n=a.boundSource.splice(e,0,t);return a.refreshIndexes(),a._notify({action:"insert",index:e,data:t}),a.refreshHierarchy(),n}move(e,t){if(t>e&&t-e==1||e===t)return;const a=this,n=a.boundSource.splice(e,1)[0];t>e?(t--,a.boundSource.splice(t,0,n)):a.boundSource.splice(t,0,n),a.refreshIndexes(),a._notify({action:"move",index:t,data:a.boundSource[t]}),a.refreshHierarchy()}indexOf(e){return this.boundSource.indexOf(e)}get length(){const e=this;return void 0!==e.virtualDataSourceLength?e.virtualDataSourceLength:e.dataSourceLength?e.dataSourceLength:"number"==typeof e.dataSource?e.dataSource:e.bindingCompleted?e.boundSource.length:e.dataSource&&"string"!=typeof e.dataSource&&e.dataSource.length?e.dataSource.length:e.boundSource.length}clear(){const e=this;if(!e.isInitialized)return e._cachedValues=[],void(e.dataItemById=[]);for(let t=0;t<e.boundSource.length;t++)delete e[t];e._expandedRowIds=[],e._cachedValues=[],e.boundSource=e.observable?new Smart.ObservableArray:[],e.dataItemById=[],e.refreshHierarchy()}_getId(e,t,a){if(null===e||void 0===e.name||!e.name||!t.getAttribute){if(e&&e.toString().length>0&&t.getAttribute){let a=t.getAttribute(e);if(null!==a&&a.toString().length>0)return a.trim().split(" ").join("").replace(/([ #;?%&,.+*~\':'!^$[\]()=>|\/@])/g,"");{let a=e.split(this.mapChar);if(a.length>1){let e=t;for(let t=0;t<a.length;t++)void 0!==e&&(e=e[a[t]]);if(void 0!==e)return e}else if(void 0!==t[e])return t[e]}}return a}{let n=t.getAttribute(e.name);if(null!==n&&n.toString().length>0)return n;if(e.map)try{let a=t.getAttribute(e.map);if(null!==a&&a.toString().length>0)return a}catch(e){return a}}}_buildHierarchy(){const e=this;if(e.reservedNames){const t=e.reservedNames;t.leaf||(t.leaf="leaf"),t.parent||(t.parent="parent"),t.expanded||(t.expanded="expanded"),t.checked||(t.checked="checked"),t.selected||(t.selected="selected"),t.level||(t.level="level"),t.data||(t.data="data")}else e.reservedNames={leaf:"leaf",parent:"parent",expanded:"expanded",checked:"checked",selected:"selected",level:"level",icon:"icon",data:"data"};const t=e.reservedNames;if(e.childrenDataField){const a=[];for(let n=0;n<e.boundSource.length;n++){const r=Object.assign({},e.boundSource[n]);if(!r)continue;a.push(r);const i=function(a){const n=e.childrenDataField.split(e.mapChar);let r=null;if(n.length>1){let e=a;for(let t=0;t<n.length;t++)void 0!==e&&(e=e[n[t]]);r=e}else r=a.children;a.children=r,(null===a.children||void 0===a.children||a.children&&0===a.children.length)&&(a[t.leaf]=!0)};i(r),r[t.level]=0,r.$||(r.$={}),r[t.parent]=null,r[t.data]=r,void 0===r[t.expanded]&&(r[t.expanded]=!1,e.expandHierarchy&&(r[t.expanded]=!0));const o=function(a,n){if(n)for(let r=0;r<n.length;r++){let d=e._getDataItem(n[r],r);if(d){if(i(d),!e.id){const e=function(){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()};d.$.id=e()}d[t.level]=a[t.level]+1,d[t.parent]=a,d[t.data]=Object.assign({},d),a&&(a.children[r]=d),void 0===d[t.expanded]&&(d[t.expanded]=!1,e.expandHierarchy&&(d[t.expanded]=!0)),o(d,d.children)}}else a.children=new Array};o(r,r.children)}if(e.boundHierarchy=a,!e._boundSourceUpdate){for(let t=0;t<e.boundHierarchy.length;t++){const a=e.boundHierarchy[t];if(a.children){const t=function(a){if(e.dataItemById[a.$.id]||(e.boundSource.canNotify=!1,e.dataItemById[a.$.id]=a,e.boundSource.canNotify=!0),a.children)for(let e=0;e<a.children.length;e++){const n=a.children[e];n.children&&t(n)}};t(a)}}e._boundSourceUpdate=!0}}if(e.xmlRoot&&"xml"===e.dataSourceType&&(e.boundHierarchy=this._getHierarchy("uid","_parentuid","children",null,e.boundSource)),e.keyDataField&&e.parentDataField)return["keyDataField","parentDataField"].forEach((t=>{switch(e[t]){case"parent":e[t]="$"+e[t]}})),void(e.boundHierarchy=this._getHierarchy(e.keyDataField,e.parentDataField,"children",null,e.boundSource));e.groupBy&&e.groupBy.length>0?e.boundHierarchy=this._getGroupHierarchy(e.groupBy,"children","label",null,"data",null,"parent",e.boundSource):e.virtualDataSourceOnExpand&&(e.boundHierarchy=this._getHierarchy("id","parentId","children",null,e.boundSource))}_getGroupHierarchy(e,t,a,n,r,i,o,d,l){let s=this;l||(l=0);let c=s.reservedNames;const u=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()};let f=new Array;for(let t=0;t<e.length;t++)f[t]=u();t||(t="children"),a||(a="group"),r||(r="item"),o||(o="parent"),void 0===i&&(i="value");const h=new Array,p=new Array;let g=0;const S=function(e){let t=e;if(n)for(let e in n){const a=n[e];a.name&&a.map&&(t[a.map]=t[a.name])}return t};let y=!1;for(let n=0;n<d.length;n++){let m=Object.assign({},S(d[n]));m[c.leaf]=!1;let T=new Array,b=0;for(let t=0;t<e.length;t++){const a=e[t],n=m[a];null!=n?((""===n||void 0===n&&0===t)&&(y=!0),T[b++]={value:n,group:a,hash:f[t]}):(T[b++]={value:null,group:a,hash:f[t]},0===t&&(y=!0))}if(T.length!==e.length)break;let v=null,E="";for(let e=0;e<T.length;e++){const n=T[e].value,d=T[e].group;if(E=E+"_"+T[e].hash+"_"+n,void 0===p[E]||null===p[E]){if(null===v){v={$:{}},v[c.level]=0,v[c.leaf]=!1,v[o]=null,v[a]=n,v[r]=m,v.groupDataField=d,v[d]||(v[d]=v.data[d]),void 0!==m[c.expanded]?v[c.expanded]=m[c.expanded]:(v[c.expanded]=!1,s.expandHierarchy&&(v[c.expanded]=!0)),i&&(v[i]=m[i]),v[t]=new Array;let e=h.length+l;this.id&&"number"!=typeof m.$.id&&!isFinite(m.$.id)||(e="Item"+e),void 0===v.$.id&&(v.$.id=e),s._expandedRowIds[v.$.id]&&(v[c.expanded]=!0),h[g++]=v}else{const e={$:{}};e[c.level]=v[c.level]+1,e[o]=v,e[a]=n,e[t]=new Array,e[r]=m,e.groupDataField=d,e[c.leaf]=!1,e[d]||(e[d]=e.data[d]),void 0!==m[c.expanded]?e[c.expanded]=m[c.expanded]:(e[c.expanded]=!1,s.expandHierarchy&&(e[c.expanded]=!0)),i&&(e[i]=m[i]),void 0===e.$.id&&(e.$.id=v.$.id+"_"+v[t].length),s._expandedRowIds[e.$.id]&&(e[c.expanded]=!0),v[t][v[t].length]=e,v=e}p[E]=v}else v=p[E]}m&&(m[c.leaf]=!0),null!==v?(null===this.id?void 0===m.$.id&&(m.$.id=v.$.id+"_"+v[t].length):void 0===m.$.id&&-1===m.$.id.toString().indexOf(v.$.id)&&(m.$.id=v.$.id+"_"+m.$.id),m[o]=v,m[c.level]=v[c.level]+1,v[t][v[t].length]=m):void 0===m.$.id&&(m.$.id=u())}if(y){let e=null,t=!1;for(let a=0;a<h.length;a++){const n=h[a];if(!n[n.groupDataField]){e=n,e.$.id.toString().startsWith("Item")&&(t=!0),h.splice(a,1);break}}if(e&&(h.push(e),t))for(let e=0;e<h.length;e++){h[e].$.id="Item"+e}}return h}_getHierarchy(e,t,a,n,r){const i=this,o=new Array;let d=this.boundSource;if(r&&(d=r),0===this.boundSource.length)return null;const l=null!==a?a:"children";let s=new Array,c=d,u=c.length,f=i.reservedNames;const h=function(e){let t=e;if(n)for(let e in n){const a=n[e];a.name&&a.map&&(t[a.map]=t[a.name])}return t};for(let a=0;a<u;a++){let n=c[a],r=n[t],o=n[e];"parentId"===t&&(r=n.$.parentId),"id"===e&&(o=n.$.id),n[l]=new Array,i.expandHierarchy&&void 0===n[f.expanded]&&(n[f.expanded]=i.expandHierarchy),s[o]={parentId:r,item:n}}for(let a=0;a<u;a++){const n=c[a];let r=n[t],i=n[e];if("parentId"===t&&(r=n.$.parentId),"id"===e&&(i=n.$.id),void 0!==s[r]){let e={parentId:r,item:s[i].item},t=s[r].item;t[l]||(t[l]=new Array);let a=t[l].length;e=e.item,f?e[f.parent]=t:e.parent=t;const n=h(e);t[l][a]=n,s[r].item=t,s[i].item=e}else{let e=s[i].item;f?void 0===e[f.parent]&&(e[f.parent]=null):void 0===e.parent&&(e.parent=null);const t=h(e);f?t[f.level]=0:t.level=0,o[o.length]=t}}if(0!==o.length){let e=function(t,a){for(let n=0;n<a.length;n++){const r=a[n];f?r[f.level]=t:r.level=t;const o=r[l];o&&o.length>0?(r.leaf=!1,e(t+1,o)):i.virtualDataSourceOnExpand?void 0===r.leaf&&(r.leaf=!1):f?r[f.leaf]=!0:r.leaf=!0}};e(0,o)}return o}summarize(e,t){const a=this;Array.isArray(e)||(e=[e]);let n=[];for(let t=0;t<e.length;t++){const a=e[t];for(let e in a){const t=a[e];n.push({dataField:e,functions:t})}}e=n;let r={},i=new Array;t||(t=a.boundSource);let o=t.length,d=0;if(0!==o&&void 0!==o){for(let a=0;a<o;a++){let n=t[a];if((!n||!n.$||!1!==n.$.filtered)&&n){d++;for(let t=0;t<e.length;t++){const o=e[t];let d=n[o.dataField];if(o.functions&&o.functions.length>0){r[o.dataField]=r[o.dataField]||{},i[o.dataField]=i[o.dataField]||0,i[o.dataField]++;const e=function(e){for(let t in e){let a=r[o.dataField][t];null==a&&(r[o.dataField][t]=0,a=0),"function"==typeof e[t]&&(a=e[t](a,d,o.dataField,n)),r[o.dataField][t]=a}},t=d;let l=parseFloat(d);l=!isNaN(l),t&&t.toDate&&(l=!1),"string"==typeof d&&d.startsWith("+")&&(l=!1),l&&(d=parseFloat(d)),"number"==typeof d&&isFinite(d)?o.functions.forEach((function(t){let n=r[o.dataField][t];if(null==n&&(n=0,"min"===t&&(n=9999999999999),"max"===t&&(n=-9999999999999),"median"===t&&(n=[])),"sum"===t||"avg"===t||"stdev"===t||"stdevp"===t||"var"===t||"varp"===t)n+=parseFloat(d);else if("product"===t)0===a?n=parseFloat(d):n*=parseFloat(d);else if("min"===t)n=Math.min(n,parseFloat(d));else if("max"===t)n=Math.max(n,parseFloat(d));else if("count"===t)n++;else if("median"===t)n.push(parseFloat(d));else if("blank"===t)n=r[o.dataField][t],null==n&&(n=0),d||n++;else if("filled"===t)n=r[o.dataField][t],null==n&&(n=0),void 0!==d&&n++;else if("unique"===t)n=r[o.dataField][t],null==n&&(n=[]),-1===n.indexOf(d)&&n.push(d);else if("object"==typeof t)return void e(t);r[o.dataField][t]=n})):o.functions.forEach((function(t){if("min"===t||"max"===t||"count"===t||"product"===t||"sum"===t||"avg"===t||"stdev"===t||"stdevp"===t||"var"===t||"varp"===t){if(null===d&&"count"!==t)return!0;let e=r[o.dataField][t];return null==e&&(e=0),r[o.dataField][t]=e,!0}if("blank"===t){let e=r[o.dataField][t];null==e&&(e=0),d||e++,r[o.dataField][t]=e}else if("filled"===t){let e=r[o.dataField][t];null==e&&(e=0),d&&e++,r[o.dataField][t]=e}else if("unique"===t){let e=r[o.dataField][t];null==e&&(e=[]),-1===e.indexOf(d)&&e.push(d),r[o.dataField][t]=e}"object"==typeof t&&e(t)}))}}}}for(let a=0;a<e.length;a++){const n=e[a];if(n.functions&&(!n.functions||0!==n.functions.length)){if(r[n.dataField]||(r[n.dataField]={},n.functions.forEach((function(e){r[n.dataField][e]=0}))),void 0!==r[n.dataField].avg){const e=r[n.dataField].avg,t=i[n.dataField];r[n.dataField].avg=0===t||void 0===t?0:e/t}else void 0!==r[n.dataField].count&&(r[n.dataField].count=d);if(void 0!==r[n.dataField].unique){const e=r[n.dataField].unique;r[n.dataField].unique=e.length}if(void 0!==r[n.dataField].median){let e=r[n.dataField].median;e.sort((function(e,t){return e-t})),r[n.dataField].median=.5*(e[Math.floor((e.length+1)/2)-1]+e[Math.ceil((e.length+1)/2)-1])}(r[n.dataField].stdev||r[n.dataField].stdevp||r[n.dataField].var||r[n.dataField].varp)&&n.functions.forEach((function(e){if("stdev"===e||"var"===e||"varp"===e||"stdevp"===e){const a=r[n.dataField][e],i=o,d=a/o;let l=0;for(let e=0;e<o;e++){let a=t[e][n.dataField];l+=(a-d)*(a-d)}let s="stdevp"===e||"varp"===e?i:i-1;0===s&&(s=1),"var"===e||"varp"===e?r[n.dataField][e]=l/s:"stdevp"!==e&&"stdev"!==e||(r[n.dataField][e]=Math.sqrt(l/s))}}))}}return r}}_getDataItem(e,t){const a=this,n={},r="number"==typeof a.dataSource||a.dataSourceLength;if(!e)return{$:{id:t,isEmpty:!0,index:t}};if("string"==typeof e&&(e={"":e}),r){for(let e=0;e<a.dataFields.length;e++){n[(a.dataFields?a.dataFields[e]:{}).name]=""}return n.$={},n.$.id=t,n.$.index=t,n}const i=e;if(void 0!==i.expanded&&(n.expanded=i.expanded,"true"===i.expanded||!0===i.expanded||1===i.expanded?n.expanded=!0:n.expanded=!1),a.childrenDataField?void 0!==i[a.childrenDataField]&&(n.children=i[a.childrenDataField]):void 0!==i.children?n.children=i.children:void 0!==i.items&&(n.children=i.items),void 0!==i.leaf&&(n.leaf=i.leaf),void 0!==i.level&&(n.level=i.level),a.keyDataField&&void 0!==i[a.keyDataField]&&(n[a.keyDataField]=i[a.keyDataField]),a.parentDataField&&void 0!==i[a.parentDataField]&&(n[a.parentDataField]=i[a.parentDataField]),0===a.dataFields.length){const t=Object.getOwnPropertyNames(e);for(let e=0;e<t.length;e++)"$"!==t[e]&&a.dataFields.push({name:t[e],dataType:"string"})}for(let t=0;t<a.dataFields.length;t++){const r=a.dataFields?a.dataFields[t]:{};let o="";if(null==r)continue;if(e.length&&(o=e[t]),r.map){let e=r.map.split(a.mapChar);if(e.length>0){let t=i;for(let a=0;a<e.length;a++)i&&(t=t[e[a]]);o=t}else o=i[r.map]}null!=o?o=o.toString():void 0===o&&null!==o&&(o="");let d=!1;if(""===o&&(d=!0,o=e[r.name],void 0===r.dataType&&(r.dataType="any"),null!=o?"array"!==r.dataType&&("any"===r.dataType?o=Array.isArray(e[r.name])?[...e[r.name]]:"object"==typeof e[r.name]?Object.assign({},e[r.name]):e[r.name]:"date"!==r.dataType&&(o=o.toString())):o=void 0===o&&"any"===r.dataType?null:""),"[object Object]"===o&&r.map&&d&&(o=""),a._cachedValues[o+"_"+r.dataType])o=a._cachedValues[o+"_"+r.dataType];else{if("bool"===r.dataType||"boolean"===r.dataType)"true"===o||"1"===o?o=!0:"false"!==o&&"0"!==o||(o=!1);else if("number"===r.dataType)-1===o.indexOf(".")&&o.indexOf(",")>=0&&o.substring(1+o.indexOf(",")).length<3&&(o=o.replace(",",".")),o=a.$document.deserialize(""+o,r.dataType,!0);else if("date"===r.dataType)if(r.formatString&&Smart.Utilities.DateTime){o=Smart.Utilities.DateTime.ParseDate(o,r.formatString)}else o=a.$document.deserialize(""+o,r.dataType,!0);else"any"!==r.dataType&&(o=a.$document.deserialize(""+o,r.dataType,!0));"any"!==r.dataType&&(a._cachedValues[o+"_"+r.dataType]=o)}"string"!==r.dataType&&"boolean"!==r.dataType&&"bool"!==r.dataType&&"any"!==r.dataType&&(isNaN(o)||o===-1/0||o===1/0)&&(o="date"===r.dataType||"number"===r.dataType?null:0),"parent"!==r.name&&"group"!==r.name&&"leaf"!==r.name&&"level"!==r.name?("string"===r.dataType&&/<.+?>/.test(o)&&o.replace&&("all"===a.sanitizeHTML?o=o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;"):"blackList"===a.sanitizeHTML&&(o=window.Smart.Utilities.Core.sanitizeHTML(o))),n[r.name]=o):n.$[r.name]=o}let o=t;if(a.id){if(o=i[a.id],void 0===o){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};o=e()+e()}"object"==typeof o&&(o=t),i.$&&void 0!==i.$.id&&(o=i.$.id)}else if(!a.virtualDataSource&&a.dataItemById&&a.dataItemById[o])for(o=a.length;a.dataItemById[o];)o++;return n.$||(n.$={}),n.$.id=o,n.$.index=t,new Object(n)}_bindToArray(){const e=this,t="number"==typeof e.dataSource||e.dataSourceLength,a=[];e.boundSource.canNotify=!1;const n=t?"number"==typeof e.dataSource?e.dataSource:e.dataSource.length:e.observable?e.length:e.dataSource.length;for(let r=0;r<n;r++){const n=t?{}:e.dataSource[r],i=e._getDataItem(n,r);a.push(i)}if(t&&e.dataSourceLength&&e.dataSource.length>0)for(let t=0;t<e.dataSource.length;t++){const n=e.dataSource[t].cell,r=e.dataSource[t].value,i=n.replace(/[^0-9]/g,""),o=n.replace(/[0-9]/g,"");a[i-1][o]=r}e.boundSource=!1===e.observable||e.virtualDataSource?[]:new Smart.ObservableArray(a),e.observable&&(e.boundSource=new Smart.ObservableArray(a));for(let t=0;t<n;t++)e.observable?e[t]=e.boundSource[t]:e[t]=a[t],e.dataItemById[e[t].$.id]=e[t];!1===e.observable&&(e.boundSource=a),e.boundSource.canNotify=!0}_bindToICS(){const e=this,t=""+e.dataSource,a=e.rowDelimiter||"\n",n=t.split("\r"),r=[];let i=t.split(a),o=i.length;1===o&&n.length>1&&(i=n,o=i.length);const d=function(e,t){var a=/^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z)?$/.exec(e);if(!a)throw new Error("Invalid UNTIL value: "+e);return t?new Date(a[1],a[2]-1,a[3],0,0,0,0):new Date(Date.UTC(a[1],a[2]-1,a[3],a[5]||0,a[6]||0,a[7]||0))};for(let e=0;e<o;e++){const t=i[e].trim();if(t.indexOf("BEGIN:VEVENT")>=0)var l={};else if(l)if(t.indexOf("BEGIN:VALARM")>=0)var s={};else{if(s){if(t.indexOf("ACTION")>=0){s.ACTION=t.substring(t.indexOf("ACTION")+7);continue}if(t.indexOf("DESCRIPTION")>=0){s.DESCRIPTION=t.substring(t.indexOf("DESCRIPTION")+12);continue}if(t.indexOf("TRIGGER")>=0){s.TRIGGER=t.substring(t.indexOf("TRIGGER")+8);continue}if(t.indexOf("END:VALARM")>=0){l.ALARM||(l.ALARM=[]),l.ALARM.push(s),s=void 0;continue}}if(t.indexOf("SUMMARY")>=0)l.SUMMARY=t.substring(t.indexOf("SUMMARY")+8);else if(t.indexOf("LOCATION")>=0)l.LOCATION=t.substring(t.indexOf("LOCATION")+9);else if(t.indexOf("DESCRIPTION")>=0)l.DESCRIPTION=t.substring(t.indexOf("DESCRIPTION")+12);else if(t.indexOf("RRULE")>=0)l.RRULE=t.substring(t.indexOf("RRULE")+6);else if(t.indexOf("RECURRENCE-ID")>=0)l.RECURRENCEID=t.substring(t.indexOf("RECURRENCE-ID")+14);else if(t.indexOf("RECURRENCE-ID;VALUE=DATE")>=0)l.RECURRENCEID=t.substring(t.indexOf("RECURRENCE-ID;VALUE=DATE")+25);else if(t.indexOf("EXDATE;VALUE=DATE")>=0){const e=t.substring(t.indexOf("EXDATE;VALUE=DATE")+20);l.EXDATE=e}else if(t.indexOf("EXDATE")>=0){const e=t.substring(t.indexOf("EXDATE")+7);l.EXDATE=e}else t.indexOf("DTEND;VALUE=DATE")>=0?l.DTEND=d(t.substring(t.indexOf("DTEND;VALUE=DATE")+17),!0):t.indexOf("DTEND")>=0?l.DTEND=d(t.substring(t.indexOf("DTEND")+6)):t.indexOf("DTSTART;VALUE=DATE")>=0?l.DTSTART=d(t.substring(t.indexOf("DTSTART;VALUE=DATE")+19),!0):t.indexOf("DTSTART")>=0?l.DTSTART=d(t.substring(t.indexOf("DTSTART")+8)):t.indexOf("UID")>=0?l.uid=l.UID=t.substring(t.indexOf("UID")+4):t.indexOf("STATUS")>=0?l.STATUS=t.substring(t.indexOf("STATUS")+7):t.indexOf("TITLE")>=0?l.TITLE=t.substring(t.indexOf("TITLE")+6):t.indexOf("CATEGORIES")>=0?l.CATEGORIES=t.substring(t.indexOf("CATEGORIES")+11):t.indexOf("END:VEVENT")>=0&&(r.push(l),l.ALARM&&(l.ALARM=JSON.stringify(l.ALARM)),s=void 0)}}e.canNotify=!1,e.dataSource=r,e.canNotify=!0,e._bindToArray()}_bindToJSON(){const e=this,t=[],a=e.dataSource.length?e.dataSource:Object.entries(e.dataSource);e.boundSource.canNotify=!1;for(let n=0;n<a.length;n++){const r=a[n],i=e._getDataItem(r,n);t.push(i)}e.boundSource=!1===e.observable||e.virtualDataSource?[]:new Smart.ObservableArray(t);for(let t=0;t<e.length;t++)e[t]=e.boundSource[t],e.dataItemById[e[t].$.id]=e[t];!1===e.observable&&(e.boundSource=t),e.boundSource.canNotify=!0}sortBy(e,t,a){const n=this;if(!t)for(let a=0;a<n.dataFields.length;a++){const r=n.dataFields[a];if(r.name===e){t=r.dataType;break}}if(n.boundHierarchy){if((!e||0===e.length)&&n.groupBy.length>0)return void n.refreshHierarchy();const r=(e=>{let t=[];for(;e;){t=t.concat(e);for(let a=0;a<e.length;a++)e[a].children&&(t=t.concat(e[a].children));e=e.children}return t})(n.boundHierarchy);if(r){r.find((e=>{if(e.summaryRow)return e}))&&n.refreshHierarchy()}const i=function(r){n._sort(r,e,a,t);for(let n=0;n<r.length;n++){const o=r[n];o.children&&i(o.children,e,a,t)}};i(n.boundHierarchy)}else n._sort(n.boundSource,e,a,t)}_createFilter(e,t){const a={"=":"EQUAL","<>":"NOT_EQUAL","!=":"NOT_EQUAL",not_like:"DOES_NOT_CONTAIN",like:"CONTAINS","<":"LESS_THAN",">":"GREATER_THAN","<=":"LESS_THAN_OR_EQUAL",">=":"GREATER_THAN_OR_EQUAL",equal:"EQUAL","not equal":"NOT_EQUAL","less than":"LESS_THAN","greater than":"GREATER_THAN","greater than or equal":"GREATER_THAN_OR_EQUAL","less than or equal":"LESS_THAN_OR_EQUAL","starts with":"STARTS_WITH","ends with":"ENDS_WITH",notEqual:"NOT_EQUAL",not_equal:"NOT_EQUAL",lessThan:"LESS_THAN",greaterThan:"GREATER_THAN",greaterThanOrEqual:"GREATER_THAN_OR_EQUAL",lessThanOrEqual:"LESS_THAN_OR_EQUAL",less_than:"LESS_THAN",greater_than:"GREATER_THAN",greater_than_or_equal:"GREATER_THAN_OR_EQUAL",less_than_or_equal:"LESS_THAN_OR_EQUAL",null:"null","":"EMPTY",isblank:"EMPTY",isnotblank:"NOT_EMPTY",isBlank:"EMPTY",isNotBlank:"NOT_EMPTY",CONTAINS:"CONTAINS",DOES_NOT_CONTAIN:"DOES_NOT_CONTAIN",contains:"CONTAINS",does_not_contain:"DOES_NOT_CONTAIN","not contains":"DOES_NOT_CONTAIN",notcontains:"DOES_NOT_CONTAIN",notContains:"DOES_NOT_CONTAIN",startswith:"STARTS_WITH",endswith:"ENDS_WITH",starts_with:"STARTS_WITH",ends_with:"ENDS_WITH",startsWith:"STARTS_WITH",endsWith:"ENDS_WITH",NULL:"NULL",NOT_NULL:"NOT_NULL"};let n=[];"string"==typeof t&&(t=[t]);for(let e=0;e<t.length;e++){const a=t[e],r=-1===a.indexOf('"')?a.split(" "):a.split('"');let i=[];for(let e=0;e<r.length;e++){const t=r[e];""!==t&&" "!==t&&i.push(t.trim())}n.push(i)}const r=new Smart.FilterGroup,i=[],o=[];for(let t=0;t<n.length;t++){const r=n[t];if(r.length>1){const t=new Smart.FilterGroup;let n="and",i=0;for(let o=0;o<r.length;o++){let d=r[o];if("and"!==d&&"or"!==d){if(i++,2===i){let l=a[r[o-1]];l||(l=r[o-1]),"number"===e&&(d=parseFloat(d)),"date"===e&&(d=new Date(d));const s=t.createFilter(e,d,l);i=0,n&&t.addFilter(n,s)}}else n=d}o.push(t)}else{const e=r[0];if("and"!==e&&"or"!==e)throw new Error('Filter Exprresion expects "AND" or "OR", but the token is: '+e);i.push(e)}}let d=0;if(1===o.length)return o[0];for(let e=0;e<o.length;e++){let t=i[d];(e+1)%2==0&&d++,t||(t="and"),r.addFilter(t,o[e])}return r}filterBy(e,...t){const a=this,n=(()=>{for(let t=0;t<a.dataFields.length;t++){const n=a.dataFields[t];if(n.name===e)return n.dataType}})(),r=a._createFilter(n,t);return a.boundSource.filter((t=>r.evaluate(t[e])))}_filter(e,t="and"){const a=this,n=[],r=[];if(0===e.length)return void a.clearFilter();const i=e=>{for(let t=0;t<a.dataFields.length;t++){const n=a.dataFields[t];if(n.name===e)return n.dataType}};let o,d;"and"===t?(o=!0,d=function(e,t,a){return e&&t.evaluate(a[t.dataField])}):(o=!1,d=function(e,t,a){return e||t.evaluate(a[t.dataField])});for(let t=0;t<e.length;t++){const o=e[t],d=o[0];let l=null;l=o[1]instanceof Smart.FilterGroup?o[1]:a._createFilter(i(d),o.splice(1)),l&&(r.push(d),l.dataField=d,n.push(l))}if(a.boundHierarchy){const e=function(e){let t=o;for(let a=0;a<n.length;a++){const r=n[a];t=d(t,r,e)}return e.$.filtered=t,t},t=function(n,r,i){let o=0;for(let a=0;a<n.length;a++){const i=n[a];e(i),i.$.filtered&&o++,i.children&&t(i.children,i,r)}o>0&&a.groupBy.length>0&&r?(r.$.filtered=!0,i&&!i.$.filtered&&(i.$.filtered=!0)):o>0&&o!==n.length&&r?(r.$.filtered=null,i&&!i.$.filtered&&(i.$.filtered=null)):o>0&&o===n.length&&r&&(r.$.filtered=!0,i&&!i.$.filtered&&(i.$.filtered=!0))};t(a.boundHierarchy,null,null)}else for(let e=0;e<a.boundSource.length;e++){const t=a.boundSource[e];let r=o;for(let e=0;e<n.length;e++){const a=n[e];r=d(r,a,t)}t.$.filtered=r}a.onFilter&&a.onFilter()}clearGroup(){const e=this;e.groupBy=[],e.boundHierarchy=null,e.refreshHierarchy(),e.onGroup&&e.onGroup()}clearFilter(){const e=this;for(let t=0;t<e.boundSource.length;t++){e.boundSource[t].$.filtered=!0}if(e.boundHierarchy){const t=function(e,a,n){for(let n=0;n<e.length;n++){const r=e[n];r.$.filtered=!0,r.$.filtered,r.children&&t(r.children,r,a)}a&&(a.$.filtered=!0,n&&!n.$.filtered&&(n.$.filtered=!0))};t(e.boundHierarchy,null,null)}e.onFilter&&e.onFilter()}clearSort(){this._sort(this.boundSource,[],[],[])}_sort(e,t,a,n,r,i){const o=this;let d=!1;if(0===e.length)return;if(e&&e.constructor&&e instanceof Smart.ObservableArray&&(d=!0),(!e||!Array.isArray(e)||0===e.length||!t||Array.isArray(t)&&0===t.length)&&!d&&!o.boundHierarchy)throw new Error("sort: Missing or Invalid arguments!");"string"==typeof t&&(t=[t]);const l=[],s=[];void 0===a&&(a=[]);const c=function(e,t){let a;switch(t||typeof e){case"string":a=(new Intl.Collator).compare;break;case"number":case"int":case"bigInt":case"float":case"double":a=function(e,t){return e-t};break;case"boolean":case"bool":a=function(e,t){return e===t?0:!1===e?-1:1};break;case"date":case"time":case"dateTime":a=e instanceof Date?function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0}:e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber?function(e,t){return e.compare(t)}:function(e,t){return e-t};break;case"object":if(e instanceof Date)a=function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0};else if(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)a=function(e,t){return e.compare(t)};else if(e instanceof Smart.Utilities.Complex||window.NIComplex&&e instanceof window.NIComplex){const e=new Smart.Utilities.ComplexNumericProcessor;a=function(t,a){return e.compareComplexNumbers(t,a)}}}return a};for(let r=0;r<t.length;r++){void 0===a[r]||"asc"===a[r]||"ascending"===a[r]?l[r]=1:l[r]=-1;let o=e[0][t[r]];if(void 0===o&&e[0]&&e[0].children&&e[0].data&&(o=e[0].data[t[r]]),i&&i){const e=t[r];if(i[e]){s[r]=i[e];continue}}s[r]=c(o,n[r])}t.length>0&&r?r(e,t,a,s):e.sort((function(e,a){for(let n=0;n<t.length;n++){const r=s[n](e[t[n]],a[t[n]]);if(0===r){if(t[n+1])continue;return void 0!==e.$.index?(e.$.index-a.$.index)*l[n]:0}return r*l[n]}if(0===t.length)return e.$.index<a.$.index?-1:e.$.index>a.$.index?1:0}));for(let t=0;t<e.length;t++)o[t]=e[t]}static Filter(e,t,a,n,r="and"){let i,o;"and"===r?(i=!0,o=function(e,t,a,r){return n?e&&n(t,a,r):e&&r.evaluate(t[a])}):(i=!1,o=function(e,t,a,r){return n?e||n(t,a,r):e||r.evaluate(t[a])});return e.filter((e=>{let n=i;for(let r=0;r<a.length;r++){const i=a[r],d=t[r];n=o(n,e,d,i)}return n}))}filter(e,t,a){Smart.DataAdapter.Filter(this.boundSource,e,t,a)}sort(e,t,a){Smart.DataAdapter.Sort(this.boundSource,e,t,a)}static Sort(e,t,a,n){const r=function(e){let t;switch(typeof e){case"string":if(e.indexOf("-")>=0||e.indexOf("/")>=0){const t=new Date(e);if(t&&"Invalid Date"!==t.toString()){return function(e,t){const a=new Date(e),n=new Date(t);return a||n?a?n?a.getTime()-n.getTime():1:-1:0}}}t=(new Intl.Collator).compare;break;case"number":t=function(e,t){return e-t};break;case"boolean":t=function(e,t){return e===t?0:!1===e?-1:1};break;case"object":if(e instanceof Date)t=function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0};else if(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)t=function(e,t){return e.compare(t)};else if(e instanceof Smart.Utilities.Complex||window.NIComplex&&e instanceof window.NIComplex){const e=new Smart.Utilities.ComplexNumericProcessor;t=function(t,a){return e.compareComplexNumbers(t,a)}}else t=function(e,t){return e-t}}return t};if(!e||!Array.isArray(e)||0===e.length||!t||Array.isArray(t)&&0===t.length)return;"string"==typeof t&&(t=[t]);const i=[],o=[];void 0===a&&(a=[]);for(let n=0;n<t.length;n++)void 0===a[n]||"asc"===a[n]||"ascending"===a[n]?i[n]=1:i[n]=-1,o[n]=r(e[0][t[n]]);if(n)return void n(e,t,a,o);const d=e.slice(0);return d.sort((function(e,a){for(let n=0;n<t.length;n++){const r=o[n](e[t[n]],a[t[n]]);if(0===r){if(t[n+1])continue;return void 0!==e._index?(e._index-a._index)*i[n]:0}return r*i[n]}})),d}};class e{constructor(e,t){const a=this;a.config=e,a.callback=t,!1!==e.autoFetch&&a.call(e)}call(e){const t=this;e||(e=t.config);let a="GET",n=e.url,r=null,i=!0;if(e.type&&(a=e.type),e.data)if("GET"===a){n+="?";for(let t in e.data)Object.prototype.hasOwnProperty.call(e.data,t)&&(n+=encodeURI(t+"="+e.data[t]+"&"));"&"===n.charAt(n.length-1)&&(n=n.slice(0,n.length-1))}else"POST"===a&&(r=JSON.stringify(e.data));e&&!1===e.async&&"xlsx"!==e.dataSourceType&&(i=!1),void 0!==window.fetch&&i?t.ajaxFetch(e,a,n,r):t.ajaxXMLHttpRequest(e,a,n,r,i)}ajaxFetch(e,t,a,n){const r=this,i={method:t};let o,d,l,s;switch(e.dataSourceType){case"json":o="json";break;case"xlsx":o="arrayBuffer";break;default:o="text"}if(e&&e.contentType&&(i.headers=new Headers({"Content-Type":e.contentType})),null!==n&&(i.body=n),e.timeout&&(l=setTimeout((function(){s=!0}),e.timeout)),e.beforeSend){if(!1===e.beforeSend(i,e))return}fetch(a,i).then((function(e){if(s)throw d=408,new Error("timeout");if(l&&clearTimeout(l),d=e.status,!e.ok)throw new Error(e.statusText);return e[o]()})).then((function(t){if("arrayBuffer"===o)return JSZip.loadAsync(t).then((function(t){return t.files["xl/worksheets/sheet1.xml"].async("text").then((function(a){return t.files["xl/sharedStrings.xml"].async("text").then((function(t){const n=r.parseXLSXData(a,t);r.ajaxComplete(e,n,d)}))}))}));r.ajaxComplete(e,t,d)})).catch((function(t){"JSZip is not defined"===t.message&&(t.message="JSZip is not defined. Please include a reference to JSZip to be able to load data from XLSX files."),e&&e.loadError&&e.loadError(d,t),r.callback&&r.callback(t,d)}))}ajaxXMLHttpRequest(e,t,a,n,r){const i=new XMLHttpRequest,o=this;if(i.open(t,a,r),i.ontimeout=function(){e&&e.loadError&&e.loadError(408,"timeout")},i.onload=function(){if(4===i.readyState){const t=i.status;let a=i.response;t>=200&&t<=299?("json"===e.dataSourceType&&(a=JSON.parse(a)),o.ajaxComplete(e,a,t)):e&&e.loadError&&e.loadError(t,a)}},i.onerror=function(){e&&e.loadError&&e.loadError(i.status,i.response)},e&&e.contentType&&i.setRequestHeader("Content-Type",e.contentType),r&&e.timeout&&(i.timeout=e.timeout),e.beforeSend){if(!1===e.beforeSend(i,e))return}i.send(n)}ajaxComplete(e,t,a){if(e){if(e.beforeLoadComplete){const a=e.beforeLoadComplete(t);a&&(t=a)}e.loadComplete&&e.loadComplete(t,a),this.callback&&this.callback(t,a)}}parseXLSXData(e,t){const a=new DOMParser,n=a.parseFromString(t,"text/xml"),r=Array.from(n.getElementsByTagName("si")),i=[],o=a.parseFromString(e,"text/xml"),d=Array.from(o.getElementsByTagName("row")),l=[];return r.forEach((function(e){let t=e.getElementsByTagName("t");if(1===t.length)i.push(t[0].innerHTML);else{let e="";t=Array.from(t),t.forEach((function(t){e+=t.innerHTML})),i.push(e)}})),d.forEach((function(e){const t={};Array.from(e.getElementsByTagName("c")).forEach((function(e){const a=e.getAttribute("r").match(/\D+/)[0],n=e.getAttribute("t"),r=e.getElementsByTagName("v")[0].innerHTML;let o;switch(n){case"s":o=i[parseFloat(r)];break;case"b":o=1===parseFloat(r);break;default:o=parseFloat(r)}t[a]=o})),l.push(t)})),l}}Smart.Ajax=window.Ajax=e})();
27
+ (()=>{Smart.DataAdapter=window.smartDataAdapter=class{constructor(e){e||(e={});const t=Object.assign(this,e);t.key=(65536*(1+Math.random())|0).toString(16).substring(1),t.$document=Smart.Utilities.Extend(document),t.boundSource=!1===t.observable||t.virtualDataSource?[]:new Smart.ObservableArray,t.dataItemById=[],void 0===t.allowAdd&&(t.allowAdd=!0),void 0===t.allowRemove&&(t.allowRemove=!0),void 0===t.allowUpdate&&(t.allowUpdate=!0),void 0===t.mapChar&&(t.mapChar="."),void 0!==e.observable||t.virtualDataSource?t.observable=!1:t.observable=!0,void 0===t.sanitizeHTML&&(t.sanitizeHTML="blackList"),t._expandedRowIds=[],e.dataSource||(t.dataSource=[]),e.dataFields||(t.dataFields=[]),e.dataSourceType||(t.dataSourceType="array"),e.id||(t.id=null),e.autoFetch||(t.autoFetch=!0),e.dataFields&&(t.dataFields=e.dataFields),Object.defineProperty(t,"groupBy",{configurable:!1,enumerable:!0,get:()=>t._groupBy?t._groupBy:[],set(e){const a=()=>{t.boundHierarchy=null,t.refreshHierarchy(),t.onGroup&&t.onGroup()};t._groupBy=new Smart.ObservableArray(e),t._groupBy.notify((function(){a()})),t.isInitialized&&a()}}),e.groupBy?e.groupBy.toArray?t.groupBy=e.groupBy.toArray():t.groupBy=e.groupBy:t.groupBy=[],e&&!1!==e.autoBind&&t.dataBind(),t.isInitialized=!0}beginUpdate(){this.isUpdating=!0}endUpdate(){const e=this;e.isUpdating=!1,e.refreshIndexes(),e.refreshHierarchy()}get expandHierarchy(){return void 0===this._expandHierarchy&&(this._expandHierarchy=!1),this._expandHierarchy}set expandHierarchy(e){const t=this;t._expandHierarchy=e,t.isInitialized&&t.refreshHierarchy()}_getDataField(e){switch(e.name){case"leaf":case"parent":case"expanded":case"checked":case"selected":case"level":case"icon":case"data":case"group":case"children":case"items":e.map?e.map=e.map.replace(e.name,"$"+e.name):e.map=e.name,e.name="$"+e.name}}get dataFields(){return this._dataFields}set dataFields(e){const t=this;return t._dataFields=t._getDataFieldObjects(e),t._dataFields}_getDataFieldObjects(e){const t=this;let a=[];if("number"==typeof e){const t="A".charCodeAt(0);let n="",r=0;for(let i=0;i<e;i++){const e=String.fromCharCode(t+r);r++;const i=n+e;a.push({name:i,dataType:"string"}),r>=26&&(r=0,n+="A")}}else if(Array.isArray(e)&&e.length>0)for(let n=0;n<e.length;n++){const r=e[n];if("string"==typeof r){const e=r.split(":"),t=e[0].trim(),n=e.length>1?e[1].trim():"string";a.push({name:t,dataType:n})}else a.push(r);t._getDataField(a[a.length-1])}return a}get dataSource(){const e=this;return e._dataSource||(e._dataSource=[]),e._dataSource}set dataSource(e){const t=this;t._dataSource=e,t.isInitialized&&(t.boundSource=!1===t.observable||t.virtualDataSource?[]:new Smart.ObservableArray,t.dataItemById=[],t.bindingCompleted=!1,t.dataBind(),t.refreshIndexes())}get canNotify(){const e=this;return void 0===e._canNotify&&(e._canNotify=!0),e._canNotify}set canNotify(e){this._canNotify=e}_notify(e){const t=this;t.canNotify&&t.notifyFn&&t.notifyFn(e)}notify(e){e&&(this.notifyFn=e)}toArray(){const e=this;return!1===e.observable?e.boundSource:e.boundSource.toArray()}dataBind(){const t=this;t.bindingCompleted=!1,t.clear();const a=()=>{t.observable&&(t.boundSource.notify||(t.boundSource=new Smart.ObservableArray),t.boundSource.notify((function(e){if("update"===e.action&&e.path&&e.path.indexOf(".")>=0&&-1===e.path.indexOf("children")&&-1===e.path.indexOf("loaded")&&-1===e.path.indexOf("level")&&-1===e.path.indexOf("leaf")&&-1===e.path.indexOf("expanded")){let a=!1;for(let n=0;n<t.dataFields.length;n++){const r=t.dataFields[n].name;e.path.indexOf(r)>=0&&(a=!0)}t._notify&&a&&t._notify({action:"update",data:e.target,index:e.index})}}))),t._onBindingComplete()};"string"==typeof t.dataSource&&(t.dataSource.indexOf(".json")>=0||"json"===t.dataSourceType)?(t.url=t.dataSource,t.dataSourceType="json",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&t.dataSource.indexOf(".xml")>=0?(t.url=t.dataSource,t.dataSourceType="xml",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&t.dataSource.indexOf(".xlsx")>=0?(t.url=t.dataSource,t.dataSourceType="xlsx",new e(t,(e=>{if(!e[0])return e=[],t._bindToArray(),void a();const n=Object.keys(e[0]),r={},i=[];if(!1!==t.exportHeader){let a=0;for(let e in n){r[n[e]]=t.dataFields[a++].name}for(let t=1;t<e.length;t++){const a=e[t],o={};for(let e in n){const t=n[e];o[r[t]]=a[t]}i.push(o)}t.dataSource=i}t._bindToArray(),a()}))):"string"==typeof t.dataSource&&t.dataSource.indexOf(".csv")>=0?(t.url=t.dataSource,t.dataSourceType="csv",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&t.dataSource.indexOf(".tsv")>=0?(t.url=t.dataSource,t.dataSourceType="tsv",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&(t.dataSource.indexOf(".ics")>=0||t.dataSource.indexOf(".php")>=0&&"ics"===t.dataSourceType||t.dataSource.indexOf(".txt")>=0&&"ics"===t.dataSourceType)?(t.url=t.dataSource,t.dataSourceType="ics",new e(t,(e=>{t.dataSource=e}))):"string"==typeof t.dataSource&&(t.dataSource.indexOf("BEGIN:VCALENDAR")>=0||"ics"===t.dataSourceType)?(t._bindToICS(),a()):"string"==typeof t.dataSource&&(t.dataSource.indexOf("<?xml")>=0||"xml"===t.dataSourceType)?(t._bindToXML(),a()):"string"==typeof t.dataSource&&(t.dataSource.indexOf(" ")>=0||t.dataSource.indexOf(",")>=0||"tsv"===t.dataSourceType||"csv"===t.dataSourceType||"tab"===t.dataSourceType)?(t._bindToCSV(),a()):"array"===t.dataSourceType?(t._bindToArray(),a()):"json"===t.dataSourceType&&(t._bindToJSON(),a())}_bindToXML(){const e=this;let t=null,a=null;window.DOMParser&&(t=new DOMParser,a=t.parseFromString(e.dataSource,"text/xml")),void 0===e.root&&(e.root=""),void 0===e.record&&(e.record="");const n=a.querySelectorAll(e.root+" "+e.record),r=n.length,i=[];let o=e.dataFields?e.dataFields.length:0;if(0===o){const t=n[0],a=new Array;for(let e in t){const t=e;a[a.length]={name:t}}e.dataFields=a,o=a.length}for(let t=0;t<r;t++){const a=n[t],r={};if(void 0===a)break;if(e.id){const t=a.querySelector(e.id);r[e.id]=t.textContent}for(let t=0;t<o;t++){const n=e.dataFields[t],i=a.querySelector(n.map||n.name);r[n.name]=i.textContent}i[t]=r}e.canNotify=!1,e.dataSource=i,e.canNotify=!0,e._bindToArray()}static BindToCSV(e,t=!1){const a=""+e,n=-1===a.indexOf(",")?"\t":",",r=a.split("\r"),i=new Array,o=[];let d=a.split("\n"),l=d.length;1===l&&r.length>1&&(d=r,l=d.length);const s=!0===t;for(let e=0;e<l;e++){const t={},a=d[e].split(n);for(let n=0;n<a.length;n++){let r=o[n],i=a[n];if(r||(o.push({name:i.trim()}),r=o[o.length-1]),i=i.trim(),1!==e||s)switch(r.dataType){case"boolean":i="false"!==i;break;case"number":i=parseFloat(i);break;case"date":i=new Date(i)}else{let e="string";"false"===i||"true"===i?(e="boolean",i="false"!==i):isNaN(parseInt(i)&&-1===i.indexOf("/"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}t[r.name]=i}(s||e>0)&&i.push(t)}return i}_bindToCSV(){const e=this,t=""+e.dataSource,a=-1===t.indexOf(",")?"\t":",",n=t.split("\r"),r=new Array;let i=t.split("\n"),o=i.length;1===o&&n.length>1&&(i=n,o=i.length);const d=e.dataFields.length>0;for(let t=0;t<o;t++){const n=i[t],o={},l=i[t].split(a);for(let a=0;a<l.length;a++){let r=e.dataFields[a],i=l[a];if(r||(e.dataFields.push({name:i.trim()}),r=e.dataFields[e.dataFields.length-1]),r.map&&(i=n[r.map]),i=i.trim(),1!==t||d)switch(r.dataType){case"boolean":i="false"!==i;break;case"number":i=parseFloat(i);break;case"date":i=new Date(i)}else{let e="string";"false"===i||"true"===i?(e="boolean",i="false"!==i):isNaN(parseInt(i)&&-1===i.indexOf("/"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}o[r.map||r.name||a.toString()]=i}(d||t>0)&&r.push(o)}e.canNotify=!1,e.dataSource=r,e.canNotify=!0,e._bindToArray()}_onBindingComplete(){const e=this;e._buildHierarchy(),e.onBindingComplete&&e.onBindingComplete({data:e.boundSource}),e._notify&&e._notify({action:"bindingComplete",data:e.boundSource}),e.bindingCompleted=!0}refreshHierarchy(){this.isUpdating||this._buildHierarchy()}find(){return this.boundSource.find.apply(this.boundSource,arguments)}onVirtualDataSourceRequested(e,t){const a=this;let n=t?t.first:1/0,r=t?t.last:1/0,i=t?t.row:null;if(void 0===n&&(n=1/0),void 0===r&&(r=1/0),a.virtualFirstIndex=n,a.virtualLastIndex=r,a.virtualDataSource){const o=function(r){void 0!==r.virtualDataSourceLength&&(a.virtualDataSourceLength=r.virtualDataSourceLength),new Smart.DataAdapter({dataSource:r.dataSource,dataFields:r.dataFields||a.dataFields,data:t,keyDataField:r.keyDataField,parentDataField:r.parentDataField,observable:!1,id:r.id||a.id,onBindingComplete(r){if(void 0===t.result&&(t.result=!0),a.virtualDataSourceOnExpand&&i)return a.groupBy.length>0?r.data&&r.data.length>0&&a.add(r.data):r.data&&r.data.length>0?a.add(r.data,i.$.id):i.leaf=!0,a.onFilter&&a.onFilter(),void e(t);n===1/0&&"scroll"===t.action?r.data&&r.data.length&&a.add(r.data):"filter"===t.action||"group"===t.action?(a.canNotify=!1,a.dataSource=r.data,a.canNotify=!0):("add"===t.action||"update"===t.action||t.action,a.canNotify=!1,a.dataSource=r.data,a.canNotify=!0),a.onFilter&&a.onFilter(),e(t)}})};let d={};if(t.sorting&&t.sorting.length>0){let e=[];for(let a in t.sorting)e.push(a+" "+t.sorting[a].sortOrder.toUpperCase());const a=" ORDER BY "+e.join(", ");d.orderBy=a}else d.orderBy="";if(void 0===n||void 0===r||0===n&&0===r)d.limit="";else{const e=r-n,t=" LIMIT "+e+" OFFSET "+n;d.limit=t,isNaN(e)&&(d.limit="")}if(t.grouping&&t.grouping.length>0){const e=" GROUP BY "+t.grouping[0];d.groupBy=e}else d.groupBy="";if(t.filtering&&t.filtering.length>0){const e=(e,t)=>{switch(t.condition){case"EMPTY":return e+" = ''";case"NOT_EMPTY":return e+" != ''";case"EQUAL":return e+" = '"+t.value+"'";case"NOT_EQUAL":return e+" != '"+t.value+"'";case"CONTAINS_CASE_SENSITIVE":case"CONTAINS":return e+" LIKE '%"+t.value+"%'";case"DOES_NOT_CONTAIN_CASE_SENSITIVE":case"DOES_NOT_CONTAIN":return e+" NOT LIKE '%"+t.value+"%'";case"STARTS_WITH_CASE_SENSITIVE":case"STARTS_WITH":return e+" LIKE '"+t.value+"%'";case"ENDS_WITH_CASE_SENSITIVE":case"ENDS_WITH":return e+" LIKE '%"+t.value+"'";case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL"}},a=(e,t)=>{switch(t.condition){case"EQUAL":return e+" = "+t.value;case"NOT_EQUAL":return e+" != "+t.value;case"GREATER_THAN":return e+" > "+t.value;case"GREATER_THAN_OR_EQUAL":return e+" >= "+t.value;case"LESS_THAN":return e+" < "+t.value;case"LESS_THAN_OR_EQUAL":return e+" <= "+t.value;case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL";case"RANGE":return"("+e+" >= "+t.value+" and "+e+" <= "+t.valueTo+")"}},n=(e,t,a)=>{if(a.operator){var n=e(t,a.condition1),r=e(t,a.condition2);return"("+n+" "+a.operator+" "+r+")"}return e(t,a)};let r=[];for(let i in t.filtering){const o=t.filtering[i];let d=o.filters,l=[],s=" AND ";for(let t=0;t<d.length;t++){const r=d[t];switch(r.type){case"stringFilter":l.push(n(e,i,r));break;case"numericFilter":case"dateFilter":case"booleanFilter":l.push(n(a,i,r))}1===o.logicalOperators[t]&&(s=" OR ")}r.push("("+l.join(s)+")")}if(r.length>0){let e=" AND ";t.filterOperator&&"or"===t.filterOperator.toLowerCase()&&(e=" OR "),d.where=" WHERE "+r.join(e)}else d.where=""}else d.where="";if("dataBind"===t.action&&a.virtualDataSourceOnExpand&&a.keyDataField&&a.parentDataField&&(d.where?d.where+=" AND "+a.parentDataField+" IS NULL":d.where=" WHERE "+a.parentDataField+" IS NULL"),"update"===t.action){const e=[];for(let n in t.edit.row)"$"!==n&&n!==a.id&&e.push(n+"='"+t.edit.row[n]+"'");d.update=" SET "+e.join(", ")+" WHERE "+a.id+"="+t.edit.row[a.id]}if("remove"===t.action){const e=[];for(let n in t.edit.row)"$"!==n&&n!==a.id&&e.push(n+" = '"+t.edit.row[n]+"'");d.remove=" WHERE "+a.id+"="+t.edit.row[a.id]}if("add"===t.action){const e=[],a=[];for(let n in t.edit.row)"$"!==n&&(a.push(n),e.push("'"+t.edit.row[n]+"'"));d.add=" ("+a.join(", ")+") VALUES ("+e.join(", ")+")"}"expand"===t.action?(a.groupDataField?d.where?d.where+=" AND "+a.groupDataField+" = '"+i[a.groupDataField]+"'":d.where=" WHERE "+a.groupDataField+" = '"+i[a.groupDataField]+"'":a.keyDataField&&a.parentDataField?d.where?d.where+=" AND "+a.parentDataField+" = "+i[a.keyDataField]:d.where=" WHERE "+a.parentDataField+" = "+i[a.keyDataField]:d.where?d.where+=" AND "+i.groupDataField+" = '"+i.label+"'":d.where=" WHERE "+i.groupDataField+" = '"+i.label+"'",d.limit="",d.groupBy="",a.virtualDataSourceOnExpand(o,{first:n,last:r,row:t.row,sorting:t.sorting,filtering:t.filtering,grouping:t.grouping,action:t.action,query:d})):a.virtualDataSource(o,{first:n,last:r,sorting:t.sorting,filtering:t.filtering,filterOperator:t.filterOperator||"and",grouping:t.grouping,action:t.action,query:d})}else e()}add(e,t){const a=this;if(!e)return;let n=!0;const r=function(e){const r=a._getDataItem(e,a.boundSource.length);if(a.dataItemById[r.$.id])return void 0!==t&&(r.$.parentId=t),null;a[a.boundSource.length]=r,a.dataItemById[r.$.id]=r;const i=a.boundSource.push(r);return void 0!==t&&(r.$.parentId=t),i||(n=!1),r};if(e.length){let t=[];for(let a=0;a<e.length;a++){const n=r(e[a]);n&&t.push(n)}a._notify({action:"add",data:t})}else{const t=r(e);a._notify({action:"add",data:t})}return a.refreshHierarchy(),n}refreshIndexes(){const e=this;for(let t=0;t<e.boundSource.length;t++)e[t]=e.boundSource[t],e[t].$.index=t,e.dataItemById[e[t].$.id]=e[t];let t=e.boundSource.length;for(;e[t];)delete e[t],t++}removeLast(){const e=this;delete e[e.boundSource.length-1];const t=e.boundSource.pop();return delete e.dataItemById[t.$.id],e._notify({action:"removeLast",data:t}),e.refreshHierarchy(),t}remove(e){const t=this;let a=t.indexOf(e);-1===a&&e&&e.$&&(a=t.indexOf(t.dataItemById[e.$.id]));t.boundSource[a]&&t.removeAt(a)}removeAt(e){const t=this,a=t.boundSource[e];if(!a)throw new Error("Invalid Item Index");t.boundSource.splice(e,1),delete t.dataItemById[a.$.id],t.refreshIndexes(),t._notify({action:"remove",index:e,data:a}),t.refreshHierarchy()}update(e,t){const a=this;if(Smart.Utilities.Types.isArray(e)&&Smart.Utilities.Types.isArray(t)&&0===e.length&&0===t.length)return void a.refreshHierarchy();if(t.length&&e.length){let n=[];for(let r=0;r<e.length;r++){const i=a._getDataItem(t[r],e[r]),o=e[r];n.push(i),a.boundSource[o]=i,a[o]=a.boundSource[o],a.dataItemById[i.$.id]=a[o]}return a._notify({action:"update",index:e,data:n}),void a.refreshHierarchy()}const n=a._getDataItem(t,e),r=a.boundSource[e].$.id;return n.$.id=r,a.boundSource[e]=n,a[e]=a.boundSource[e],a.dataItemById[n.$.id]=a[e],a._notify({action:"update",index:e,data:n}),a.refreshHierarchy(),n}insert(e,t){const a=this;if(t.length){const n=[];for(let r=0;r<t.length;r++){const i=a._getDataItem(t[r],e+r);n.push(i)}t=n}else t=a._getDataItem(t,e);const n=a.boundSource.splice(e,0,t);return a.refreshIndexes(),a._notify({action:"insert",index:e,data:t}),a.refreshHierarchy(),n}move(e,t){if(t>e&&t-e==1||e===t)return;const a=this,n=a.boundSource.splice(e,1)[0];t>e?(t--,a.boundSource.splice(t,0,n)):a.boundSource.splice(t,0,n),a.refreshIndexes(),a._notify({action:"move",index:t,data:a.boundSource[t]}),a.refreshHierarchy()}indexOf(e){return this.boundSource.indexOf(e)}get length(){const e=this;return void 0!==e.virtualDataSourceLength?e.virtualDataSourceLength:e.dataSourceLength?e.dataSourceLength:"number"==typeof e.dataSource?e.dataSource:e.bindingCompleted?e.boundSource.length:e.dataSource&&"string"!=typeof e.dataSource&&e.dataSource.length?e.dataSource.length:e.boundSource.length}clear(){const e=this;if(!e.isInitialized)return e._cachedValues=[],void(e.dataItemById=[]);for(let t=0;t<e.boundSource.length;t++)delete e[t];e._expandedRowIds=[],e._cachedValues=[],e.boundSource=e.observable?new Smart.ObservableArray:[],e.dataItemById=[],e.refreshHierarchy()}_getId(e,t,a){if(null===e||void 0===e.name||!e.name||!t.getAttribute){if(e&&e.toString().length>0&&t.getAttribute){let a=t.getAttribute(e);if(null!==a&&a.toString().length>0)return a.trim().split(" ").join("").replace(/([ #;?%&,.+*~\':'!^$[\]()=>|\/@])/g,"");{let a=e.split(this.mapChar);if(a.length>1){let e=t;for(let t=0;t<a.length;t++)void 0!==e&&(e=e[a[t]]);if(void 0!==e)return e}else if(void 0!==t[e])return t[e]}}return a}{let n=t.getAttribute(e.name);if(null!==n&&n.toString().length>0)return n;if(e.map)try{let a=t.getAttribute(e.map);if(null!==a&&a.toString().length>0)return a}catch(e){return a}}}_buildHierarchy(){const e=this;if(e.reservedNames){const t=e.reservedNames;t.leaf||(t.leaf="leaf"),t.parent||(t.parent="parent"),t.expanded||(t.expanded="expanded"),t.checked||(t.checked="checked"),t.selected||(t.selected="selected"),t.level||(t.level="level"),t.data||(t.data="data")}else e.reservedNames={leaf:"leaf",parent:"parent",expanded:"expanded",checked:"checked",selected:"selected",level:"level",icon:"icon",data:"data"};const t=e.reservedNames;if(e.childrenDataField){const a=[];for(let n=0;n<e.boundSource.length;n++){const r=Object.assign({},e.boundSource[n]);if(!r)continue;a.push(r);const i=function(a){const n=e.childrenDataField.split(e.mapChar);let r=null;if(n.length>1){let e=a;for(let t=0;t<n.length;t++)void 0!==e&&(e=e[n[t]]);r=e}else r=a.children;a.children=r,(null===a.children||void 0===a.children||a.children&&0===a.children.length)&&(a[t.leaf]=!0)};i(r),r[t.level]=0,r.$||(r.$={}),r[t.parent]=null,r[t.data]=r,void 0===r[t.expanded]&&(r[t.expanded]=!1,e.expandHierarchy&&(r[t.expanded]=!0));const o=function(a,n){if(n)for(let r=0;r<n.length;r++){let d=e._getDataItem(n[r],r);if(d){if(i(d),!e.id){const e=function(){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+e()};d.$.id=e()}d[t.level]=a[t.level]+1,d[t.parent]=a,d[t.data]=Object.assign({},d),a&&(a.children[r]=d),void 0===d[t.expanded]&&(d[t.expanded]=!1,e.expandHierarchy&&(d[t.expanded]=!0)),o(d,d.children)}}else a.children=new Array};o(r,r.children)}if(e.boundHierarchy=a,!e._boundSourceUpdate){for(let t=0;t<e.boundHierarchy.length;t++){const a=e.boundHierarchy[t];if(a.children){const t=function(a){if(e.dataItemById[a.$.id]||(e.boundSource.canNotify=!1,e.dataItemById[a.$.id]=a,e.boundSource.canNotify=!0),a.children)for(let e=0;e<a.children.length;e++){const n=a.children[e];n.children&&t(n)}};t(a)}}e._boundSourceUpdate=!0}}if(e.xmlRoot&&"xml"===e.dataSourceType&&(e.boundHierarchy=this._getHierarchy("uid","_parentuid","children",null,e.boundSource)),e.keyDataField&&e.parentDataField)return["keyDataField","parentDataField"].forEach((t=>{switch(e[t]){case"parent":e[t]="$"+e[t]}})),void(e.boundHierarchy=this._getHierarchy(e.keyDataField,e.parentDataField,"children",null,e.boundSource));e.groupBy&&e.groupBy.length>0?e.boundHierarchy=this._getGroupHierarchy(e.groupBy,"children","label",null,"data",null,"parent",e.boundSource):e.virtualDataSourceOnExpand&&(e.boundHierarchy=this._getHierarchy("id","parentId","children",null,e.boundSource))}_getGroupHierarchy(e,t,a,n,r,i,o,d,l){let s=this;l||(l=0);let c=s.reservedNames;const u=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()};let f=new Array;for(let t=0;t<e.length;t++)f[t]=u();t||(t="children"),a||(a="group"),r||(r="item"),o||(o="parent"),void 0===i&&(i="value");const h=new Array,p=new Array;let g=0;const S=function(e){let t=e;if(n)for(let e in n){const a=n[e];a.name&&a.map&&(t[a.map]=t[a.name])}return t};let y=!1;for(let n=0;n<d.length;n++){let m=Object.assign({},S(d[n]));m[c.leaf]=!1;let T=new Array,b=0;for(let t=0;t<e.length;t++){const a=e[t],n=m[a];null!=n?((""===n||void 0===n&&0===t)&&(y=!0),T[b++]={value:n,group:a,hash:f[t]}):(T[b++]={value:null,group:a,hash:f[t]},0===t&&(y=!0))}if(T.length!==e.length)break;let v=null,E="";for(let e=0;e<T.length;e++){const n=T[e].value,d=T[e].group;if(E=E+"_"+T[e].hash+"_"+n,void 0===p[E]||null===p[E]){if(null===v){v={$:{}},v[c.level]=0,v[c.leaf]=!1,v[o]=null,v[a]=n,v[r]=m,v.groupDataField=d,v[d]||(v[d]=v.data[d]),void 0!==m[c.expanded]?v[c.expanded]=m[c.expanded]:(v[c.expanded]=!1,s.expandHierarchy&&(v[c.expanded]=!0)),i&&(v[i]=m[i]),v[t]=new Array;let e=h.length+l;this.id&&"number"!=typeof m.$.id&&!isFinite(m.$.id)||(e="Item"+e),void 0===v.$.id&&(v.$.id=e),s._expandedRowIds[v.$.id]&&(v[c.expanded]=!0),h[g++]=v}else{const e={$:{}};e[c.level]=v[c.level]+1,e[o]=v,e[a]=n,e[t]=new Array,e[r]=m,e.groupDataField=d,e[c.leaf]=!1,e[d]||(e[d]=e.data[d]),void 0!==m[c.expanded]?e[c.expanded]=m[c.expanded]:(e[c.expanded]=!1,s.expandHierarchy&&(e[c.expanded]=!0)),i&&(e[i]=m[i]),void 0===e.$.id&&(e.$.id=v.$.id+"_"+v[t].length),s._expandedRowIds[e.$.id]&&(e[c.expanded]=!0),v[t][v[t].length]=e,v=e}p[E]=v}else v=p[E]}m&&(m[c.leaf]=!0),null!==v?(null===this.id?void 0===m.$.id&&(m.$.id=v.$.id+"_"+v[t].length):void 0===m.$.id&&-1===m.$.id.toString().indexOf(v.$.id)&&(m.$.id=v.$.id+"_"+m.$.id),m[o]=v,m[c.level]=v[c.level]+1,v[t][v[t].length]=m):void 0===m.$.id&&(m.$.id=u())}if(y){let e=null,t=!1;for(let a=0;a<h.length;a++){const n=h[a];if(!n[n.groupDataField]){e=n,e.$.id.toString().startsWith("Item")&&(t=!0),h.splice(a,1);break}}if(e&&(h.push(e),t))for(let e=0;e<h.length;e++){h[e].$.id="Item"+e}}return h}_getHierarchy(e,t,a,n,r){const i=this,o=new Array;let d=this.boundSource;if(r&&(d=r),0===this.boundSource.length)return null;const l=null!==a?a:"children";let s=new Array,c=d,u=c.length,f=i.reservedNames;const h=function(e){let t=e;if(n)for(let e in n){const a=n[e];a.name&&a.map&&(t[a.map]=t[a.name])}return t};for(let a=0;a<u;a++){let n=c[a],r=n[t],o=n[e];"parentId"===t&&(r=n.$.parentId),"id"===e&&(o=n.$.id),n[l]=new Array,i.expandHierarchy&&void 0===n[f.expanded]&&(n[f.expanded]=i.expandHierarchy),s[o]={parentId:r,item:n}}for(let a=0;a<u;a++){const n=c[a];let r=n[t],i=n[e];if("parentId"===t&&(r=n.$.parentId),"id"===e&&(i=n.$.id),void 0!==s[r]){let e={parentId:r,item:s[i].item},t=s[r].item;t[l]||(t[l]=new Array);let a=t[l].length;e=e.item,f?e[f.parent]=t:e.parent=t;const n=h(e);t[l][a]=n,s[r].item=t,s[i].item=e}else{let e=s[i].item;f?void 0===e[f.parent]&&(e[f.parent]=null):void 0===e.parent&&(e.parent=null);const t=h(e);f?t[f.level]=0:t.level=0,o[o.length]=t}}if(0!==o.length){let e=function(t,a){for(let n=0;n<a.length;n++){const r=a[n];f?r[f.level]=t:r.level=t;const o=r[l];o&&o.length>0?(r.leaf=!1,e(t+1,o)):i.virtualDataSourceOnExpand?void 0===r.leaf&&(r.leaf=!1):f?r[f.leaf]=!0:r.leaf=!0}};e(0,o)}return o}summarize(e,t){const a=this;Array.isArray(e)||(e=[e]);let n=[];for(let t=0;t<e.length;t++){const a=e[t];for(let e in a){const t=a[e];n.push({dataField:e,functions:t})}}e=n;let r={},i=new Array;t||(t=a.boundSource);let o=t.length,d=0;if(0!==o&&void 0!==o){for(let a=0;a<o;a++){let n=t[a];if((!n||!n.$||!1!==n.$.filtered)&&n){d++;for(let t=0;t<e.length;t++){const o=e[t];let d=n[o.dataField];if(o.functions&&o.functions.length>0){r[o.dataField]=r[o.dataField]||{},i[o.dataField]=i[o.dataField]||0,i[o.dataField]++;const e=function(e){for(let t in e){let a=r[o.dataField][t];null==a&&(r[o.dataField][t]=0,a=0),"function"==typeof e[t]&&(a=e[t](a,d,o.dataField,n)),r[o.dataField][t]=a}},t=d;let l=parseFloat(d);l=!isNaN(l),t&&t.toDate&&(l=!1),"string"==typeof d&&d.startsWith("+")&&(l=!1),l&&(d=parseFloat(d)),"number"==typeof d&&isFinite(d)?o.functions.forEach((function(t){let n=r[o.dataField][t];if(null==n&&(n=0,"min"===t&&(n=9999999999999),"max"===t&&(n=-9999999999999),"median"===t&&(n=[])),"sum"===t||"avg"===t||"stdev"===t||"stdevp"===t||"var"===t||"varp"===t)n+=parseFloat(d);else if("product"===t)0===a?n=parseFloat(d):n*=parseFloat(d);else if("min"===t)n=Math.min(n,parseFloat(d));else if("max"===t)n=Math.max(n,parseFloat(d));else if("count"===t)n++;else if("median"===t)n.push(parseFloat(d));else if("blank"===t)n=r[o.dataField][t],null==n&&(n=0),d||n++;else if("filled"===t)n=r[o.dataField][t],null==n&&(n=0),void 0!==d&&n++;else if("unique"===t)n=r[o.dataField][t],null==n&&(n=[]),-1===n.indexOf(d)&&n.push(d);else if("object"==typeof t)return void e(t);r[o.dataField][t]=n})):o.functions.forEach((function(t){if("min"===t||"max"===t||"count"===t||"product"===t||"sum"===t||"avg"===t||"stdev"===t||"stdevp"===t||"var"===t||"varp"===t){if(null===d&&"count"!==t)return!0;let e=r[o.dataField][t];return null==e&&(e=0),r[o.dataField][t]=e,!0}if("blank"===t){let e=r[o.dataField][t];null==e&&(e=0),d||e++,r[o.dataField][t]=e}else if("filled"===t){let e=r[o.dataField][t];null==e&&(e=0),d&&e++,r[o.dataField][t]=e}else if("unique"===t){let e=r[o.dataField][t];null==e&&(e=[]),-1===e.indexOf(d)&&e.push(d),r[o.dataField][t]=e}"object"==typeof t&&e(t)}))}}}}for(let a=0;a<e.length;a++){const n=e[a];if(n.functions&&(!n.functions||0!==n.functions.length)){if(r[n.dataField]||(r[n.dataField]={},n.functions.forEach((function(e){r[n.dataField][e]=0}))),void 0!==r[n.dataField].avg){const e=r[n.dataField].avg,t=i[n.dataField];r[n.dataField].avg=0===t||void 0===t?0:e/t}else void 0!==r[n.dataField].count&&(r[n.dataField].count=d);if(void 0!==r[n.dataField].unique){const e=r[n.dataField].unique;r[n.dataField].unique=e.length}if(void 0!==r[n.dataField].median){let e=r[n.dataField].median;e.sort((function(e,t){return e-t})),r[n.dataField].median=.5*(e[Math.floor((e.length+1)/2)-1]+e[Math.ceil((e.length+1)/2)-1])}(r[n.dataField].stdev||r[n.dataField].stdevp||r[n.dataField].var||r[n.dataField].varp)&&n.functions.forEach((function(e){if("stdev"===e||"var"===e||"varp"===e||"stdevp"===e){const a=r[n.dataField][e],i=o,d=a/o;let l=0;for(let e=0;e<o;e++){let a=t[e][n.dataField];l+=(a-d)*(a-d)}let s="stdevp"===e||"varp"===e?i:i-1;0===s&&(s=1),"var"===e||"varp"===e?r[n.dataField][e]=l/s:"stdevp"!==e&&"stdev"!==e||(r[n.dataField][e]=Math.sqrt(l/s))}}))}}return r}}_getDataItem(e,t){const a=this,n={},r="number"==typeof a.dataSource||a.dataSourceLength;if(!e)return{$:{id:t,isEmpty:!0,index:t}};if("string"==typeof e&&(e={"":e}),r){for(let e=0;e<a.dataFields.length;e++){n[(a.dataFields?a.dataFields[e]:{}).name]=""}return n.$={},n.$.id=t,n.$.index=t,n}const i=e;if(void 0!==i.expanded&&(n.expanded=i.expanded,"true"===i.expanded||!0===i.expanded||1===i.expanded?n.expanded=!0:n.expanded=!1),a.childrenDataField?void 0!==i[a.childrenDataField]&&(n.children=i[a.childrenDataField]):void 0!==i.children?n.children=i.children:void 0!==i.items&&(n.children=i.items),void 0!==i.leaf&&(n.leaf=i.leaf),void 0!==i.level&&(n.level=i.level),a.keyDataField&&void 0!==i[a.keyDataField]&&(n[a.keyDataField]=i[a.keyDataField]),a.parentDataField&&void 0!==i[a.parentDataField]&&(n[a.parentDataField]=i[a.parentDataField]),0===a.dataFields.length){const t=Object.getOwnPropertyNames(e);for(let e=0;e<t.length;e++)"$"!==t[e]&&a.dataFields.push({name:t[e],dataType:"string"})}for(let t=0;t<a.dataFields.length;t++){const r=a.dataFields?a.dataFields[t]:{};let o="";if(null==r)continue;if(e.length&&(o=e[t]),r.map){let e=r.map.split(a.mapChar);if(e.length>0){let t=i;for(let a=0;a<e.length;a++)i&&(t=t[e[a]]);o=t}else o=i[r.map]}null!=o?o=o.toString():void 0===o&&null!==o&&(o="");let d=!1;if(""===o&&(d=!0,o=e[r.name],void 0===r.dataType&&(r.dataType="any"),null!=o?"array"!==r.dataType&&("any"===r.dataType?o=Array.isArray(e[r.name])?[...e[r.name]]:"object"==typeof e[r.name]?Object.assign({},e[r.name]):e[r.name]:"date"!==r.dataType&&(o=o.toString())):o=void 0===o&&"any"===r.dataType?null:""),"[object Object]"===o&&r.map&&d&&(o=""),a._cachedValues[o+"_"+r.dataType])o=a._cachedValues[o+"_"+r.dataType];else{if("bool"===r.dataType||"boolean"===r.dataType)"true"===o||"1"===o?o=!0:"false"!==o&&"0"!==o||(o=!1);else if("number"===r.dataType)-1===o.indexOf(".")&&o.indexOf(",")>=0&&o.substring(1+o.indexOf(",")).length<3&&(o=o.replace(",",".")),o=a.$document.deserialize(""+o,r.dataType,!0);else if("date"===r.dataType)if(r.formatString&&Smart.Utilities.DateTime){o=Smart.Utilities.DateTime.ParseDate(o,r.formatString)}else o=a.$document.deserialize(""+o,r.dataType,!0);else"any"!==r.dataType&&(o=a.$document.deserialize(""+o,r.dataType,!0));"any"!==r.dataType&&(a._cachedValues[o+"_"+r.dataType]=o)}"string"!==r.dataType&&"boolean"!==r.dataType&&"bool"!==r.dataType&&"any"!==r.dataType&&(isNaN(o)||o===-1/0||o===1/0)&&(o="date"===r.dataType||"number"===r.dataType?null:0),"parent"!==r.name&&"group"!==r.name&&"leaf"!==r.name&&"level"!==r.name?("string"===r.dataType&&/<.+?>/.test(o)&&o.replace&&("all"===a.sanitizeHTML?o=o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;"):"blackList"===a.sanitizeHTML&&(o=window.Smart.Utilities.Core.sanitizeHTML(o))),n[r.name]=o):n.$[r.name]=o}let o=t;if(a.id){if(o=i[a.id],void 0===o){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};o=e()+e()}"object"==typeof o&&(o=t),i.$&&void 0!==i.$.id&&(o=i.$.id)}else if(!a.virtualDataSource&&a.dataItemById&&a.dataItemById[o])for(o=a.length;a.dataItemById[o];)o++;return n.$||(n.$={}),n.$.id=o,n.$.index=t,new Object(n)}_bindToArray(){const e=this,t="number"==typeof e.dataSource||e.dataSourceLength,a=[];e.boundSource.canNotify=!1;const n=t?"number"==typeof e.dataSource?e.dataSource:e.dataSource.length:e.observable?e.length:e.dataSource.length;for(let r=0;r<n;r++){const n=t?{}:e.dataSource[r],i=e._getDataItem(n,r);a.push(i)}if(t&&e.dataSourceLength&&e.dataSource.length>0)for(let t=0;t<e.dataSource.length;t++){const n=e.dataSource[t].cell,r=e.dataSource[t].value,i=n.replace(/[^0-9]/g,""),o=n.replace(/[0-9]/g,"");a[i-1][o]=r}e.boundSource=!1===e.observable||e.virtualDataSource?[]:new Smart.ObservableArray(a),e.observable&&(e.boundSource=new Smart.ObservableArray(a));for(let t=0;t<n;t++)e.observable?e[t]=e.boundSource[t]:e[t]=a[t],e.dataItemById[e[t].$.id]=e[t];!1===e.observable&&(e.boundSource=a),e.boundSource.canNotify=!0}_bindToICS(){const e=this,t=""+e.dataSource,a=e.rowDelimiter||"\n",n=t.split("\r"),r=[];let i=t.split(a),o=i.length;1===o&&n.length>1&&(i=n,o=i.length);const d=function(e,t){var a=/^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z)?$/.exec(e);if(!a)throw new Error("Invalid UNTIL value: "+e);return t?new Date(a[1],a[2]-1,a[3],0,0,0,0):new Date(Date.UTC(a[1],a[2]-1,a[3],a[5]||0,a[6]||0,a[7]||0))};for(let e=0;e<o;e++){const t=i[e].trim();if(t.indexOf("BEGIN:VEVENT")>=0)var l={};else if(l)if(t.indexOf("BEGIN:VALARM")>=0)var s={};else{if(s){if(t.indexOf("ACTION")>=0){s.ACTION=t.substring(t.indexOf("ACTION")+7);continue}if(t.indexOf("DESCRIPTION")>=0){s.DESCRIPTION=t.substring(t.indexOf("DESCRIPTION")+12);continue}if(t.indexOf("TRIGGER")>=0){s.TRIGGER=t.substring(t.indexOf("TRIGGER")+8);continue}if(t.indexOf("END:VALARM")>=0){l.ALARM||(l.ALARM=[]),l.ALARM.push(s),s=void 0;continue}}if(t.indexOf("SUMMARY")>=0)l.SUMMARY=t.substring(t.indexOf("SUMMARY")+8);else if(t.indexOf("LOCATION")>=0)l.LOCATION=t.substring(t.indexOf("LOCATION")+9);else if(t.indexOf("DESCRIPTION")>=0)l.DESCRIPTION=t.substring(t.indexOf("DESCRIPTION")+12);else if(t.indexOf("RRULE")>=0)l.RRULE=t.substring(t.indexOf("RRULE")+6);else if(t.indexOf("RECURRENCE-ID")>=0)l.RECURRENCEID=t.substring(t.indexOf("RECURRENCE-ID")+14);else if(t.indexOf("RECURRENCE-ID;VALUE=DATE")>=0)l.RECURRENCEID=t.substring(t.indexOf("RECURRENCE-ID;VALUE=DATE")+25);else if(t.indexOf("EXDATE;VALUE=DATE")>=0){const e=t.substring(t.indexOf("EXDATE;VALUE=DATE")+20);l.EXDATE=e}else if(t.indexOf("EXDATE")>=0){const e=t.substring(t.indexOf("EXDATE")+7);l.EXDATE=e}else t.indexOf("DTEND;VALUE=DATE")>=0?l.DTEND=d(t.substring(t.indexOf("DTEND;VALUE=DATE")+17),!0):t.indexOf("DTEND")>=0?l.DTEND=d(t.substring(t.indexOf("DTEND")+6)):t.indexOf("DTSTART;VALUE=DATE")>=0?l.DTSTART=d(t.substring(t.indexOf("DTSTART;VALUE=DATE")+19),!0):t.indexOf("DTSTART")>=0?l.DTSTART=d(t.substring(t.indexOf("DTSTART")+8)):t.indexOf("UID")>=0?l.uid=l.UID=t.substring(t.indexOf("UID")+4):t.indexOf("STATUS")>=0?l.STATUS=t.substring(t.indexOf("STATUS")+7):t.indexOf("TITLE")>=0?l.TITLE=t.substring(t.indexOf("TITLE")+6):t.indexOf("CATEGORIES")>=0?l.CATEGORIES=t.substring(t.indexOf("CATEGORIES")+11):t.indexOf("END:VEVENT")>=0&&(r.push(l),l.ALARM&&(l.ALARM=JSON.stringify(l.ALARM)),s=void 0)}}e.canNotify=!1,e.dataSource=r,e.canNotify=!0,e._bindToArray()}_bindToJSON(){const e=this,t=[],a=e.dataSource.length?e.dataSource:Object.entries(e.dataSource);e.boundSource.canNotify=!1;for(let n=0;n<a.length;n++){const r=a[n],i=e._getDataItem(r,n);t.push(i)}e.boundSource=!1===e.observable||e.virtualDataSource?[]:new Smart.ObservableArray(t);for(let t=0;t<e.length;t++)e[t]=e.boundSource[t],e.dataItemById[e[t].$.id]=e[t];!1===e.observable&&(e.boundSource=t),e.boundSource.canNotify=!0}sortBy(e,t,a){const n=this;if(!t)for(let a=0;a<n.dataFields.length;a++){const r=n.dataFields[a];if(r.name===e){t=r.dataType;break}}if(n.boundHierarchy){if((!e||0===e.length)&&n.groupBy.length>0)return void n.refreshHierarchy();const r=(e=>{let t=[];for(;e;){t=t.concat(e);for(let a=0;a<e.length;a++)e[a].children&&(t=t.concat(e[a].children));e=e.children}return t})(n.boundHierarchy);if(r){r.find((e=>{if(e.summaryRow)return e}))&&n.refreshHierarchy()}const i=function(r){n._sort(r,e,a,t);for(let n=0;n<r.length;n++){const o=r[n];o.children&&i(o.children,e,a,t)}};i(n.boundHierarchy)}else n._sort(n.boundSource,e,a,t)}_createFilter(e,t){const a={"=":"EQUAL","<>":"NOT_EQUAL","!=":"NOT_EQUAL",not_like:"DOES_NOT_CONTAIN",like:"CONTAINS","<":"LESS_THAN",">":"GREATER_THAN","<=":"LESS_THAN_OR_EQUAL",">=":"GREATER_THAN_OR_EQUAL",equal:"EQUAL","not equal":"NOT_EQUAL","less than":"LESS_THAN","greater than":"GREATER_THAN","greater than or equal":"GREATER_THAN_OR_EQUAL","less than or equal":"LESS_THAN_OR_EQUAL","starts with":"STARTS_WITH","ends with":"ENDS_WITH",notEqual:"NOT_EQUAL",not_equal:"NOT_EQUAL",lessThan:"LESS_THAN",greaterThan:"GREATER_THAN",greaterThanOrEqual:"GREATER_THAN_OR_EQUAL",lessThanOrEqual:"LESS_THAN_OR_EQUAL",less_than:"LESS_THAN",greater_than:"GREATER_THAN",greater_than_or_equal:"GREATER_THAN_OR_EQUAL",less_than_or_equal:"LESS_THAN_OR_EQUAL",null:"null","":"EMPTY",isblank:"EMPTY",isnotblank:"NOT_EMPTY",isBlank:"EMPTY",isNotBlank:"NOT_EMPTY",CONTAINS:"CONTAINS",DOES_NOT_CONTAIN:"DOES_NOT_CONTAIN",contains:"CONTAINS",does_not_contain:"DOES_NOT_CONTAIN","not contains":"DOES_NOT_CONTAIN",notcontains:"DOES_NOT_CONTAIN",notContains:"DOES_NOT_CONTAIN",startswith:"STARTS_WITH",endswith:"ENDS_WITH",starts_with:"STARTS_WITH",ends_with:"ENDS_WITH",startsWith:"STARTS_WITH",endsWith:"ENDS_WITH",NULL:"NULL",NOT_NULL:"NOT_NULL"};let n=[];"string"==typeof t&&(t=[t]);for(let e=0;e<t.length;e++){const a=t[e],r=-1===a.indexOf('"')?a.split(" "):a.split('"');let i=[];for(let e=0;e<r.length;e++){const t=r[e];""!==t&&" "!==t&&i.push(t.trim())}n.push(i)}const r=new Smart.FilterGroup,i=[],o=[];for(let t=0;t<n.length;t++){const r=n[t];if(r.length>1){const t=new Smart.FilterGroup;let n="and",i=0;for(let o=0;o<r.length;o++){let d=r[o];if("and"!==d&&"or"!==d){if(i++,2===i){let l=a[r[o-1]];l||(l=r[o-1]),"number"===e&&(d=parseFloat(d)),"date"===e&&(d=new Date(d));const s=t.createFilter(e,d,l);i=0,n&&t.addFilter(n,s)}}else n=d}o.push(t)}else{const e=r[0];if("and"!==e&&"or"!==e)throw new Error('Filter Exprresion expects "AND" or "OR", but the token is: '+e);i.push(e)}}let d=0;if(1===o.length)return o[0];for(let e=0;e<o.length;e++){let t=i[d];(e+1)%2==0&&d++,t||(t="and"),r.addFilter(t,o[e])}return r}filterBy(e,...t){const a=this,n=(()=>{for(let t=0;t<a.dataFields.length;t++){const n=a.dataFields[t];if(n.name===e)return n.dataType}})(),r=a._createFilter(n,t);return a.boundSource.filter((t=>r.evaluate(t[e])))}_filter(e,t="and"){const a=this,n=[],r=[];if(0===e.length)return void a.clearFilter();const i=e=>{for(let t=0;t<a.dataFields.length;t++){const n=a.dataFields[t];if(n.name===e)return n.dataType}};let o,d;"and"===t?(o=!0,d=function(e,t,a){return e&&t.evaluate(a[t.dataField])}):(o=!1,d=function(e,t,a){return e||t.evaluate(a[t.dataField])});for(let t=0;t<e.length;t++){const o=e[t],d=o[0];let l=null;l=o[1]instanceof Smart.FilterGroup?o[1]:a._createFilter(i(d),o.splice(1)),l&&(r.push(d),l.dataField=d,n.push(l))}if(a.boundHierarchy){const e=function(e){let t=o;for(let a=0;a<n.length;a++){const r=n[a];t=d(t,r,e)}return e.$.filtered=t,t},t=function(n,r,i){let o=0;for(let a=0;a<n.length;a++){const i=n[a];e(i),i.$.filtered&&o++,i.children&&t(i.children,i,r)}o>0&&a.groupBy.length>0&&r?(r.$.filtered=!0,i&&!i.$.filtered&&(i.$.filtered=!0)):o>0&&o!==n.length&&r?(r.$.filtered=null,i&&!i.$.filtered&&(i.$.filtered=null)):o>0&&o===n.length&&r&&(r.$.filtered=!0,i&&!i.$.filtered&&(i.$.filtered=!0))};t(a.boundHierarchy,null,null)}else for(let e=0;e<a.boundSource.length;e++){const t=a.boundSource[e];let r=o;for(let e=0;e<n.length;e++){const a=n[e];r=d(r,a,t)}t.$.filtered=r}a.onFilter&&a.onFilter()}clearGroup(){const e=this;e.groupBy=[],e.boundHierarchy=null,e.refreshHierarchy(),e.onGroup&&e.onGroup()}clearFilter(){const e=this;for(let t=0;t<e.boundSource.length;t++){e.boundSource[t].$.filtered=!0}if(e.boundHierarchy){const t=function(e,a,n){for(let n=0;n<e.length;n++){const r=e[n];r.$.filtered=!0,r.$.filtered,r.children&&t(r.children,r,a)}a&&(a.$.filtered=!0,n&&!n.$.filtered&&(n.$.filtered=!0))};t(e.boundHierarchy,null,null)}e.onFilter&&e.onFilter()}clearSort(){this._sort(this.boundSource,[],[],[])}_sort(e,t,a,n,r,i){const o=this;let d=!1;if(0===e.length)return;if(e&&e.constructor&&e instanceof Smart.ObservableArray&&(d=!0),(!e||!Array.isArray(e)||0===e.length||!t||Array.isArray(t)&&0===t.length)&&!d&&!o.boundHierarchy)throw new Error("sort: Missing or Invalid arguments!");"string"==typeof t&&(t=[t]);const l=[],s=[];void 0===a&&(a=[]);const c=function(e,t){let a;switch(t||typeof e){case"string":a=(new Intl.Collator).compare;break;case"number":case"int":case"bigInt":case"float":case"double":a=function(e,t){return e-t};break;case"boolean":case"bool":a=function(e,t){return e===t?0:!1===e?-1:1};break;case"date":case"time":case"dateTime":a=e instanceof Date?function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0}:e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber?function(e,t){return e.compare(t)}:function(e,t){return e-t};break;case"object":if(e instanceof Date)a=function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0};else if(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)a=function(e,t){return e.compare(t)};else if(e instanceof Smart.Utilities.Complex||window.NIComplex&&e instanceof window.NIComplex){const e=new Smart.Utilities.ComplexNumericProcessor;a=function(t,a){return e.compareComplexNumbers(t,a)}}}return a};for(let r=0;r<t.length;r++){void 0===a[r]||"asc"===a[r]||"ascending"===a[r]?l[r]=1:l[r]=-1;let o=e[0][t[r]];if(void 0===o&&e[0]&&e[0].children&&e[0].data&&(o=e[0].data[t[r]]),i&&i){const e=t[r];if(i[e]){s[r]=i[e];continue}}s[r]=c(o,n[r])}t.length>0&&r?r(e,t,a,s):e.sort((function(e,a){for(let n=0;n<t.length;n++){const r=s[n](e[t[n]],a[t[n]]);if(0===r){if(t[n+1])continue;return void 0!==e.$.index?(e.$.index-a.$.index)*l[n]:0}return r*l[n]}if(0===t.length)return e.$.index<a.$.index?-1:e.$.index>a.$.index?1:0}));for(let t=0;t<e.length;t++)o[t]=e[t]}static Filter(e,t,a,n,r="and"){let i,o;"and"===r?(i=!0,o=function(e,t,a,r){return n?e&&n(t,a,r):e&&r.evaluate(t[a])}):(i=!1,o=function(e,t,a,r){return n?e||n(t,a,r):e||r.evaluate(t[a])});return e.filter((e=>{let n=i;for(let r=0;r<a.length;r++){const i=a[r],d=t[r];n=o(n,e,d,i)}return n}))}filter(e,t,a){Smart.DataAdapter.Filter(this.boundSource,e,t,a)}sort(e,t,a){Smart.DataAdapter.Sort(this.boundSource,e,t,a)}static Sort(e,t,a,n){const r=function(e){let t;switch(typeof e){case"string":if(e.indexOf("-")>=0||e.indexOf("/")>=0){const t=new Date(e);if(t&&"Invalid Date"!==t.toString()){return function(e,t){const a=new Date(e),n=new Date(t);return a||n?a?n?a.getTime()-n.getTime():1:-1:0}}}t=(new Intl.Collator).compare;break;case"number":t=function(e,t){return e-t};break;case"boolean":t=function(e,t){return e===t?0:!1===e?-1:1};break;case"object":if(e instanceof Date)t=function(e,t){return e||t?e?t?e.getTime()-t.getTime():1:-1:0};else if(e instanceof Smart.Utilities.DateTime||e instanceof Smart.Utilities.BigNumber)t=function(e,t){return e.compare(t)};else if(e instanceof Smart.Utilities.Complex||window.NIComplex&&e instanceof window.NIComplex){const e=new Smart.Utilities.ComplexNumericProcessor;t=function(t,a){return e.compareComplexNumbers(t,a)}}else t=function(e,t){return e-t}}return t};if(!e||!Array.isArray(e)||0===e.length||!t||Array.isArray(t)&&0===t.length)return;"string"==typeof t&&(t=[t]);const i=[],o=[];void 0===a&&(a=[]);for(let n=0;n<t.length;n++)void 0===a[n]||"asc"===a[n]||"ascending"===a[n]?i[n]=1:i[n]=-1,o[n]=r(e[0][t[n]]);if(n)return void n(e,t,a,o);const d=e.slice(0);return d.sort((function(e,a){for(let n=0;n<t.length;n++){const r=o[n](e[t[n]],a[t[n]]);if(0===r){if(t[n+1])continue;return void 0!==e._index?(e._index-a._index)*i[n]:0}return r*i[n]}})),d}};class e{constructor(e,t){const a=this;a.config=e,a.callback=t,!1!==e.autoFetch&&a.call(e)}call(e){const t=this;e||(e=t.config);let a="GET",n=e.url,r=null,i=!0;if(e.type&&(a=e.type),e.data)if("GET"===a){n+="?";for(let t in e.data)Object.prototype.hasOwnProperty.call(e.data,t)&&(n+=encodeURI(t+"="+e.data[t]+"&"));"&"===n.charAt(n.length-1)&&(n=n.slice(0,n.length-1))}else"POST"===a&&(r=JSON.stringify(e.data));e&&!1===e.async&&"xlsx"!==e.dataSourceType&&(i=!1),void 0!==window.fetch&&i?t.ajaxFetch(e,a,n,r):t.ajaxXMLHttpRequest(e,a,n,r,i)}ajaxFetch(e,t,a,n){const r=this,i={method:t};let o,d,l,s;switch(e.dataSourceType){case"json":o="json";break;case"xlsx":o="arrayBuffer";break;default:o="text"}if(e&&e.contentType&&(i.headers=new Headers({"Content-Type":e.contentType})),null!==n&&(i.body=n),e.timeout&&(l=setTimeout((function(){s=!0}),e.timeout)),e.beforeSend){if(!1===e.beforeSend(i,e))return}fetch(a,i).then((function(e){if(s)throw d=408,new Error("timeout");if(l&&clearTimeout(l),d=e.status,!e.ok)throw new Error(e.statusText);return e[o]()})).then((function(t){if("arrayBuffer"===o)return JSZip.loadAsync(t).then((function(t){return t.files["xl/worksheets/sheet1.xml"].async("text").then((function(a){return t.files["xl/sharedStrings.xml"].async("text").then((function(t){const n=r.parseXLSXData(a,t);r.ajaxComplete(e,n,d)}))}))}));r.ajaxComplete(e,t,d)})).catch((function(t){"JSZip is not defined"===t.message&&(t.message="JSZip is not defined. Please include a reference to JSZip to be able to load data from XLSX files."),e&&e.loadError&&e.loadError(d,t),r.callback&&r.callback(t,d)}))}ajaxXMLHttpRequest(e,t,a,n,r){const i=new XMLHttpRequest,o=this;if(i.open(t,a,r),i.ontimeout=function(){e&&e.loadError&&e.loadError(408,"timeout")},i.onload=function(){if(4===i.readyState){const t=i.status;let a=i.response;t>=200&&t<=299?("json"===e.dataSourceType&&(a=JSON.parse(a)),o.ajaxComplete(e,a,t)):e&&e.loadError&&e.loadError(t,a)}},i.onerror=function(){e&&e.loadError&&e.loadError(i.status,i.response)},e&&e.contentType&&i.setRequestHeader("Content-Type",e.contentType),r&&e.timeout&&(i.timeout=e.timeout),e.beforeSend){if(!1===e.beforeSend(i,e))return}i.send(n)}ajaxComplete(e,t,a){if(e){if(e.beforeLoadComplete){const a=e.beforeLoadComplete(t);a&&(t=a)}e.loadComplete&&e.loadComplete(t,a),this.callback&&this.callback(t,a)}}parseXLSXData(e,t){const a=new DOMParser,n=a.parseFromString(t,"text/xml"),r=Array.from(n.getElementsByTagName("si")),i=[],o=a.parseFromString(e,"text/xml"),d=Array.from(o.getElementsByTagName("row")),l=[];return r.forEach((function(e){let t=e.getElementsByTagName("t");if(1===t.length)i.push(t[0].innerHTML);else{let e="";t=Array.from(t),t.forEach((function(t){e+=t.innerHTML})),i.push(e)}})),d.forEach((function(e){const t={};Array.from(e.getElementsByTagName("c")).forEach((function(e){const a=e.getAttribute("r").match(/\D+/)[0],n=e.getAttribute("t"),r=e.getElementsByTagName("v")[0].innerHTML;let o;switch(n){case"s":o=i[parseFloat(r)];break;case"b":o=1===parseFloat(r);break;default:o=parseFloat(r)}t[a]=o})),l.push(t)})),l}}Smart.Ajax=window.Ajax=e})();
28
28
 
29
29
  /***/ }),
30
30
 
@@ -87,7 +87,7 @@ Smart.Utilities.Assign("ConditionalFormatter",class{constructor(e){const t=this;
87
87
  /***/ 859:
88
88
  /***/ (() => {
89
89
 
90
- Smart("smart-gantt-chart",class extends Smart.ScrollViewer{static get properties(){return{adjustToNonworkingTime:{value:!1,type:"boolean"},autoSchedule:{value:!1,type:"boolean"},autoScheduleStrictMode:{value:!1,type:"boolean"},autoScrollStep:{value:5,type:"number"},columnMenu:{value:!1,type:"boolean"},columnMinWidth:{value:"50px",type:"any"},columnResize:{value:!1,type:"boolean"},columnResizeFeedback:{value:!1,type:"boolean"},currentTimeIndicator:{value:!1,type:"boolean"},currentTimeIndicatorInterval:{value:1,validator:"_currentTimeIndicatorIntervalValidator",type:"number"},dataExport:{value:{exportFiltered:{value:!1,type:"boolean"},itemType:{value:"task",type:"string"},fileName:{value:"smartGanttChart",type:"string?"}},type:"object"},dataSource:{value:[],type:"any",reflectToAttribute:!1},dateEnd:{value:"",type:"any",validator:"_dateValidator"},dateStart:{value:"",type:"any",validator:"_dateValidator"},dateMarkers:{value:[],reflectToAttribute:!1,type:"array"},dayFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},disableAutoScroll:{value:!1,type:"boolean"},disableTaskDrag:{value:!1,type:"boolean"},disableTaskProgressChange:{value:!1,type:"boolean"},disableTaskResize:{value:!1,type:"boolean"},disableSelection:{value:!1,type:"boolean"},disableSegmentDrag:{value:!1,type:"boolean"},disableSegmentResize:{value:!1,type:"boolean"},disableWindowEditor:{value:!1,type:"boolean"},durationUnit:{value:"milisecond",allowedValues:["day","week","hour","minute","second","milisecond"],type:"string"},filterRow:{value:!1,type:"boolean"},groupByResources:{value:!1,type:"boolean"},headerTemplate:{value:null,type:"any"},hourFormat:{value:"default",allowedValues:["default","2-digit","numeric"],type:"string"},hideDateMarkers:{value:!1,type:"boolean"},hideTimelineHeaderDetails:{value:!1,type:"boolean"},hideResourcePanel:{value:!1,type:"boolean"},showSelectionColumn:{value:!1,type:"boolean"},infiniteTimeline:{value:!1,type:"boolean"},infiniteTimelineStep:{value:5,type:"number"},inverted:{value:!1,type:"boolean"},keyboardNavigation:{value:!1,type:"boolean"},messages:{extend:!0,value:{en:{duplicateIds:"{{elementType}}: DataSource contains duplicate ids. Tasks should have unique ids. The following ids are duplicating: {{duplicates}}.",invalidNonworkingRange:"{{elementType}}: Invalid {{property}} value. {{property}} should not contain all possible days/hours because it will result in an endless timeline. The value has been validated by removing the last item from the new value range.",invalidValue:"{{elementType}}: Invalid {{property}} value. {{property}} should be of type {{typeOne}} or {{typeTwo}}.",incorrectArgument:"{{elementType}}: Incorrect argument {{argumentName}} in method {{methodName}}.",outOfBounds:"{{elementType}}: Out of bounds argument {{argumentName}} in method {{methodName}}.",missingReference:"{{elementType}}: Missing reference to {{file}} in method {{methodName}}.",alreadyExists:"{{elementType}}: The item already exists when calling the {{methodName}} method.",notExisting:"{{elementType}}: The item does not exists when calling the {{methodName}} method.",notAProject:"{{elementType}}: The {{argumentName}} argument in {{methodName}} method does not reference an item of type 'project'.",noId:"smartGanttChart requires an id in order to save/load/clear a state.",ok:"Ok",add:"Add",remove:"Remove",cancel:"Cancel",delete:"Delete",confirm:"{{componentName}} will be deleted permanently, <b>are you sure? </b>",taskColumnLabel:"Task Name",resourceColumnLabel:"Resource Name",deleteLink:"Delete link",unassigned:"Unassigned",generalTab:"General",dependencyTab:"Dependency",segmentsTab:"Segments",segment:"Segment",dependencyValidation:"*The Task cannot be connected to itself.",segmentsCountValidation:"*Segmented Tasks must have at least 2 segments. ",segmentConflictError:'*The Segment "{{label}}" is in conflict, because it starts on/before and ends on/after the {{dateConflict}} of Segment "{{conflictLabel}}." ',segmentStartError:'*The Segment "{{label}}" cannot start before it ends and cannot end before it starts.',segmentEndError:'*The Segment "{{label}}" cannot start when it ends.',segmentRangeError:'*The Segment "{{label}}" is out of Task date range. The first segment must start when the task starts and the last segment must end when the task ends.',label:"Label",duration:"Duration",dateStart:"Date Start",dateEnd:"Date End",id:"Id",name:"Name",type:"Type",lag:"Lag",startToStart:"Start-To-Start",endToStart:"End-To-Start",endToEnd:"End-To-End",startToEnd:"Start-To-End",overdue:"Overdue",weeks:"week(s)",days:"day(s)",hours:"hour(s)",minutes:"minute(s)",seconds:"second(s)",miliseconds:"milisecond(s)",task:"Task",resource:"Resource",assignments:"Assignments",startTask:"Task Start",endTask:"Task End",deadline:"Deadline"}},type:"object"},monthFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},max:{value:new Date(2100,0,1),type:"any",validator:"_dateValidator"},min:{value:new Date(1900,0,1),type:"any",validator:"_dateValidator"},nonworkingDays:{value:[],type:"array",validator:"_nonworkingDayValidator"},nonworkingHours:{value:[],type:"array",validator:"_nonworkingTimeValidator"},popupWindowCustomizationFunction:{value:null,reflectToAttribute:!1,type:"function?"},popupWindowTabs:{value:["general","dependency","segments"],reflectToAttribute:!1,type:"array"},progressLabelFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resizeHandlesVisibility:{allowedValues:["auto","hidden","visible"],value:"auto",type:"string"},resourceColumns:{value:[{label:"resourceColumnLabel",value:"label"}],type:"array",reflectToAttribute:!1},resourceFiltering:{value:!1,type:"boolean"},resourceGroupFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resourcePanelHeaderTemplate:{value:null,type:"any"},resourcePanelMin:{value:100,type:"any"},resourcePanelSize:{value:"",type:"any"},resourcePanelRefreshRate:{value:0,reflectToAttribute:!1,type:"number"},resourceTimelineFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resourceTimelineMode:{allowedValues:["diagram","histogram","custom"],value:"diagram",type:"string"},resourceTimelineView:{allowedValues:["hours","tasks","custom"],value:"hours",type:"string"},selectedTaskIds:{value:[],type:"array"},selectedResourceIds:{value:[],type:"array"},shadeUntilCurrentTime:{value:!1,type:"boolean"},showBaseline:{value:!1,type:"boolean"},showProgressLabel:{value:!1,type:"boolean"},snapToNearest:{value:!1,type:"boolean"},sortFunction:{value:null,type:"function?",reflectToAttribute:!1},sortMode:{value:"none",allowedValues:["none","one","many"],type:"string"},taskColumns:{value:[{label:"taskColumnLabel",value:"label"}],type:"array",reflectToAttribute:!1},taskFiltering:{value:!1,type:"boolean"},taskPanelMin:{value:200,type:"any"},taskPanelSize:{value:"",type:"any"},timelineHeaderFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},timelineMin:{value:200,type:"any"},treeMin:{value:100,type:"any"},treeSize:{value:"20%",type:"any"},tooltip:{value:{enabled:{value:!1,type:"boolean"},arrow:{value:!1,type:"boolean"},delay:{value:50,type:"number"},offset:{value:[0,5],type:"array"}},type:"object"},verticalScrollBarVisibility:{type:"string",value:"auto",allowedValues:["auto","disabled","hidden","visible"]},view:{value:"year",allowedValues:["day","week","month","year"],type:"any"},yearFormat:{value:"numeric",allowedValues:["2-digit","numeric"],type:"string"},weekFormat:{value:"long",allowedValues:["long","numeric"],type:"string"}}}template(){return'<div id="container" role="presentation">\n <smart-splitter id="mainSplitter" auto-fit-mode="end" keep-proportions-on-resize right-to-left="[[rightToLeft]]" animation="[[animation]]" orientation="horizontal">\n <smart-splitter-item id="taskSplitterItem" class="smart-task-splitter-item">\n <div id="taskSplitterItemHeader" class="smart-task-panel-header"></div>\n <smart-splitter id="taskSplitter" class="smart-task-splitter" auto-fit-mode="end">\n <smart-splitter-item id="tableSplitterItem">\n <smart-table right-to-left="[[rightToLeft]]" wait id="taskTable" class="smart-task-table" virtualization animation="none" deferred-scroll-delay="0" ></smart-table>\n </smart-splitter-item>\n <smart-splitter-item id="timelineSplitterItem" class="smart-timeline-splitter-item">\n <div id="timeline" class="smart-timeline">\n <div id="timelineHeader" class="smart-timeline-header" role="rowgroup">\n <div id="timelineHeaderContent" class="smart-timeline-header-content">\n <div class="smart-timeline-view-details" id="timelineViewDetails" role="row"></div>\n <div class="smart-timeline-view-cells" id="timelineViewCells" role="row"></div>\n </div>\n </div>\n <div id="taskTimelineContainer" class="smart-timeline-content-container">\n <div id="timelineContent" class="smart-timeline-content">\n <div id="taskTimelineCellsContainer" class="smart-timeline-cells-container" aria-hidden="true"></div>\n <div id="taskIndicatorsContainer" class="smart-timeline-indicators-container" role="group"></div>\n <div id="timelineConnectionsContainer" class="smart-timeline-connections-container" role="group"></div>\n <div id="timelineBaselinesContainer" class="smart-timeline-baselines-container" role="group"></div>\n <div id="timelineTasksContainer" class="smart-timeline-tasks-container" role="group"></div>\n <div id="timelineMarkers" class="smart-timeline-markers-container" role="group"></div>\n <div id="timelineDeadlines" class="smart-timeline-deadlines-container" role="group"></div>\n </div>\n </div>\n </div>\n <smart-scroll-bar id="verticalScrollBar" class="smart-timeline-scroll-bar" orientation="vertical"\n right-to-left="[[rightToLeft]]" aria-controls="[[id]]">\n </smart-scroll-bar>\n </smart-splitter-item>\n </smart-splitter>\n </smart-splitter-item>\n </smart-splitter>\n <smart-scroll-bar wait id="horizontalScrollBar" class="smart-timeline-scroll-bar"></smart-scroll-bar>\n </div>'}static get listeners(){return{down:"_downHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler","document.dragstart":"_dragStartHandler","container.wheel":"_mouseWheelHandler","horizontalScrollBar.change":"_horizontalScrollbarHandler","verticalScrollBar.change":"_verticalScrollbarHandler","resourceVerticalScrollBar.change":"_verticalScrollbarHandler","mainSplitter.resizeEnd":"_resizeEventHandler","mainSplitter.resize":"_resizeEventHandler",move:"_moveHandler","mainSplitter.change":"_tableChangeHandler","mainSplitter.filter":"_tableSortFilterHandler","mainSplitter.sort":"_tableSortFilterHandler","mainSplitter.columnResize":"_tableColumnResizeHandler","taskTable.group":"_taskTableGroupEventHandler","taskTable.collapse":"_taskTableExpandHandler","taskTable.expand":"_taskTableExpandHandler","taskTable.keydown":"_taskTableKeyDownHandler"}}static get styleUrls(){return["smart.ganttchart.css"]}attached(){const e=this;if(super.attached(),e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e.$.taskSplitterItem,e.$.horizontalScrollBar,e.$.verticalScrollBar)),!e._resourceScrollView&&e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._resourceScrollView=new Smart.Utilities.Scroll(e.$.resourceSplitterItem,e.$.horizontalScrollBar,e.$.resourceVerticalScrollBar)),e.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);e.$.timelineHeader.scrollLeft=e.$.taskTimelineContainer.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineHeader.scrollLeft=e.$.resourceTimelineContent.scrollLeft=t)}if(e.scrollTop){const t=e.scrollTop;e.$.taskTimelineContainer.scrollTop=t,e.$.timelineContent.scrollTop=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollTop=t)}const t=["taskPopupWindow","connectionPopupWindow","confirmPopupWindow"];for(let i=0;i<t.length;i++){const n=t[i];if(e.$[n]&&e.$[n].opened){const t=e["$"+n];e._handleModal(!0),t.listen("close",e._popupWindowCloseHandler.bind(e)),t.listen("closing",e._popupWindowClosingHandler.bind(e)),t.listen("open",e._popupWindowOpenHandler.bind(e)),t.listen("click",e._popupWindowClickHandler.bind(e)),t.listen("change",e._popupWindowChangeHandler.bind(e)),t.listen("transitionend",e._popupWindowTransitionendHandler.bind(e)),e.getShadowRootOrBody().appendChild(e.$[n])}}e._handleTooltipEvents(!0),e._currentTimeIndicatorInterval||!e.currentTimeIndicator&&!e.shadeUntilCurrentTime||e._setCurrentTimeIndicators()}detached(){const e=this;super.detached(),e._scrollView&&(e._scrollView.unlisten(),delete e._scrollView),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView);const t=["taskPopupWindow","connectionPopupWindow","confirmPopupWindow"];e._handleModal();for(let i=0;i<t.length;i++){const n=t[i],a=e["$"+n];e.$[n]&&e.$[n].remove(),a&&(a.unlisten("open"),a.unlisten("close"),a.unlisten("closing"),a.unlisten("click"),a.unlisten("change"),a.unlisten("transitionend"))}e._handleTooltipEvents(),clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval}propertyChangedHandler(e,t,i){const n=this;switch(e){case"adjustToNonworkingTime":for(let e=0;e<n._tasks.length;e++){const t=n._tasks[e],i=t.$.project;n._validateTaskDates(t,i),n._validateTaskSegments(t),n._synchronizeProjectDates(t,i),n._refreshTableColumnsData(t,["dateEnd","duration"])}n._refreshTimeline();break;case"animation":break;case"autoSchedule":i?n._autoSchedule():n._autoScheduleRestore();break;case"autoScheduleStrictMode":i&&(n._autoSchedule(),n._refreshTimeline());break;case"columnMinWidth":case"columnResizeFeedback":case"columnResize":{const t=n.$.taskTable,a=n.$.resourceTable;t[e]=i,a&&(a[e]=i);break}case"currentTimeIndicator":case"shadeUntilCurrentTime":n._setCurrentTimeIndicators();break;case"dataSource":n.scrollLeft=n.scrollTop=0,n._createTasks(),n._refreshTableDataSource(),n._createTimeline(),n._createResourceTimeline(),n._setAriaControls();break;case"dateMarkers":n._createDateMarkers();break;case"hideDateMarkers":n._recycleDateMarkers();break;case"disableSelection":i?(n.$.taskTree.selectionMode="none",n.$.resourceTree.selectionMode="none",n._unselectAll("task"),n._unselectAll("resource")):(n.$.taskTree.selectionMode="zeroOrOne",n.$.resourceTree.selectionMode="zeroOrOne");break;case"durationUnit":for(let e=0;e<n._tasks.length;e++){const t=n._tasks[e],i=t.$.project;n._validateTaskDuration(t),n._validateTaskDates(t,i),n._validateTaskSegments(t),n._synchronizeProjectDates(t,i)}n._createTimelineCells(),n._insertTimelineTasks(),n.taskColumns.some((e=>(e.value+"").toLowerCase().indexOf("duration")>-1))&&n._refreshTableDataSource();break;case"filterRow":n.$.taskTable[e]=i;break;case"groupByResources":n._setTable(n.$.taskTable),n._createTimelineContent(),n._recycleTimelineTasks(),n._refresh();break;case"infiniteTimeline":i?n._scrollView.hScrollBar.value===n._scrollView.hScrollBar.max&&n._handleInfiniteTimeline():n.set("dateEnd","");break;case"keyboardNavigation":n.$.taskTable[e]=i,n.$.resourceTable&&(n.$.resourceTable[e]=i);break;case"popupWindowTabs":case"popupWindowCustomizationFunction":{const e=n.$.taskPopupWindow;e&&(e.opened&&(e.close(),delete e._target),e.clear());break}case"taskFiltering":n.$.taskTable.filtering=i,n._refresh();break;case"resourceFiltering":{const e=n.$.resourceTable;e&&(e.filtering=i,n._refresh());break}case"tooltip_enabled":{const e=n.$.tooltip;e&&(i||e.remove(),n._handleTooltipEvents(i));break}case"tooltip_arrow":case"tooltip_delay":case"tooltip_offset":{const t=n.$.tooltip;t&&(t[e.replace("tooltip_","")]=i);break}case"headerTemplate":n._handleHeaderTemplate();break;case"inverted":if(n._handleInverted(),n.scrollLeft){const e=n._getScrollLeft(n.scrollLeft);n.$.timelineHeader.scrollLeft=n.$.taskTimelineContainer.scrollLeft=e,n.$.mainSplitter.contains(n.$.resourceTimelineHeader)&&(n.$.resourceTimelineHeader.scrollLeft=n.$.resourceTimelineContent.scrollLeft=e)}break;case"rightToLeft":Array.from(n.querySelectorAll("smart-splitter, smart-table, smart-scroll-bar")).forEach((t=>t[e]=i)),n.closeWindow(),n._handleInverted(),n._refreshTimeline();break;case"dateStart":case"dateEnd":n._refreshTimeline();break;case"messages":case"locale":case"dayFormat":case"hourFormat":case"timelineHeaderFormatFunction":case"monthFormat":case"yearFormat":n._refreshHeaderDate(!0),n._refreshColumnsHeaders(),n._recycleResourceHeaderCells();break;case"hideResourcePanel":n._createResourceTimeline(),n._refreshTimeline();break;case"nonworkingDays":case"nonworkingHours":n._refreshAfterWorkingTimeChange();break;case"selectedTaskIds":n.$.taskTable.selected=n._getSelection("task",i);break;case"selectedResourceIds":n.$.resourceTable&&(n.$.resourceTable.selected=n._getSelection("resource",i));break;case"resourceColumns":n._setTable(n.$.resourceTable),n._highlightAssignedItem("task",n._getSelection("task",n.selectedTaskIds));break;case"resourcePanelHeaderTemplate":n._handleHeaderTemplate("resource");break;case"resourceTimelineView":case"resourceTimelineMode":case"resourceTimelineFormatFunction":n.$.mainSplitter.contains(n.$.resourceSplitter)&&n._resources.forEach((e=>n._refreshResourceTimelineContent(e)));break;case"showProgressLabel":case"progressLabelFormatFunction":n._tasks.forEach((e=>n._setTaskBarProgress(e)));break;case"sortFunction":n.$.taskTable.sort=i,n.$.resourceTable&&(n.$.resourceTable.sort=i);break;case"showSelectionColumn":n.$.taskTable.hideSelectionColumn=!i,n.$.resourceTable&&(n.$.resourceTable.hideSelectionColumn=!i);break;case"columnMenu":case"hideSelectionColumn":case"sortMode":n.$.taskTable[e]=i,n.$.resourceTable&&(n.$.resourceTable[e]=i);break;case"taskColumns":n._setTable(n.$.taskTable);break;case"timelineMin":n.$.timelineSplitterItem.min=i,n.$.taskSplitter.refresh(),n.$.mainSplitter.contains(n.$.resourceSplitter)&&n._synchronizeSplitters(n.$.taskSplitter,n.$.resourceSplitter);break;case"treeMin":case"treeSize":{const t=e.toLowerCase().indexOf("size")>-1?"size":"min";n.$.tableSplitterItem[t]=i,n.$.taskSplitter.refresh(),n.$.mainSplitter.contains(n.$.resourceSplitter)&&n._synchronizeSplitters(n.$.taskSplitter,n.$.resourceSplitter);break}case"taskPanelMin":case"taskPanelSize":case"resourcePanelSize":case"resourcePanelMin":{const t=e.indexOf("Min")>-1?"min":"size",a=e.indexOf("resource")>-1?"resource":"task";n.$.mainSplitter.contains(n.$.resourceSplitter)&&(n.$[`${a}SplitterItem`][t]=i,n.$.taskSplitterItem._setSize("size",n.taskPanelSize),n.refresh());break}case"unfocusable":n._setFocusable();break;case"view":n._refreshTimeline(t);break;default:super.propertyChangedHandler(e,t,i)}}_predefPropertyGetter(e){const t=this;Object.defineProperty(t,e,{get:function(){switch(e){case"dataSource":{if(t.context===t)return t.properties[e].value;const i=function(e){if(!e.length)return e;for(let n=0;n<e.length;n++){const a=e[n];let s=t._getProjectTasks(a);s&&Array.isArray(s)&&(s=i(s.filter((e=>e.$&&e.$.project===a)))),e[n]=t._cloneObject(a),s&&s.length?e[n].tasks=s:delete e[n].tasks}return e},n=t.properties[e].value;return n instanceof Smart.DataAdapter?n:i(n.slice(0))}case"dateStart":case"dateEnd":{const i=t._timelineCells;if(i.length){const n=t._getCellDateRange({_date:i["dateStart"===e?0:i.length-1].date});return new Date(n[e])}return t.properties[e].value}default:return t.properties[e].value}},set(i){t.updateProperty(t,t._properties[e],i)}})}ready(){this._customScrollView=!0,super.ready()}render(){const e=this,t=window.getComputedStyle(e),i=Smart.Utilities.Core;e._isMobile=i.isMobile,e._isFirefox=i.Firefox,e._taskBarMinWidth=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-task-min-width"))||0,e._taskDefaultHeight=parseFloat(t.getPropertyValue("--smart-gantt-chart-task-default-height"))||30,e._timelineCellSize=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-cell-size"))||0,e._timelineCellMinSize=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-cell-min-size"))||0,e._taskConnectionWidth=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-task-connection-width"))||1,e._baselineProportion=parseFloat(t.getPropertyValue("--smart-gantt-chart-baseline-proportion"))||0,e._predefPropertyGetter("dataSource"),e._predefPropertyGetter("dateStart"),e._predefPropertyGetter("dateEnd"),e.$.tableSplitterItem.size=e.treeSize,e.$.tableSplitterItem.min=e.treeMin,e.$.timelineSplitterItem.min=e.timelineMin,e._setScrollBars(),e._handleHeaderTemplate(),e._handleInverted(!0),e._createTasks(),e._setTable(),e._createTimeline(),e._createResourceTimeline(),e._setAriaControls(),e._setFocusable(),e.checkLicense(),(e.shadowRoot||e._isFirefox)&&requestAnimationFrame((()=>e.refresh())),super.render()}refresh(e){const t=this;if(e)return t._refreshTimeline(),t._setTable(t.$.taskTable),void t._createResourceTimeline();t.isRendered&&t._resizeEventHandler()}addFilter(e,t){const i=this;if(!i.taskFiltering&&!i.resourceFiltering||!(t instanceof Smart.Utilities.FilterGroup))return;Array.isArray(e)||(e="object"==typeof e?[e]:[]);const n=i.taskColumns,a=i.resourceColumns,s=i.$.taskTable,r=i.$.resourceTable;for(let i=0;i<e.length;i++){const o=e[i],l=o.type,[c,d]="resource"===l||a.includes(o)?[r,a]:[s,n],m=d.find((e=>o.value&&e.value===o.value));m&&c.addFilter(m.value,t)}}clearSelection(){this._unselectAll("task"),this._unselectAll("resource")}static get requires(){return{"Smart.Splitter":"smart.splitter.js","Smart.Tree":"smart.tree.js","Smart.Window":"smart.window.js"}}ensureVisible(e,t="task"){const i=this,n=i._getValidItemAndIndex(e,t);(e=n?n.item:void 0)&&(i._ensureVisible(e,t),i._scrollTo(e.dateStart,!0))}removeAllConnections(){const e=this;e.isCompleted&&(e.$.timelineConnectionsContainer.innerHTML="",e._connections=[],e._tasks.map((e=>e.connections=[])))}removeConnection(){const e=this,t=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted)return;let i;if(1===t.length){if("string"==typeof t[0]){const e=document.getElementById(t[0]);e&&(i=e.getAttribute("connection-id"))}i||(i=(t[0]+"").split("-"),i=e._getValidConnectionId(i[0],i[1],i[2],"removeConnection"))}else 3===t.length&&(i=e._getValidConnectionId(t[0],t[1],t[2],"removeConnection"));i&&(e._removeConnection(i),e.$.fireEvent("itemRemove",{type:"connection",id:`${i[0]}-${i[1]}-${i[2]}`,item:{source:i[0],target:i[1],type:i[2]}}))}removeTaskConnection(e,t){const i=this;if(!i.isCompleted)return;if((e+="").indexOf("-")>-1&&!t){const i=e.split("-");t=i[1],e=i[0]}const n=i._getValidItemAndIndex(e),a=i._getValidItemAndIndex(t);e=n?n.index:void 0,t=a?a.index:void 0,isNaN(e)?i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"removeTaskConnection",argumentName:"taskEndIndex"})):i._removeConnection(""+e+(isNaN(t)?"":t))}beginUpdate(){this._isUpdating={started:!0,type:{}},this.$.fireEvent("beginUpdate")}endUpdate(){const e=this;function t(){e._refreshTableDataSource(),e._createTimelineContent(),e._recycleTimelineTasks(),e._setAriaControls();const t=e._resources;for(let i=0;i<t.length;i++)e._refreshTableColumnsData(t[i],void 0,"resource")}function i(){if(e.hideResourcePanel)return;e._refreshTableDataSource("resource"),e._recycleResourceHeaderCells(),e._createResourceTimelineContent(),e._refresh();const t=e._tasks;for(let i=0;i<t.length;i++)e._refreshTableColumnsData(t[i])}if(!e._isUpdating)return;const n=1===Object.keys(e._isUpdating.type).length?Object.keys(e._isUpdating.type)[0]:void 0;let a,s;switch(e._selected&&({task:a,resource:s}=e._selected),delete e._isUpdating,n){case"task":t();break;case"resource":i();break;default:t(),i()}a&&(e._refreshSelectedItems("task",a),e.$.taskTable.selected=e._getSelection("task",e.selectedTaskIds)),s&&(e._refreshSelectedItems("resource",s),e.$.resourceTable.selected=e._getSelection("resource",e.selectedResourceIds)),e.$.fireEvent("endUpdate")}clearFilters(e){this._resetFromAction(e,"clearFilters")}clearSort(e){const t=this;"task"!==e&&"resource"!==e?(t._resetFromAction("task","clearSort"),t._resetFromAction("resource","clearSort")):t._resetFromAction(e,"clearSort")}clearTasks(){this._clearTasks()}_clearTasks(){const e=this;e._selected&&delete e._selected.task,e.set("selectedTaskIds",[]),e._tasks=[],e._timelineCells=[],e._timelineVCells=[],e._timelineHeaderCells=[],e.$.timelineContent.style.width="",e.$.container.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e.$.timelineViewDetails.innerHTML="",e.$.timelineViewCells.innerHTML="",e.$.taskTimelineCellsContainer.innerHTML="",e.$.timelineConnectionsContainer.innerHTML="",e.$.timelineTasksContainer.innerHTML="",e.$.taskIndicatorsContainer.innerHTML="",e.$.timelineContent.style.height="",delete e._hoveredItem,e.$.taskTable.dataSource=[],e._closeTooltip(),e.closeWindow(),e._refresh()}clearResources(){const e=this;e._unselectAll("resource"),e._resources=[],e.$.resourceTable&&(e.$.resourceTable.dataSource=[]),e.$.resourceTimelineCellsContainer.innerHTML="",e._tasks.forEach((t=>{t.resources=[],e._refreshTableColumnsData(t,["resources"])})),e._refreshTimeline(),e._createResourceTimeline()}createConnection(){const e=this,t=e._tasks;let i,n=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted||0===t.length)return;if(i=1===n.length?(n[0]+"").split("-"):n,!e._getValidConnectionId(i[0],i[1],i[2],"createConnection"))return;const a=parseInt(i[3]);e._connectTask([i[0],i[1],i[2],isNaN(a)?0:a]),e._recycleConnections(),e.$.fireEvent("itemInsert",{type:"connection",item:{source:i[0],target:i[1],type:i[2],lag:a}})}collapse(e){this._handleCollapseExpandMethods(e,"collapse")}expand(e){this._handleCollapseExpandMethods(e,"expand")}exportData(e,t){const i=this;if(!Smart.Utilities.DataExporter)return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"smart.export.js"}));try{new JSZip}catch(e){return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"jszip.min.js"}))}if("pdf"===e&!window.pdfMake)return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"pdfMake.min.js"}));const n="task"===i.dataExport.itemType?i.$.taskTable:i.$.resourceTable;return n?n.exportData(e,i.dataExport.fileName,i.dataExport.exportFiltered,t):void 0}print(){const e=this,t=e.dataExport.fileName;e.dataExport.fileName=null;const i=e.exportData("html"),n=window.open("","","width=800,height=500"),a=n.document.open(),s='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+i+"</body></html>";try{a.write(s),a.close(),setTimeout((function(){n.print(),n.close()}),100)}catch(e){}e.dataExport.fileName=t}getConnectionDetails(e){const t=this;if("string"!=typeof e)return;const i=t._getConnectionObjById(e);if(!i)return;const n=i.startTask,a=i.endTask,s={startTask:t._cloneObject(i.startTask),endTask:t._cloneObject(i.endTask),startTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,endTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,type:i.type};return void 0!==i.lag&&(s.lag=i.lag),s}getConnections(){const e=this;return e._connections.map((t=>{const i=t.startTask,n=t.endTask;return{id:t.startIndex+"-"+t.endIndex+"-"+t.type,startTask:e._cloneObject(i),endTask:e._cloneObject(n),startIndex:t.startIndex,startTaskId:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,endTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,endIndex:t.endIndex,type:t.type,lag:t.lag}}))}getState(){const e=this,t=e._getTasksJSON(!0)||[];return{tasks:JSON.parse(JSON.stringify(t)),selectedTaskIds:e.selectedTaskIds.slice(0),resources:JSON.parse(JSON.stringify(e._resources.slice(0))),scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}get tasks(){return this.isReady?this.getTasks():[]}get resources(){return this.isReady?this.getResources():[]}getTask(e){const t=this,i=t._getValidItemAndIndex(e);if(i.item)return t._cloneObject(i.item)}getTasks(){const e=this,t=e._tasks;return e.isReady&&t&&t.length?t.map((t=>e._cloneObject(t))):[]}getResource(e){const t=this,i=t._getValidItemAndIndex(e,"resource");if(i.item)return t._cloneObject(i.item)}getResources(){const e=this,t=e._resources;return e.isReady&&t&&t.length?t.map((t=>e._cloneObject(t))):[]}getItemPath(e){if(!e||void 0===e.type)return;const t="string"==typeof e.type?"task":"resource",i=this._getValidItemAndIndex(e,t);return i.item?i.item.$.id:void 0}getTaskIndex(e){const t=this;return"string"==typeof e?t._getTaskIndexById(e):t._getItemIndex(e,"task")}getTaskProject(e){const t=this;if((e=t._tasks[t._getItemIndex(e,"task")])&&e.$&&e.$.project)return t._cloneObject(e.$.project)}getTaskConnections(e){const t=this._getValidItemAndIndex(e,"task");return t&&t.item?this._getTaskConnections(t.item).taskConnections.map((e=>({target:e.endIndex,type:e.type,lag:e.lag}))):[]}getResourceIndex(e){return this._getItemIndex(e,"resource")}getResourceTasks(e){const t=this._getValidItemAndIndex(e,"resource");if(e=t?t.item:void 0)return this._getTasksAssigned(e)}getSelectedIds(){const e=this,t=e.selectedTaskIds,i=e.selectedResourceIds;return e.disableSelection||!t.length&&!i.length?null:{task:t.slice(),resources:i.slice()}}getSelectedTasks(){return this._getSelectedItems("task")}getSelectedResources(){return this._getSelectedItems("resource")}getWorkingHours(){const e=this.nonworkingHours;let t=[];for(let i=0,n=23;i<n;i+=1)e.indexOf(i)<0&&t.push(i);return t}isWorkingDay(e){return e=new Date(e),!isNaN(e.getTime())&&this.nonworkingDays.indexOf(e.getDay())<0}clearState(){const e=this;e.id?window.localStorage.removeItem("smartGanttChart"+e.id):e.warn(e.localize("noId"))}loadState(e){const t=this;if(!e){if(!t.id)return;e=JSON.parse(window.localStorage.getItem("smartGanttChart"+t.id))}if(!e)return;let i=JSON.stringify(e.tasks),n=JSON.stringify(e.selectedTaskIds),a=JSON.stringify(e.resources);if(i&&(i=JSON.parse(i)),n&&(n=JSON.parse(n)),a&&(a=JSON.parse(a)),t._noChangeEvent=!0,Array.isArray(i)&&(t._createTasks(i),t.set("dataSource",i)),Array.isArray(a)){let e=a;for(let i=0;i<e.length;i++){const e=a[i];let n=t._resources.find((t=>t.id&&t.id.toString()===e.id.toString()))||{};t._setResource(n,e),Object.values(n).length&&!t._resources.includes(n)&&t._resources.push(n)}t._refreshItemIds("resource")}"number"==typeof e.scrollLeft&&(t.scrollLeft=e.scrollLeft),"number"==typeof e.scrollTop&&(t.scrollTop=e.scrollTop),t._setTable(t.$.taskTable),t._createTimeline(),t._createResourceTimeline(),Array.isArray(n)&&(t.$.taskTable.selected=t._getSelection("task",n)),delete t._noChangeEvent}saveState(){const e=this;e.id?window.localStorage.setItem("smartGanttChart"+e.id,JSON.stringify(e.getState())):e.warn(e.localize("noId"))}insertTask(e,t,i){const n=this;if("object"!=typeof e)return void n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:"insertTask",argumentName:"newTask"}));const a=n._tasks;if(a.indexOf(e)>-1)return void n.error(n.localize("alreadyExists",{elementType:n.nodeName.toLowerCase(),methodName:"insertTask"}));const s=n._createTasks([e],!0);if(!a)return;let r,o,l;const c=n._getSelection("task",n.selectedTaskIds);if("string"==typeof i&&i.indexOf(!1)){const e=i.split(".");i=parseInt(e.slice(-1)),null==t&&(t=e.slice(0,-1).join("."))}if("string"==typeof t?(r=a.find((e=>e.id&&e.id.toString()===t)),r||(r=n._getItemByTableId("task",t))):"number"==typeof t&&(r=a[t]),r){if("project"!==r.type)return void n.error(n.localize("notAProject",{elementType:n.nodeName.toLowerCase(),argumentName:"project",methodName:"insertTask"}));s[0].$.project=r}return n._synchronizeProjectVisibility(s[0].$.project,s[0]),n._insertTasks(s,r,i),n._refreshItemIds(),n._refreshConnectionIds(),n._isUpdating?(n._isUpdating.type.task=!0,void(n._isUpdating.type.resource=!0)):(n._selected&&n._selected.task&&n._setSelection("task",l=n._selected.task.map((e=>e.$.id))),n._refreshTableDataSource(),n._refreshTimeline(),l&&c.toString()!==l.toString()&&(n.$.taskTable.selected=l.slice(0)),n._refreshTaskResources(o),n._ensureVisible(o),n.$.fireEvent("itemInsert",{type:"task",item:n._cloneObject(s[0])}),s[0].id||s[0].$.id+"")}openWindow(e){const t=this;if(t.disableWindowEditor)return;if("string"==typeof e){if(e.indexOf(".")>-1){const i=t._getVCellById("task",e),n=i?i.task:void 0;return void(n&&t._openPopupWindow(n))}if(e.indexOf("-")>-1){let e=(arguments[0]+"").split("-");if(e=t._getValidConnectionId(e[0],e[1],e[2],"openEditor"),e)return void t._openPopupWindow(e)}}const i=t._getValidItemAndIndex(e);i&&t._openPopupWindow(i.item)}closeWindow(){const e=this,t=["confirm","task","connection"];for(let i=0;i<t.length;i++){const n=e.$[t[i]+"PopupWindow"];n&&(n.close(),delete n._target)}}updateTask(e,t){const i=this,n=i._getValidItemAndIndex(e),a=n?n.item:void 0;"object"==typeof a?"object"==typeof t?i._updateTask(a,t):i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"updateTask",argumentName:"taskDetails"})):i.error(i.localize("notExisting",{elementType:i.nodeName.toLowerCase(),methodName:"updateTask",argumentName:"newTask"}))}removeTask(e){const t=this,i=t._tasks,n=t._getValidItemAndIndex(e),a=n?n.item:void 0;i&&i.length&&("object"==typeof a?t._removeTask(a):t.error(t.localize("notExisting",{elementType:t.nodeName.toLowerCase(),methodName:"removeTask",argumentName:"index"})))}setWorkTime(e){this._setWorkTime(e,(function(e,t){for(let i=0,n=e.length;i<n;i+=1){const n=parseInt(e[i]),a=t.indexOf(n);a>-1&&t.splice(a,1)}return t}))}selectTask(e){this._handleItemSelection(e,"task")}selectResource(e){const t=this;t.$.mainSplitter.contains(t.$.resourceTable)&&t._handleItemSelection(e,"resource")}sort(e){const t=this;if("none"===t.sortMode)return;Array.isArray(e)||(e="object"==typeof e?[e]:[]);const i=t.taskColumns,n=t.resourceColumns,a=t.$.taskTable,s=t.$.resourceTable;for(let t=0;t<e.length;t++){const r=e[t],o="desc"===r.sortOrder?"desc":"asc",[l,c]="resource"===r.type||n.includes(r)?[s,n]:[a,i],d=c.find((e=>r.value&&e.value===r.value));d&&l.sortBy(d.value,o)}}unselectTask(e){this._handleItemSelection(e,"task",!0)}unselectResource(e){const t=this;t.$.mainSplitter.contains(t.$.resourceTable)&&t._handleItemSelection(e,"resource",!0)}unsetWorkTime(e){this._setWorkTime(e,(function(e,t){for(let i=0,n=e.length;i<n;i+=1){const n=parseInt(e[i]);t.indexOf(n)<0&&t.push(n)}return t}),!0)}hideTooltip(){this._closeTooltip()}showTooltip(e,t){this._openTooltip(e,void 0,t)}_getSelectedItems(e="task"){const t=this,i=t[`_${e}s`],n=t._getSelection(e,"task"===e?t.selectedTaskIds:t.selectedResourceIds);if(!n.length)return[];let a=[];for(let e=0,s=i.length;e<s;e+=1){const s=i[e];n.indexOf(s.$.id)>-1&&a.push(t._cloneObject(s))}return a}_getTasksAssigned(e){const t=this,i=t._tasks||[];let n=[];for(let a=0;a<i.length;a++){const s=i[a];!s.disableResources&&s.resources.find((t=>t===e.id))&&n.push(t._cloneObject(s))}return n}_getItemIndex(e,t){t||(t="task");const i=this[`_${t}s`];if(e instanceof HTMLElement&&e.classList.contains("smart-timeline-task"))return i.indexOf(e._cellObj[`_${t}`]);const n="resource"===t?["id","label","value","progress"]:["id","label","type","class","dateStart","dateEnd","resources","connections"];if("object"==typeof e)for(let t=0;t<i.length;t++)if(n.every((n=>Array.isArray(e[n])?JSON.stringify(e[n])===JSON.stringify(i[t][n]):n.indexOf("date")>-1?new Date(e[n]).getTime()===new Date(i[t][n]).getTime():e[n]===i[t][n])))return i.indexOf(i[t]);return-1}_handleItemSelection(e,t="task",i){const n=this,a=n._getValidItemAndIndex(e,t);if(a.item){const s=a.item,r=n._getSelection(t,"task"===t?n.selectedTaskIds:n.selectedResourceIds);if(e=s.$.id,i){const i=r.indexOf(e);i>-1&&(r.splice(i,1),n.$[`${t}Table`].selected=r)}else r.indexOf(e)<0&&(r.push(e),n.$[`${t}Table`].selected=r);return"string"==typeof s.id||"number"==typeof s.id?s.id:s.$.id}}_refreshAfterWorkingTimeChange(){const e=this;if(e.adjustToNonworkingTime)for(let t=0;t<e._tasks.length;t++){const i=e._tasks[t],n=i.$.project;e._validateTaskDates(i,n),e._synchronizeProjectDates(i,n),e._refreshTableColumnsData(i,["dateEnd","duration"])}e._refreshTimeline()}_refreshItemIds(e="task"){const t=this[`_${e}s`];if(!t)return;let i={},n=0;for(let e=0,a=t.length;e<a;e+=1){const a=t[e],s=a.$.project;if(void 0!==s){const e=s.$.id;i[e]||(i[e]=0),a.$.id=e+"."+i[e],i[e]++}else a.$.id=n+"",n++}}_refreshConnectionIds(){const e=this._tasks,t=this._connections;if(t&&t.length)for(let i=0,n=t.length;i<n;i+=1){const a=t[i],s=e.indexOf(a.startTask),r=e.indexOf(a.endTask);(s<0||r<0)&&(t.splice(i,1),n--),a.startIndex=s,a.endIndex=r}}_refreshSelectedItems(e="task",t){const i=this,n=i[`_${e}s`];if(n&&(!t&&i._selected&&i._selected[e]&&(t=i._selected[e]),t)){for(let e=0,i=t.length;e<i;e+=1){const a=t[e];(n.indexOf(a)<0||a.hidden)&&(t.splice(e,1),e-=1,i--)}i._setSelection(e,t.map((e=>e.$.id)))}}_resetFromAction(e="task",t="clearSort"){const i=this;function n(){i.$.taskTable[t](),i._createTimelineContent(),i._recycleTimelineTasks()}function a(){const e=i.$.resourceTable;e&&(e[t](),i._createResourceTimelineVCells(),i._recycleResourceContent())}"resource"===e?a():"task"===e?n():(n(),a())}_setWorkTime(e,t,i){const n=this;if("object"!=typeof e)return;let a,s=e.days,r=e.hours;null!=s&&(Array.isArray(s)||(s=[s]),s=n._nonworkingDayValidator(void 0,s),a=t(s,i?n.nonworkingDays:[0,1,2,3,4,5,6]),n.set("nonworkingDays",7===a.length?[]:a),n._refreshAfterWorkingTimeChange()),null!=r&&(Array.isArray(r)||(r=[r]),r=n._nonworkingTimeValidator(void 0,r),a=t(r,i?n.nonworkingHours:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),n.set("nonworkingHours",24===a.length?[]:a),n._refreshAfterWorkingTimeChange())}_getValidConnectionId(e,t,i,n){const a=this,s=a._tasks,r=0===n.indexOf("_");let o;if("string"==typeof e&&(o=a._getTaskIndexById(e),o>=0&&(e=o)),"string"==typeof t&&(o=a._getTaskIndexById(t),o>=0&&(t=o)),e=parseInt(e),t=parseInt(t),i=parseInt(i),isNaN(e)||isNaN(t)||e===t)r||a.error(a.localize("incorrectArgument",{elementType:a.nodeName.toLowerCase(),methodName:n,argumentName:"taskIndex"}));else if(e>=s.length||e<0||t>=s.length||t<0)r||a.error(a.localize("outOfBounds",{elementType:a.nodeName.toLowerCase(),methodName:n,argumentName:"taskIndex"}));else{if(!(isNaN(i)||i<0||i>3))return r?[e,t,i]:e+"-"+t+"-"+i;r||a.error(a.localize("incorrectArgument",{elementType:a.nodeName.toLowerCase(),methodName:n,argumentName:"connectionType"}))}}_autoSchedule(e){const t=this,i=t._tasks;if(t.autoSchedule){e?Array.isArray(e)||(e=[e]):e=i;for(let i=0;i<e.length;i++){const n=e[i];"project"===n.type&&n.synchronized||(n.minDateStart=n.minDateEnd=void 0,t._autoScheduleTasks(n))}t._isUpdateRequired&&(t._createTimelineCells(),t._recycleTimelineTasks(!0),delete t._isUpdateRequired)}}_getTaskConnections(e){const t=this._tasks,i=this._connections;let n=[],a=[];if(t&&t.length&&i&&i.length){const s=t.indexOf(e);for(let e=0;e<i.length;e+=1){const t=i[e];t.startIndex===s?n.push(t):t.endIndex===s&&a.push(t)}}return{taskConnections:n,connectedTasks:a}}_autoScheduleTasks(e){const t=this,i=t._tasks,n=t._getTaskConnections(e),a=n.taskConnections,s=n.connectedTasks;let r,o,l;for(let n=0;n<a.length;n++)t._isAutoScheduled(e,i[a[n].endIndex],!0);for(let n=0;n<s.length;n++){const a=s[n],c=i[a.startIndex],d=a.type,m=a.lag,u=e.$.project;c&&"project"===c.type&&c.synchronized||(0===d||1===d?(l=new Date((0===d?c.dateStart:c.dateEnd).getTime()+m),e.minDateStart=new Date(e.minDateStart?Math.max(e.minDateStart.getTime(),l.getTime()):l),o=e.minDateStart.getTime()-e.dateStart.getTime(),r=new Date(e.dateEnd.getTime()+(t.autoScheduleStrictMode?o:Math.max(0,o))),r.getTime()!==e.dateEnd.getTime()&&(e.dateEnd=r,t._isUpdateRequired=!0),t.autoScheduleStrictMode&&e.minDateStart.getTime()!==e.dateStart.getTime()&&(e.dateStart=e.minDateStart,t._isUpdateRequired=!0)):(l=new Date((2===d?c.dateEnd:c.dateStart).getTime()+m),e.minDateEnd=new Date(e.minDateEnd?Math.min(e.minDateEnd.getTime(),l.getTime()):l),o=e.minDateEnd.getTime()-e.dateEnd.getTime(),r=new Date(e.dateStart.getTime()+(t.autoScheduleStrictMode?o:Math.max(0,o))),r.getTime()!==e.dateStart.getTime()&&(e.dateStart=r,t._isUpdateRequired=!0),t.autoScheduleStrictMode&&e.minDateEnd.getTime()!==e.dateEnd.getTime()&&(e.dateEnd=e.minDateEnd,t._isUpdateRequired=!0)),t._validateTaskDates(e,u),t._synchronizeProjectDates(e,u))}for(let e=0;e<a.length;e++){const n=i[a[e].endIndex];!n||"project"===n.type&&n.synchronized||(n.minDateStart=n.minDateEnd=void 0,t._autoScheduleTasks(n))}}_autoScheduleRestore(e,t){const i=this._tasks;e||(e=i),Array.isArray(e)||(e=[e]);for(let n=0;n<e.length;n++){const a=e[n];i.indexOf(e[n])>-1&&(t?0===t||1===t?a.minDateStart=void 0:a.minDateEnd=void 0:a.minDateStart=a.minDateEnd=void 0)}}_autoScroll(e){const t=this,i=t.hasAttribute("dragged"),n=t.hasAttribute("resized");function a(a,s){if(!t._dragDetails)return clearInterval(t._scrollInterval),t._scrollInterval=void 0,void delete t._autoScrolling;t._autoScrolling=!0,s?i||(t.scrollTop-=t.autoScrollStep*a,t._dragDetails.coordinates.y+=t.autoScrollStep*a):(t.scrollLeft-=(t.rightToLeft?-1:1)*t.autoScrollStep*a,t._dragDetails.coordinates.x+=t.autoScrollStep*a),i?t._handleTaskBarDrag(e):n&&t._handleTaskBarResize(e)}if(t.disableAutoScroll||!e||!i&&!n&&!t.hasAttribute("connecting-task"))return;const s=t.$.timeline.getBoundingClientRect();t._scrollInterval&&clearInterval(t._scrollInterval),t._scrollInterval=setInterval((function(){(t.scrollLeft||t.rightToLeft)&&e.clientX<=s.left+20?a(1):t.scrollLeft!==(t.rightToLeft?0:t.scrollWidth)&&e.clientX>=s.left+s.width-20?a(-1):t.scrollTop&&e.clientY<=s.top+20?a(1,!0):t.scrollTop!==t.scrollHeight&&e.clientY>=s.top+s.height-20?a(-1,!0):(clearInterval(t._scrollInterval),t._scrollInterval=void 0,delete t._autoScrolling)}),1)}_checkTaskBarResizability(e){const t=this;let i=e.originalEvent.target;t.shadowRoot&&i===t&&(i=e.originalEvent.composedPath()[0]);const n=t.$.timeline;if(!i.closest)return void n.removeAttribute("task-bar-hovered");let a,s=i.closest(".smart-timeline-row")||i.closest(".smart-timeline-task");if(t.disabled||t.disableTaskResize||!s||!n.contains(s))return void n.removeAttribute("task-bar-hovered");const r=s._cellObj.task,o=t._getTaskDOMIndex(r);if(s.classList.contains("smart-timeline-row")?a=t.$.timelineTasksContainer.children[o]:s.classList.contains("smart-timeline-task")&&(a=s,s=t.$.taskTimelineCellsContainer.children[o]),!a||a.classList.contains("milestone")||r.synchronized||r.disableResize)return;const l=i.closest(".smart-task-segment"),c=r.segments?r.segments.length:1;if(i.classList&&i.classList.contains("smart-task-connection-point")||l&&(c>1&&t.disableSegmentResize||l._segmentObj&&l._segmentObj.disableResize))return void n.removeAttribute("task-bar-hovered");const d=e.pageX-window.pageXOffset,m="visible"===t.resizeHandlesVisibility||t._isMobile?20:5,u=(l||a).getBoundingClientRect(),h=s.getBoundingClientRect(),g=Math.min(m,d-h.left),f=Math.min(m,h.left+h.width-d);Math.round(u.left)+g>=d&&Math.round(u.left)-g<=d?n.setAttribute("task-bar-hovered","left"):Math.round(u.left+u.width)+f>=d&&Math.round(u.left+u.width)-f<=d?n.setAttribute("task-bar-hovered","right"):n.removeAttribute("task-bar-hovered")}_onShadowDomLoaded(e,t,i){requestAnimationFrame((function n(){const a=(e.shadowRoot||e.getRootNode()).querySelectorAll("link");for(let e=0;e<a.length;e++)if(-1!==a[e].href.indexOf(t))return void i();requestAnimationFrame(n)}))}_getConnectionObjById(e){const t=this._connections;if(!e||!t||!t.length)return;const i=e.split("-"),n=parseInt(i[0]),a=parseInt(i[1]),s=parseInt(i[2]);for(let e=0,i=t.length;e<i;e+=1){const i=t[e];if(i.startIndex===n&&i.endIndex===a&&i.type===s)return i}}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),i=[e.$.taskPopupWindow,e.$.connectionPopupWindow,e.$.confirmPopupWindow];for(let n=0;n<i.length;n++){const a=i[n];if(!a||!t.contains(a))continue;const s=e.getBoundingClientRect();a.opened||(a.style.left=a.style.top=""),e._isMobile?(a.setAttribute("mobile",""),a.style.left=s.left+window.pageXOffset+"px",a.style.top=s.top+window.pageYOffset+"px",a.style.width=s.width+"px",a.style.height=s.height+"px"):(a.style.left=Math.max(s.left+window.pageXOffset,s.left+window.pageXOffset+s.width/2-a.offsetWidth/2)+"px",a.style.top=Math.max(s.top+window.pageYOffset,s.top+window.pageYOffset+s.height/2-a.offsetHeight/2)+"px")}}_openPopupWindow(e,t){const i=this;function n(){function t(){i._positionWindow(),s.opened?(s.bringToFront(),s._onOpenCallback?s._onOpenCallback():s._handleActiveState()):s.open()}if(i.popupWindowCustomizationFunction?i.popupWindowCustomizationFunction(s,a,"connection"===a?e.startIndex+"-"+e.endIndex+"-"+e.type:i._cloneObject(e)):s._onOpenCallback=()=>{const e=(s.shadowRoot||s).querySelectorAll(".smart-gantt-chart-popup-window-editor .smart-input, .smart-popup-window-button");(e[0]||e[1]||s).focus({preventScroll:!0}),s._handleActiveState()},i._setPopupWindowTemplate("header",a,e),i._setPopupWindowTemplate("footer",a,e),i._setPopupWindowTemplate("content",a,e),!i._popupWindow[a+"PopupWindow"]){const e=i["$"+a+"PopupWindow"];e.unlisten("transitionend"),e.unlisten("open"),e.unlisten("close"),e.unlisten("closing"),e.unlisten("click"),e.unlisten("change"),e.listen("transitionend",i._popupWindowTransitionendHandler.bind(i)),e.listen("open",i._popupWindowOpenHandler.bind(i)),e.listen("close",i._popupWindowCloseHandler.bind(i)),e.listen("closing",i._popupWindowClosingHandler.bind(i)),e.listen("click",i._popupWindowClickHandler.bind(i)),e.listen("change",i._popupWindowChangeHandler.bind(i))}s.shadowRoot?(s.importStyle(Smart.Utilities.Core.getScriptLocation()+Smart.StyleBaseUrl.replace("/scoped/","/smart.textbox.css")),i._onShadowDomLoaded(s,"smart.window.css",t)):t();const n=(i.getAttribute("aria-owns")||"")+" "+s.id;i.setAttribute("aria-owns",n.trim()),i._popupWindow[a+"PopupWindow"]=s}if(e&&e.classList)if(e.classList.contains("smart-task-connection"))e=i._getConnectionObjById(e.getAttribute("connection-id"));else if("TR"===e.nodeType){const t=e?"task":"resource",n=i._getVCellById(t,e.getAttribute("row-id"));e=n?n[t]:void 0}else e=e._cellObj.task;if(!e||e.isGroup)return;const a=t?"confirm":"string"==typeof e.type?"task":"connection",s=i._createPopupWindow(a);!t&&i.$.fireEvent("opening",{target:s,type:a}).defaultPrevented||(i._closeTooltip(),s._target=e,i._popupWindow||(i._popupWindow={}),s.parentElement||i.getShadowRootOrBody().appendChild(s),s.isCompleted?n():s.whenReady((()=>n())))}_createPopupWindow(e){const t=this,i=e+"PopupWindow";if(t.$[i])return t.$[i];const n=document.createElement("smart-window");return n.classList.add("smart-"+e+"-popup-window"),n.classList.add("smart-gantt-chart-popup-window"),n.setAttribute("smart-id",i),t.$[i]=n,t["$"+i]=Smart.Utilities.Extend(n),n.rightToLeft=t.rightToLeft,n.theme=t.theme,n.animation=t.animation,n.disableSnap=!0,n.headerButtons=["close"],n}_popupWindowOpenHandler(e){const t=this,i=t["$"+e.target.getAttribute("smart-id")];if(i){const n=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";t._handleModal(!0),t.$.fireEvent(e.type,Object.assign({type:n,target:e.target},e.detail)),i.unlisten("open")}}_popupWindowClosingHandler(e){const t=this["$"+e.target.getAttribute("smart-id")];if(!t)return;const i=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";this.$.fireEvent(e.type,{target:e.target,type:i}).defaultPrevented?e.preventDefault():t.unlisten(e.type)}_popupWindowCloseHandler(e){const t=this,i=e.target.getAttribute("smart-id"),n=t["$"+i];if(n){const a=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";if(t._handleModal(),t.$.fireEvent(e.type,Object.assign({type:a,target:e.target},e.detail)),n.unlisten("close"),n.unlisten("click"),t.hasAttribute("aria-owns")){const e=t.getAttribute("aria-owns").replace(t._popupWindow[i].id,"").trim();e?t.setAttribute("aria-owns",e):t.removeAttribute("aria-owns")}delete t._popupWindow[i];const s=Object.keys(t._popupWindow);1===s.length&&t._popupWindow.confirmPopupWindow&&(delete t._popupWindow.confirmPopupWindow._target,t._popupWindow.confirmPopupWindow.close()),s.length?requestAnimationFrame((()=>{const e=t._popupWindow[s[s.length-1]];e&&e.focus()})):t.keyboardNavigation&&t.$.taskTable.focus({preventScroll:!0})}}_popupWindowTransitionendHandler(e){const t=this,i=e.target;i instanceof Smart.Window&&!i.opened&&"visibility"===e.propertyName&&(t["$"+i.getAttribute("smart-id")].unlisten("transitionend"),i.parentElement&&i.parentElement.removeChild(i))}_handleModal(e){const t=this;let i=(t.shadowRoot||t).querySelector(".smart-popup-window-modal");e?(i||(i=document.createElement("div"),i.classList.add("smart-popup-window-modal")),i.parentElement||(t.$.container.appendChild(i),t.setAttribute("modal",""))):i&&i.parentElement&&Object.keys(t._popupWindow).length<2&&(i.parentElement.removeChild(i),t.removeAttribute("modal"))}_findTaskEditor(e,t){if(!e||!t)return;const i=t.children;for(let t=0,n=i.length;t<n;t+=1){const n=i[t];if(n.getAttribute("value")===e)return n}}_createTaskEditor(e,t,i){const n=this,a=e.value,s=t[e.value];let r,o,l=i.find((e=>e._label===a));if(l)r=l.querySelector(".smart-gantt-chart-label-container"),o=l.lastElementChild;else{const t="editorLabel"+Math.floor(65536*(1+Math.random())).toString(16).substring(1);if(r=document.createElement("div"),r.classList.add("smart-gantt-chart-label-container"),r.innerHTML=`<label id="${t}"></label>`,"deadline"===a){const e=document.createElement("span");e.classList.add("smart-popup-window-editor-toggle"),r.appendChild(e)}if(l=document.createElement("div"),l.classList.add("smart-gantt-chart-popup-window-editor"),l.setAttribute("value",a||""),l._label=a,e.customEditor)return l.appendChild(e.customEditor(a,s)),l;if("number"==typeof s||"string"==typeof s)o=document.createElement("input"),o.classList.add("smart-input");else if(s instanceof Date||"deadline"===a)Smart.DateTimePicker?(o=document.createElement("smart-date-time-picker"),o.locale=n.locale,o.dropDownAppendTo="body",o.calendarButton=!0,o.dropDownDisplayMode="auto",o.enableMouseWheelAction=!0,o.formatString="yyyy-MMM-dd HH:mm:ss"):(o=document.createElement("input"),o.type="datetime-local");else if(Array.isArray(s))if(Smart.DropDownList)o=document.createElement("smart-drop-down-list"),o.virtualized=!0,o.dropDownAppendTo="body",o.selectionMode="zeroOrMany";else{o=document.createElement("input"),o.classList.add("smart-input");const e=document.createElement("datalist");e.id="resourceList",o.setAttribute("list",e.id),l.appendChild(e)}o&&o.setAttribute("aria-labelledby",t)}if(!l.parentElement)return r&&l.appendChild(r),o&&l.appendChild(o),l;n._setPopupWindowEditors(e,t,l)}_setAriaControls(){this.setAttribute("role","treegrid")}_setPopupWindowEditors(e,t,i){const n=this,a=i.querySelector("label"),s=i.querySelector(".smart-popup-window-editor-toggle"),r=i.lastElementChild,o=e.value+"",l=o.split(/(?=[A-Z])/).join(" "),c=t[o];if(e.customEditor)e.setCustomEditorValue&&e.setCustomEditorValue(i,l,c);else{if(a.innerHTML=n.localize(e.value)||l.charAt(0).toUpperCase()+l.slice(1),s)if("deadline"===o){const e=null==c?"add":"remove";r.classList[e]("smart-hidden"),s.textContent=n.localize(e)}else s.remove();if("number"==typeof c)r.value=parseFloat(c);else if("string"==typeof c)r.value=c;else if(c instanceof Date)r.value=new Date(c);else if(Array.isArray(c)){const e=n._resources;if(r.placeholder=n.localize("unassigned"),Smart.DropDownList&&r instanceof Smart.DropDownList)r.dataSource=e.map((e=>({label:e.label,value:e.id}))),r.selectedValues=t.disableResources?[]:t.resources.map((e=>e.toString()));else{let n=i.querySelector("datalist"),a=document.createDocumentFragment();n.innerHTML="";for(let t=0;t<e.length;t++){const i=e[t],n=document.createElement("option");n.value=i.id,n.innerHTML=i.label,a.appendChild(n)}r.value=t.resources.toString(),n.appendChild(a)}}"project"===t.type&&t.synchronized&&["duration","date"].indexOf(l.toLowerCase())>-1||"resources"===l&&t.disableResources?r.disabled=!0:r.disabled=!!e.disableEdit,r.rightToLeft=n.rightToLeft,r.animation=n.animation,r.theme=n.theme}}_setupPopupWindowTabs(e,t){const i=this,n=i.popupWindowTabs,a="milestone"===t.type,s=[{label:i.localize("generalTab"),value:"general"},{label:i.localize("dependencyTab"),value:"dependency"},{label:i.localize("segmentsTab"),value:"segments"}];let r=e.querySelector(".smart-gantt-chart-popup-window-tabs");r||(r=document.createElement("smart-tabs"),r.classList.add("smart-gantt-chart-popup-window-tabs"),e.clear(),e.appendChild(r)),r.animation=i.animation,r.rightToLeft=i.rightToLeft,r.theme=i.theme;const o=r.getTabs().slice(0);for(let e=0,t=s.length;e<t;e+=1){const t=s[e],i=t.value;let l=o[e];n.indexOf(i)<0?l&&r.removeChild(l):(l||(l=document.createElement("smart-tab-item"),r.appendChild(l)),l.label=t.label,l.setAttribute("value",i||""),l.disabled=a&&"segments"===i)}return r}_setPopupWindowContent(e,t){const i=this,n=i.$[e+"PopupWindow"],a=[].slice.call(n.querySelectorAll(".smart-gantt-chart-popup-window-editor"));if(n.content&&(!n.content.innerHTML||a.length))if("task"===e&&t){const e=i.taskColumns;let s=[];const r=i._setupPopupWindowTabs(n,t);0!==r.selectedIndex&&(r.selectedIndex=0);const o=r.getTabs()[0];if("general"!==o.getAttribute("value"))return void i._handleTabsContent(o,n);"string"==typeof o.content?o.content="":o.content.innerHTML="";for(let n=0;n<e.length;n++){const r=e[n],l=r.value;if(void 0===t[l]&&"deadline"!==l||"overdue"===l)continue;let c=i._findTaskEditor(l,o);c||(c=i._createTaskEditor(r,t,a),o.appendChild(c)),i._setPopupWindowEditors(r,t,c),s.push(c)}for(let e=0,t=a.length;e<t;e+=1){const t=a[e];s.indexOf(t)<0&&t.remove()}t.id&&n.setAttribute("aria-controls",t.id)}else if("confirm"===e){if(n.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("confirm",{componentName:"The task"})+"</div >",i._popupWindow){const e=Object.keys(i._popupWindow);e.length&&n.setAttribute("aria-controls",i._popupWindow[e[e.length-1]].id)}}else{const e=t.startTask,a=t.endTask;n.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("deleteLink")+"<b> "+e.label+" - "+a.label+"?</b></div>"}}_setPopupWindowTemplate(e,t,i){const n=this,a=n.$[t+"PopupWindow"];if("content"!==e){if(a[e+"Template"]||(a[e+"Template"]=n._createPopupWindowTemplate(e,t)),"header"===e&&i&&"string"==typeof i.type){const e=(a.shadowRoot||a).querySelector(".smart-popup-window-label");e&&(e.innerHTML=i.label)}else if("footer"===e){const e=(a.shadowRoot||a).querySelectorAll(".smart-popup-window-button");for(let i=0;i<e.length;i++){const a=e[i];a.innerHTML="task"===t?'<span class="smart-icon"></span>':"",a.theme=n.theme,a.rightToLeft=n.rightToLeft,a.animation=n.animation,a.disabled=!1,a.classList.contains("ok")?(a.innerHTML+=n.localize("ok"),a.setAttribute("aria-label","ok")):a.classList.contains("cancel")?(a.innerHTML+=n.localize("cancel"),a.setAttribute("aria-label","cancel")):a.classList.contains("delete")&&(a.innerHTML+=n.localize("delete"),a.setAttribute("aria-label","delete"));const s=a.querySelector(".smart-ripple");s&&s.parentElement.removeChild(s)}}}else n._setPopupWindowContent(t,i)}_createPopupWindowTemplate(e,t){const i=this,n=document.createElement("template");if("footer"===e)switch(t){case"task":n.innerHTML=`<smart-button class="smart-popup-window-button ok primary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button cancel"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button delete secondary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>`;break;case"connection":case"confirm":n.innerHTML=`<smart-button class="smart-popup-window-button ok primary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button cancel"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>`}else"header"!==e||"task"!==t&&"confirm"!==t||(n.innerHTML='<span class="smart-popup-window-label"></span>');return n}_handleTabsContent(e,t){const i=this,n=t._target;if(!e|!n)return;const a=e.getAttribute("value");if("general"===a)return;let s=e.querySelector(".smart-gantt-popup-window-table"),r=e.querySelector(".smart-gantt-window-table-buttons"),o=e.querySelector(".smart-gantt-window-validation-message");r||(r=document.createElement("div"),r.classList.add("smart-gantt-window-table-buttons"),r.innerHTML=`<smart-button class="smart-gantt-chart-button" action="add">${i.localize("add")}</smart-button>\n <smart-button class="smart-gantt-chart-button" disabled action="delete">${i.localize("delete")}</smart-button>`,e.insertBefore(r,s)),s||(s=document.createElement("smart-table"),s.classList.add("smart-gantt-popup-window-table"),s.editing=!0,s.editMode="row",s.keyboardNavigation=!0,s.wait=!0,s.hideSelectionColumn=!0,s.selection=!0,s.selectionMode="one",s.columnMinWidth="10px",s.addEventListener("rowEndEdit",(r=>{const o=r.detail.row;switch(a){case"dependency":{const e=i._tasks,t=o.name,a=e.indexOf(n),r=e.findIndex((e=>e.$.id===t));r>-1&&s.updateRow(o.$.id,{id:`${r}-${a}-${o.type}`});break}case"segments":{const e=o.dateStart,t=o.dateEnd;e.getTime&&t.getTime&&s.updateRow(o.$.id,{duration:parseFloat(i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e,t):t.getTime()-e.getTime(),!0).toFixed(2))});break}}i._applyTableValidation(e,s,t),i._isPopupWindowTableModified=!0})),e.innerHTML&&(e.innerHTML=""),e.appendChild(s));const l=i._getTabsTableData(a,n);s.selected.length&&(s.selected=[]),s.dataSource=l.source,s.columns=l.columns,s.wait=!1,delete i._isPopupWindowTableModified,o||(o=document.createElement("label"),o.classList.add("smart-gantt-window-validation-message"),e.appendChild(o)),o.textContent=""}_applyTableValidation(e,t,i){const n=this,a=e.getAttribute("value"),s=e.querySelector(".smart-gantt-window-validation-message"),r=i.querySelector(".smart-popup-window-button.ok"),o=t.dataSource,l=o.length;if(!s)return void(r&&(r.disabled=!1));if(!l)return s.textContent="",void(r&&(r.disabled=!1));let c="";if("segments"===a)if(l<2)c=n.localize("segmentsCountValidation");else{const e=i._target,t=e.dateStart.getTime(),a=e.dateEnd.getTime();let s={};for(let e=0;e<l;e+=1){const i=o[e],r=i.label,l=i.dateStart.getTime(),d=i.dateEnd.getTime();for(let e in s){const t=s[e],a=t.timeStart,r=t.timeEnd,o=l<=a&&d>=a,m=l<=r&&d>=r;(o||m)&&(c+=n.localize("segmentConflictError",{dateConflict:o?"dateStart":"dateEnd",label:i.label,conflictLabel:t.label})+"\r\n")}l>d?c+=n.localize("segmentStartError",{label:i.label})+"\r\n":l===d&&(c+=n.localize("segmentEndError",{label:i.label})+"\r\n"),(l<t||d>a)&&(c+=n.localize("segmentRangeError",{label:i.label})+"\r\n"),void 0===s[e]&&(s[e]={label:r,timeStart:l,timeEnd:d})}}else if("dependency"===a)for(let e=0;e<l;e+=1){const t=o[e].id.split("-");t[0]===t[1]&&(c+=n.localize("dependencyValidation")+"\r\n")}s.textContent=c,r&&(r.disabled=c.length>0)}_getTabsTableData(e,t){const i=this;if("dependency"===e){const e=i._getTaskConnections(t).connectedTasks,n={connectionTypes:[{label:i.localize("startToStart"),value:0},{label:i.localize("endToStart"),value:1},{label:i.localize("endToEnd"),value:2},{label:i.localize("startToEnd"),value:3}],tasks:(()=>{const e=i._tasks;let n=[];for(let i=0,a=e.length;i<a;i+=1){const a=e[i];a!==t&&n.push({value:a.$.id,label:a.label})}return n})()};return{source:new window.Smart.DataAdapter({dataSource:e&&e.length?e.map((e=>({id:e.startIndex+"-"+e.endIndex+"-"+e.type,name:e.startTask.$.id||"",type:e.type,lag:e.lag||0}))):[],dataFields:["id: any","name: any","type: number","lag: number"]}),columns:[{label:i.localize("id"),dataField:"id",dataType:"any",autoWidth:!1,allowEdit:!1},{label:i.localize("name"),dataField:"name",dataType:"any",width:"35%",autoWidth:!1,editor:i._getColumnEditorSetup("name",n),formatFunction:e=>{const t=n.tasks.find((t=>t.value===e.value));t&&(e.value=t.label)}},{label:i.localize("type"),dataField:"type",dataType:"number",width:"25%",autoWidth:!1,editor:i._getColumnEditorSetup("type",n),formatFunction:e=>{const t=n.connectionTypes.find((t=>t.value===e.value));t&&(e.value=t.label)}},{label:i.localize("lag"),dataField:"lag",dataType:"number",autoWidth:!1}]}}if("segments"===e){const e={task:t};return{source:new window.Smart.DataAdapter({dataSource:t.segments,dataFields:["label: string","dateStart: date","dateEnd: date","duration: number"]}),columns:[{label:i.localize("name"),dataField:"label",dataType:"string",autoWidth:!1,width:"20%"},{label:i.localize("dateStart"),dataField:"dateStart",dataType:"date",autoWidth:!1,editor:i._getColumnEditorSetup("dateStart",e),formatFunction:e=>{e.value=i._formatDate(e.data.dateStart)}},{label:i.localize("dateEnd"),dataField:"dateEnd",dataType:"date",autoWidth:!1,editor:i._getColumnEditorSetup("dateEnd",e),formatFunction:e=>{e.value=i._formatDate(e.data.dateEnd)}},{label:i.localize("duration"),dataField:"duration",dataType:"number",autoWidth:!1,width:"15%",allowEdit:!1}]}}return{source:[],columns:[]}}_getColumnEditorSetup(e,t){const i=this;switch(e){case"dateStart":case"dateEnd":return{template:'<smart-date-time-picker drop-down-append-to="body" wait></smart-date-time-picker>',onInit:(e,n,a,s)=>{const r=t.task;s||(s=new Date(r.dateStart)),a.rightToLeft=i.rightToLeft,a.animation=i.animation,a.theme=i.theme,a.min=r.dateStart,a.max=r.dateEnd,a.locale=i.locale,a.calendarButton=!0,a.dropDownDisplayMode="auto",a.enableMouseWheelAction=!0,a.formatString="yyyy-MMM-dd HH:mm:ss",a.value=new Date(Math.max(r.dateStart.getTime(),Math.min(r.dateEnd.getTime(),s.getTime()))),a.removeAttribute("wait")},getValue:e=>e.value.toDate()};case"name":return{template:'<smart-drop-down-list virtualized drop-down-append-to="body" wait></smart-drop-down-list>',onInit:(e,n,a,s)=>{a.rightToLeft=i.rightToLeft,a.animation=i.animation,a.theme=i.theme,a.dataSource=t.tasks,a.selectedValues=[s],a.removeAttribute("wait")},getValue:e=>e.selectedValues[0]};case"type":return{template:"<smart-input wait></smart-input>",onInit:(e,n,a,s)=>{const r=t.connectionTypes,o=r.find((e=>e.value===s));a.readonly=!0,a.rightToLeft=i.rightToLeft,a.animation=i.animation,a.theme=i.theme,a.dropDownButtonPosition="right",a.dataSource=r,a.value=(o||r[0]).label+"",a.removeAttribute("wait")},getValue:e=>{if(e.selectedValues.length)return e.selectedValues[0];const i=t.connectionTypes.find((t=>t.label===e.value));return i?i.value:void 0}}}}_popupWindowChangeHandler(e){const t=this,i=e.target,n=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0);if(n._target)if(i.classList.contains("smart-gantt-chart-popup-window-tabs")){const a=n.querySelector(".smart-popup-window-button.ok");a&&(a.disabled=!1),t._handleTabsContent(i.getTabs()[e.detail.index],n)}else if(i.classList.contains("smart-gantt-popup-window-table")){const e=i.closest("smart-tab-item").querySelector('.smart-gantt-chart-button[action="delete"]');e&&(e.disabled=0===i.selected.length)}}_popupWindowClickHandler(e){const t=this;let i=(e.originalEvent||e).target;i.shadowRoot&&(i=(e.originalEvent||e).composedPath()[0]);const n=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0),a=n._target;if(i.closest(".smart-popup-window-button.cancel"))return t._popupWindow&&t._popupWindow.confirmPopupWindow&&n!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),n.close(),void delete n._target;if(i.closest(".smart-popup-window-button.ok")){if(n===t.$.connectionPopupWindow&&"number"==typeof a.type)t._removeConnection(a.startIndex+"-"+a.endIndex+"-"+a.type);else if(n===t.$.confirmPopupWindow){const e=a;void 0!==e.$._resourceId?t._removeResource(e):t._removeTask(e),n.close(),t.$.taskPopupWindow&&t.$.taskPopupWindow.close(),delete n._target}else{const e=n.shadowRoot||n,i=e.querySelectorAll(".smart-gantt-chart-popup-window-editor"),s=a;let r={};for(let e=0;e<i.length;e++){const n=i[e]._label,a=t.taskColumns.find((e=>e.value===n));if(a.customEditor&&a.getCustomEditorValue)r[n]=a.getCustomEditorValue(i[e]);else{const t=i[e].lastElementChild;let a;if(!t)continue;if(t.classList.contains("smart-hidden")){r[n]=void 0;continue}a=Smart.DateTimePicker&&t instanceof Smart.DateTimePicker?t.value.toDate?t.value.toDate():t.value:t instanceof HTMLInputElement&&"datetime-local"===t.type?new Date(t.value):Smart.DropDownList&&t instanceof Smart.DropDownList?t.selectedValues.slice(0):t.hasAttribute("list")?t.value.split(",").map((e=>e.trim())):t.value,a instanceof Date&&isNaN(a.getTime())&&(a=void 0),null!=a&&(r[n]=a)}}if(void 0!==s.$._resourceId)t._updateResource(s,r);else{const i=r.dateStart?r.dateStart:void 0,n=r.dateEnd?r.dateEnd:void 0;if((i&&i.getTime&&i.getTime()!==s.dateStart.getTime()||n&&n.getTime&&n.getTime()!==s.dateEnd.getTime())&&(r.duration=void 0),t._isPopupWindowTableModified){const i=e.querySelectorAll(".smart-gantt-popup-window-table");for(let e=0,n=i.length;e<n;e+=1){const n=i[e];n.closest('.smart-tab-item[value="dependency"]')?t._updateTaskDependencies(n,s):n.closest('.smart-tab-item[value="segments"]')&&t._updateTaskSegments(n,s)}}t._updateTask(s,r)}}return t._popupWindow&&t._popupWindow.confirmPopupWindow&&n!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),n.close(),void delete n._target}if(i.closest(".smart-popup-window-button.delete"))return void t._openPopupWindow(n._target,!0);if(i.closest(".smart-popup-window-editor-toggle")){const e=i.closest('.smart-gantt-chart-popup-window-editor[value="deadline"]'),n=e?e.lastElementChild:void 0;if(n){const e=n.classList.contains("smart-hidden")?"remove":"add";n.classList[e]("smart-hidden"),i.textContent=t.localize(e)}return}const s=i.closest(".smart-gantt-chart-button");if(s){const e=i.closest("smart-tab-item"),r=e.querySelector(".smart-gantt-popup-window-table");if(!r)return;const o=s.getAttribute("action"),l=e.getAttribute("value"),c=a;switch(o){case"add":{let e;e="segments"===l?{label:`${t.localize("segment")} ${r.dataSource.length+1}`,dateStart:new Date(c.dateStart),dateEnd:new Date(c.dateEnd),duration:parseFloat((c.duration||0).toFixed(2))}:{id:"",name:"",type:0,lag:0},r.addRow(e),r.beginEdit(r.rows.length-1),t._isPopupWindowTableModified=!0;break}case"delete":{const e=r.selected;r.beginUpdate();for(let t=0,i=e.length;t<i;t+=1)r.removeRow(e[t]);r.endUpdate(),t._isPopupWindowTableModified=!0;break}}t._applyTableValidation(e,r,n)}}_updateTaskDependencies(e,t){const i=this,n=i._tasks.indexOf(t),a=i._getTaskConnections(t).connectedTasks,s=e.rows;for(let e=0,t=a.length;e<t;e+=1){const t=a[e];i._removeConnection(`${t.startIndex}-${t.endIndex}-${t.type}`)}for(let e=0,t=s.length;e<t;e+=1){const t=s[e].data,a=t.name,r=t.type;if(!i._getValidConnectionId(a,n,r,"_"))continue;const o=parseInt(t.lag);i._connectTask([a,n,r,isNaN(o)?0:o])}i._recycleConnections()}_updateTaskSegments(e,t){const i=e.rows;let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e].data,a=t.label,s=new Date(t.dateStart),r=new Date(t.dateEnd);isNaN(s)||isNaN(r)||n.push({label:"string"==typeof a?a:"",dateStart:s,dateEnd:r})}t.segments=n,this._validateTaskSegments(t)}_createTasks(e,t){const i=this,n={},a=[];e||(e=i.dataSource),i.dataSource instanceof Smart.DataAdapter&&(e=i._parseAdapterData(i.dataSource.toArray())),t||i.clearTasks();let s=[];if(function e(r,o){let l=[];if(!r||0===r.length)return[];for(let c=0;c<r.length;c++){let d,m=r[c];if("object"!=typeof m)continue;if(m=i._validateTaskProperties(m,o),!m)continue;const u=m.tasks,h=m.id;m.$.project=o,m.$.id=o?o.$.id+"."+c:c+"","string"!=typeof h&&"number"!=typeof h||(n[h]?a.push(h):n[h]=1),u instanceof Array&&u.length>0&&(m.synchronized&&(m.dateStart=m.minDateStart=m.maxDateStart=void 0,m.dateEnd=m.minDateEnd=m.maxDateEnd=void 0),m.type="project",d=e(u,m),d.length&&(m.hidden=!d.some((e=>!e.hidden)),m.hidden?d.forEach((e=>e.hidden=m.hidden)):i._synchronizeProjectVisibility(o,m))),(!m.type||["project","task","milestone"].indexOf(m.type)<0)&&(m.type="task"),o&&"project"===m.type&&d&&d.length>0?(l.push(m),l=l.concat(d)):(o||((t&&"project"===m.type&&m.synchronized||m.dateStart&&m.dateEnd&&!isNaN(m.dateStart.getTime())&&!isNaN(m.dateEnd.getTime()))&&s.push(m),d&&(s=s.concat(d))),l.push(m))}return o&&i._synchronizeProjectDates(o,l),l}(e),t)return s.slice(0);a.length&&console.warn(i.localize("duplicateIds",{elementType:i.nodeName.toLowerCase(),duplicates:a.toString()})),i._tasks=s.slice(0),i._handleResources()}_createTimeline(){const e=this;e._tasks&&0!==e._tasks.length?(delete e.__tasks,e._createConnections(),e._autoSchedule(),e._createTimelineCells(),e._insertTimelineTasks(),e.$.taskSplitter.refresh()):e._clearTasks()}_createConnections(){const e=this,t=e._tasks;e._connections=[];for(let i=0,n=t.length;i<n;i+=1)t[i].connections&&e._handleTaskConnections(i)}_createTooltip(){const e=this,t=e.tooltip;let i=e.$.tooltip;if(t.enabled)return i||(e.$.tooltip=i=document.createElement("smart-tooltip"),i.classList.add("smart-gantt-chart-tooltip"),i.setAttribute("smart-id","tooltip")),e.$tooltip||e._handleTooltipEvents(!0),i.rightToLeft=e.rightToLeft,i.theme=e.theme,i.openMode="manual",i.arrow=t.arrow,i.delay=t.delay,i.parentElement||e.$.container.appendChild(i),i;i&&(i.close(),i.remove())}_handleTooltipEvents(e){const t=this,i=t.$.tooltip;if(!i)return;let n=t.$tooltip;e?(n=t.$tooltip=Smart.Utilities.Extend(i),n.listen("close",t._tooltipVisibilityHandler.bind(t)),n.listen("closing",t._tooltipVisibilityHandler.bind(t)),n.listen("open",t._tooltipVisibilityHandler.bind(t)),n.listen("opening",t._tooltipVisibilityHandler.bind(t))):n&&(n.unlisten("close"),n.unlisten("closing"),n.unlisten("open"),n.unlisten("opening"),delete t.$tooltip)}_toggleTooltip(e){const t=this;if(t._dragDetails||!t.tooltip.enabled||!t.$.container.contains(e.target))return void t._closeTooltip();const i=t.getRootNode(),n={"smart-task-segment":null,"smart-timeline-task":null,"smart-gantt-chart-task-indicator":null,"smart-resource-timeline-view-cell":null,"smart-task-connection":null},a=(i.host?i.host.shadowRoot:i).elementsFromPoint(e.clientX,e.clientY);let s;for(let e=0,t=a.length;e<t;e+=1){const t=a[e],i=t.classList;if(i.contains("smart-task-container"))n["smart-timeline-task"]=t.closest(".smart-timeline-task");else for(let e in n)i.contains(e)&&(n[e]=t)}if(n["smart-task-segment"]){const e=n["smart-timeline-task"],t=e?e._cellObj.task:void 0;s=t&&t.segments&&t.segments.length?n["smart-task-segment"]:e}else if(n["smart-gantt-chart-task-indicator"])s=n["smart-gantt-chart-task-indicator"];else for(let e in n)if(n[e]){s=n[e];break}s?t._openTooltip(s,e):t._closeTooltip()}_getConnectionTypeName(e){const t=this;switch(e){case 0:return t.localize("startToStart");case 1:return t.localize("endToStart");case 2:return t.localize("endToEnd");case 3:return t.localize("startToEnd");default:return""}}_getSegmentTask(e){const t=this._tasks;for(let i=0,n=t.length;i<n;i+=1){const n=t[i];if(Array.isArray(n.segments)&&n.segments.indexOf(e)>-1)return n}}_getTooltipContent(e){const t=this;if(!e)return;const i=e.classList;let n,a;if(i.contains("smart-task-segment")){if(a=e._segmentObj,a){let e=a.label;if(void 0===e){const i=t._getSegmentTask(a);i&&(e=i.label)}n=`<label><b>${t.localize("segment")}</b>: ${e||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(a.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(a.dateEnd)||""}</label>`}}else if(i.contains("smart-timeline-task"))a=e._cellObj.task,a&&!a.segments&&(n=`<label><b>${t.localize("task")}</b>: ${a.label||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(a.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(a.dateEnd)||""}</label>`);else if(i.contains("smart-gantt-chart-task-indicator"))a=e._indicatorObj,a&&(n=a.label||"");else if(i.contains("smart-resource-timeline-view-cell")){if(!e.hasAttribute("load"))return;const i=e.closest(".smart-timeline-cell");if((e=e.closest(".smart-timeline-row"))&&e._cellObj&&(a=e._cellObj.resource),a){const s=t._getResourceTasks(a),r="hours"===t.resourceTimelineView?"h":"",o=t._tasks,l=t.$.resourceTimelineViewCells.children,c=Array.from(e.children).findIndex((e=>e===i));n=`<label><b>${t.localize("resource")}</b>: ${a.label||""}</label>\n <label><b>${t.localize("assignments")}</b>:</label>`;for(let e=0,i=s.length;e<i;e+=1){const i=s[e],d=o.indexOf(i),m=t._getResourceCellCapacity({cellDateRange:t._getCellDateRange(l[c]),cellTaskIndexAssigned:[d],index:c,resource:a,task:i,cellIndex:c});void 0!==m&&(n+=`<label>${t.localize("task")} #${d}: (${parseFloat(m.capacity.toFixed(1))}${r}) ${i.label||""}</label>`)}}}else i.contains("smart-task-connection")&&(a=t.getConnectionDetails(e.getAttribute("connection-id")),void 0!==a&&(n=`<label><b>${t.localize("startTask")}</b>: ${a.startTask.label||""}</label>\n <label><b>${t.localize("endTask")}</b>: ${a.endTask.label||""}</label>\n <label><b>${t.localize("type")}</b>: ${t._getConnectionTypeName(a.type)||""}</label>`,a.lag&&(n+=`<label><b>${t.localize("lag")}</b>: ${parseFloat(a.lag.toFixed(1))}</label>`)));return a?a.tooltip?a.tooltip+"":n||"":void 0}_openTooltip(e,t,i){const n=this,a=n.tooltip;if(i="string"==typeof i?i:n._getTooltipContent(e),!(a.enabled&&i&&e&&e.nodeName))return void n._closeTooltip();const s=n.$.tooltip||n._createTooltip();let r,o;if(i&&s.value!==i&&(s.value=i),s.selector=e,t&&t.pageX){const i=document.body.getBoundingClientRect(),n=e.getBoundingClientRect(),l=a,c=l.offset[0]||0,d=l.offset[1]||0,m=s.offsetWidth,u=s.offsetHeight;let h="bottom";"absolute"!==s.position&&(s.position="absolute",s.offset=[]),o=Math.min(i.left+i.width-m,t.pageX-m/2-c),r=n.top-u-d,r<i.top&&(r=n.bottom+d,h="top"),o<i.left&&(o=i.left+c,h="left"),h!==s.arrowDirection&&(s.arrowDirection=h),s.style.left=o+"px",s.style.top=r+"px"}else"auto"!==s.position&&(s.position="auto",s.offset=a.offset);s.visible||(n.getShadowRootOrBody().appendChild(s),s.open())}_closeTooltip(){const e=this.$.tooltip;e&&e.visible&&e.close()}_tooltipVisibilityHandler(e){const t=this,i=e.type,n=t.$.tooltip;e.target===n&&(e.stopPropagation(),t._fireTooltipVisibilityEvent(e)?e.preventDefault():"opening"===i?n.classList.remove("smart-visibility-hidden"):"closing"===i&&(n.hasAnimation?n.addEventListener("transitionend",(()=>{n.visible||(n.classList.add("smart-visibility-hidden"),n.style.top=n.style.left=0,t.$.container.appendChild(n))}),{once:!0}):t.$.container.appendChild(n)))}_fireTooltipVisibilityEvent(e){const t=this,i=e.type,n=t.$.tooltip,a=e.detail.owner;let s={target:n,owner:a};if(a)if(a.classList.contains("smart-task-connection")){s.type="connection";const e=t.getConnectionDetails(a.getAttribute("connection-id"));e&&(s.item=e)}else if(a.classList.contains("smart-gantt-chart-task-indicator"))s.type="indicator",a._indicatorObj&&(s.item=t._cloneObject(a._indicatorObj));else if(a.classList.contains("smart-task-segment"))s.type="segment",a._segmentObj&&(s.item=t._cloneObject(a._segmentObj));else if(a.classList.contains("smart-timeline-task"))s.type="task",a._cellObj&&a._cellObj.task&&(s.item=t._cloneObject(a._cellObj.task));else if(a.classList.contains("smart-resource-timeline-view-cell")){s.type="resource";const e=a.closest(".smart-timeline-row");e._cellObj&&(s.item=t._cloneObject(e._cellObj.resource))}let r=t.getAttribute("aria-owns")||"";switch(i){case"open":t.setAttribute("aria-owns",(r+" "+n.id).trim()),t.$.fireEvent(i,s);break;case"close":r=r.replace(n.id,"").trim(),r?t.setAttribute("aria-owns",r):t.removeAttribute("aria-owns"),t.$.fireEvent(i,s);break;case"closing":case"opening":if(t.$.fireEvent(i,s).defaultPrevented)return!0}}_parseAdapterData(e){let t={};for(let i=0,n=e.length;i<n;i+=1){const n=e[i],a=Object.assign({},n),s=n.parent,r=n.$.id;if(s&&s!==n){const e=s.$.id;t[e]||(t[e]=Object.assign({},s));const i=t[e];i.tasks||(i.tasks=[]),i.tasks.push(a)}else t[r]=a;delete a.parent,delete a.children,delete a.$}return Object.values(t)}_handleTaskConnections(e){const t=this,i=t._tasks;let n;if("number"==typeof e&&(n=e,e=i[e]),!e)return;void 0===n&&(n=i.indexOf(e));const a=e.connections,s=i.length;for(let e=0;e<a.length;e++){const i=a[e],r=t._getTaskIndexById(i.target);null==r||isNaN(r)||r<0||r>=s||r===n||t._connectTask([n,r,i.type,i.lag])}delete e.connections}_insertTasks(e,t,i){const n=this,a=n._tasks;if(t){const s=n._getProjectTasks(t,!0);if(s.length){const t=s[s.length-1];let r,o;"number"==typeof i&&i<s.length?r=s[i=Math.max(0,i)]:(r=t,o=!0);const l=n._getProjectTasks(r);i=o&&l.length?a.indexOf(l[l.length-1]):a.indexOf(r),a.splice.apply(a,[i+(o?1:0),0].concat(e))}else a.splice.apply(a,[a.indexOf(t)+1,0].concat(e))}else"number"==typeof i?(i+="",(i=a.findIndex((e=>e.$.id===i)))<0&&(i=a.length)):i=a.length,a.splice.apply(a,[i,0].concat(e))}_insertTimelineTasks(){const e=this,t=e._timelineVCells;t&&t.length?(e._recycleTimelineTasks(),e._refresh()):e._resetTimeline()}_recycleTimelineTasks(e){const t=this,i=t.$.taskIndicatorsContainer,n=i.children,a=t.$.taskTimelineCellsContainer.childElementCount,s=t._timelineVCells;for(;i.childElementCount>a;)i.firstElementChild.remove();if(t._closeTooltip(),!s||!s.length)return;const r=s.indexOf(t._getFirstContentCellInView()),o=t._getSelection("task",t.selectedTaskIds),l={timelineStart:t.dateStart.getTime(),timelineEnd:t.dateEnd.getTime()};for(let i=0,c=a;i<c;i++){const a=n[i],c=s[r+i];if(!c){a&&a.remove();continue}const d=c.task;t._snapToNearestDates(d),t._recycleTaskBars(c,i,o),t._setTimelineTaskBar(c,i),t._setTimelineTaskBaseline(c,i),t._setTaskBarProgress(d,i),t._setTaskBarLabel(d,i),t._setTaskIndicators(c,i,l),t._setTaskDeadline(c,i,l),e&&t._refreshTableColumnsData(d)}t._recycleConnections()}_ensureVisible(e,t="task"){const i=this;if(null==e)return;let n,a="task"===t?i._timelineVCells:i._timelineResourceVCells;n||(n=i.$[`${t}Table`]);const s=a.find((i=>i[t]===e));if(!s)return;let r,o;if("task"===t){const t=i._getTimelineTaskCellByDate(e.dateStart);if(r=i.$.taskTimelineContainer.offsetHeight,o=i,t){const e=i.scrollLeft,n=i.$.taskTimelineContainer.offsetWidth;t.left+t.width>e+n?i.scrollLeft=Math.max(0,t.left+t.width-n):t.left<e&&(i.scrollLeft=Math.max(0,t.left))}}else r=i.$.resourceTimelineContent.offsetHeight,o=i._resourceScrollView;const l=o.scrollTop;s.top+s.height>l+r?o.scrollTop=Math.max(0,s.top+s.height-r):s.top<l&&(o.scrollTop=Math.max(0,s.top))}_isTaskExpanded(e,t){if(!e||!e.$)return;let i,n=e.$[this.groupByResources?"group":"project"];if(!n)return!0;for(;n;){if(i=n.expanded,!i)return!1;if(n=n.$.project,n===t)break}return i}_getItemByTreeIndex(e,t,i){if(!t)return;const n=t.split(".");let a=this[`_${e}s`].filter((e=>!e.$.project))[t.split(".")[0]];if(a){if(!a[`${e}s`]||!a[`${e}s`].length)return i?null:a;for(let t=1;t<n.length;t++){const s=a[`${e}s`].filter((e=>!e.hidden&&e.$.project===a))[n[t]];if(!s||i&&"project"!==s.type)break;if(a=s,"project"!==a.type)break}return i?a&&"project"===a.type?a:void 0:a}}_getItemByTableId(e,t,i){if(null==t)return;const n=this[`_${e}s`];let a;for(let e=0,i=n.length;e<i;e+=1){const i=n[e];if(i.$.id===t){a=i;break}}return a?i?"project"===a.type?a:void 0:a:void 0}_tableChangeHandler(e){const t=e.target;(t.classList.contains("smart-task-table")||t.classList.contains("smart-resource-table"))&&(e.stopPropagation(),this._handleTableSelection(t===this.$.taskTable?"task":"resource",t.selected))}_tableColumnResizeHandler(e){const t=e.target,i=e.detail,n=t.classList.contains("smart-task-table");if(!n&&!t.classList.contains("smart-resource-table"))return;e.stopPropagation();const a=i.dataField,s=this[(n?"task":"resource")+"Columns"].find((e=>e.value===a));s&&(s.size=i.width),this.$.fireEvent("columnResize",i)}_tableSortFilterHandler(e){const t=this,i=e.target;let n;i.classList.contains("smart-task-table")?(n="task",t._createTimelineContent(),t._recycleTimelineTasks()):i.classList.contains("smart-resource-table")&&(n="resource",t._createResourceTimelineContent(),t._recycleResourceContent()),n&&(t._refresh(),e.stopPropagation(),t.$.fireEvent(e.type,Object.assign({type:n},e.detail)))}_taskTableExpandHandler(e){const t=this,i=e.target;if(!i.classList.contains("smart-task-table")&&!i.classList.contains("smart-resource-table"))return;const n=i===t.$.taskTable?"task":"resource";if(e.stopPropagation(),!t[`${n}s`]||!t[`${n}s`].length)return;const a=e.detail.record.itemId,s=t._getItemByTableId(n,a,!0);s&&(delete t._hoveredItem,s.expanded="collapse"!==e.type,t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks(),t.$.fireEvent(e.type,{item:t._cloneObject(s),id:s.id||s.$.id,index:t._tasks.indexOf(s),label:s.label,value:s.value}))}_taskTableKeyDownHandler(e){const t=this,i=e.key;if(t.keyboardNavigation&&!t.disabled&&!t.readonly)switch(i){case"Delete":case"Enter":{const e=t.$.taskTable._focusedCell;if(!e||!e.closest)return;const n=e.closest("tbody tr");if(!n)return;const a=t._getVCellById("task",n.getAttribute("row-id"));a&&t._openPopupWindow(a.task,"Delete"===i);break}}}_getVCellById(e="task",t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let n=0,a=i.length;n<a;n+=1){const a=i[n][e];if(a.$&&a.$.id===t)return i[n]}}_getGroupVCellByPath(e,t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let n=0,a=i.length;n<a;n+=1){const a=i[n][e];if(a.$&&a.$.id===t)return i[n]}}_taskTableGroupEventHandler(e){const t=this,i=e.detail.action,n=e.target;if(["collapse","expand"].indexOf(i)<0||!n.classList.contains("smart-task-table")&&!n.classList.contains("smart-resource-table"))return;const a=n===t.$.taskTable?"task":"resource",s=t.$.taskTable._getGroupByIndex(e.detail.path),r=t._getGroupVCellByPath(a,s.$.id);if(!r||!r[a].isGroup)return;const o=r[a];e.stopPropagation(),o.expanded="collapse"!==i,t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks(),t.$.fireEvent(i,{isGroup:!0,item:t._cloneObject(o),id:o.$.id,label:o.label})}_resetTimeline(){const e=this,t=e.$.taskTimelineContainer;if(e.$.taskTimelineCellsContainer.innerHTML="",e.$.timelineTasksContainer.innerHTML="",e.$.timelineConnectionsContainer.innerHTML="",e.$.timelineContent.style.height="",e.$.taskIndicatorsContainer.innerHTML="",e.rightToLeft&&e.scrollLeft!==t.scrollLeft){const i=e._getScrollLeft(e.scrollLeft);t.scrollLeft=i,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=i)}e._closeTooltip(),e.$.container.style.removeProperty("--smart-gantt-chart-task-timeline-content-height")}_refreshTimeline(e){const t=this;e||(e=t.view);const i=t._getDateFromCell(t.scrollLeft,t._getFirstCellObjInView(),e),n=t.scrollTop;t.scrollLeft=0,t.scrollTop=0,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&t._resourceScrollView&&(t._resourceScrollView.scrollLeft=0),t._resetTimeline(),t._createTimelineCells(),t._recycleTimelineTasks(!0),t.$.mainSplitter.contains(t.$.resourceSplitter)&&t._refreshResourceTimeline(),t._refresh(),t._scrollTo(i),t.scrollTop=n}_scrollTo(e,t){const i=this,n=i._timelineCells;let a;if(void 0!==e&&!isNaN(new Date(e).getTime()))for(let s=0;s<n.length;s++){const r=n[s],o=r.date;switch(i.view){case"year":if(o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()){if(t){a=r.left;break}let i=new Date(e);i.setMonth(e.getMonth()+1),i.setDate(0),i=i.getDate(),a=r.left+(e.getDate()-1)/i*r.width}break;case"month":{let i=new Date(o),n=new Date(o);i.setDate(i.getDate()-i.getDay()),n.setDate(n.getDate()+(6-n.getDay())+1),n.setMilliseconds(n.getMilliseconds()-1),e.getTime()>=i.getTime()&&e.getTime()<=n.getTime()&&(a=r.left+(t||t?0:e.getDay()/7*r.width));break}case"week":o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate()&&(a=r.left+parseFloat(e.getHours()+"."+e.getMinutes()+e.getSeconds())/24*r.width);break;case"day":o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate()&&o.getHours()===e.getHours()&&(a=r.left+(t?0:parseFloat(e.getMinutes()+e.getSeconds())/60*r.width))}if(void 0!==a)return i.scrollLeft=a,void(i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=i.$.resourceTimelineContent.scrollLeft=a,i._refreshResourceTimeline()))}}_updateConnection(e,t){const i=this,n=i._tasks,[a,s,r,o]=e,l=n[a],c=n[s];if(!l||!c||"number"!=typeof r)return;let d=i._connections,m=-1;d||(d=i._connections=[]);for(let e=0,t=d.length;e<t;e+=1){const t=d[e],i=t.startIndex,n=t.endIndex;if(i===a&&n===s||i===s&&n===a){m=e;break}}if(!t){if(m<0)d.push({startTask:n[a],endTask:n[s],startIndex:a,endIndex:s,type:r,lag:o});else{const e=d[m];if(!e)return;if(e.startIndex=a,e.startTask=n[a],e.endIndex=s,e.endTask=n[s],e.type=r,o!==e.lag){const t=parseInt(o);isNaN(t)||(e.lag=t)}}return!0}m>-1&&d.splice(m,1)}_createTimelineCells(){const e=this,t=e._tasks,i=new Date(e.properties.dateStart.value),n=new Date(e.properties.dateEnd.value);let a,s;if(isNaN(i.getTime())||(a=i),isNaN(n.getTime())||(s=n),t.length>0){let e=t[0].dateStart,i=t[0].dateEnd;for(let n=0;n<t.length;n++)t[n].dateStart&&t[n].dateEnd&&(e||(e=t[n].dateStart),i||(i=t[n].dateEnd),e.getTime()>t[n].dateStart.getTime()&&(e=t[n].dateStart),i.getTime()<t[n].dateEnd.getTime()&&(i=t[n].dateEnd));(!a||a.getTime()>e.getTime())&&(a=e),(!s||s.getTime()<i.getTime())&&(s=i)}a&&s&&(a=e._minMaxDateValidator(a),s=e._minMaxDateValidator(s),e._createTimelineHeader(a,e._getCellsCount(a,s)),e._createTimelineContent(),e._createDateMarkers(),e._refresh())}_getCellsCount(e,t,i){let n,a,s,r,o,l,c=new Date(e),d=new Date(t);const m=t.getFullYear()-e.getFullYear();if(a=n=Math.round(m)+1,"year"===i)return{year:a};if(c.setHours(c.getHours(),0,0,0),d.setHours(d.getHours(),0,0,0),l=Math.floor((t.getTime()-e.getTime())/36e5),l>0){let e=new Date(c);if(l=1,c.getFullYear()!==d.getFullYear()){let t=new Date(c.getFullYear()+1,0,1,0,0,0,0);for(;e.getTime()!==t.getTime();){const t=e.getTime();e.setHours(e.getHours()+1),e.getTime()===t&&e.setHours(e.getHours()+2),l++}const i=d.getFullYear()-t.getFullYear();for(let t=0;t<i;t++){const t=e.getFullYear();l+=24*((t%100==0?t%400==0:t%4==0)?366:365)-1,e.setFullYear(t+1)}}for(;e.getTime()<d.getTime();){const t=e.getTime();e.setHours(e.getHours()+1),e.getTime()===t&&e.setHours(e.getHours()+2),l++}}if("hour"===i)return{hour:l};if(c.setHours(0,0,0,0),d.setHours(23,59,59,999),o=n=Math.round((d.getTime()-c.getTime())/864e5),"day"===i)return{day:o};if(c.setDate(c.getDate()-c.getDay()),d.setDate(d.getDate()+6-d.getDay()),r=n=Math.round((d.getTime()-c.getTime())/6048e5),"week"===i)return{week:r};if("month"===this.view&&(0!==e.getDay()&&(e=new Date(e.setDate(e.getDate()-e.getDay()))),6!==t.getDay()&&(t=new Date(t.setDate(t.getDate()+6-t.getDay())))),e.getFullYear()!==t.getFullYear()){n=12-e.getMonth();const i=t.getFullYear();for(let a=e.getFullYear()+1;a<=i;a++)n+=a===t.getFullYear()?t.getMonth()+1:12}else n=t.getMonth()-e.getMonth()+1;return s=Math.ceil(n),"months"===i?{month:s}:{year:a,month:s,week:r,day:o,hour:l}}_recycleTaskBars(e,t,i){const n=this,a=e.task,s=n.$.timelineTasksContainer,r=n.$.taskTimelineCellsContainer,o="project"===a.type&&a.synchronized,l=a.type,c=a.$.id,d=s.children[t],m=r.children[t];m._cellObj=e,m.setAttribute("row-id",c),m.style.top=e.top+"px",m.removeAttribute("hover"),d.removeAttribute("hover"),d.classList.contains(l)||(d.innerHTML="milestone"===l?'<div class="smart-task-container" aria-hidden="true">\n <div class="smart-task-connection-point start"></div>\n <div class="smart-task-segments"></div>\n <div class="smart-task-connection-point end"></div>\n </div>':'<div class="smart-task-container" aria-hidden="true">\n <div class="smart-task-connection-point start"></div>\n <div class="smart-task-segments"></div>\n <div class="smart-timeline-task-progress-thumb"></div>\n <div class="smart-task-connection-point end"></div>\n </div>'),n._recycleSegments(a,d),delete d._cellStart,delete d._cellEnd,a.disableDrag||o&&!a.dragProject?d.setAttribute("disable-drag",""):d.removeAttribute("disable-drag"),a.disableResize||o?d.setAttribute("disable-resize",""):d.removeAttribute("disable-resize"),a.isGroup?d.setAttribute("resource-group",""):d.removeAttribute("resource-group"),i&&(i.indexOf(c)>-1?(d.setAttribute("selected",""),m.setAttribute("selected","")):(d.removeAttribute("selected"),m.removeAttribute("selected"))),a.id?d.id=a.id:d.id="ganttTask"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),d._cellObj=e,d.className="smart-timeline-task "+l,d.setAttribute("row-id",c),a.class&&d.classList.add(a.class),d.setAttribute("aria-label",a.label+" Start date: "+n._toISODate(a.dateStart)+", End date: "+n._toISODate(a.dateEnd)),d.setAttribute("aria-selected","false")}_toISODate(e){const t=e.getFullYear(),i=e.getMonth()+1,n=e.getDate();return t+"-"+(i<10?"0"+i:i)+"-"+(n<10?"0"+n:n)}_recycleSegments(e,t){const i=this,n=t.querySelector(".smart-task-segments");let a,s=e.segments;if(!n)return;for(Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);n.childElementCount>s.length;)n.children[0].remove();const r=document.createDocumentFragment(),o=n.children,l="milestone"===e.type?'<div class="smart-timeline-task-fill"></div>':'<div class="smart-timeline-task-fill">\n <div class="smart-timeline-task-progress"></div>\n </div>\n <div class="smart-timeline-task-label"></div>';for(let t=0,n=s.length;t<n;t+=1){const n=s[t];let c=o[t];n.dateStart=new Date(Math.max(e.dateStart.getTime(),n.dateStart.getTime())),n.dateEnd=new Date(Math.min(e.dateEnd.getTime(),n.dateEnd.getTime())),c?(delete c._cellStart,delete c._cellEnd):(c=document.createElement("div"),c.classList.add("smart-task-segment"),c.innerHTML=l,r.appendChild(c)),n.disableDrag?c.setAttribute("disable-drag",""):c.removeAttribute("disable-drag"),n.disableResize?c.setAttribute("disable-resize",""):c.removeAttribute("disable-resize"),c._segmentObj=n,c.setAttribute("aria-label",(n.label||"")+" Start date: "+i._toISODate(n.dateStart)+", End date: "+i._toISODate(n.dateEnd)),a=c}r.childElementCount&&n.appendChild(r),i._setTaskBarDeadline(e,a)}_createCells(e){let t,i=document.createDocumentFragment();for(let n=0;n<e;n++)t=document.createElement("div"),t.classList.add("smart-timeline-view-cell"),t.setAttribute("role","columnheader"),i.appendChild(t);return i}_getTimelineVisibleCellsCount(){const e=this,t=e._timelineCells;if(!t)return;const i=e._getFirstCellObjInView(),n=1-(i.left+i.width-e.scrollLeft)/t[0].width;return Math.min(t.length,Math.ceil(parseFloat((e.$.timeline.offsetWidth/i.width).toFixed(2))+n))}_getHeaderVisibleCellsCount(){const e=this;if(!e._timelineHeaderCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,n=e._timelineHeaderCells;let a=0;for(let e=0;e<n.length;e++){const s=n[e];s.left+s.width>t&&s.left<i+t&&a++}return a}_refreshHeaderDate(e){const t=this,i=t._getCellsViewType(),n=t.$.timelineHeader.scrollLeft,a=t.$.timelineViewCells.children,s=t._timelineCells;let r;t._refreshHeaderDetailsDate(e);for(let e=0;e<s.length;e++){const t=s[e];if(n<=t.left+t.width){r=e;break}}for(let n=0;n<a.length;n++){const o=a[n],l=s[r];if(!l)break;r++;const c=l.date;o.innerHTML=`<div>${t._getDateString(new Date(c),i)}</div>`,e||(o._date=new Date(c),o.style.width=l.width+"px",o.style[t.rightToLeft?"right":"left"]=l.left+"px",l.weekend?o.setAttribute("weekend",""):o.removeAttribute("weekend"),l.nonworking?o.setAttribute("nonworking",""):o.removeAttribute("nonworking"))}}_getDateString(e,t,i){const n=this,a=["2-digit","numeric"][n.dayFormat]||"numeric";let s;return"year"===t?s=e.toLocaleDateString(n.locale,{year:n.yearFormat}):"month"===t?s=e.toLocaleDateString(n.locale,{month:n.monthFormat}):"week"===t?s="numeric"!==n.weekFormat&&i?e.toLocaleDateString(n.locale,{day:a,month:n.monthFormat,year:n.yearFormat}):n._getWeekNumber(e):"day"===t?s=e.toLocaleDateString(n.locale,"day"===n.view?{day:a,month:n.monthFormat,year:n.yearFormat}:["long","short","narrow"].indexOf(n.dayFormat)>-1?{weekday:n.dayFormat}:{day:n.dayFormat}):"hour"===t&&(s="default"===n.hourFormat?e.toLocaleTimeString(n.locale,{hour12:!1}):e.toLocaleDateString(n.locale,{hour:n.hourFormat})),n.timelineHeaderFormatFunction?n.timelineHeaderFormatFunction(new Date(e),t,i,s):s}_refreshHeaderDetailsDate(e){const t=this,i=t.view,n=t.scrollLeft,a=t.$.timelineViewDetails.children,s=t._timelineHeaderCells;let r;for(let e=0;e<s.length;e++){const t=s[e];if(n<=t.left+t.width){r=e;break}}for(let n=0;n<a.length;n++){const o=s[r],l=a[n];let c=new Date(o.date);"week"===t.view&&c.setDate(c.getDate()-c.getDay()),r++,c=new Date(Math.max(o.date.getTime(),c.getTime())),l.innerHTML=`<div>${t._getDateString(c,i,!0)}</div>`,e||(l._date=c,l.style[t.rightToLeft?"right":"left"]=o.left+"px",l.style.width=o.width+"px")}}_getWeekNumber(e){let t,i=new Date(e.getFullYear(),0,1),n=Math.round((e.getTime()-i.getTime()-6e4*(e.getTimezoneOffset()-i.getTimezoneOffset()))/864e5)+1,a=i.getDay();return a=a>=0?a:a+7,a<4?(t=Math.floor((n+a-1)/7)+1,t>52&&(i=new Date(e.getFullYear()+1,0,1),a=i.getDay(),a=a>=0?a:a+7,t=a<4?1:53)):t=Math.round((n+a-1)/7),t}_convertDuration(e,t){if(!e)return 0;let i;switch(this.durationUnit){case"day":i=864e5;break;case"hour":i=36e5;break;case"minute":i=6e4;break;case"second":i=1e3;break;case"milisecond":return e;case"week":i=6048e5}return Math.max(0,t?e/i:e*i)}_createTimelineHeader(e,t){const i=this,n=i._getCellsViewType();if(!e){const t=i.$.timelineViewCells.children;if(0===t.length)return;e=t[0]._date}if("day"!==i.view&&e.setHours(0,0,0,0),i.$.timelineContent.offsetWidth===i.$.timeline.offsetWidth&&i._timelineCells&&i._timelineCells[0]&&i._timelineCells[0].date.getTime()===e.getTime()&&i._timelineCells.length===t[i._getCellsViewType()])i._refresh();else{if(i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width="",i._createTimelineCellsObj(e,t),i._createTimelineHeaderCellsObj(e,t),i.$.timelineViewDetails.innerHTML="",i.$.timelineViewDetails.appendChild(i._createCells(i._getHeaderVisibleCellsCount())),i.$.timelineViewCells.innerHTML="",i.$.timelineViewCells.appendChild(i._createCells(i._getTimelineVisibleCellsCount())),i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width=Math.max(t[n]*i._timelineCells[0].width,i.$.timeline.parentElement.offsetWidth)+"px",i.scrollLeft){const e=i._getScrollLeft(i.scrollLeft);i.$.timelineHeader.scrollLeft=e,i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=e)}i._refreshHeaderDate(),i._setCurrentTimeIndicators()}}_createTimelineContent(){const e=this,t=e.$.container,i=e.$.timelineContent,n=e._taskDefaultHeight,a=e.$.taskTimelineContainer,s=e.scrollLeft;if(i.style.height="",t.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e._createTimelineVCells(n),i.style.height=e._timelineVCells.length*n+"px",t.style.setProperty("--smart-gantt-chart-task-timeline-content-height",e.$.timeline.offsetHeight+"px"),s||s!==a.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);a.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=t)}e.scrollTop&&(a.scrollTop=e.scrollTop),e._recycleContentCells()}_createDateMarkers(){const e=this,t=e.dateMarkers;let i=[];delete e._markers;for(let n=0,a=t.length;n<a;n+=1){const a=t[n],s=e._dateValidator(void 0,a.date);if(s){const e={date:s},t=a.label,n=a.className;("string"==typeof t||"number"==typeof t&&!isNaN(t))&&(e.label=t),"string"==typeof n&&(e.className=n),i.push(e)}}i.length&&(e._markers=i),e._recycleDateMarkers()}_createTimelineRowCells(e,t){const i=this,n=e.children,a=e.querySelectorAll(".smart-task-bar-limiter"),s=document.createDocumentFragment(),[r,o]=i.rightToLeft?["right","left"]:["left","right"];t||(t=i.$.timelineViewCells.children);for(let e=0,t=a.length;e<t;e+=1)a[e].remove();const l=t.length;for(;e.childElementCount>l;)e.lastElementChild.remove();for(let t=e.childElementCount;t<l;t+=1){const e=document.createElement("div");e.classList.add("smart-timeline-cell"),s.appendChild(e)}s.childElementCount&&e.appendChild(s);for(let e=0;e<l;e+=1){const i=t[e],a=n[e];i.hasAttribute("weekend")?a.setAttribute("weekend",""):a.removeAttribute("weekend"),i.hasAttribute("nonworking")?a.setAttribute("nonworking",""):a.removeAttribute("nonworking"),a.style[o]=i.style[o],a.style[r]=i.style[r],a.style.width=i.style.width}for(let t=0,i=a.length;t<i;t+=1)e.appendChild(a[t])}_recycleTimelineRowCells(){const e=this,t=e.$.timelineViewCells.children,i=e.$.taskTimelineCellsContainer.children;for(let n=0,a=i.length;n<a;n+=1)e._createTimelineRowCells(i[n],t)}_createTimelineVCells(e){const t=this,i=t._tasks,n=t.$.taskTable.rows,a=t.groupByResources;let s=0,r={};t._timelineVCells=[];for(let o=0,l=n.length;o<l;o++){const l=n[o].data;let c=i[l.itemIndex];if(a)if(!c&&l.groupDataField){const e=l.$.id;c={$:{id:e,project:void 0},label:t._formatResourceGroupLabel(l.label),value:l.label,expanded:l.expanded,synchronized:!0,isGroup:!0,type:"project"},r[e]=c}else l.parent?(c.$.group=r[l.parent.$.id],t._synchronizeProjectDates(c.$.group,[c])):delete c.$.group;else delete c.$.group;!c.hidden&&t._isTaskExpanded(c)&&(t._timelineVCells.push({top:s,height:e,task:c}),s=parseFloat((s+e).toFixed(2)))}}_getCellsViewType(){switch(this.view){case"year":return"month";case"month":return"week";case"week":return"day";case"day":return"hour"}}_createTimelineCellsObj(e,t){const i=this,n=i._getCellsViewType();t=t[n];const a=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<a&&(s=a/t),s=parseFloat(s.toFixed(2)),i._timelineCells=[];for(let e=0;e<t;e++){const e={left:r,width:s};if("year"===n)o.setMonth(0),e.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===n)o.setDate(1),e.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===n)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),e.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===n)i.nonworkingDays.indexOf(o.getDay())>-1&&(e.nonworking=!0),o.setHours(0,0,0,0),e.date=new Date(o),o.setDate(o.getDate()+1),e.weekend=0===e.date.getDay()||6===e.date.getDay();else if("hour"===n){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(e.nonworking=!0),o.setHours(o.getHours(),0,0,0),e.date=new Date(o);const t=o.getTime();o.setHours(o.getHours()+1),t===o.getTime()&&o.setHours(o.getHours()+2),e.weekend=0===e.date.getDay()||6===e.date.getDay()}i._timelineCells.push(e),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderCellsObj(e,t){const i=this,n=i.view;let a=0,s=new Date(e);t=t[n],i._timelineHeaderCells=[];for(let e=0;e<t;e++){const t={};switch(t.date=new Date(s),n){case"year":s.setFullYear(s.getFullYear()+1);break;case"month":s.setDate(1),s.setMonth(s.getMonth()+1);break;case"week":s.setDate(s.getDate()+7);break;case"day":s.setDate(s.getDate()+1)}a=i._refreshViewDetailCell(t,a,e),i._timelineHeaderCells.push(t)}}_minMaxDateValidator(e){if(!e||isNaN(e.getTime()))return e;const t=new Date(this.min),i=new Date(this.max);return t&&(e=new Date(Math.max(t.getTime(),e.getTime()))),i&&(e=new Date(Math.min(i.getTime(),e.getTime()))),e}_dateValidator(e,t){const i=this;let n;if(t instanceof Date)return i._minMaxDateValidator(t);if(Smart.Utilities.DateTime&&t instanceof Smart.Utilities.DateTime)return i._minMaxDateValidator(t.toDate());if("string"!=typeof t)return i._minMaxDateValidator(e);{const e=/\d+:\d+:\d+/;if("new Date()"===t.trim()||"new Smart.Utilities.DateTime()"===t.trim())return i._minMaxDateValidator(new Date);if(isNaN(Date.parse(t))){const i=/(\d+[,-.\/]{1}\s*\d+[,-.\/]{1}\s*\d+)/;if(i.test(t)){const a=i.exec(t)[0].replace(/[,-.\/]/g,",").split(",");if(3===a.length){const[i,s]=parseInt(a[0])<parseInt(a[2])?[a[0],a[2]]:[a[2],a[0]];if(n=new Date(parseInt(s),parseInt(a[1])-1,parseInt(i)),e.test(t)){const i=e.exec(t)[0].split(":");n.setHours(i[0]||0,i[1]||0,i[2]||0)}t=n}}}else n=new Date(Date.parse(t)),e.test(t)||n.setHours(0,0,0,0),t=n}return i._minMaxDateValidator(new Date(t))}_currentTimeIndicatorIntervalValidator(e,t){return Math.max(1,t)}_getTaskBarPositionLimits(e,t){const i=this;function n(e){const t=i._getTimelineTaskCellByDate(e);if(t)return t.left+i._getTimelineTaskOffset(t,e)||0}return{min:n(e["min"+t]),max:n(e["max"+t])}}_getTimelineTaskOffset(e,t){if(!e)return;let i,n;switch(this.view){case"year":{const a=t.getHours()/24+t.getMinutes()/1440+t.getSeconds()/86400;i=new Date(e.date.getFullYear(),e.date.getMonth()+1,0),n=(t.getDate()-1+a)/i.getDate()*e.width;break}case"month":n=t.getDay()/7*e.width;break;case"week":n=parseFloat(t.getHours()+t.getMinutes()/60+t.getSeconds()/3600)/24*e.width;break;case"day":n=parseFloat(t.getMinutes()+t.getSeconds()/60)/60*e.width}return n}_getTaskBarSizeLimits(e,t){const i=this,n=i._getTaskBarDateRange(e);let a,s=0,r=i._convertDuration(e._cellObj.task.minDuration)||i._getMinDuration(e,t),o=i._convertDuration(e._cellObj.task.maxDuration);function l(a,s){if(!a)return;let r,o;"left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft?(a*=-1,o=n.dateEnd):o=n.dateStart,s&&Math.abs(r)===Math.abs(a)&&(r=0);let l=i._getTaskWorkingDateEnd({dateStart:o},a);const c=l.getTime()+60*(l.getTimezoneOffset()-o.getTimezoneOffset())*1e3,d=i._getTimelineTaskCellByDate(new Date(c));if(!d)return;const m=i._getTimelineTaskOffset(d,new Date(c));return i.rightToLeft?"left"===t?m-(i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth-d.left):i.$.timelineContent.offsetWidth-e.offsetLeft-d.left-m:"left"===t?e.offsetLeft+e.offsetWidth-d.left-m:d.left-e.offsetLeft+m}if("left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft){const t=e._cellObj.task.maxDateStart,i=e._cellObj.task.minDateStart;i&&(s=60*(i.getTimezoneOffset()-n.dateEnd.getTimezoneOffset())*1e3,a=Math.abs(i.getTime()-n.dateEnd.getTime())+s,o=o?Math.min(a,o):a),t&&(s=60*(t.getTimezoneOffset()-n.dateEnd.getTimezoneOffset())*1e3,a=Math.abs(t.getTime()-n.dateEnd.getTime())+s,r=r?Math.max(a,r):a)}else{const t=e._cellObj.task.maxDateEnd,i=e._cellObj.task.minDateEnd;i&&(s=60*(i.getTimezoneOffset()-n.dateStart.getTimezoneOffset())*1e3,a=Math.abs(i.getTime()-n.dateStart.getTime())+s,r=r?Math.max(a,r):a),t&&(s=60*(t.getTimezoneOffset()-n.dateStart.getTimezoneOffset())*1e3,a=Math.abs(t.getTime()-n.dateStart.getTime())+s,o=o?Math.min(a,o):a)}return o&&(r=Math.min(r,o)),{min:l(r,!0),max:l(o)}}_getMinDuration(e,t){const i=this,n=i._taskBarMinWidth;if(!n||!i._timelineCells||0===i._timelineCells.length)return;const a=e._cellObj.task;let s,r,o=1;r=i.rightToLeft?parseFloat(e.style.right)||i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth:parseFloat(e.style.left)||e.offsetLeft,"left"===t?(s=a.dateEnd,r+=parseFloat(e.style.width)||e.offsetWidth,o=-1):s=a.dateStart;const l=r+o*n;let c;for(let e=0;e<i._timelineCells.length;e++){const t=i._timelineCells[e];if(l<t.left)break;c=t}const d=i._getDateFromCell(l,c);return d?Math.abs(s.getTime()-d.getTime()):void 0}_createDelimiter(e,t){const i=this,n=i._dragDetails,a=n.segment,s=e.slice(0,3),r=document.createElement("div");if(r.classList.add("smart-task-bar-limiter",e),e.indexOf("date")>-1){if(!n[s]||!n[s].left)return;const[e,t]=a?[a.element,a.originalPosition.x]:[n.timelineTask,0],o=i.$.taskTimelineCellsContainer.children[i._getTaskDOMIndex(n.task)];s.indexOf("max")>-1?r.style.width=o.offsetWidth-n[s].left-t-e.offsetWidth+"px":r.style.width=n[s].left+t+"px"}else{if(!n[s].width)return;r.style["left"===t?"right":"left"]=n[s].width+"px"}return r}_doubleClickHandler(e){const t=this;let i=e.target;if(t.disabled||t.disableWindowEditor)return;t.shadowRoot&&i===t&&(i=e.composedPath()[0]);let n=i.closest?i.closest(".smart-task-connection"):void 0;if(n)t._openPopupWindow(n);else if(n=i.closest(".smart-timeline-task")||i.closest(".smart-table tbody tr[row-id]"),n&&t.$.taskSplitter.contains(n))if(n.classList.contains("smart-timeline-task"))t._openPopupWindow(n._cellObj.task);else{const e=t._getVCellById("task",n.getAttribute("row-id"));e&&t._openPopupWindow(e.task)}}_checkDoubleClick(e){const t=this;let i=e.target;if(t.shadowRoot&&i===t&&(i=e.composedPath()[0]),void 0===t._dblClickDetails&&(t._dblClickDetails={clicks:0}),clearTimeout(t._dblClickDetails.timeOut),i!==t._dblClickDetails.target&&(t._dblClickDetails.clicks=0),t._dblClickDetails.target=i,t._dblClickDetails.clicks++,t._dblClickDetails.timeOut=setTimeout((function(){t._dblClickDetails&&(t._dblClickDetails.clicks=0)}),250),2===t._dblClickDetails.clicks)return t._doubleClickHandler(e),t._dblClickDetails.clicks=0,!0}_downHandler(e){const t=this,i=e.originalEvent,n=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target,a=n.closest?n.closest(".smart-timeline-row")||n.closest(".smart-timeline-task"):null;if(e.stopPropagation(),delete t._itemClickDetails,t._dragDetails)return delete t._dragDetails,void t._setConnectionFeedback();const s=t.$.taskSplitter.contains(n)?"task":"resource";if((n.closest(".smart-timeline-content")||n.closest(`.smart-${s}-table`))&&requestAnimationFrame((()=>t.$[`${s}Table`].focus({preventScroll:!0}))),t._itemClickDetails={target:n},!t._isMobile&&0!==e.button)return;if(!a){if(n.classList.contains("smart-popup-window-modal")){if(t._popupWindow){const e=Object.keys(t._popupWindow);requestAnimationFrame((()=>t._popupWindow[e[e.length-1]].focus()))}return}return void((n.closest(".smart-table tbody tr[row-id]")&&!n.classList.contains("smart-arrow")||n.closest(".smart-task-connection"))&&t._checkDoubleClick(i))}if(n.closest(".smart-resource-timeline-view-cell")||t.disabled)return;const r=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===a._cellObj.task));if(!r)return;const o=r._cellObj.task;if(!o)return;const l=t.$.timeline.getAttribute("task-bar-hovered");if(r.getElementsByClassName("smart-timeline-task-fill")[0]||l){if((n.closest(".smart-timeline-task-fill")||r.classList.contains("milestone")&&n.closest(".smart-task-container"))&&t._checkDoubleClick(i))return;const a=n.closest(".smart-timeline-task-progress-thumb"),s=e.pageX-window.pageXOffset,c=e.pageY-window.pageYOffset,d=t._dragDetails={},m=t.rightToLeft;let u,h=n.closest(".smart-task-segment");if(l&&!h){const e=r.querySelectorAll(".smart-task-segment");d.segments=e,h="left"===l&&!m||"right"===l&&m?e[0]:e[e.length-1]}if(d.target=(a||n).className,d.timelineTask=r,d.task=r._cellObj.task,d.taskDimensions={width:r.offsetWidth,height:r.offsetHeight,left:r.offsetLeft,top:r.offsetTop},d.coordinates={x:s,y:c},!e.ctrlKey&&h&&o.segments&&o.segments.length>1&&!t.disableSegmentDrag){const e=h.getBoundingClientRect(),t=h._segmentObj,i=d.task.segments,n=i.indexOf(t);d.segment={element:h,dimensions:{width:e.width,left:h.offsetLeft},offset:{x:s-e.left},originalSize:{width:e.width},isFirstSegment:0===n,isLastSegment:n===i.length-1,min:{},max:{}},u=d.segment.dimensions}const g=d.taskDimensions;t.rightToLeft?(g.right=t.$.timelineContent.offsetWidth-(g.left+g.width),d.originalPosition={x:g.right,y:g.top},d.segment&&(u.right=g.width-(u.left+u.width),d.segment.originalPosition={x:u.right})):(d.originalPosition={x:g.left,y:g.top},d.segment&&(d.segment.originalPosition={x:u.left}));const f=(a||r).getBoundingClientRect();if(d.offset={x:s-f.left,y:c-f.top},d.originalSize={width:g.width,height:g.height},a||!a&&"project"===o.type&&o.synchronized&&!o.dragProject)return void(n.closest(".smart-task-connection-point")&&(d.timelineTask=void 0,d.relatedConnections={}));("visible"===t.resizeHandlesVisibility||t._isMobile&&"auto"===t.resizeHandlesVisibility)&&(n.closest(".smart-timeline-task-fill")?t._checkTaskBarResizability(e):t.$.timeline.removeAttribute("task-bar-hovered")),d.min={},d.max={},t._setDragLimits(n)}}_documentMoveHandler(e){const t=this;if(!t._dragDetails||!t._dragDetails.target){let i=e.originalEvent.target;t.shadowRoot&&i===t&&(i=e.originalEvent.composedPath()[0]);const n=i.closest&&i.closest(".smart-table tbody tr[row-id]");return n&&n.data?t._handleTableItemHover(n.data.itemId,i):t._handleTimelineHover(e),t._checkTaskBarResizability(e),void t._toggleTooltip(e.originalEvent)}if(t._dragDetails.target.includes("smart-task-connection-point"))return t._setConnectionFeedback(e),t._handleTimelineHover(e),void t._autoScroll(e);if(t._dragDetails.target.includes("smart-timeline-task-progress-thumb"))t._handleTaskProgressChange(e);else if(t._autoScroll(e),!t._autoScrolling)if(t.$.timeline.hasAttribute("task-bar-hovered"))t._handleTaskBarResize(e);else if(t._dragDetails.target.includes("smart-timeline-task-fill")){const i=t._dragDetails.task;if(!i||i.disableDrag||"project"===i.type&&i.synchronized&&!i.dragProject)return;t._handleTaskBarDrag(e)}}_documentUpHandler(e){const t=this,i=e.originalEvent;let n=i.target;if(t._upHandler(),!t._dragDetails)return void t._handleItemClick(i);if(t._scrollView.disableSwipeScroll=t._touchmoveInside=!1,t.shadowRoot&&n===t&&(n=i.composedPath()[0]),t.hasAttribute("connecting-task")){const i=t._connectTask(e),n=t._tasks;if(t._setConnectionFeedback(),i){const e=i.taskStart,a=i.taskEnd,[s,r,o]=[n.indexOf(i.taskStart),n.indexOf(i.taskEnd),i.type];t.$.fireEvent("connectionEnd",{id:`${s}-${r}-${o}`,startIndex:s,startTaskId:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,endIndex:r,endTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,type:o}),t._autoSchedule(i.taskStart)}return t._isMobile&&t._handleTimelineHover(e,!0),void delete t._dragDetails}const a=t._dragDetails.task;if(!a)return void delete t._dragDetails;let s;const r=t._dragDetails.segment?t._dragDetails.segment.element:void 0;if(s||(s=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===a))),t.hasAttribute("dragged")){t._snapToNearest(s,r),r||t._checkWorkingDays(s,r),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),t._autoSchedule(a),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(a)):(t.snapToNearest||t.nonworkingDays.length>0||t.nonworkingHours.length>0)&&t._refreshAssignedResources(a),t.removeAttribute("dragged");const e={id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),dateStart:new Date(a.dateStart),dateEnd:new Date(a.dateEnd)};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("dragEnd",e)}else if(t.hasAttribute("progress-change"))t._resourceTreeRefreshTimeout&&(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(a,["progress"])),t.removeAttribute("progress-change"),t.$.fireEvent("progressChangeEnd",{id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),progress:a.progress||0});else if(t.hasAttribute("resized")){t._snapToNearest(s,r),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(a,["workload"])):t.snapToNearest&&t._refreshAssignedResources(a,["workload"]),t.removeAttribute("resized");const e={id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),dateStart:a.dateStart,dateEnd:a.dateEnd};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("resizeEnd",e),t._autoSchedule(a)}else n.closest(".smart-timeline-task")===s&&(t._select("task",a.$.id,!0),delete t._dragDetails,t._handleItemClick(i));const o=t.$.timelineContent.querySelectorAll(".smart-task-bar-limiter");for(let e=0,t=o.length;e<t;e+=1)o[e].remove();delete t._dragDetails}_handleItemClick(e){const t=this,i=e.target;if(t._dragDetails||!t._itemClickDetails||t._itemClickDetails.target!==i)return void delete t._itemClickDetails;let n,a,s;if(i.closest(".smart-timeline-task-fill"))a=i.closest(".smart-timeline-task")._cellObj.task,s="task";else if(n=i.closest(".smart-task-connection"),n)a=n.getAttribute("connection-id").split("-"),a={source:a[0],target:a[1],type:a[2]},s="connection";else if(n=i.closest(".smart-table tbody tr"),n){const e=t._getVCellById(s,n.getAttribute("row-id"));s=t.$.taskTable.contains(n)?"task":"resource",a=e?e[s]:void 0}if(!a)return;const r={originalEvent:e,type:s,item:t._cloneObject(a)};r.id="connection"===s?`${a.source}-${a.target}-${a.type}`:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,delete t._itemClickDetails,t.$.fireEvent("itemClick",r)}_moveHandler(e){const t=this;t._isMobile||e.stopPropagation(),(t.hasAttribute("dragged")||t.hasAttribute("progress-change"))&&"touchmove"===e.originalEvent.type&&e.originalEvent.preventDefault()}_handleTableItemHover(e,t){const i=this,n=i._hoveredItem;let a,s;if(t&&([a,s]=i.$.taskSplitter.contains(t)?[i.$.taskTable,"task"]:[i.$.resourceTable,"resource"]),n&&"itemType"===n.type&&n.id===e)return;const r=i.$.mainSplitter.querySelectorAll("table tbody tr[hover]");for(let e=0;e<r.length;e++)r[e].removeAttribute("hover");if(void 0===e)return void i._handleTimelineHover({target:i});if(!a)return;i._setTableHoverState(a,e);const o=i.$["task"===s?"taskTimelineCellsContainer":"resourceTimelineCellsContainer"].children;for(let t=0,n=o.length;t<n;t+=1){const n=o[t];if(n._cellObj[s].$.id===e){i._handleTimelineHover({target:n});break}}}_setTableHoverState(e,t){const i=this;e||(e=i.$.taskTable);const n=e===i.$.taskTable?"task":"resource",a=e.querySelectorAll("table tbody tr");if(!i._isMobile&&i[n+"Columns"].length)for(let e=0;e<a.length;e++){let i=a[e];const n=i.data;n&&n.itemId===t&&i.setAttribute("hover","")}}_checkWorkingDays(e){const t=this,i=t._dragDetails;if(!(i&&i._taskDuration||t._timelineCells.length))return;if(!e.classList||!e.classList.contains("smart-timeline-task")||!t.hasAttribute("dragged")||0===t.nonworkingDays.length&&0===t.nonworkingHours.length||!i||!i._taskDuration)return;const n=e._cellObj,a=n.task,s=t._getTaskWorkingDateEnd(a),r=a.segments;let o=new Date(t._timelineCells[t._timelineCells.length-1].date);if("year"===t.view?(o.setMonth(o.getMonth()+1),o.setDate(0),o.setHours(23,59,59,999)):"month"===t.view?(o.setDate(o.getDate()+6-o.getDay()),o.setHours(23,59,59,999)):"week"===t.view?o.setHours(23,59,59,999):o.setHours(o.getHours(),59,59,999),s&&(a.dateEnd=a.maxDateEnd?new Date(Math.min(s.getTime(),a.maxDateEnd.getTime())):s),a.dateEnd=new Date(Math.min(o.getTime(),a.dateEnd.getTime())),a.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(a.dateStart,a.dateEnd):a.dateEnd.getTime()-a.dateStart.getTime(),!0),r&&r.length>1){for(let e=0,i=r.length;e<i;e+=1)t._snapToNearestDates(r[e],!0);t._validateTaskSegments(a),a.segments.length!==r.length&&t._recycleSegments(a,e),t._setTaskBarSegments(n,e,!0),t._setTaskBarProgress(a)}t._setTimelineTaskBar(n,void 0,!0),t._refreshTaskConnections(n.task),t._refreshTableColumnsData(a,["dateEnd","duration","overdue"])}_getTaskWorkingDateEnd(e,t){const i=this;if(!e||!e.dateStart)return;let n,a,s=new Date(e.dateStart);if(t||(t=i._dragDetails?i._dragDetails._taskDuration:i._getWorkingTime(e.dateStart,e.dateEnd)),!i.adjustToNonworkingTime)return new Date(e.dateStart.getTime()+t);const r=t<0?-1:1,o=i.nonworkingDays,l=i.nonworkingHours;for(t=Math.abs(t);t>0;){const e=Math.min(t,36e5-(60*s.getMinutes()*1e3+1e3*s.getSeconds()+s.getMilliseconds()));if(o.indexOf(s.getDay())>-1)a=new Date(s),a.setHours(0,0,0,0),a.setDate(s.getDate()+1*r),n=Math.min(e,a.getTime()-s.getTime()),s=new Date(s.getTime()+n);else if(l.indexOf(s.getHours())>-1){a=new Date(s);const t=a.getTime();a.setHours(s.getHours()+1*r,0,0,0),t===a.getTime()&&a.setHours(s.getHours()+2*r,0,0,0),n=Math.min(e,a.getTime()-s.getTime()),s=new Date(s.getTime()+n)}else t-=e,s=new Date(s.getTime()+r*e)}return s}_createConnectingElement(e,t,i,n,a){const s=this;if(!s._connectionDetails||!s._connectionDetails.start)return;const r=s._connectionDetails,o=r.type,l=s.$.timelineConnectionsContainer;let c=r.connections.shift();c||(c=document.createElement("div"),c.classList.add("smart-task-connection")),c.style.width=c.style.width="","horizontal"===n?(c.style.width=Math.abs(i)+"px",c.style.height=""):(c.style.width="",c.style.height=Math.abs(i)+"px"),c.style[s.rightToLeft?"left":"right"]="",c.style[s.rightToLeft?"right":"left"]=e+"px",c.style.top=t+"px",c.setAttribute("connection-id",r.id);const d=r.start.task.label,m=0===o||3===o?"start":"end",u=r.end.task.label,h=0===o||1===o?"start":"end";if(c.setAttribute("aria-label","Connection between "+d+" ("+m+") and "+u+" ("+h+")"),a){let e=0===o||1===o?"right":"left";s.rightToLeft&&(e="left"===e?"right":"left"),c.setAttribute("arrow-direction",e)}else c.removeAttribute("arrow-direction");c.parentElement||l.appendChild(c)}_getConnectionType(e,t){if(!e||!t)return;let i,n;return"string"==typeof e?i=!e.includes("end"):e instanceof HTMLElement&&(i=!e.classList.contains("end")),"string"==typeof t?n=t.includes("end"):t instanceof HTMLElement&&(n=t.classList.contains("end")),i&&!n?0:i||n?!i&&n?2:i&&n?3:void 0:1}_setConnectionFeedback(e){const t=this,i=t._dragDetails;if(!i||!i.target||!e){const e=t._connectionFeedback;return e&&e.parentElement&&e.remove(),t.removeAttribute("connecting-task"),void delete t._connectionFeedback}if(!i.target||!i.target.includes("smart-task-connection-point"))return;const n=i.task,a=i.taskDimensions;if(!n)return;if(!t.hasAttribute("connecting-task")){if(t.$.fireEvent("connectionStart",{startIndex:t._tasks.indexOf(n)}).defaultPrevented)return void delete t._dragDetails.target;t.setAttribute("connecting-task",""),t._isMobile&&(t._scrollView.disableSwipeScroll=t._touchmoveInside=!0)}const s="milestone"===n.type,r=t.rightToLeft;let o=s?-1*a.height/2:0;t._dragDetails.target.includes("end")&&(o=s?-1*o:a.width),t._connectionFeedback||(t._connectionFeedback=document.createElement("div"),t._connectionFeedback.classList.add("smart-task-connection-feedback"));const l=t._dragDetails.coordinates.x+(r?-1:1)*o,c=t._dragDetails.coordinates.y,d=t._dragDetails.offset.x-(r?a.width:0),m=t._dragDetails.offset.y,u=e.pageX-window.pageXOffset+d,h=e.pageY-window.pageYOffset+m-a.height/2;r?(t._connectionFeedback.style.left="",t._connectionFeedback.style.right=a.right+o+"px"):(t._connectionFeedback.style.left=a.left+o+"px",t._connectionFeedback.style.right=""),t._connectionFeedback.style.top=a.top+a.height/2+"px",t._connectionFeedback.style.width=Math.sqrt(Math.pow(Math.abs(u-l),2)+Math.pow(Math.abs(h-c),2))+"px",t._connectionFeedback.style.transform=t.rightToLeft?"rotate("+180*(Math.atan2(c-h,l-u)||0)/Math.PI+"deg)":"rotate("+180*(Math.atan2(h-c,u-l)||0)/Math.PI+"deg)",t._connectionFeedback.parentElement||t.$.timelineContent.appendChild(t._connectionFeedback)}_connectTask(e){const t=this,i=t._tasks;let n,a,s,r,o,l,c,d,m;if(e.originalEvent){const r=e.originalEvent;let o=t._isMobile?document.elementFromPoint(r.pageX-window.pageXOffset,r.pageY-window.pageYOffset):r.target;if(!(t._dragDetails&&t._dragDetails.target&&o&&o.classList))return;if(t.shadowRoot&&o===t&&(o=t._isMobile?t.shadowRoot.elementFromPoint(r.pageX-window.pageXOffset,r.pageY-window.pageYOffset):r.composedPath()[0]),n=t._dragDetails.target.includes("smart-task-connection-point")?t._dragDetails.target:void 0,a=o.classList.contains("smart-task-connection-point")?o:void 0,n&&(l=t._dragDetails.task),a)s=a.closest(".smart-timeline-task");else if(t._isMobile&&o.classList.contains("smart-timeline-task-fill")&&(s=o.closest(".smart-timeline-task"),s)){const e=r.pageX-window.pageXOffset-s.getBoundingClientRect().left;a=s.querySelector(".smart-task-connection-point."+(e>=s.offsetWidth/2?"end":"start"))}if(!l||!s)return;c=s._cellObj.task;for(let e=0,t=i.length;e<t;e+=1){const t=i[e];if(t!==l)if(t!==c){if(void 0!==d&&void 0!==m)break}else m=e;else d=e}}else{if(!e||e.length<3)return;const n=t._getValidConnectionId(e[0],e[1],e[2],"_connectTask");if(void 0===n)return;[d,m]=[parseInt(n[0]),parseInt(n[1])],[l,c]=[i[d],i[m]],r=parseInt(e[2]),o=e[4]||0}if(!l||!c||l===c||l.isGroup||c.isGroup||t._isAutoScheduled(l,c)||t.hasAttribute("dragged")||t.hasAttribute("resized"))return;void 0===r&&(r=t._getConnectionType(n,a));let u=t._connections;return u||(t._connections=u=[]),t._updateConnection([d,m,r,o])?(e.originalEvent&&t._recycleConnections([{startIndex:d,endIndex:m,type:r}]),e.originalEvent&&t.$.fireEvent("itemInsert",{type:"connection",item:{source:d,target:m,type:r}}),{taskStart:l,taskEnd:c,type:r}):void 0}_recycleConnections(e){const t=this,i=t._tasks;if(e?Array.isArray(e)||(e=[e]):e=t._connections,!i||!i.length||!e)return;const n=t.$.timelineTasksContainer.children,a=t.$.timelineConnectionsContainer;let s,r=[];if(n.length){const a=n[0],o=(()=>{let e=[];for(let t=0,a=n.length;t<a;t+=1)e.push(i.indexOf(n[t]._cellObj.task));return e})(),l=a.querySelector(".smart-task-connection-point."+(t.rightToLeft?"end":"start")),c=t._baselineProportion,d=t.showBaseline?t._taskDefaultHeight/c:0;s={top:l.offsetTop,width:l.offsetWidth},s.offset=Math.abs(l.offsetLeft)-s.width;for(let n=0,a=e.length;n<a;n+=1){const a=e[n],l=a.startIndex,c=a.endIndex;if(o.indexOf(l)<0&&o.indexOf(c)<0)continue;const m=i[l],u=i[c],{vCellStart:h,vCellEnd:g}=t._getTasksVCell(m,u);if(!h||!g)continue;const f=a.type,p={start:{width:s.width,top:s.top,index:l,task:m},end:{width:s.width,top:s.top,index:c,task:u},type:f},_=t._getTaskBarDetails(h,t._getTimelineCellByDate(m.dateStart),t._getTimelineCellByDate(m.dateEnd)),T=t._getTaskBarDetails(g,t._getTimelineCellByDate(u.dateStart),t._getTimelineCellByDate(u.dateEnd));"milestone"===m.type&&(_.width=h.height-d),"milestone"===u.type&&(T.width=h.height-d),p.start.left=0===f||3===f?-1*(s.width+s.offset):_.width+s.offset,p.end.left=0===f||1===f?-1*(s.width+s.offset):T.width+s.offset,t._connectionDetails=p,_.height=T.height=h.height-d,_.type=m.type,T.type=u.type,t._setConnectionDetails(_,T),t._createTaskConnection(),r.push(t._connectionDetails.id),delete t._connectionDetails}}if(arguments.length)return;const o=Array.from(a.children);for(let e=0,t=o.length;e<t;e+=1){const t=o[e];r.indexOf(t.getAttribute("connection-id"))<0&&t.remove()}}_getTasksVCell(e,t){const i=this._timelineVCells;let n,a;for(let s=0,r=i.length;s<r;s+=1){const r=i[s];if(r.task===e&&(n=r),r.task===t&&(a=r),n&&a)break}return{vCellStart:n,vCellEnd:a}}_isAutoScheduled(e,t,i){const n=this,a=n._tasks;let s={};if(n.autoSchedule)return e instanceof HTMLElement&&(e=e._cellObj.task),t instanceof HTMLElement&&(t=t._cellObj.task),function e(t,r){const o=n._getTaskConnections().taskConnections,l=a.indexOf(t);s[l]=!0;for(let t=0;t<o.length;t++){const c=o[t],d=c.endIndex;if(d===r)return i&&n._removeConnection(l+"-"+d+"-"+c.type,!0),!0;if(!s[d]&&e(a[d],r))return!0}}(t,a.indexOf(e))}_setConnectionDetails(e,t){const i=this;if(!i._connectionDetails)return;const n=i._connectionDetails,a=n.start,s=n.end,r=n.type;if(!a||!s)return;let o,l=e.width,c=t.width,d=e.left,m=t.left,u=e.top,h=t.top,g=a.left,f=s.left;const p=a.index,_=s.index;if("milestone"===e.type&&(l=e.height,d-=l/2),"milestone"===t.type&&(c=t.height,m-=c/2),n.id=p+"-"+_+"-"+r,!n.connectionStartOffset||!n.connectionEndOffset){switch(r){case 0:g=Math.abs(g)-a.width,f=Math.abs(f)-s.width;break;case 1:g-=l,f=Math.abs(f)-s.width;break;case 2:g-=l,f-=c;break;default:g=Math.abs(g)-a.width,f-=c}n.start.offset=g+=a.width/2,n.end.offset=f+=s.width/2}if(0===r&&d>m||1===r&&d+l+g>m-f&&h>u||2===r&&m+c>d+l||3===r&&(d-g<m+c+f&&h>u||d-g>m+c+f&&u>h)){o=!0;let i=e;e=t,t=i,i=g,g=f,f=i,i=l,l=c,c=i,i=d,d=m,m=i,i=u,u=h,h=i}let T=d,k=m;!o&&1===r||o&&3===r?T+=l:!o&&3===r||o&&1===r?k+=c:2===r&&(T+=l,k+=c);let b=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+p+"-"+_+'-"]');0===b.length&&(b=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+_+"-"+p+'"]')),n.connections=[].slice.call(b),n.start.x=T,n.start.y=u+a.top,n.end.x=k,n.end.y=h+s.top,n.type=r,n.inverted=o}_createTaskConnection(){const e=this,t=e._connectionDetails;if(!t)return;const i=2*e._taskConnectionWidth,n=t.start.x,a=t.start.y,s=t.start.offset,r=t.start.top,o=t.end.x,l=t.end.y,c=t.end.offset,d=t.type,m=t.inverted,u=!m&&3===d||m&&1===d,h=!m&&1===d||m&&3===d;let g,f,p,_=n,T=o;u?(_=n-c,T=o+c):h&&(_=n+s,T=o-c);const k=_<=T&&u,b=_>=T&&h,y=2===d||h;!function c(u){g!==o&&(u?"horizontal"===u?(p=g-o+(k?-1:1)*s,g=_>T?g-Math.abs(p):g,e._createConnectingElement(g,f,(_===T?0:Math.abs(p))+(y?i:0),"horizontal"),g=_<T?g-p:g,c("vertical")):(p=Math.abs(f-l),f+=a<l?0:-1*p,g-=m&&1===d||!m&&3===d&&a>l?i:0,e._createConnectingElement(g,f,p,"vertical"),c()):(g?(p=Math.abs(g-o),g>=o&&(g+=-1*p,p+=i),e._createConnectingElement(g,f+(a<l?Math.abs(f-l):0),p,"horizontal",!t.inverted),g=o):(g=n,f=a,(0===d||!m&&3===d||m&&1===d)&&(g-=s),e._createConnectingElement(g,f,s,"horizontal",t.inverted),y&&(g+=s-i),k||b?(e._createConnectingElement(g,f-=a>l?r:0,r,"vertical"),f+=a<l?r:0):c("vertical")),c("horizontal")))}(),t.connections.map((e=>e.parentElement.removeChild(e)))}_getTaskIndexById(e,t){const i=this;if(t||(t=i._tasks),"number"==typeof e)return isNaN(parseInt(e))?-1:parseInt(e);if("object"==typeof e)return i._getItemIndex(e,"task");for(let i=0,n=t.length;i<n;i+=1)if(t[i].id===e)return i;return-1}_refreshTaskConnections(e){const t=this,i=e instanceof HTMLElement?e._cellObj.task:e,n=t._tasks.indexOf(i);if(void 0===n||e.classList&&e.classList.contains("smart-visibility-hidden"))return;let a;if(t._dragDetails&&(a=t._dragDetails.relatedConnections[n]),!a){a=[];const e=t._connections;if(!e||!e.length)return;for(let t=0,i=e.length;t<i;t+=1){const i=e[t];i.startIndex!==n&&i.endIndex!==n||a.push(i)}t._dragDetails&&(t._dragDetails.relatedConnections[n]=a)}t._recycleConnections(a)}_dragStartHandler(e){const t=this,i=e.target.closest;(t._dragDetails||i&&i.call(t,"smart-gantt-chart")===t)&&e.preventDefault()}_getFirstCellObjInView(e){const t=this;if(e||(e=t._timelineCells),!e)return;const i=Math.abs(t.scrollLeft);let n,a;for(let t=0;t<e.length;t++){const s=e[t];if(s.left+s.width>i){n=s;break}a=s}return!n&&a&&(n=i>a.left?a:e[0]),n}_getFirstContentCellInView(e="task"){const t=this;let i,n,a,s;if("task"===e?(i=t._timelineVCells,n=t.scrollTop):(i=t._timelineResourceVCells,n=t.$.resourceVerticalScrollBar.value),!i)return 0;for(let e=0;e<i.length;e++){const t=i[e];if(t.top+t.height>n){a=t;break}s=t}return!a&&s&&(a=n>s.left?s:i[0]),a}_getProjectTasks(e,t){const i=this,n=i.groupByResources&&e.isGroup?"group":"project",a=i._tasks;if(!e||"project"!==e.type)return[];let s=[];for(let r=0,o=a.length;r<o;r+=1){const o=a[r];o.$[n]===e&&(s.push(o),"project"!==o.type||t||(s=s.concat(i._getProjectTasks(o,t))))}return s}_getSubTaskLimits(e){const t=this;if(!e)return;const i=e._cellObj.task,n=t._getProjectTasks(i);let a,s;if(!n.length)return;let r=n[0],o=n[0];for(let e=0;e<n.length;e++){const t=n[e];n[e].dateEnd&&n[e].dateStart&&(r.dateStart||(r=t[e]),o.dateEnd||(o=t[e]),n[e].dateEnd.getTime()>o.dateEnd.getTime()&&(o=n[e]),n[e].dateStart.getTime()<r.dateStart.getTime()&&(r=n[e]))}const l=t.$.timelineContent.offsetWidth;let c,d,m;if(r&&(c=t._getTimelineSubTaskOffset(r),c&&(d=c.left,m=c.width,a=Math.max(0,t.rightToLeft?l-e.offsetLeft-e.offsetWidth-(l-d-m):e.offsetLeft-d))),o&&(c=t._getTimelineSubTaskOffset(o),c))if(d=c.left,m=c.width,t.rightToLeft){const t=l-e.offsetLeft-e.offsetWidth;s=Math.max(t,t+l-(l-d))}else s=Math.max(e.offsetLeft,e.offsetLeft+l-(d+m));return{min:a,max:s}}_getTimelineSubTaskOffset(e){const t=this,i=t.$.timelineTasksContainer.children[t._tasks.filter((e=>!e.hidden)).indexOf(e)];let n,a,s;if(i)n=i.offsetLeft,s=i.offsetWidth;else{const i=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);i&&(n=i.left+t._getTimelineTaskOffset(i,e.dateStart)||0),r&&(a=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0),s=a-n}return{left:n,width:s}}_getTaskDragLimits(e){const t=this,i=t._dragDetails,n=i.segment?i.segment.element:void 0,a=n&&n.previousElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateStart"),s=n&&n.nextElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateEnd"),r=t._dragDetails.taskDimensions;let o={};return(a.min||s.min)&&(o.min=Math.max(a.min||0,Math.max(0,(s.min||0)-r.width))),s.max&&(o.max=Math.max(0,s.max-r.width)),a.max&&(o.max=o.max?Math.min(a.max,o.max):a.max),o}_getTaskBarDateRange(e){if(!e)return;const t=this,i=e.classList.contains("milestone"),n=parseFloat(e.style.width)||e.offsetWidth,a=i?n/2:n,s=t.rightToLeft?parseFloat(e.style.right)||t.$.timelineContent.offsetWidth-e.offsetLeft-a:parseFloat(e.style.left)||e.offsetLeft,r=e._cellStart,o=e._cellEnd,l=e._cellObj.task,c=l.minDateStart,d=l.maxDateEnd;let m,u;return m=t._getDateFromCell(s,r),!c||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(m=new Date(Math.max(c.getTime(),m.getTime()))),u=i?new Date(m):t._getDateFromCell(s+a,o),!d||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(u=new Date(Math.min(d.getTime(),u.getTime()))),{dateStart:m,dateEnd:u}}_getTaskBarDetails(e,t,i){const n=this,a=e.task;if(!e)return;let s=new Date(a.dateStart);const r=new Date(a.dateEnd);if(!n._dragDetails&&n.snapToNearest){let s,r,o=a.dateStart,l=a.dateEnd;const c=new Date(t.date),d=n._getDateFromCell(t.left+t.width,t),m=new Date(i.date),u=n._getDateFromCell(i.left+i.width,i);return s=d.getTime()-o.getTime()>=d.getTime()-c.getTime()?t.left:t.left+t.width,"milestone"!==a.type&&(r=u.getTime()-l.getTime()>=l.getTime()-m.getTime()?i.left-s:i.left-s+i.width),{left:s,width:r,top:e.top}}let o,l,c,d,m,u;switch(n.view){case"year":{c=new Date(s.getFullYear(),s.getMonth()+1,0).getDate(),d=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();const e=s.getHours()/24+s.getMinutes()/1440+s.getSeconds()/86400,n=r.getHours()/24+r.getMinutes()/1440+r.getSeconds()/86400;o=t.left+(s.getDate()-1+e)/c*t.width,l=i.left+(r.getDate()-1+n)/d*i.width-o;break}case"month":m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*(t.width/7),u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*(t.width/7),o=t.left+s.getDay()/7*t.width+m,l=i.left+r.getDay()/7*i.width-o+u;break;case"week":m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*t.width,u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*t.width,o=t.left+m,l=i.left+(u-m)-t.left;break;case"day":m=parseFloat(s.getMinutes()+s.getSeconds()/60)/60*t.width,u=parseFloat(r.getMinutes()+r.getSeconds()/60)/60*t.width,o=t.left+m,l=i.left+(u-m)-t.left}return{width:"milestone"===a.type?"":l,left:o,top:e.top}}_snapToNearestDates(e,t){const i=this;if(!i.snapToNearest)return;if(e.classList&&e._cellObj&&(e=e._cellObj.task),!e)return;let n=e.dateStart,a=e.dateEnd;const{cellStart:s,cellEnd:r}={cellStart:i._getTimelineCellByDate(n),cellEnd:i._getTimelineCellByDate(a)},o=new Date(s.date),l=i._getDateFromCell(s.left+s.width,s),c=new Date(r.date),d=i._getDateFromCell(r.left+r.width,r);if(n=l.getTime()-n.getTime()>=l.getTime()-o.getTime()?o:l,"milestone"!==e.type&&(a=d.getTime()-a.getTime()>=d.getTime()-c.getTime()?c:d),e.dateEnd=a,a.getTime()<n.getTime()&&(n=new Date(a)),e.dateStart=n,e.duration=e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0),!t&&e.segments&&e.segments.length>1){const t=e.segments;for(let e=0,n=t.length;e<n;e+=1)i._snapToNearestDates(t[e],!0);i._validateTaskSegments(e)}}_getTimelineTaskCellByDate(e){if(!e)return;const t=this,i=t.view,n=t._timelineCells;for(let a=0;a<n.length;a++){const s=n[a];if(t._isDateInCell(s.date,e,i))return s}}_isDateInCell(e,t,i){switch(i){case"year":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth())return!0;break;case"month":{let i=new Date(e);if(i.setDate(i.getDate()+(6-i.getDay())+1),i.setMilliseconds(i.getMilliseconds()-1),t.getTime()>=e.getTime()&&t.getTime()<=i.getTime())return!0;break}case"week":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())return!0;break;case"day":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()&&e.getHours()===t.getHours())return!0}}_handleInverted(e){const t=this;function i(e){e||(e="task");const i=t.$[`${e}Splitter`];if(!t.$.mainSplitter.contains(i))return;const[n,a,s,r,o]="task"===e?[t.$.tableSplitterItem,t.$.timelineSplitterItem,t,t.$.taskTimelineContainer,"scrollTop"]:[t.$.resourceTableItem,t.$.resourceTimelineSplitterItem,t.$.resourceVerticalScrollBar,t.$.resourceTimelineContent,"value"],l=t.treeSize!==n.size?n.style[i._measurements.dimension]:t.treeSize;n.size="",i.removeChild(a),t.inverted&&!t.rightToLeft||!t.inverted&&t.rightToLeft?i.insertBefore(a,n):i.appendChild(a),n.size=l,r.scrollTop=s[o]}(!e||t.inverted||t.rightToLeft)&&(i("task"),i("resource"))}_createResourceTimeline(){const e=this;if(e._handleResourcePanelVisibility(),e.$.taskSplitterItem._setSize("size",e.taskPanelSize),!e._resources||!e.$.mainSplitter.contains(e.$.resourceTable))return;const t=e.$.resourceSplitterItemHeader.innerHTML;(e.resourcePanelHeaderTemplate&&!t||!e.resourcePanelHeaderTemplate&&t)&&e._handleHeaderTemplate("resource"),e._setTable(e.$.resourceTable),e._recycleResourceHeaderCells(),e._createResourceTimelineContent(),e._synchronizeSplitters(e.$.taskSplitter,e.$.resourceSplitter),e.$.resourceTimelineContent.scrollLeft=e.$.resourceTimelineHeader.scrollLeft=e.$.timelineHeader.scrollLeft,e.$.resourceSplitter.refresh(),e._refresh(),e._highlightAssignedItem("task",e._getSelection("task",e.selectedTaskIds))}_createResourceTimelineContent(){const e=this,t=e._timelineVCells,i=t.length?t[0].height:e._taskDefaultHeight;e._createResourceTimelineVCells(i);const n=e._timelineResourceVCells.length*i;e.$.resourceTimelineCellsContainer.style.height=n+"px",e.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",n+"px"),e._recycleResourceContent()}_recycleResourceContent(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e._timelineResourceVCells,i=e.$.resourceTimelineCellsContainer,n=e._getFirstContentCellInView("resource"),a=e.$.tooltip;if(a&&i.contains(a.selector)&&e._closeTooltip(),!n)return void(i.innerHTML="");const s=t.indexOf(n),r=n.height,o=1-(n.top+r-Math.abs(e.$.resourceVerticalScrollBar.value))/r,l=t?t.length:0,c=!e.$.resourceSplitter.offsetHeight,d=e.$.resourceTimelineContent.offsetHeight,m=!c&&d?Math.min(l,Math.ceil((parseFloat((d/r).toFixed(2))+o).toFixed(2))):l,u=i.children,h=e.$.timelineViewCells.children,g=document.createDocumentFragment();for(;i.childElementCount>m;)i.lastElementChild.remove();for(let t=0;t<m;t+=1){let i=u[t];i||(i=document.createElement("div"),i.classList.add("smart-timeline-row"),g.appendChild(i)),e._createTimelineRowCells(i,h)}g.childElementCount&&i.appendChild(g);const f=i.children,p=e._getSelection("resource",e.selectedResourceIds);for(let i=0;i<m;i+=1){const n=t[s+i],a=f[i];if(!n){a&&a.remove();continue}const r=n.resource,o=r.$.id;p.indexOf(o)>-1?a.setAttribute("selected",""):a.removeAttribute("selected"),a._cellObj=n,a.setAttribute("row-id",o),a.style.top=n.top+"px",e._refreshResourceTimelineContent(r,a)}}_createResourceTimelineVCells(e){const t=this,i=t._resources,n=t.$.resourceTable.rows,a=t._timelineResourceVCells=[];let s=0;if(void 0===e){const i=t._timelineVCells;e=i.length?i[0].height:t._taskDefaultHeight}for(let t=0,r=n.length;t<r;t+=1){const r=i[n[t].data.itemIndex];r.hidden||(a.push({top:s,height:e,resource:r}),s=parseFloat((s+e).toFixed(2)))}}_handleResourcePanelVisibility(){const e=this,t=e.$.container,i=e._resources.filter((e=>!e.hidden)),n=e.$.mainSplitter,a=e.$.resourceSplitterItem,s=e.$.taskSplitterItem;if(!i||!i.length||e.hideResourcePanel)return a&&!a.size&&(a._size=a.style[n._measurements.dimension]),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView),s.size="",s.min="",e.$.resourceTable&&e.$.resourceTable.clearSelection(),n.contains(a)&&(n.removeChild(a),e._refresh()),e._highlightAssignedItem("resource"),void t.removeAttribute("show-resource-panel");n.contains(a)||(s.min=e.taskPanelMin,e._createResourcePanel(),e._setupResourcePanel(),e._resourceScrollView=new Smart.Utilities.Scroll(e.$.resourceSplitterItem,e.$.horizontalScrollBar,e.$.resourceVerticalScrollBar)),t.setAttribute("show-resource-panel",""),e._synchronizeSplitters(e.$.taskSplitter,e.$.resourceSplitter)}_createResourcePanel(){const e=this,t=e.$.mainSplitter;let i=e.$.resourceSplitterItem;if(!i){i=document.createElement("smart-splitter-item"),i.classList.add("smart-resource-splitter-item"),i.innerHTML=`<div smart-id="resourceSplitterItemHeader" class="smart-resource-panel-header"></div>\n <smart-splitter smart-id="resourceSplitter" wait class="smart-resource-splitter" auto-fit-mode="end">\n <smart-splitter-item smart-id="resourceTableItem" class="smart-resource-table-item">\n <smart-table wait smart-id="resourceTable" class="smart-resource-table" virtualization deferred-scroll-delay="0"></smart-table>\n </smart-splitter-item>\n <smart-splitter-item smart-id="resourceTimelineSplitterItem" class="smart-timeline-splitter-item">\n <div class="smart-timeline" smart-id="resourceTimeline">\n <div class="smart-timeline-container" role="presentation">\n <div class="smart-timeline-header" smart-id="resourceTimelineHeader" role="rowgroup">\n <div class="smart-timeline-view-cells" smart-id="resourceTimelineViewCells" role="row"></div>\n </div>\n <div smart-id="resourceTimelineContent" class="smart-timeline-content" role="rowgroup">\n <div smart-id="resourceTimelineCellsContainer" class="smart-timeline-cells-container" aria-hidden="true"></div>\n </div>\n </div>\n </div>\n <smart-scroll-bar wait smart-id="resourceVerticalScrollBar" class="smart-timeline-scroll-bar smart-resource-scroll-bar" \n orientation="vertical" aria-controls="[[${e.id||""}]]">\n </smart-scroll-bar>\n </smart-splitter-item>\n </smart-splitter>`,t.contains(i)||t.appendChild(i);const n=Smart.Utilities,a=i.querySelectorAll(".smart-resource-panel-header, .smart-resource-splitter, .smart-resource-table-item, \n .smart-resource-table, .smart-timeline-splitter-item, .smart-timeline, .smart-timeline-header, .smart-timeline-view-cells, .smart-timeline-content,\n .smart-timeline-cells-container, .smart-timeline-scroll-bar"),[s,r,o,l,c,d,m,u,h,g,f]=a;e.$.resourceSplitterItem=i,e.$resourceSplitterItem=n.Extend(i),e.$.resourceSplitterItemHeader=s,e.$resourceSplitterItemHeader=n.Extend(s),e.$.resourceSplitter=r,r.hasResizeObserver=!1,r.wait=!1,e.$resourceSplitter=n.Extend(r),e.$.resourceTableItem=o,e.$resourceTableItem=n.Extend(o),e.$.resourceTable=l,l.hasResizeObserver=!1,e.$resourceTable=n.Extend(l),e.$.resourceTimelineSplitterItem=c,e.$resourceTimelineSplitterItem=n.Extend(c),e.$.resourceTimelineViewCells=u,e.$resourceTimelineViewCells=n.Extend(u),e.$.resourceTimeline=d,e.$resourceTimeline=n.Extend(d),e.$.resourceTimelineContent=h,e.$resourceTimelineContent=n.Extend(h),e.$.resourceTimelineHeader=m,e.$resourceTimelineHeader=n.Extend(m),e.$.resourceTimelineCellsContainer=g,e.$resourceTimelineCellsContainer=n.Extend(g),e.$.resourceVerticalScrollBar=f,e.$resourceVerticalScrollBar=n.Extend(f)}}_setupResourcePanel(){const e=this,t=e.rightToLeft,i=e.$.resourceSplitterItem,n=e.$.resourceTableItem,a=e.$.resourceTable,s=e.$.resourceTimelineSplitterItem,r=e.$.resourceVerticalScrollBar;e.$.mainSplitter.contains(i)?([e.$.resourceSplitter,a,e.$.resourceVerticalScrollBar].forEach((e=>e.rightToLeft=t)),a.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,a.$.virtualizationContainer.verticalScrollBarVisibility="hidden",a.$.virtualizationContainer.disabled=!0,n.size=e.treeSize,n.min=e.treeMin,s.min=e.timelineMin,i.min=e.resourcePanelMin,i.size=i._size||e.resourcePanelSize,r.hasStyleObserver=!1,r.hasResizeObserver=!1,r.wait=!1):e.$.mainSplitter.appendChild(i)}_refreshResourceTimeline(){const e=this;e._resources&&e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._recycleResourceHeaderCells(),e._recycleResourceContent())}_getResourceCellWorkTime(e,t){const i=e.dateStart,n=e.dateEnd,a=t.dateStart,s=t.dateEnd,r=e.dateStart.getTime()<a.getTime()?a:i,o=n.getTime()>s.getTime()?s:n,l=Math.round(this._getWorkingTime(r,o)/36e5);return{value:Math.max(0,l),max:r.getTime()===a.getTime()&&o.getTime()===s.getTime()?l:Math.round(this._getWorkingTime(a,s)/36e5)}}_refreshResourceTimelineContent(e,t){const i=this,n=i._resources.indexOf(e),a=i._getResourceTasks(e);if(t||(t=(()=>{const t=i.$.resourceTimelineCellsContainer.children;for(let i=0,n=t.length;i<n;i+=1){const n=t[i];if(n._cellObj&&n._cellObj.resource===e)return n}})()),n<0||!t||!t.childElementCount)return;let s=t.children;const r=i.$.resourceTimelineViewCells.children,o=i._tasks.filter((e=>!e.hidden));for(let t=0,l=s.length;t<l;t+=1){const l=s[t];let c,d=l.firstElementChild;a.length&&!e.hidden?(d?(d.classList.remove("hide-left-border","hide-right-border"),d.removeAttribute("load"),d.innerHTML=d.style.height=""):(d=document.createElement("div"),d.classList.add("smart-resource-timeline-view-cell"),c=!0),e.class&&d.classList.add(e.class),i._setResourceCellLoad({cell:d,cellIndex:t,resource:e,resourceCell:l,resourceIndex:n,resourceTasks:a,tasks:o,viewCells:r}),d.hasAttribute("load")?c&&l.appendChild(d):d.remove()):d&&d.remove()}}_setResourceCellLoad(e){const t=this,i=t.resourceTimelineFormatFunction,{cell:n,cellIndex:a,resource:s,resourceCell:r,resourceIndex:o,resourceTasks:l,tasks:c,viewCells:d}=e;let m={};for(let e=0,u=l.length;e<u;e+=1){const u=l[e];if(u.hidden)continue;const h=c.indexOf(u),g=t._getCellDateRange(d[a]),{dateStart:f,dateEnd:p}=g;if(!f||f.getTime()>=u.dateEnd.getTime()||p.getTime()<=u.dateStart.getTime())continue;if(m[a]&&m[a].indexOf(h)<0?m[a].push(h):m[n]||(m[a]=[h]),"custom"===t.resourceTimelineMode){i&&(n.innerHTML=i.call(t,m[a]||[],o,new Date(f))||"");continue}const _=t._getResourceCellCapacity({cell:n,cellDateRange:g,cellTaskIndexAssigned:m,index:o,resource:s,task:u,cellIndex:a});if(!_)continue;const{capacity:T,maxCapacity:k}=_,b=parseFloat(((parseFloat(n.getAttribute("load"))||0)+(T||0)).toFixed(1));b>k?n.classList.add("warning"):n.classList.remove("warning"),"histogram"!==t.resourceTimelineMode?b&&n.setAttribute("load",b):t._setCellHistogram({cell:n,load:b,maxCapacity:k,previousViewCell:r.previousElementSibling})}}_getResourceCellCapacity(e){const t=this,i=t.resourceTimelineView,{cell:n,cellDateRange:a,cellTaskIndexAssigned:s,index:r,resource:o,task:l,cellIndex:c}=e;let d,m;if("tasks"===i)d=1,m=o.maxCapacity;else if("hours"===i){const e=t._getResourceCellWorkTime(l,a),i=e.max/24;d=parseFloat((e.value/e.max*o.capacity*i).toFixed(1)),m=Math.min(e.max,parseFloat((o.maxCapacity*i).toFixed(1)))}else{const e=t.resourceTimelineFormatFunction;if(!e)return;let i=e.call(t,s[c]||[],r,new Date(a.dateStart));if(null!=i)if(i="object"!=typeof i?[i]:Object.values(i),2===i.length)d=parseFloat(i[0])||0,m=parseFloat(i[1])||0;else if(1===i.length)return void(n&&n.setAttribute("load",i[0]))}return{capacity:d,maxCapacity:m}}_setCellHistogram(e){const{load:t,cell:i,maxCapacity:n,previousViewCell:a}=e,s=Math.min(100,100*parseFloat((t/n).toFixed(2))),r=a?a.firstElementChild:void 0;if(r){const e=parseFloat(r.style.height)||0;s?e===s?(i.classList.add("hide-left-border"),r.classList.add("hide-right-border")):e>s?(i.classList.add("hide-left-border"),r.classList.remove("hide-right-border")):e<s&&(i.classList.remove("hide-left-border"),r.classList.add("hide-right-border")):(i.classList.remove("hide-left-border"),r.classList.remove("hide-right-border"))}i.style.height=s+"%",t&&i.setAttribute("load",t+"/"+n)}_recycleResourceHeaderCells(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e.$.resourceTimelineViewCells,i=t.children,n=e.$.timelineViewCells.children;let a=document.createDocumentFragment();for(;i.length>n.length;)i[0].remove();for(let e=0;e<n.length;e++){const t=n[e];let s=i[e];s||(s=t.cloneNode(!0),a.appendChild(s)),s.style.left=t.style.left,s.style.right=t.style.right,s.style.width=t.style.width,s.innerHTML=t.innerHTML,s._date=t._date,t.hasAttribute("weekend")?s.setAttribute("weekend",""):s.removeAttribute("weekend"),t.hasAttribute("nonworking")?s.setAttribute("nonworking",""):s.removeAttribute("nonworking")}a.childElementCount&&t.appendChild(a),e.$.resourceTimelineCellsContainer.style.width=e.$.resourceTimelineViewCells.style.width=e.$.timelineContent.style.width}_refreshResourceScrollBar(){const e=this,t=e.$.resourceVerticalScrollBar;if(!e.$.mainSplitter.contains(e.$.resourceSplitter))return;const i=Math.max(0,e.$.resourceTimelineCellsContainer.offsetHeight-e.$.resourceTimelineContent.offsetHeight);0===i&&"visible"===e.verticalScrollBarVisibility?(t.max=1,e.scrollHeight||e.$container.removeClass("vscroll")):i&&e.$container.addClass("vscroll"),t.max=i,t.disabled="disabled"===e.verticalScrollBarVisibility||e.disabled||i<=0,!e.$.container.classList.contains("vscroll")&&t.disabled?t.classList.add("smart-hidden"):(t.classList.remove("smart-hidden"),t.refresh(),e.$.container.classList.contains("hscroll")?e.$.horizontalScrollBar.classList.add("bottom-corner"):e.$.container.classList.contains("vscroll")||e.$.horizontalScrollBar.classList.remove("bottom-corner"))}_handleResources(e){const t=this,i=e?[e]:t._tasks;t._resources||(t._resources=[]);for(let e=0;e<i.length;e++){let n=i[e].resources;Array.isArray(n)||(n=[n].reduce(((e,t)=>e.concat(t)),[]));for(let a=0;a<n.length;a++){let s=n[a];if("object"!=typeof s||!s||void 0===s.id||null===s.id){"number"==typeof s&&(n[a]=s+"");continue}let r=t._resources.find((e=>e.id&&e.id.toString()===s.id.toString()))||{};t._setResource(r,s,i[e]),n[a]=r.id,Object.values(r).length&&!t._resources.includes(r)&&t._resources.push(r)}}t._refreshItemIds("resource");const n=t._resources;for(let e=0,i=n.length;e<i;e+=1)t._refreshResource(n[e])}_refreshAssignedResources(e,t=[]){const i=this;if(!e.$.id||i._tasks.indexOf(e)<0)return;const n=i._getTaskResources(e);for(let e=0;e<n.length;e++){const a=n[e];let s=[];i.resourceColumns.forEach((e=>{void 0!==e.formatFunction&&s.push(e.value)})),s.concat(t),i.$.mainSplitter.contains(i.$.resourceSplitter)&&i._refreshResourceTimelineContent(a),t.includes("workload")?i._refreshResource(a,"workload"):t.includes("progress")&&i._refreshResource(a,"progress"),s.length&&i._refreshTableColumnsData(a,s,"resource")}}_refreshResource(e,t){const i=this;if(!i._resources.length)return;const n=i._getResourceTasks(e),a=864e5;switch(t){case"progress":e.progress=parseFloat((n.reduce(((e,t)=>e+t.progress),0)/n.length).toFixed(2));break;case"workload":e.workload=parseFloat((i._convertDuration(n.reduce(((e,t)=>e+t.duration),0))/a*e.maxCapacity).toFixed(2));break;default:e.progress=parseFloat((n.reduce(((e,t)=>e+t.progress),0)/n.length).toFixed(2)),e.workload=parseFloat((i._convertDuration(n.reduce(((e,t)=>e+t.duration),0))/a*e.maxCapacity).toFixed(2))}i.$.mainSplitter.contains(i.$.resourceSplitter)&&i._refreshResourceTimelineContent(e)}_setResource(e,t){if(t&&"object"==typeof t)return e.id?e.id=e.id.trim():e.id=(t.id+"").trim(),e.$||(e.$={}),e.class=t.class||e.class,e.minCapacity=t.minCapacity||e.minCapacity||0,e.maxCapacity=t.maxCapacity||e.maxCapacity||24,e.progress=t.progress||e.progress||0,e.capacity=t.capacity||e.capacity||8,e.type=t.type||e.type,e.hidden=!!("boolean"==typeof t.hidden?t.hidden:e.hidden),e.workload=e.workload||0,t.label?e.label=t.label:void 0===e.label&&(e.label=""),t.value&&(e.value=t.value),e}insertResource(e,t){const i=this,n=Array.from(arguments).filter((e=>void 0!==e));let a,s=i._resources;if(1===n.length&&(t=n[0]),"object"!=typeof t)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"insertResources",argumentName:"resource"}));if(t.id&&s.find((e=>e.id&&e.id.toString()===t.id.toString())))return void i.updateResource(t.id,t);if(t.assignedTo&&(a=[t.assignedTo].reduce(((e,t)=>e.concat(t,[])))),!(t=i._setResource({},t)))return;i._refreshItemIds("resource"),s=i._resources;const r=i._getValidItemAndIndex(e,"resource").index;if(r<0?s.push(t):s.splice(r,0,t),i._tasks.length){if(void 0!==a){Array.isArray(a)||(a=[a]);for(let e=0,n=a.length;e<n;e+=1){const n=i._getValidItemAndIndex(a[e],"task");if(n){const e=n.item;!e||e.disableResources||e.resources.includes(t.id.toString())||e.resources.push(t.id)}}if(i._isUpdating)return void(i._isUpdating.type.resource=!0);i._highlightAssignedItem("task",i._getSelection("task",i.selectedTaskIds)),i._refreshResource(t)}if(i._isUpdating)return i._isUpdating.type.resource=!0,void(i._isUpdating.type.task=!0);if(i.groupByResources)i._refreshTableDataSource(),i._refreshTimeline();else if(i.taskColumns.find((e=>"resources"===e.value))){const e=i._tasks.filter((e=>e.resources.includes(t.id)));for(let t=0;t<e.length;t++)i._refreshTableColumnsData(e[t],["resources"])}}i._isUpdating?i._isUpdating.type.resource=!0:(i._createResourceTimeline(),i.$.fireEvent("itemInsert",{type:"resource",item:i._cloneObject(t)}))}_insertTimelineResource(e,t,i){const n=this,a=n.$.resourceTimelineCellsContainer,s=document.createElement("div");s.classList.add("smart-timeline-row"),s._resource=t,n._refreshResourceTimelineContent(t,s),n.$.resourceTimelineCellsContainer.insertBefore(s,e>-1?a.children[e]:void 0),n.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",a.offsetHeight+"px"),n._refreshResourceScrollBar(),n._insertNewTreeItem(e,t,i,"resource"),n.$.resourceTree.refresh(),n._highlightAssignedItem("task",n._getSelection("task",n.selectedTaskIds))}updateResource(e,t){if(void 0===e)return;const i=this._getValidItemAndIndex(e,"resource");i&&i.item&&this._updateResource(i.item,t)}removeResource(e){if(void 0===e)return;const t=this._getValidItemAndIndex(e,"resource");t&&t.item&&this._removeResource(t.item)}_getResourceTasks(e){const t=this._resources,i=this._tasks;if(!e||!t.length||!i.length)return;let n=[];for(let t=0;t<i.length;t++)i[t].resources.includes(e.id)&&n.push(i[t]);return n}_getTaskResources(e){const t=this;if(!e)return[];const i=[e.resources].reduce(((e,t)=>e.concat(t)),[]);let n=[];for(let e=0;e<i.length;e++){const a=t._resources.find((t=>t.id&&t.id.toString()===i[e].toString()));a&&n.push(a)}return n}_resourceValidator(e,t){const i=this;return Array.isArray(t)||t instanceof Smart.ObservableArray||"number"==typeof t||"string"==typeof t||null==t?t:(i.error(i.localize("invalidValue",{elementType:i.nodeName.toLowerCase(),property:"resources",typeOne:"array",typeTwo:"number"})),null)}_handleTaskProgressChange(e){const t=this,i=t._dragDetails.task,n=t._dragDetails.timelineTask;if(t.disableTaskProgressChange)return;if(!t.hasAttribute("progress-change")){if(t.$.fireEvent("progressChangeStart",{id:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,item:t._cloneObject(i),progress:i.progress||0}).defaultPrevented)return void delete t._dragDetails.target;t._closeTooltip(),t.setAttribute("progress-change",""),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}const{left:a,width:s}=n.getBoundingClientRect(),r=e.pageX-window.pageXOffset;t._dragDetails.progress||(t._dragDetails.progress=i.progress/100*s),t._dragDetails.progress=Math.max(0,Math.min(s,t._dragDetails.progress+(t.rightToLeft?-1:1)*(r-t._dragDetails.coordinates.x))),t._dragDetails.coordinates.x=Math.max(a+t._dragDetails.offset.x,Math.min(a+s+t._dragDetails.offset.x,r));const o=t._dragDetails.task.progress=t._dragDetails.progress/s*100;i.progress=parseFloat(o.toFixed(2)),t._setTaskBarProgress(i,n),t._refreshTableColumnsData(i,["progress"]),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(i,["progress"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleTaskSegmentDrag(e){const t=this,i=t._dragDetails,n=i.segment,a=n.element,s=a._segmentObj;if(!s||s.disableDrag)return;const r=i.task,o=t._dragDetails.timelineTask,l=n.isFirstSegment,c=n.isLastSegment,d=t.rightToLeft,m=d?"right":"left";i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===r)));const u=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{id:"string"==typeof r.id||"number"==typeof r.id?r.id:r.$.id,item:t._cloneObject(r),dateStart:r.dateStart,dateEnd:r.dateEnd,segment:t._cloneObject(s)}).defaultPrevented)return void delete i.timelineTask;if(t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0,l||c){const e=t._createDelimiter("min-date"),i=t._createDelimiter("max-date");e&&u.appendChild(e),i&&u.appendChild(i)}}if(l){const n=i.size?i.size.width:i.originalSize.width;t._handleTaskResize(e,d?"right":"left"),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const a=i.size.width-n,s=i.segments;for(let e=0,t=s.length;e<t;e+=1){const t=s[e];0!==e&&(t.style[m]=(parseFloat(t.style[m])||t.offsetLeft)+a+"px")}}else{if(!c)return void t._handleSegmentDrag(e);{const s=n.dimensions;t._handleTaskResize(e,d?"left":"right"),a.style[m]=i.size.width-s.width+"px"}}t._refreshTask(o,[a]),t._refreshProject(r.$.project),t.groupByResources&&t._refreshProject(r.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(o._cellObj.task),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleSegmentDrag(e){const t=this,i=t._dragDetails,n=i.segment,a=n.element,s=i.task,r=t._dragDetails.timelineTask,o=t.rightToLeft,l=o?"right":"left";i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===s)));const c=i.timelineRow,{left:d}=c.getBoundingClientRect(),m=i.taskDimensions.left;n.position||(n.position={x:n.originalPosition.x});const u=r.offsetWidth,h=e.pageX-window.pageXOffset;let g=0,f=n.min.left||0,p=n.max.left;o&&(f=u-(f+n.dimensions.width),p=u-p),n.position.x=Math.max(f,Math.min(p,n.position.x+(o?-1:1)*(h-i.coordinates.x))),void 0!==p&&(g=o?m+n.min.left:m+n.max.left,n.position.x=Math.min(p,n.position.x)),f=m+(o?n.max.left-n.dimensions.width:f),i.coordinates.x=Math.max(d+n.offset.x+f,Math.min(d+n.offset.x+g,h)),a.style[l]=n.position.x+"px",t._refreshTaskSegments(r,[a])}_handleTaskBarDrag(e){const t=this;if(t.disableTaskDrag)return;const i=t._dragDetails;if(Math.abs(e.pageX-i.coordinates.x)<=5)return void(t._scrollView.disableSwipeScroll=!0);if(i.segment)return void t._handleTaskSegmentDrag(e);const n=i.task,a=i.timelineTask;i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const s=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:n.dateStart,dateEnd:n.dateEnd}).defaultPrevented)return void delete i.timelineTask;t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0;const e=t._createDelimiter("min-date"),a=t._createDelimiter("max-date");e&&s.appendChild(e),a&&s.appendChild(a)}i.position||(i.position={x:i.originalPosition.x,y:i.originalPosition.y});const r=s.getBoundingClientRect().left,o=s.offsetWidth,l=a.offsetWidth,c=i.min.left||0,d=i.max.left,m=e.pageX-window.pageXOffset,u=t.rightToLeft;let h=0;i.position.x=Math.max(c,Math.min(o-l,i.position.x+(u?-1:1)*(m-i.coordinates.x))),void 0!==d&&(i.position.x=Math.min(d,i.position.x),h=o-l-d),i.coordinates.x=u?Math.max(r+i.offset.x+h,Math.min(r+o-(l-i.offset.x+c),m)):Math.max(r+i.offset.x+c,Math.min(r+o-(l-i.offset.x+h),m));const g=n.dateStart.getTime(),f=n.dateEnd.getTime();a.style[u?"right":"left"]=i.position.x+"px",t._refreshTask(a),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),"project"===n.type&&n.dragProject&&t._refreshProjectTasks(n,{startTime:n.dateStart.getTime()-g,endTime:n.dateEnd.getTime()-f}),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(a._cellObj.task),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleTaskBarResize(e){const t=this;if(t.disableTaskResize)return;const i=t._dragDetails;if(i.segment)return void t._handleTaskSegmentResize(e);const n=i.timelineTask,a=i.task;if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),dateStart:a.dateStart,dateEnd:a.dateEnd}).defaultPrevented)return void t.$.timeline.removeAttribute("task-bar-hovered");t.setAttribute("resized",""),t._closeTooltip(),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}t._handleTaskResize(e,t.$.timeline.getAttribute("task-bar-hovered")),t._updateSegmentsOnTaskResize(),t._refreshTask(n),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(n._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_updateSegmentsOnTaskResize(){const e=this,t=e._dragDetails,i=t.task,n=t.timelineTask;if(!i||!i.segments)return;let a;t&&t.segments?a=t.segments:t.segments=a=n.querySelectorAll(".smart-task-segment");const s=a.length,r=t.size.width,o=e.rightToLeft?"right":"left";for(let t=0;t<s;t+=1){const i=a[t],n=i.style.width?parseFloat(i.style.width):i.offsetWidth,l=i.style[o]?parseFloat(i.style[o]):0;if(l+n>r){const t=r-(l+n),a=n+t;a<e._taskBarMinWidth&&(i.style[o]=l+t+"px"),i.style.width=a+"px"}else t===s-1&&(i.style.width=r-l+"px")}}_handleTaskSegmentResize(e){const t=this,i=t._dragDetails,n=i.segment,a=n.element,s=a._segmentObj;if(!s||s.disableResize)return;const r=i.task,o=t._dragDetails.timelineTask,l=n.isFirstSegment,c=n.isLastSegment,d=t.rightToLeft,m=d?"right":"left";if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{id:"string"==typeof r.id||"number"==typeof r.id?r.id:r.$.id,item:t._cloneObject(r),dateStart:r.dateStart,dateEnd:r.dateEnd,segment:t._cloneObject(s)}).defaultPrevented)return void t.$.timeline.removeAttribute("task-bar-hovered");t.setAttribute("resized",""),t._closeTooltip(),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}const u=t.$.timeline.getAttribute("task-bar-hovered");if(l&&("left"===u&&!d||"right"===u&&d)){const s=i.size?i.size.width:i.originalSize.width;void 0===n.size&&(n.size={width:n.originalSize.width}),t._handleTaskResize(e,u),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const r=i.size.width-s,l=i.segments;for(let e=0,t=l.length;e<t;e+=1){const t=l[e];0!==e&&(t.style[m]=(parseFloat(t.style[m])||t.offsetLeft)+r+"px")}a.style.width=(n.size.width+=r)+"px"}else{if(!c||!("right"===u&&!d||"left"===u&&d))return t._handleSegmentResize(e,u),void t._refreshTaskSegments(o,[a]);{const s=i.size?i.size.width:i.originalSize.width;void 0===n.size&&(n.size={width:n.originalSize.width}),t._handleTaskResize(e,u),a.style.width=(n.size.width+=i.size.width-s)+"px"}}t._refreshTask(o,[a]),t._refreshProject(r.$.project),t.groupByResources&&t._refreshProject(r.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(o._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleSegmentResize(e,t){const i=this,n=i._dragDetails,a=n.task,s=n.segment,r=s.element,o=i.rightToLeft,l=n.taskDimensions.left;n.timelineRow||(n.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===a)));const c=n.timelineRow;s.position||(s.position={x:s.originalPosition.x}),s.size||(s.size={width:s.originalSize.width});const d=e.pageX-window.pageXOffset;let m=s.size.width,u=s.min.width||0,h=s.max.width,g=s.min.left||0,f=s.max.left,p=r.offsetLeft,{left:_}=c.getBoundingClientRect(),T="object"==typeof e?d-n.coordinates.x:e;if(_+=l,"left"===t&&!o||"right"===t&&o)if(o){const e=n.taskDimensions.width;T=T<0?-1*Math.min(Math.abs(T),m-u):Math.min(h-m,Math.abs(T)),m=Math.max(u,Math.min(h,m+T)),r.style.left="",r.style.right=(p=Math.max(e-g,(parseFloat(r.style.right)||c.offsetWidth-p-m)-T))+"px",n.coordinates.x=Math.max(_+e-p+u,Math.min(_+e-p,d))}else T=T>0?Math.min(T,m-(u||0)):-1*Math.min(h-m,Math.abs(T)),m=Math.max(u,Math.min(p+m,m-T)),r.style.right="",r.style.left=(p=Math.max(g,(parseFloat(r.style.left)||p)+T))+"px",n.coordinates.x=Math.max(_+g+u,Math.min(_+p+m-u,d));else o?(T<0&&(T=-1*Math.min(h-m,Math.abs(T))),m=Math.max(u,Math.min(p+m,m-T)),f-=s.dimensions.width,n.coordinates.x=Math.max(_+f,Math.min(_+f+h,d))):(T>0&&(T=Math.min(h-m,T)),m=Math.max(u,Math.min(h,m+T)),n.coordinates.x=Math.max(_+p+u,Math.min(_+p+h,d)));r.style.width=(s.size.width=m)+"px"}_handleTaskResize(e,t){const i=this,n=i._dragDetails,a=n.task;n.position||(n.position={x:n.originalPosition.x,y:n.originalPosition.y}),n.size||(n.size={width:n.originalSize.width}),n.timelineRow||(n.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===a)));const s=n.timelineRow,r=n.timelineTask,o=n.segment,l=e.pageX-window.pageXOffset;let c=n.size.width,d=n.min.width||0,m=n.max.width,u=s.getBoundingClientRect().left,h=i.rightToLeft,g="object"==typeof e?l-n.coordinates.x:e;if("left"===t&&!h||"right"===t&&h)if(o&&(h?(u-=o.dimensions.width-o.offset.x,d=Math.max(o.max.left+o.min.width,d)):(u+=o.offset.x,d=Math.max(n.taskDimensions.width-o.max.left+o.min.width,d))),h){g<0?g=-1*Math.min(Math.abs(g),c-(d||0)):void 0!==m&&(g=Math.min(m-c,Math.abs(g))),c=n.size.width=Math.max(d,Math.min(s.offsetWidth-r.offsetLeft,c+g));const e=r.offsetLeft;r.style.left="",r.style.right=(n.position.x=Math.max(0,(parseFloat(r.style.right)||s.offsetWidth-r.offsetLeft-r.offsetWidth)-g))+"px",n.coordinates.x=Math.max(u+r.offsetLeft+d,Math.min(u+e+c,l))}else g>0?g=Math.min(g,c-(d||0)):void 0!==m&&(g=-1*Math.min(m-c,Math.abs(g))),c=n.size.width=Math.max(d,Math.min(r.offsetLeft+c,c-g)),r.style.right="",r.style.left=(n.position.x=Math.max(0,(parseFloat(r.style.left)||r.offsetLeft)+g))+"px",n.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+c-d,l));else h?(o&&(u+=o.offset.x,d=Math.max(n.taskDimensions.width-o.min.left+o.min.width,d)),g<0&&void 0!==m&&(g=-1*Math.min(m-c,Math.abs(g))),c=n.size.width=Math.max(d,Math.min(r.offsetLeft+r.offsetWidth,c-g)),r.style.width=n.size.width+"px",n.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+c-d,l))):(o&&(u-=o.dimensions.width-o.offset.x,d=Math.max(o.min.left+o.min.width,d)),g>0&&void 0!==m&&(g=Math.min(m-c,g)),c=n.size.width=Math.max(d,Math.min(s.offsetWidth-r.offsetLeft,c+g)),n.coordinates.x=Math.max(u+r.offsetLeft+d,Math.min(u+r.offsetLeft+(m||c),l)));r.style.width=n.size.width+"px"}_handleTimelineConnectionHover(e){const t=this;if(!(t.shadowRoot||t).contains(e))return;const i=t.$.timelineConnectionsContainer.children,n=e.closest(".smart-task-connection");if(n||!t.$.timelineConnectionsContainer.querySelector(".smart-task-connection[hover]")){if(n){const e=n.getAttribute("connection-id");for(let t=0;t<i.length;t++){const n=i[t];n.getAttribute("connection-id")===e?n.setAttribute("hover",""):n.removeAttribute("hover")}t._hoveredConnectionTasks=n.tasks}}else for(let e=0;e<i.length;e++)i[e].removeAttribute("hover")}_resetItemHover(){const e=this;if(e._hoveredItem){const t=e.$.mainSplitter.querySelectorAll(".smart-timeline-task[hover], .smart-timeline-row[hover], tr[hover]");for(let e=0;e<t.length;e++)t[e].removeAttribute("hover");e.$.timeline.removeAttribute("task-bar-hovered"),delete e._hoveredItem}}_handleTimelineHover(e,t){const i=this,n=i._isMobile;if(!e||n)return void i._resetItemHover();const a=e.originalEvent||e;let s="task",r=a.pageX&&n?document.elementFromPoint(a.pageX-window.pageXOffset,a.pageY-window.pageYOffset):a.target;if(a.pageX&&i.shadowRoot&&r===i&&(r=a.pageX&&n?i.shadowRoot.elementFromPoint(a.pageX-window.pageXOffset,a.pageY-window.pageYOffset):a.composedPath()[0]),!r||!r.closest||r===i||t)return void i._resetItemHover();i.$.resourceSplitter&&i.$.resourceSplitter.contains(r)?s="resource":i._handleTimelineConnectionHover(r);let o=r.closest(".smart-timeline-row")||r.closest(".smart-timeline-task");if(!o||!(i.shadowRoot||i).contains(o))return void i._resetItemHover();const l=o._cellObj[s],c=l.$.id,d=i._hoveredItem;if(!(d&&d.type===s&&d.id===c||(i._resetItemHover(),l.isGroup||("task"===s&&o.classList.contains("smart-timeline-row")&&(o=i.$.timelineTasksContainer.querySelector(`.smart-timeline-task[row-id="${c}"]`)),!o||i._connectionFeedback&&o.contains(i._connectionFeedback)||(o.setAttribute("hover",""),i._hoveredItem={id:c,type:s},n))))){const e=("task"===s?i.$.taskTimelineCellsContainer:i.$.resourceTimelineCellsContainer).querySelector(`.smart-timeline-row[row-id="${c}"]`);e&&(e.setAttribute("hover",""),i._handleTableItemHover(c,r))}}_getScrollLeft(e){return this.rightToLeft?e*=-1:e}_synchronizeSplitters(e,t){if(this.$.mainSplitter.contains(this.$.resourceSplitter)){const i=e._measurements,n=e.items,a=t.items,[s,r,o]=[i.dimension,i.minDimension,i.maxDimension],[l,c]=[a[0],n[0]],[d,m]=[a[1],n[1]];t.keepProportionsOnResize=!0,t.setAttribute("orientation-change",""),[r,o,s].forEach((e=>{const t=e===s?"size":e===r?"min":"max";l.set(t,""),d.set(t,""),l[t]=c.style[e],d[t]=m.style[e]})),t.removeAttribute("orientation-change"),t.keepProportionsOnResize=!1}}_resizeEventHandler(e){const t=this,i=t.$.taskSplitter;function n(e){e.refresh(),e===i&&t._synchronizeSplitters(i,t.$.resourceSplitter)}if(e&&"resizeEnd"===e.type){if(e.target===t.$.taskTreeSplitter||e.target===t.$.resourceTreeSplitter)return void n(e.target);e.target===t.$.resourceSplitter&&t._synchronizeSplitters(t.$.resourceSplitter,i)}if(!t._timelineCells)return void t._refresh();t.$.mainSplitter.refresh(),n(i);const a=t._getScrollLeft(t.scrollLeft);t._autoSchedule(),t._createTimelineCells(),t._recycleTimelineTasks(),t._recycleTimelineRowCells(),t._refreshResourceTimeline(),t._refresh(),t.$.taskTable.refresh(),t.$.timelineHeader.scrollLeft=t.$.taskTimelineContainer.scrollLeft=a,t.$.taskTable.scrollTop=t.$.taskTimelineContainer.scrollTop=t.scrollTop,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=a,t.$.resourceTable.refresh(),t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=t.$.resourceVerticalScrollBar.value),t._positionWindow()}_recycle(e){const t=this,i=e&&"horizontal"===e.context.orientation;if(e&&!i||(t._recycleHeaderCells(t.$.timelineViewCells),t._recycleHeaderCells(t.$.timelineViewDetails),t._recycleResourceContent()),i)return;if(t._recycleResourceContent(),t._recycleContentCells(),t._recycleTimelineTasks(),!e)return;const n=Math.round(e.detail.value);e.target!==t.$.resourceVerticalScrollBar?t._refreshTableScrollTop(t.$.taskTable,n):t._refreshTableScrollTop(t.$.resourceTable,n)}_recycleContentCells(){const e=this,t=e._getFirstContentCellInView(),i=e.$.taskTimelineCellsContainer,n=e.$.timelineTasksContainer;if(!t)return void(i.innerHTML=n.innerHTML="");const a=t.height,s=1-(t.top+a-Math.abs(e.scrollTop))/a,r=e._timelineVCells?e._timelineVCells.length:0,o=!e.$.taskSplitter.offsetHeight,l=e.$.taskTimelineContainer.offsetHeight,c=!o&&l?Math.min(r,Math.ceil((parseFloat((l/a).toFixed(2))+s).toFixed(2))):r,d=e.$.timelineViewCells.children,m=document.createDocumentFragment();for(;i.childElementCount>c;)i.lastElementChild.remove();for(;n.childElementCount>c;)n.lastElementChild.remove();for(let t=i.childElementCount;t<c;t+=1){const t=document.createElement("div");t.classList.add("smart-timeline-row"),e._createTimelineRowCells(t,d),m.appendChild(t)}m.childElementCount&&i.appendChild(m);for(let e=n.childElementCount;e<c;e+=1){const e=document.createElement("div");e.classList.add("smart-timeline-task"),m.appendChild(e)}m.childElementCount&&n.appendChild(m)}_getCellIndexByDate(e){const t=this._timelineCells;let i=[];if(e&&e.length&&t){Array.isArray(e)||(e=[e]);for(let t=0,n=e.length;t<n;t+=1){const n=e[t];e[t]=n.getTime?n.getTime():n,i[t]=-1}for(let n=0,a=t.length;n<a;n+=1){const a=t[n],s=e.indexOf(a.date.getTime());if(s>-1&&(i[s]=n,i.every((e=>-1!==e))))break}return 1===i.length?i[0]:i}}_recycleDateMarkers(){const e=this,t=e.$.timelineMarkers,i=e._markers;if(!i||e.hideDateMarkers)return void(t.childElementCount&&(t.innerHTML=""));const n=e.$.timelineViewCells.children,a=n[0]._date,s=n[n.length-1]._date,[r,o]=e._getCellIndexByDate([a,s]);if(!a||!s)return;const l=a.getTime(),c=e._getCellDateRange({_date:s}).dateEnd.getTime(),d=t.children,[m,u]=e.rightToLeft?["right","left"]:["left","right"],h=document.createDocumentFragment();let g=0;for(let t=0,n=i.length;t<n;t+=1){const n=i[t],a=i[t].date,s=a.getTime();if(s<l||s>c)continue;const f=e._getTimelineCellByDate(a,r,o);if(f){const t=f.left+e._getTimelineTaskOffset(f,a),i=n.label,s=n.className;let r=d[g];r||(r=document.createElement("div"),h.appendChild(r)),r.className="smart-gantt-chart-date-marker",void 0!==i&&(r.firstElementChild||(r.innerHTML='<div class="smart-gantt-chart-marker-label"></div>'),r.firstElementChild.textContent=i+""),void 0!==s&&r.classList.add(s),r.style[u]="",r.style[m]=t+"px",g++}}for(h.childElementCount&&t.insertBefore(h,t.firstElementChild);d.length>g;)d[d.length-1].remove()}_refreshTableScrollTop(e,t){this.$.mainSplitter.contains(e)&&void 0!==t&&(e.scrollTop=t)}_recycleHeaderCells(e){const t=this,i=e.children,n=t.scrollLeft,a=e===t.$.timelineViewCells,s=a?t._timelineCells:t._timelineHeaderCells;if(!s.length)return;let r=document.createDocumentFragment();for(;i.length;)r.appendChild(e.firstElementChild);const o=t._getFirstCellObjInView(s),l=1-(o.left+o.width-Math.abs(n))/s[0].width,c=r.children.length,d=a?Math.ceil((parseFloat((t.$.timeline.offsetWidth/o.width).toFixed(2))+l).toFixed(2)):t._getHeaderVisibleCellsCount();if(c>d)for(;r.children.length&&r.children.length!==d;)r.removeChild(r.firstElementChild);else if(c<d){const e=t._createCells(d-c);for(;e.children.length;)r.appendChild(e.firstElementChild)}const m=[t.rightToLeft?"right":"left"],u=a?t._getCellsViewType():t.view;let h=s.indexOf(o);for(let e=0;e<r.children.length;e++){const i=r.children[e],n=s[h];if(!n)break;let o=new Date(n.date);a||"week"!==t.view||(o.setDate(o.getDate()-o.getDay()),o=new Date(Math.max(n.date.getTime(),o.getTime()))),i.style[m]=n.left+"px",i.style.width=n.width+"px",i._date=o,i.innerHTML=`<div>${t._getDateString(o,u,!a)}</div>`,n.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),n.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),h++}e.appendChild(r),a&&(t._recycleTimelineRowCells(),t._recycleResourceHeaderCells(),t._recycleDateMarkers(),t._setTodayCell())}_refresh(){const e=this;let t="disabled"===e.verticalScrollBarVisibility;function i(){const t=e.$.timelineHeader,i=t.scrollWidth-t.offsetWidth;return i>0&&"hidden"!==e.horizontalScrollBarVisibility||"visible"===e.horizontalScrollBarVisibility?e.$container.addClass("hscroll"):e.$container.removeClass("hscroll"),i}function n(){let i=Math.max(0,e.$.timelineContent.offsetHeight-e.$.taskTimelineContainer.offsetHeight);return i>0&&"hidden"!==e.verticalScrollBarVisibility||"visible"===e.verticalScrollBarVisibility?e.$container.addClass("vscroll"):e.$.mainSplitter.contains(e.$.resourceSplitter)?(i=1,t=!0,e.$.resourceVerticalScrollBar.max||e.$container.removeClass("vscroll")):e.$container.removeClass("vscroll"),i}const a=e.scrollWidth,s=e.scrollHeight;let r=i(),o=n();o&&s===o||(r=i()),r&&a===r||(o=n()),e.scrollWidth=r,e.scrollHeight=o,e.$.verticalScrollBar.disabled=t,e.$.horizontalScrollBar.refresh(),e.$.verticalScrollBar.refresh(),e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._refreshResourceScrollBar(),e._refreshTableScrollTop(e.$.resourceTable))}_refreshProjectTasks(e,t){const i=this,n=i._getProjectTasks(e);if(!n.length)return;const a=i.nonworkingDays,s=i.nonworkingHours,r=i._timelineVCells;for(let e=0,o=n.length;e<o;e++){const o=n[e];if(o){const e=i._getTaskDOMIndex(o),n=r[e],l=o.segments;if(o.dateStart=new Date(Math.max(i.dateStart.getTime(),o.dateStart.getTime()+t.startTime)),o.dateEnd=new Date(Math.min(i.dateEnd.getTime(),o.dateEnd.getTime()+t.endTime)),o.duration=i._convertDuration(a.length>0||s.length>0?i._getWorkingTime(o.dateStart,o.dateEnd):o.dateEnd.getTime()-o.dateStart.getTime(),!0),l&&l.length>1){for(let e=0,i=l.length;e<i;e+=1){const i=l[e];i.dateStart=new Date(i.dateStart.getTime()+t.startTime),i.dateEnd=new Date(i.dateEnd.getTime()+t.endTime)}i._validateTaskSegments(o)}n&&(i._recycleTaskBars(n,e),i._setTimelineTaskBar(n,e),l&&l.length>1&&i._setTaskBarProgress(o),i._refreshTaskConnections(o),i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"]))}}}_refreshProject(e){const t=this;function i(e){let i,n,a;if(e instanceof HTMLElement)i=e.offsetLeft,a=e.offsetWidth;else if(e){const s=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);s&&r&&(i=s.left+t._getTimelineTaskOffset(s,e.dateStart)||0,n=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0,a=n-i)}return[i,a]}if(!e)return;const n=t.groupByResources&&e.isGroup?"group":"project";if(e.synchronized)for(;e&&e.synchronized;){const a=t._getProjectTasks(e);let s=a[0],r=a[0];for(let e=0;e<a.length;e++)s.dateStart.getTime()>=a[e].dateStart.getTime()&&(s=a[e]),r.dateEnd.getTime()<=a[e].dateEnd.getTime()&&(r=a[e]);const o=t.$.timelineTasksContainer.children,l=t.$.timelineContent.offsetWidth;let c,d,m;for(let t=0,i=o.length;t<i;t+=1){const i=o[t],n=i._cellObj?i._cellObj.task:void 0;n&&(n===e?c=i:n===s?d=i:n===e&&(m=i))}if(!c){s&&(e.dateStart=s.dateStart),r&&(e.dateEnd=r.dateEnd),e=e.$[n];continue}s&&(e.dateStart=s.dateStart);let[u,h]=i(d||s);void 0!==u&&void 0!==h&&(t.rightToLeft?(c.style.width=c.offsetWidth-(l-u-h-(l-c.offsetLeft-c.offsetWidth))+"px",c.style.right=d?d.style.right:u+"px"):(c.style.width=c.offsetWidth-(u-c.offsetLeft)+"px",c.style.left=d?d.style.left:u+"px")),r&&(e.dateEnd=r.dateEnd),[u,h]=i(m||r),void 0!==u&&void 0!==h&&(t.rightToLeft?c.style.width=Math.max(0,c.offsetWidth-(l-c.offsetLeft-(l-u)))+"px":c.style.width=Math.max(0,c.offsetWidth-(c.offsetLeft+c.offsetWidth-(u+h)))+"px"),t._refreshTask(c),e=e.$[n]}else t._refreshProject(e.$[n])}_refreshTask(e,t){const i=this,n=i._getTaskBarCellRange(e),a=n.cellStart,s=n.cellEnd;if(!n||!a||!s)return;e._cellStart=a,e._cellEnd=s;const r=i._getTaskBarDateRange(e);if(!r)return;const o=e._cellObj.task;if(Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===o))){if(o.dateStart=r.dateStart,o.dateEnd=r.dateEnd,o.duration=o.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(o.dateStart,o.dateEnd):o.dateEnd.getTime()-o.dateStart.getTime(),!0),e.setAttribute("aria-label",o.label+" Start date: "+i._toISODate(o.dateStart)+", End date: "+i._toISODate(o.dateEnd)),i._refreshTaskConnections(e),t)Array.isArray(t)&&i._refreshTaskSegments(e,t);else{const t=i._dragDetails;let n;e.classList.contains("task")?t&&t.segments?n=t.segments:t.segments=n=e.querySelectorAll(".smart-task-segment"):n=e.querySelectorAll(".smart-task-segment"),i._refreshTaskSegments(e,n)}i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"])}}_refreshTaskSegments(e,t){const i=this,n=e._cellObj.task;if(!n||!n.segments||!n.segments.length)return void i._setTaskBarDeadline(n,t?t[0]:void 0);const a=i.nonworkingDays.length>0||i.nonworkingHours.length>0,s=i.rightToLeft,r=s?"right":"left",o=parseFloat(e.style[r])||e.offsetLeft;let l;for(let n=0,c=t.length;n<c;n+=1){const c=t[n],d=c._segmentObj,m=i._getSegmentCellRange(c),u=m.cellStart,h=m.cellEnd;if(!m||!u||!h)continue;const g=parseFloat(c.style.width)||c.offsetWidth,f=o+parseFloat(c.style[r])||(s?(parseFloat(e.style.width)||e.offsetWidth)-(c.offsetLeft+c.offsetWidth):c.offsetLeft);c._cellStart=u,c._cellEnd=h,l=c;let p=i._getDateFromCell(f,u),_=i._getDateFromCell(f+g,h);d.dateStart=p,d.dateEnd=_,d.duration=i._convertDuration(a?i._getWorkingTime(p,_):_.getTime()-p.getTime(),!0),e.setAttribute("aria-label",(d.label||"")+" Start date: "+i._toISODate(p)+", End date: "+i._toISODate(_))}i._setTaskBarProgress(n,e),i._setTaskBarDeadline(n,l)}_refreshTaskResources(e,t=[]){const i=this;if(e&&(t||(t=i._getTaskResources(e)),t.length))for(let e=0;e<t.length;e++){const n=t[e];i._refreshResource(n),i._refreshTableColumnsData(n,void 0,"resource")}}_refreshTableColumnsData(e,t,i){const n=this;if(i||(i="task"),!e)return;const a=n[`${i}Columns`],s=n.$[`${i}Table`];if(!n.$.mainSplitter.contains(s))return;const r=e.$.id;t=t?t.map((e=>a.find((t=>t.value===e)))):a;for(let i=0;i<t.length;i++){const a=t[i];a&&s.setValue(r,a.value,n._formatColumnData(e,a))}n.$[`${i}Splitter`].refresh()}_removeConnection(e,t){const i=this,n=i.$.connectionPopupWindow,a=i.$.timelineConnectionsContainer;if(e.classList&&e.classList.contains("smart-task-connection")?e=e.getAttribute("connection-id"):e+="",void 0===e)return;const s=a.querySelectorAll('.smart-task-connection[connection-id^="'+e+(e.indexOf("-")<0?"-":"")+'"]'),r=i._tasks,o=e.split("-"),l=parseInt(o[1]);for(let e=0;e<s.length;e++)a.removeChild(s[e]);let c;const d=parseInt(o[0]),m=parseInt(o[1]),u=parseInt(o[2]);if(n&&void 0!==n._target&&"number"==typeof n._target.type){const t=n._target;c=t.startIndex+"-"+t.endIndex+"-"+t.type===e}i._updateConnection([d,m,u],!0),!t&&i.autoSchedule&&(i._autoScheduleRestore(r[l],parseInt(o[2])),i._autoSchedule(r[l])),c&&i.$.fireEvent("itemRemove",{type:"connection",id:`${d}-${m}-${u}`,item:{source:d,target:m,type:u}})}_removeTaskConnections(e,t){const i=this,n=i._connections;if(n&&n.length){for(let t=0,i=n.length;t<i;t+=1)n[t].startTask===e&&(n.splice(t,1),i--);e.connections=[],t&&i._recycleConnections()}}_removeTask(e){const t=this,i=t._tasks;if(!e||!i||!i.length)return;const n=t._getSelection("task",t.selectedTaskIds),a=t.$.taskPopupWindow;let s;if(t._highlightAssignedItem("task",[e]),a&&a._target===e&&a.close(),"project"===e.type){const n=t._getProjectTasks(e);for(let e=0,t=n.length;e<t;e+=1)i.splice(i.indexOf(n[e]),1)}if(i.splice(i.indexOf(e),1),t._refreshItemIds(),t._refreshConnectionIds(),t._isUpdating)return t._isUpdating.type.task=!0,void(t._isUpdating.type.resource=!0);t._refreshSelectedItems(),t._refreshTableDataSource(),t._refreshTimeline(),t._selected&&t._selected.task&&(s=t._selected.task.map((e=>e.$.id)),n.toString()!==s.toString()&&(t.$.taskTable.selected=t._getSelection("task",t.selectedTaskIds))),t.$.fireEvent("itemRemove",{type:"task",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:t._cloneObject(e)})}_removeResource(e){const t=this,i=t._resources,n=i.indexOf(e);if(e&&!(n<0)){if(t._isUpdating)return i.splice(n,1),t._isUpdating.type.resource=!0,void(t._isUpdating.type.task=!0);if(i.splice(n,1),t.groupByResources)t._refreshTableDataSource(),t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks();else if(t.taskColumns.find((e=>"resources"===e.value))){const i=t._tasks.filter((t=>t.resources.includes(e.id)));for(let e=0;e<i.length;e++)t._refreshTableColumnsData(i[e],["resources"])}if(!i.filter((e=>!e.hidden)).length)return t._createResourceTimeline(),t._resizeEventHandler(),void a();t._refreshResourceTimeline(),t._refreshTableDataSource("resource"),t.$.mainSplitter.contains(t.$.resourceSplitter)?(t._refreshResourceScrollBar(),t._resizeEventHandler(),a()):a()}function a(){t.$.fireEvent("itemRemove",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:t._cloneObject(e)})}}_updateTask(e,t){const i=this,n=i._tasks;if(!e||!n||!n.length)return;const a=i.$.taskPopupWindow,s=i._getSelection("task",i.selectedTaskIds);a&&a._target===e&&a.close();let r,o=i._getTaskResources(e);for(let a in t){let s=e[a],l=t[a];if("type"===a&&s!==l&&["task","project","milestone"].indexOf(l)>-1&&"project"===s){const t=i._getProjectTasks(e);for(let e=0,i=t.length;e<i;e+=1)n.splice(n.indexOf(t[e]),1);delete e.tasks}if("project"!==e.type||!e.synchronized||!(a.toLowerCase().indexOf("date")>-1||a.toLowerCase().indexOf("duration")>-1))if("dateEnd"===a&&new Date(s).getTime()!==new Date(l).getTime()&&(r=!0),"tasks"!==a)"connections"===a&&(i._removeTaskConnections(e),i._handleTaskConnections(e)),e[a]=l,"resources"===a&&(i._handleResources(e),e.disableResources||(o=o.concat(i._getTaskResources(e)),o=o.filter(((e,t)=>o.indexOf(e)===t)))),"milestone"!==e.type||"dateStart"!==a&&"dateEnd"!==a||(e.dateEnd=e.dateStart=l);else if("project"===e.type){const t=i._getProjectTasks(e);for(let e=0,i=t.length;e<i;e+=1)n.splice(n.indexOf(t[e]),1);const a=i._createTasks(l,!0);for(let t=0,i=a.length;t<i;t+=1)a[t].$.project=e;i._insertTasks(a,e,n.indexOf(e))}}r&&delete e.duration;const l=e.$,c=e.$.project;if(i._validateTaskProperties(e,c),e.$=l,c&&i._synchronizeProjectDates(c),"project"===e.type&&e.hidden&&i._getProjectTasks(e).forEach((t=>t.hidden=e.hidden)),i._synchronizeProjectVisibility(e.$.project,e),i._refreshItemIds(),i._refreshConnectionIds(),i._isUpdating)return void(i._isUpdating.type.task=!0);let d;i._selected&&i._selected.task&&i._setSelection("task",d=i._selected.task.map((e=>e.$.id))),i._refreshTableDataSource(),i._refreshTimeline(),i._ensureVisible(e),d&&s.toString()!==d.toString()&&(i.$.taskTable.selected=d.slice(0)),i._refreshTaskResources(e,o),i._highlightAssignedItem("task",i._getSelection("task",i.selectedTaskIds)),i.$.fireEvent("itemUpdate",{type:"task",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)})}_updateResource(e,t){const i=this;if(!e)return;const n=e.hidden;if(i._setResource(e,t),i._isUpdating)i._isUpdating.type.resource=!0;else{if(i.groupByResources)i._refreshTableDataSource(),i._refreshTimeline();else if(i.taskColumns.find((e=>"resources"===e.value))){const t=i._tasks.filter((t=>t.resources.includes(e.id)));for(let e=0;e<t.length;e++)i._refreshTableColumnsData(t[e],["resources"])}if(n!==e.hidden)return i._createResourceTimeline(),void i.$.fireEvent("itemUpdate",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)});if(i._refreshTableColumnsData(e,void 0,"resource"),i.$.mainSplitter.contains(i.$.resourceTimelineCellsContainer)){const t=i.$.resourceTimelineCellsContainer.children;for(let n=0;n<t.length;n++){const a=t[n];a._resource===e&&i._refreshResourceTimelineContent(e,a)}}i.$.fireEvent("itemUpdate",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)})}}_select(e="task",t){const i=this;if(i.disableSelection||!t)return void i._unselectAll(e);let n,a;"task"===e?(n="selectedTaskIds",a=i._tasks):(n="selectedResourceIds",a=i._resources);const s=a.findIndex((e=>e.$.id===t)),r=i._getSelection(e,i[n]);s<0||(r.indexOf(t)>-1?i.$[`${e}Table`].unselect(t):i.$[`${e}Table`].select(t))}_handleTableSelection(e="task",t){const i=this;if(i.disableSelection||!t.length)return void i._unselectAll(e);let n,a,s,r,o,l=i._selected;l||(l=i._selected={});const c=t[t.length-1],d=l[e]=[];"task"===e?(o=i._tasks,n="selectedTaskIds",a=i.$.taskTimelineCellsContainer.children,s=i.$.timelineTasksContainer.children):(o=i._resources,n="selectedResourceIds",a=i.$.resourceTimelineCellsContainer.children,s=[]);for(let e=0,i=o.length;e<i;e+=1){const i=o[e];t.indexOf(i.$.id)>-1&&d.push(i)}for(let i=0,n=a.length;i<n;i+=1){const n=a[i],o=s[i],l=n._cellObj[e].$.id;c===l&&(r=s[i]),t.indexOf(l)>-1?(n.setAttribute("selected",""),n.setAttribute("aria-selected","true"),o&&o.setAttribute("selected","")):(n.removeAttribute("selected"),n.setAttribute("aria-selected","false"),o&&o.removeAttribute("selected"))}const m=i[n].slice(0);if(i._setSelection(e,t),!i._tableChangeEventFired){const n=document.scrollingElement||document.documentElement,a=n.scrollLeft,s=n.scrollTop;i._highlightAssignedItem(e,t),i.$[`${e}Table`].focus({preventScroll:!0}),window.scrollTo(a,s)}if("task"===e&&r){const e=r._cellStart;if(i.scrollLeft>e.left||e.left+r.offsetWidth>i.scrollLeft+i.$.timeline.offsetWidth){const t=i._timelineCells.indexOf(e);i._scrollTo((i._timelineCells[t-1]?i._timelineCells[t-1]:e).date)}}i._noChangeEvent||i.$.fireEvent("change",{type:e,value:i[n].slice(0),oldValue:m})}_setSelection(e="task",t){const i=this;let[n,a]="task"===e?[i._tasks,"selectedTaskIds"]:[i._resources,"selectedResourceIds"],s=[];for(let e=0,i=t.length;e<i;e+=1){const i=t[e],a=n.find((e=>e.$.id===i));a&&s.push(void 0!==a.id?a.id:i)}i.set(a,s)}_getSelection(e="task",t){const i="task"===e?this._tasks:this._resources;let n=t.slice(0);if(!t||!t.length)return n;for(let e=0,a=i.length;e<a;e+=1){const a=i[e],s=t.indexOf(a.id);s>-1&&(n[s]=a.$.id)}return n}_highlightAssignedItem(e,t){const i=this,[n,a]="task"===e?["resource","_getTaskResources"]:["task","_getResourceTasks"],s=i.$[`${n}Table`],r=i[`_${n}s`];if(!s||!i.$.mainSplitter.contains(s)||!r.length)return;t&&Array.isArray(t)||(t=[]);let o=[];for(let n=0,s=t.length;n<s;n+=1){const s=i._getValidItemAndIndex(t[n],e);s&&(o=o.concat(i[a](s.item).filter((e=>!e.hidden))))}i._tableChangeEventFired=!0,s.selected=o.map((e=>e.$.id)),o.length&&i._ensureVisible(o[0],n),delete i._tableChangeEventFired}_selectResource(e){const t=this,i=t._resources.indexOf(e);if(i<0)return void t._unselectAll("resource");const n=t.$.resourceTimelineCellsContainer.children[i];n&&n.hasAttribute("selected")?t._unselectAllTasks():t.$.resourceTree.focus({preventScroll:!0})}_snapToNearest(e,t){const i=this;if(!(i.snapToNearest&&e&&e.classList&&e.classList.contains("smart-timeline-task")&&e._cellObj))return;const n=e._cellObj.task,a=n.segments;if(t&&t.classList.contains("smart-task-segment")){const n=a.indexOf(t._segmentObj),s=0===n,r=n===a.length-1;if(i._handleSnapToNearestSegment(e,t,s?"first":r?"last":void 0),i._refreshTaskSegments(e,[t]),!s&&!r)return;i._refreshTask(e,!0)}else i._handleSnapToNearest(i._getTaskBarCellRange(e),e),i._refreshTask(e);if(a&&a.length>1){for(let e=0,t=a.length;e<t;e+=1)i._snapToNearestDates(a[e],!0);i._validateTaskSegments(n),n.segments.length!==a.length&&i._recycleSegments(n,e),i._setTaskBarSegments(e._cellObj,e,!0),i._setTaskBarProgress(n)}if("project"!==n.type||!n.dragProject)return;const s=i._getProjectTasks(n);if(s&&Array.isArray(s))for(let e=0;e<s.length;e++){const t=i.$.timelineTasksContainer.children[i._tasks.indexOf(s[e])];t&&i._snapToNearest(t)}}_handleSnapToNearestSegment(e,t,i){const n=this,a=n.rightToLeft,s=a?"right":"left",r=parseFloat(e.style[s])||0,o=t,l=n._getSegmentCellRange(t),c=l.cellStart,d=l.cellEnd,m="first"===i,u="last"===i;let h=parseFloat(o.style.width)||o.offsetWidth,g=parseFloat(o.style[s])||0,f=r+g;if(n.hasAttribute("dragged")){const t=d.width-(f+h-d.left);let n;if(f-c.left<=t?(n=c.left-r,o.style[s]=Math.max(0,m?0:n)+"px"):(n=g+t,o.style[s]=Math.max(0,m?0:n)+"px"),i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&(e.style[s]=r+(n-g)+"px"),e.style.width=t+(m?-1:1)*(n-g)+"px"}}else if(n.hasAttribute("resized")){const t=c===d?n._taskBarMinWidth:0;let l;if("left"===n.$.timeline.getAttribute("task-bar-hovered")){if(l=f-c.left,l-=l>=c.width/2?c.width-t:0,f-=l,o.style[s]=Math.max(0,m?0:f-r)+"px",l=f+h>d.left+d.width/2?d.left+d.width-(f+h):d.left-(f+h),o.style.width=Math.max(t,h+l)+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&!a&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&a&&(e.style.width=t+l+"px")}}else if(f>c.left+c.width/2?(f=c.left+c.width,o.style[s]=Math.max(0,m?0:f-r)+"px"):(f=c.left,o.style[s]=Math.max(0,m?0:f-r)+"px"),l=f+h-d.left,l=-1*(l-(l>=c.width/2?d.width:t)),o.style.width=h+l+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&a&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&!a&&(e.style.width=t+l+"px")}}}_handleSnapToNearest(e,t){const i=this;if(!e)return;const n=i.rightToLeft?"right":"left",a=e.cellStart,s=e.cellEnd;let r=parseFloat(t.style.width)||t.offsetWidth,o=parseFloat(t.style[n])||0;if(i.hasAttribute("dragged")){const e=s.width-(o+r-s.left);o-a.left<=e?t.style[n]=a.left+"px":t.style[n]=o+e+"px"}else if(i.hasAttribute("resized")){const e=a===s?i._taskBarMinWidth:0;let l;"left"===i.$.timeline.getAttribute("task-bar-hovered")?(l=o-a.left,l-=l>=a.width/2?a.width-e:0,t.style[n]=(o-=l)+"px",l=o+r>s.left+s.width/2?s.left+s.width-(o+r):s.left-(o+r),t.style.width=Math.max(e,r+l)+"px"):(o>a.left+a.width/2?t.style[n]=a.left+a.width+"px":t.style[n]=a.left+"px",o=parseFloat(t.style[n])||0,l=o+r-s.left,l=-1*(l-(l>=a.width/2?s.width:e)),t.style.width=r+l+"px")}}_setDragLimits(e){const t=this,i=t._dragDetails;if(!i)return;const n=i.timelineTask;if(!n||!e)return;const a=t.$.timeline.getAttribute("task-bar-hovered"),s=n._cellObj.task;if(a){if(s.disableResize)return void delete t._dragDetails;const e=t._getTaskBarSizeLimits(n,a);i.min.width=e.min,i.max.width=e.max,t._setSegmentLimits(a);const r=t._createDelimiter("min",a),o=t._createDelimiter("max",a);r&&n.appendChild(r),o&&n.appendChild(o)}else if(e.closest(".smart-task-connection-point"))i.timelineTask=void 0;else if(e.closest(".smart-timeline-task")===n){let e;if(t._connections){const i=t._tasks.indexOf(n._cellObj.task);e=t._connections.some((e=>e.startIndex===i||e.endIndex===i))}if(s.disableDrag||e&&t.autoSchedule&&t.autoScheduleStrictMode)return void delete i.target;i._taskDuration=t._getWorkingTime(s.dateStart,s.dateEnd),n.classList.contains("milestone")&&(i.target="smart-timeline-task-fill");const a=t._getTaskDragLimits(n),r=t.rightToLeft?t.$.timelineContent.offsetWidth-n.offsetLeft-n.offsetWidth:n.offsetLeft;if(void 0!==a.min&&(i.min.left=a.min,"project"===n._cellObj.task.type&&a.min>r&&(i.min.left=r)),void 0!==a.max&&(i.max.left=a.max,"project"===n._cellObj.task.type&&a.max<r&&(i.max.left=r)),"project"===s.type&&s.dragProject&&!t.synchronized){const e=t._getSubTaskLimits(n);void 0!==e.min&&(i.min.left=i.min.left?Math.max(i.min.left,e.min):e.min),void 0!==e.max&&(i.max.left=i.max.left?Math.min(i.max.left,e.max):e.max)}else"milestone"===s.type&&(i.target="smart-timeline-task-fill");t._setSegmentLimits()}else i.timelineTask=void 0;i.relatedConnections={}}_setSegmentLimits(e){const t=this,i=t._dragDetails;if(!i||!i.segment)return;const n=i.segment;if(n){const a=n.element,s=n.dimensions,r=a.previousElementSibling,o=a.nextElementSibling;if(n.min.width=e?t._taskBarMinWidth:0,t.rightToLeft){if(r)n.min.left="left"===e?s.left+s.width:r.offsetLeft-(e?0:s.width),"right"===e&&(n.max.width=r.offsetLeft-s.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"right");i.min.width=e.min,i.max.width=e.max}if(o)n.max.left="right"===e?n.dimensions.left:o.offsetLeft+o.offsetWidth+s.width,e&&"left"!==e||(n.max.width=s.left+s.width-(o.offsetLeft+o.offsetWidth));else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}}else{if(r)n.min.left="right"===e?s.left:r.offsetLeft+r.offsetWidth+(e||o?0:s.width),"left"===e&&(n.max.width=s.left+s.width-n.min.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}if(o)n.max.left="left"===e?s.left+s.width:o.offsetLeft-s.width,e&&"right"!==e||(n.max.width=o.offsetLeft-s.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"right");i.min.width=e.min,i.max.width=e.max}}}}_setScrollBars(){const e=this;e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e.$.taskSplitterItem,e.$.horizontalScrollBar,e.$.verticalScrollBar));const t=e._scrollView.vScrollBar,i=e._scrollView.hScrollBar;i.$.addClass("smart-hidden"),t.$.addClass("smart-hidden"),t.hasStyleObserver=!1,i.hasStyleObserver=!1,t.hasResizeObserver=!1,i.hasResizeObserver=!1,t.rightToLeft=i.rightToLeft=e.rightToLeft,i.wait=!1,e._refresh()}_getWorkingTime(e,t){const i=this;if(!e||!t)return;if(!i.adjustToNonworkingTime)return t.getTime()-e.getTime();const n=i.nonworkingHours,a=i.nonworkingDays;function s(e,t){let i,s,r=t.getTime()-e.getTime(),o=new Date(e),l=0;for(;r>0;){const e=Math.min(r,36e5-(60*o.getMinutes()*1e3+1e3*o.getSeconds()+o.getMilliseconds()));if(a.indexOf(o.getDay())>-1)s=new Date(o),s.setHours(0,0,0,0),s.setDate(o.getDate()+1),i=Math.min(e,s.getTime()-o.getTime()),o=new Date(o.getTime()+i),r-=i;else if(n.indexOf(o.getHours())>-1){s=new Date(o);const t=s.getTime();s.setHours(o.getHours()+1,0,0,0),t===s.getTime()&&s.setHours(o.getHours()+2,0,0,0),i=Math.min(e,s.getTime()-o.getTime()),o=new Date(o.getTime()+i),r-=i}else l+=e,r-=e,o=new Date(o.getTime()+e)}return l}if(e.getFullYear()===t.getFullYear())return s(e,t);let r=new Date(e.getFullYear()+1,0,1,0,0,0,0),o=s(e,r);if(t.getFullYear()>r.getFullYear()){const e=Math.max(0,t.getFullYear()-r.getFullYear());for(let t=0;t<e;t++){let e=i._getWorkingDaysBetweenDays(r);o+=60*(24*e-e*i.nonworkingHours.length)*60*1e3,r.setFullYear(r.getFullYear()+1)}}return o+=s(r,t),o}_getWorkingDaysBetweenDays(e){const t=this,i=e.getFullYear(),n=(i%100==0?i%400==0:i%4==0)?366:365;let a=new Date(e),s=0;for(let e=0;e<n;e++)t.nonworkingDays.indexOf(a.getDay())<0&&s++,a.setDate(a.getDate()+1);return s}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.tabIndex=-1:e.tabIndex=e.tabIndex>0?e.tabIndex:0}_setTaskBarLabel(e,t){const i=this;void 0===t&&(t=i._getTaskDOMIndex(e));const n=i.$.timelineTasksContainer.children[t];if(!n)return;const a=n.querySelector(".smart-task-segments").children;let s=e.segments;Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);for(let i=0,n=s.length;i<n;i+=1){const n=s[i],r=a[i],o=r?r.getElementsByClassName("smart-timeline-task-label")[0]:void 0;if(!o)continue;o.firstElementChild||(o.innerHTML="<div></div>");let l=o.firstElementChild;"string"==typeof n.label||"number"==typeof n.label?l.textContent=n.formatFunction?n.formatFunction(n.label||"",t)||"":n.label||"":l.textContent=e.formatFunction?n.formatFunction(e.label||"",t)||"":e.label||""}}_setTaskBarProgress(e,t){const i=this;if("number"==typeof t?t=i.$.timelineTasksContainer.children[t]:void 0===t&&(t=i.$.timelineTasksContainer.children[i._getTaskDOMIndex(e)]),!t||!e)return;let n=e.progress;const a=t.querySelector(".smart-timeline-task-progress-thumb");if(!a)return;n=Math.min(100,Math.max(0,n))||0;const s=e.dateStart.getTime(),r=e.dateEnd.getTime(),o=t.querySelector(".smart-task-segments").children;let l,c,d=e.segments,m=0;d&&d.length||(d=[e]);for(let e=0,t=d.length;e<t;e+=1){const t=d[e],i=o[e],a=i?i.querySelector(".smart-timeline-task-progress"):void 0;if(!a)continue;const u=(t.dateStart.getTime()-s)/(r-s)*100,h=(t.dateEnd.getTime()-s)/(r-s)*100,g=Math.max(0,Math.min(100,(n-u)/(h-u)*100));a.style.width=g+"%",a.removeAttribute("value"),i.removeAttribute("show-progress-label"),n>=u?(m=Math.max(u,Math.min(n,h)),l=a,c=i):l||(l=a,c=i)}if(a.style[i.rightToLeft?"left":"right"]="",a.style[i.rightToLeft?"right":"left"]=m+"%",!l||!i.showProgressLabel)return;const u=i.progressLabelFormatFunction;c.setAttribute("show-progress-label",""),l.setAttribute("value",u?u(n)+"":parseFloat(n.toFixed(2))+"%")}_setTaskDeadline(e,t,i){const n=this,a=e.task,{timelineStart:s,timelineEnd:r}=i,o=a.deadline,l=n.$.timelineDeadlines,c=l.children,d=o&&o.getTime&&!isNaN(o.getTime())?o.getTime():void 0;let m;for(let e=0,i=c.length;e<i;e+=1){const i=c[e];if(parseInt(i.getAttribute("task-index"))===t){m=i;break}}if(!d||d<s||d>r)return void(m&&m.remove());const u=n._getTimelineCellByDate(o),[h,g]=n.rightToLeft?["right","left"]:["left","right"];m||(m=document.createElement("div"),m.classList.add("smart-gantt-chart-task-deadline"),m.setAttribute("task-index",t),l.appendChild(m)),m.setAttribute("date",o.toString()),m.setAttribute("title",n._formatDate(o)),m.style.top=e.top+"px",m.style[g]="",m.style[h]=u.left+(n._getTimelineTaskOffset(u,o)||0)+"px"}_setTaskBarDeadline(e,t){const i=this,n=e.deadline;if(!n||!n.getTime||isNaN(n)||!t)return;const a=e.deadline.getTime()-e.dateEnd.getTime();if(!e.deadline||a>0)return t.removeAttribute("deadline"),void(e.overdue=!1);e.overdue=!0,t.setAttribute("deadline",`${i.localize("overdue")}: ${Math.round(i._convertDuration(Math.abs(a),!0))} ${i.durationUnit+"s"}`)}_setTaskIndicators(e,t,i){const n=this,a=e.task,{timelineStart:s,timelineEnd:r}=i,[o,l]=n.rightToLeft?["right","left"]:["left","right"],c=n.$.taskIndicatorsContainer,d=c.children,m=a.indicators;let u;for(let e=0,i=d.length;e<i;e+=1){const i=d[e];if(parseInt(i.getAttribute("task-index"))===t){u=i;break}}if(!Array.isArray(m))return void(u&&u.remove());const h=document.createDocumentFragment(),g=document.createDocumentFragment();u||(u=document.createElement("div"),u.classList.add("smart-gantt-chart-indicator"),u.setAttribute("task-index",t),h.appendChild(u));const f=u.children;for(;f.childElementCount>m.length;)f.firstElementChild.remove();for(let t=0,i=m.length;t<i;t+=1){let i=f[t];const a=m[t],c=a.date;if(!c||!c.getTime){i&&i.remove();continue}const d=c.getTime();if(d<s||d>r){i&&i.remove();continue}const u=n._getTimelineCellByDate(c),h=a.label,p=a.className,_=a.icon;i||(i=document.createElement("div"),g.appendChild(i)),i.className="smart-gantt-chart-task-indicator",i._indicatorObj=a;const T=i.classList;"string"==typeof p&&T.add(p),_?(T.add("icon"),i.style.setProperty("--smart-gantt-chart-indicator-icon",`'${_}'`)):T.contains("icon")&&(T.remove("icon"),i.style.removeProperty("--smart-gantt-chart-indicator-icon")),i.textContent=h||"",i.style.top=e.top+"px",i.style[l]="",i.style[o]=u.left+(n._getTimelineTaskOffset(u,c)||0)+"px"}g.childElementCount&&u.appendChild(g),h.childElementCount&&c.appendChild(h)}_setTimelineTaskBar(e,t,i){const n=this,a=e.task,s=void 0===t?n._getTaskDOMIndex(a):t,r=n.$.timelineTasksContainer.children,o=r[s];let l,c;if(0===r.length||!o||!o.classList||!o.classList.contains("smart-timeline-task"))return;const d=a.dateStart instanceof Date?a.dateStart:new Date(a.dateStart),m=a.dateEnd instanceof Date?a.dateEnd:new Date(a.dateEnd);if(l=!i&&o._cellStart||n._getTimelineCellByDate(d),c=!i&&o._cellEnd||n._getTimelineCellByDate(m),!l||!c)return void o.classList.add("smart-visibility-hidden");o._cellStart=l,o._cellEnd=c,o.classList.remove("smart-visibility-hidden");const u=n._getTaskBarDetails(e,l,c);u&&(o.style[n.rightToLeft?"left":"right"]="",o.style[n.rightToLeft?"right":"left"]=u.left+"px",o.style.width=u.width?u.width+"px":"",o.style.top=u.top+"px"),n._setTaskBarSegments(e,o,i)}_setTimelineTaskBaseline(e,t){const i=this,n=e.task,a=i.$.timelineBaselinesContainer;if(!i.showBaseline)return void(a.innerHTML&&(a.innerHTML=""));const s=n.planned,r=a.children;let o;for(let e=0,i=r.length;e<i;e+=1){const i=r[e];if(parseInt(i.getAttribute("task-index"))===t){o=i;break}}if(!s||"milestone"===n.type||!s.dateStart||!s.dateEnd)return void(o&&o.remove());const l=s.dateStart,c=s.dateEnd,d=i._getTimelineCellByDate(l),m=i._getTimelineCellByDate(c);if(!d||!m)return;o||(o=document.createElement("div"),o.classList.add("smart-gantt-chart-task-baseline"),o.setAttribute("task-index",t),a.appendChild(o));const[u,h]=i.rightToLeft?["right","left"]:["left","right"],g=i._getTaskBarDetails(e,d,m);if(g){const e=o.style;e.width=g.width?g.width+"px":"",e.top=g.top+"px",e[u]=g.left+"px",e[h]=""}o.setAttribute("aria-label",n.label+" Start date: "+i._toISODate(l)+", End date: "+i._toISODate(c))}_setTaskBarSegments(e,t,i){const n=this,a=e.task,s=t.querySelector(".smart-task-segments").children;let r,o,l=a.segments;if(Array.isArray(l)&&l&&l.length&&"task"===a.type||(l=[a]),1===l.length){const e=s[0].style;return void(e.right=e.left=e.width="")}const c=n.rightToLeft,d=parseFloat(t.style[c?"right":"left"]);let m;for(let e=0,t=l.length;e<t;e+=1){const t=l[e],a=s[e];if(!a)continue;const u=t.dateStart instanceof Date?t.dateStart:new Date(t.dateStart),h=t.dateEnd instanceof Date?t.dateEnd:new Date(t.dateEnd);r=!i&&a._cellStart||n._getTimelineCellByDate(u),o=!i&&a._cellEnd||n._getTimelineCellByDate(h),a._cellStart=r,a._cellEnd=o;const g=n._getTaskBarDetails({task:t},r,o);g&&(a.style[c?"left":"right"]="",a.style[c?"right":"left"]=Math.max(0,g.left-d)+"px",a.style.width=g.width+"px"),m=a}n._setTaskBarDeadline(a,m)}_setCurrentTimeIndicators(){const e=this;if(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval,e.currentTimeIndicator||e.shadeUntilCurrentTime)e._refreshTimeIndicators(),e._currentTimeIndicatorInterval=setInterval(e._refreshTimeIndicators.bind(e),1e3*e.currentTimeIndicatorInterval);else{const t=e.$.timelineIndicatorsContainer;t&&t.remove()}}_refreshTimeIndicators(){const e=this,t=new Date,i=e.view,n=e._getTodayCellObj(t);let a=e.$.timelineIndicatorsContainer;if(!n)return a&&a.remove(),clearInterval(e._currentTimeIndicatorInterval),void delete e._currentTimeIndicatorInterval;a||(e.$.timelineIndicatorsContainer=a=document.createElement("div"),a.classList.add("smart-gantt-chart-time-indicators-container"),a.setAttribute("role","presentation"));const s=new Date(n.date);let r,o,l=t.getMinutes();switch(i){case"year":{const e=new Date(t.getFullYear(),t.getMonth()+1,1,0,0,0,0);e.setDate(0),l+=24*t.getDate()*60,r=24*e.getDate()*60;break}case"month":l+=24*(t.getDay()+1)*60,r=10080;break;case"week":l+=60*t.getHours(),r=1440;break;case"day":r=s.getHours()+60}o={cellObj:n,minutes:l,max:r,today:t},e._refreshCurrentTimeShader(o),e._refreshCurrentTimeIndicator(o),a.childElementCount||(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval),a.parentElement||e.$.timelineContent.appendChild(a)}_refreshCurrentTimeIndicator(e){const t=this,i=t.$.timelineIndicatorsContainer;let n=i.querySelector(".smart-gantt-chart-current-time-indicator");if(!t.currentTimeIndicator||!e)return void(n&&n.remove());const{cellObj:a,minutes:s,max:r}=e;n||(n=document.createElement("div"),n.classList.add("smart-gantt-chart-current-time-indicator")),n.style.left=a.left+a.width*(s/r)+"px",n.setAttribute("aria-label","Current Time Indicator"),n.parentElement||i.appendChild(n),t._setTodayCell(a.date)}_refreshCurrentTimeShader(e){const t=this.$.timelineIndicatorsContainer;let i=t.querySelector(".smart-gantt-chart-current-time-shader");if(!this.shadeUntilCurrentTime||!e)return void(i&&i.remove());const{cellObj:n,minutes:a,max:s}=e;i||(i=document.createElement("div"),i.classList.add("smart-gantt-chart-current-time-shader")),i.style.width=n.left+n.width*(a/s)+"px",i.setAttribute("aria-label","Current Time Shader"),i.parentElement||t.appendChild(i)}_setTodayCell(e){const t=this;if(e)e instanceof Date&&(e=e.getTime());else{let i=0;e=new Date,"day"===t.view&&(i=e.getHours()),e.setHours(i,0,0,0),e=e.getTime()}if("number"!=typeof e)return;const i=t.$.timelineViewCells.children;for(let t=0;t<i.length;t++){const n=i[t],a=new Date(n._date);a&&(a.getTime()===e?n.setAttribute("current",""):n.removeAttribute("current"))}}_getTodayCellObj(e){const t=this.view,i=this._timelineCells;e&&e.getTime||(e=new Date);for(let n=0,a=i.length;n<a;n+=1){const a=i[n],s=a.date;switch(t){case"year":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth())return a;break;case"month":{const t=new Date(e);if(t.setDate(e.getDate()-e.getDay()),e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&t.getDate()===s.getDate())return a;break}case"week":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate())return a;break;case"day":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate()&&s.getHours()===e.getHours())return a}}}_getTaskDOMIndex(e){const t=this.$.timelineTasksContainer.children;if(!e||void 0===e.$.id)return-1;for(let i=0,n=t.length;i<n;i+=1)if(t[i]._cellObj.task===e)return i;return-1}_getTimelineCellByDate(e,t,i){const n=this,a=n._timelineCells;if(!a||0===a.length)return;const s=a.length-1;i=Math.min(s,"number"==typeof i?i:s);for(let s=t=Math.min(i,Math.max(0,"number"==typeof t?t:0));s<=i;s++){const t=a[s];if(!t)continue;const i=t.date;switch(n.view){case"year":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth())return t;break;case"month":{const n=new Date(i);let a=new Date(i);if(a.setDate(a.getDate()+(6-a.getDay())+1),a.setMilliseconds(a.getMilliseconds()-1),e.getTime()>=n.getTime()&&e.getTime()<=a.getTime())return t;break}case"week":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate())return t;break;case"day":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours())return t}}const r=a[0],o=a[a.length-1];return e.getTime()<r.date.getTime()?r:e.getTime()>o.date.getTime()?o:void 0}_refreshViewDetailCell(e,t,i){const n=this,a=n._timelineCells,s=e.date;let r=0,o=0===i?0:void 0;for(void 0===t&&(t=0);t<a.length;t++){const e=a[t],i=n._getCellWidth(e,s);if(i)void 0===o&&(o=e.left+e.width-i),r+=i;else if(e.date.getTime()>s.getTime())break}return n._isLastWeekCellNotFull&&(delete n._isLastWeekCellNotFull,t--),e.width=r,e.left=o,t}_getCellWidth(e,t){const i=this,n=e.date,a=(e,t)=>e.getFullYear()===t.getFullYear(),s=(e,t)=>e.getMonth()===t.getMonth(),r=e.width;switch(i.view){case"month":{let e=new Date(n),o=new Date(e),l=0;for(o.setDate(o.getDate()+(6-e.getDay())+1),o.setMilliseconds(o.getMilliseconds()-1);e.getTime()<=o.getTime();)a(e,t)&&s(e,t)&&l++,e.setDate(e.getDate()+1);if(0===l)return;return i._isLastWeekCellNotFull=l/7!=1,r*l/7}case"year":if(a(n,t))return r;break;case"week":{const e=new Date(t),i=new Date(t);if(e.setDate(t.getDate()-t.getDay()),i.setDate(t.getDate()+(6-t.getDay())),n.getTime()>=e.getTime()&&n.getTime()<=i.getTime())return r;break}case"day":if(a(n,t)&&s(n,t)&&n.getDate()===t.getDate())return r}}_getCellByOffsetLeft(e){const t=this._timelineCells;if(!e)return;let i;for(let n=0;n<t.length&&!(t[n].left>=e);n++)i=t[n];return i}_unselectAll(e,t){const i=this,n=i.$[`${e}TimelineCellsContainer`];let a;delete i._selected;const s=n.querySelectorAll(".smart-timeline-row[selected]");for(let e=0;e<s.length;e++)s[e].removeAttribute("selected");if("task"===e){a="selectedTaskIds";const e=i.$.timelineTasksContainer.querySelectorAll(".smart-timeline-task[selected]");for(let t=0;t<e.length;t++)e[t].removeAttribute("selected"),e[t].setAttribute("aria-selected","false")}else a="selectedResourceIds";if(i[`_${e}TreeChangeEventFired`]||i.$[e+"Table"].clearSelection(),i._highlightAssignedItem(e),t)return;const r=i[a].slice(0);r.length&&(i[a]=[],i._noChangeEvent||i.$.fireEvent("change",{value:[],oldValue:r,type:e}))}_getSegmentCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-task-segment"))return;const i=e.closest(".smart-timeline-task");if(!i)return;let n,a,s=i._cellStart,r=i._cellEnd;s&&r||({cellStart:s,cellEnd:r}=t._getTaskBarCellRange(i));const o=t.rightToLeft,l=parseFloat(e.style.width)||e.offsetWidth,c=t._timelineCells;let d=parseFloat(i.style[o?"right":"left"]);d&&!isNaN(d)||(d=i.offsetLeft,o&&(d=t.$.timelineContent.offsetWidth-d));const m=d+parseFloat(e.style[o?"right":"left"])||(o?(parseFloat(i.style.width)||i.offsetWidth)-(e.offsetLeft+e.offsetWidth):e.offsetLeft),u=parseFloat((m+l).toFixed(2));for(let e=c.indexOf(s),t=c.indexOf(r);e<=t;e++){const t=c[e],i=t.left,s=t.width,r=parseFloat((i+s).toFixed(2));if(m>=i&&m<=r&&(n=t),!a&&u>i&&u<=r&&(a=t),n&&a)break}return n||(n=a||c[0]),a||(a=c[c.length-1]),{cellStart:n,cellEnd:a}}_getTaskBarCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-timeline-task"))return;let i=parseFloat(e.style.width)||e.offsetWidth;const n=t._timelineCells,a=t.$.timelineContent,s=parseFloat(e.style[t.rightToLeft?"right":"left"])||(t.rightToLeft?(parseFloat(a.style.width)||a.offsetWidth)-(e.offsetLeft+e.offsetWidth):e.offsetLeft);let r,o;e.classList.contains("milestone")&&(i/=2);const l=parseFloat((s+i).toFixed(2));for(let e=0;e<n.length;e++){const t=n[e],i=t.left,a=t.width,c=parseFloat((i+a).toFixed(2));if(s>=i&&s<=c&&(r=t),!o&&l>i&&l<=c&&(o=t),r&&o)break}return r||(r=e.classList.contains("milestone")&&o?o:n[0]),o||(o=n[n.length-1]),{cellStart:r,cellEnd:o}}_getDateFromCell(e,t,i){if(!t)return new Date;const n=this,a=new Date(t.date);let s,r=0,o=0,l=new Date(a);switch(l.setHours(0,0,0,0),i||(i=n.view),i){case"year":s=new Date(a.getFullYear(),a.getMonth()+1,0).getDate(),r=1,l.setDate(s);break;case"month":r=a.getDate(),s=7,l.setDate(l.getDate()+6);break;case"week":s=1,r=a.getDate();break;case"day":s=1/24,r=a.getDate(),o=a.getHours()}l.setHours(23,59,59,999);const c=parseFloat(((e-t.left)/t.width*s).toFixed(12)),d=Math.min(s,Math.floor(c)),m=c%1*24,u=Math.floor(m),h=60*Math.abs(m-u),g=Math.floor(h),f=60*Math.abs(h-g),p=Math.floor(f),_=1e3*Math.abs(f-p),T=Math.floor(_),k=new Date(a.getFullYear(),a.getMonth(),r+d,o+u,g,p,T);return k.getTime()>l?l:k}_getCellDateRange(e){if(!e||!e._date)return;const t=new Date(e._date);let i=new Date(t);switch(i.setHours(0,0,0,0),this.view){case"year":i.setDate(1),i.setMonth(i.getMonth()+1),i.setDate(0);break;case"month":i.setDate(i.getDate()+6);break;case"day":return i.setHours(t.getHours(),59,59,999),{dateStart:t,dateEnd:i}}return i.setHours(23,59,59,999),{dateStart:t,dateEnd:i}}_getTasksJSON(){const e=this;let t=e._tasks;return function t(i,n){if(!i)return;let a=[];for(let s=0;s<i.length;s++){const r=i[s];let o;if(!r.$.project&&!n||r.$.project===n){const i=e._getTaskConnections(r).taskConnections;o=e._cloneObject(r,!0),i.length&&(o.connections=i.map((e=>{const t={target:e.endIndex,type:e.type};return e.lag&&(t.lag=e.lag),t}))),o.tasks=t(e._getProjectTasks(r),r),delete o.$,a.push(o)}}return a}(t)}_cloneObject(e,t){let i={};for(let n in e){let a=e[n];"tasks"!==n&&("connections"!==n?a instanceof Date?i[n]=t?a.toISOString():new Date(a):i[n]=a:i[n]=JSON.parse(JSON.stringify(a)))}return t||delete i.$,i}_setTable(e){const t=this;e||(e=t.$.taskTable);const[i,n]=e===t.$.taskTable?[t.taskColumns,"task"]:[t.resourceColumns,"resource"];if(!t.contains(e))return;if(!i.length)return void(t.$[n+"Table"].dataSource=[]);const a=t._getTableColumns(n);"task"===n&&(e.filterRow=t.filterRow,[e.grouping,e.groupFormatFunction]=t.groupByResources?[!0,t._formatResourceGroups.bind(t)]:[!1,null]),e.isRendered&&e.resetState("expanded"),e.style.setProperty("--smart-table-row-height",""),e.columns=a,e.dataSource=t._getTableDataSource(n,a),e.wait&&(t.$.taskTable.hasResizeObserver=!1,e.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,e.$.virtualizationContainer.verticalScrollBarVisibility="hidden",e.$.virtualizationContainer.disabled=!0,e.columnMinWidth=t.columnMinWidth,e.columnResize=t.columnResize,e.columnResizeFeedback=t.columnResizeFeedback,e.filtering=t[`${n}Filtering`],e.sort=t.sortFunction,e.sortMode=t.sortMode,e.keyboardNavigation=t.keyboardNavigation,e.selectionByHierarchy=!1,e.selection=!t.disableSelection,e.hideSelectionColumn=!t.showSelectionColumn,e.onKeyboardScroll=(i,n)=>{const a=e===t.$.taskTable?t:t._resourceScrollView;n!==a.scrollTop&&(a.scrollTop=n)},e.wait=!1),e.$.virtualizationContainer.scrollTop="task"===n?t.scrollTop:t.$.resourceVerticalScrollBar.value,t._refresh()}_formatResourceGroups(e){const t=this,i=t._resources,n=e.data.data.resources.split(",");let a=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";n.indexOf(s)>-1&&a.push(t.label||t.value||t.id)}t.resourceGroupFormatFunction?e.template=t.resourceGroupFormatFunction(n):e.template="<strong>"+(a.length?a.join(", "):t.localize("unassigned"))+"</strong>"}_formatResourceGroupLabel(e){const t=this,i=t._resources,n=e.split(",");if(!e)return t.localize("unassigned");let a=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";n.indexOf(s)>-1&&a.push(t.label||t.value||t.id)}return a.length?a.join(", "):t.localize("unassigned")}_getTableColumns(e="task"){const t=this,i=["dateStart","dateEnd","minDateStart","maxDateStart","minDateEnd","maxDateEnd"],n=["progress","capacity","workload","maxCapacity","minCapacity"];let a="task"===e?t.taskColumns:t.resourceColumns,s=[];"task"===e&&t.groupByResources&&!a.find((e=>"resources"===e.value))&&(a=a.slice(0),a.push({label:"",value:"resources",hidden:!0}));for(let r=0,o=a.length;r<o;r++){const o=a[r],l=o.value,c={};c.label=t.localize(o.label)||o.label,c.dataField=l,l.startsWith("date")||i.indexOf(l)>-1?c.dataType="date":c.dataType="overdue"===l?"boolean":l.startsWith("duration")||n.indexOf(l)>-1?"number":"string",o.hidden&&(c.visible=!1),"function"==typeof o.formatFunction?c.formatFunction=i=>{const n=t._getValidItemAndIndex(i.data.itemId,e).item,a=i.column.toLowerCase();let s=i.value;a.indexOf("date")>-1?s=new Date(s):"resources"===a&&(s=s?s.split(","):[]),i.template=o.formatFunction.call(t,s,n?t._cloneObject(n):void 0)}:["date","number"].indexOf(c.dataType)>-1?c.formatFunction=i=>{const n=t._getValidItemAndIndex(i.data.itemId,e).item,a=t._formatColumnData(t._cloneObject(n),o);i.template=a}:"overdue"===l&&(c.formatFunction=e=>{const t=e.cell;e.value+""=="true"?t.setAttribute("overdue",""):t.removeAttribute("overdue"),e.value=""},c.width=t._taskDefaultHeight),o.size&&(c.width=o.size),s.push(c)}return s}_getTableDataSource(e="task",t){const i=this,n="task"===e?i._getTableData(i._tasks,i.taskColumns,e):i._getTableData(i._resources,i.resourceColumns,e),a=i.groupByResources,s=(()=>{let e=[];e.push("itemId: string"),e.push("projectId: string"),e.push("itemIndex: number"),a&&e.push("resources: string");for(let i=0,n=t.length;i<n;i+=1){const n=t[i];e.push(`${n.dataField}: ${n.dataType}`)}return e})();return i.groupByResources?new window.Smart.DataAdapter({dataFields:s,dataSource:n,groupBy:["resources"],id:"itemId"}):new window.Smart.DataAdapter({dataFields:s,dataSource:n,keyDataField:"itemId",parentDataField:"projectId",id:"itemId"})}_refreshTableDataSource(e="task"){const t=this,i="task"===e?t.$.taskTable:t.$.resourceTable;t.contains(i)&&(i.resetState("expanded"),i.dataSource=t._getTableDataSource(e,t._getTableColumns(e)))}_refreshColumnsHeaders(e){const t=this;e||(e="task");const i=t.$[`${e}Table`].columns,n=t[`${e}Columns`];for(let e=0,a=i.length;e<a;e++)i[e].label=t.localize(n[e].label)||n[e].label;!arguments.length&&t.$.mainSplitter.contains(t.$.resourceSplitter)&&t._refreshColumnsHeaders("resource")}_getTaskResourceIds(e){const t=e.resources,i=this._resources.map((e=>e.id));let n=[];if(Array.isArray(t))for(let e=0,a=t.length;e<a;e+=1){const a=t[e].id||t[e];i.indexOf(a)>-1&&n.push(a)}return n.sort()}_getTableData(e,t,i){const n=this,a=n.groupByResources;i||(i="task");const s=t.map((e=>e.value));let r=[],o=[];for(let l=0,c=e.length;l<c;l+=1){const c=e[l];if(c.hidden||a&&c.disableResources)continue;const d={},m=c.$.project,u=n._getTaskResourceIds(c);for(let e=0,a=s.length;e<a;e+=1)d[s[e]]=n._formatColumnData(c,t[e],i);d.expanded=a||c.expanded,d.itemId=c.$.id||c.id||"",d.itemIndex=l,u&&u.length?d.resources=u.toString():delete d.resources,c.$&&m&&(m.$.id?d.projectId=c.$.project.$.id:o.push(((e,t)=>{e.projectId=t.$.id}).bind(null,c,m))),r.push(d)}for(let e=0,t=o.length;e<t;e+=1)o[e]();return r}_formatColumnData(e,t){const i=this,n=t.value;let a=e[n];if(n){const e=(n+"").toLowerCase();if(e.indexOf("date")>-1||t.dateFormat)return i._formatDate(a,t);if(e.indexOf("duration")>-1||t.numberFormat){const e=parseFloat(a.toFixed(1));return t.numberFormat?i._formatNumber(e,t.numberFormat):e}}return null!=a?a.toString():i.localize("unassigned")}_formatDate(e,t){const i=this;if(e=Date.parse(e),!isNaN(e)){let n=t?t.dateFormat:void 0;if("string"==typeof n)return new Smart.Utilities.DateTime(new Date(e)).toString(n);if("object"==typeof n)n=t.dateFormat;else{const e=i.view;n={year:"numeric",month:"2-digit",day:"numeric"},["day","week"].indexOf(e)>-1&&(n.hour="numeric",n.minute="numeric",n.second="numeric")}return new Intl.DateTimeFormat(i.locale,n).format(new Date(e))}}_formatNumber(e,t,i){const n=this;if("object"==typeof t)return new Intl.NumberFormat(n.locale,t).format(""+e);i||(i={percentSymbol:"%",currencySymbol:"$",currencySymbolPosition:"before",decimalSeparator:".",thousandsSeparator:","});const a=e=>"number"==typeof e&&isFinite(e);if(""===t||null===t)return e;let s;a(e)||(e*=1),t.length>1&&(s=parseInt(t.slice(1),10));let r={},o=t.charAt(0).toUpperCase();switch(r.thousandsSeparator=i.thousandsSeparator,r.decimalSeparator=i.decimalSeparator,o){case"D":case"d":case"F":case"f":r.decimalPlaces=s;break;case"N":case"n":r.decimalPlaces=0;break;case"C":case"c":r.decimalPlaces=s,"before"===i.currencySymbolPosition?r.prefix=i.currencySymbol:r.suffix=i.currencySymbol;break;case"P":case"p":r.suffix=i.percentSymbol,r.decimalPlaces=s;break;default:throw"Bad number format specifier: "+o}if(a(e)){const t=e<0;let i=e+"";const n=r.decimalSeparator?r.decimalSeparator:".";let s;if(a(r.decimalPlaces)){var l=r.decimalPlaces,c=Math.pow(10,l);if(i=(e*c).toFixed(0)/c+"",s=i.lastIndexOf("."),l>0)for(s<0?(i+=n,s=i.length-1):"."!==n&&(i=i.replace(".",n));i.length-1-s<l;)i+="0"}else{let t=e+"";s=t.lastIndexOf("."),s>0&&void 0===l&&"."!==n&&(t=t.replace(".",n))}if(r.thousandsSeparator){const e=r.thousandsSeparator;s=i.lastIndexOf(n),s=s>-1?s:i.length;let a=i.substring(s),o=-1;for(var d=s;d>0;d--)o++,o%3==0&&d!==s&&(!t||d>1)&&(a=e+a),a=i.charAt(d-1)+a;i=a}return i=r.prefix?r.prefix+i:i,i=r.suffix?i+r.suffix:i,i}return e}_validateDate(e,t){return e[t]=this._dateValidator(void 0,e[t]),e[t]&&!isNaN(e[t].getTime())||(e[t]=void 0),e[t]}_validateTaskProperties(e,t){const i=this;if(e.$={},e.tasks instanceof Array&&e.tasks.length>0?e.type="project":(!e.type||["project","task","milestone"].indexOf(e.type)<0)&&(e.type="task"),i._validateTaskDuration(e),void 0===e.hidden&&t&&(e.hidden=t.hidden),e.hidden=!!e.hidden,void 0===e.resources?e.resources=[]:e.resources=[e.resources].reduce(((e,t)=>e.concat(t)),[]),"project"===e.type?e.expanded=!!e.expanded:delete e.expanded,e.progress=Math.min(Math.max(0,parseFloat(e.progress)||0),100),i._validateTaskDates(e,t),i._validateTaskSegments(e),i._validateTaskIndicators(e),i._validateTaskPlannedDates(e),e.deadline){const t=i._validateDate(e,"deadline");!t||isNaN(t.getTime())?delete e.deadline:e.dateEnd&&(e.overdue=e.deadline.getTime()-e.dateEnd.getTime()<0)}else e.overdue=!1,delete e.deadline;if(!e.dateStart&&!e.dateEnd&&"project"===e.type&&!e.synchronized)return;const n=e.connections;if(n instanceof Array){for(let e=0;e<n.length;e++){const t=n[e],i=t.target="string"==typeof t.target?t.target:parseInt(t.target),a=t.type=parseInt(t.type);null==i||"number"==typeof i&&isNaN(i)||isNaN(a)?(n.splice(n.indexOf(t),1),e--):t.lag=parseInt(t.lag)||0}e.connections=e.connections.map((e=>Object.assign({},e)))}else e.connections=[];return e.class=e.class?e.class+"":"",e.class=void 0!==e.class&&null!==e.class?e.class:"",e}_validateTaskIndicators(e){const t=this,i=e.indicators;if(!i||!Array.isArray(i)||!i.length)return void delete e.indicators;let n=[];for(let e=0,a=i.length;e<a;e+=1){const a=i[e];if("object"!=typeof a)continue;const s=t._validateDate(a,"date");s&&s.getTime&&!isNaN(s.getTime())&&n.push(a)}e.indicators=n}_validateTaskSegments(e){const t=this,i=e.segments;if(!i||!Array.isArray(i)||i.length<2||"task"!==e.type)return void delete e.segments;const n=t.nonworkingDays.length>0||t.nonworkingHours.length>0;let a,s=[],r=[];for(let e=0,n=i.length;e<n;e+=1){const n=i[e];if("object"!=typeof n)continue;let a=parseFloat(n.duration);isNaN(a)&&delete n.duration,t._validateTaskDates(n),n.dateStart&&n.dateEnd&&s.push(n)}s.sort(((e,t)=>e.dateStart.getTime()-t.dateStart.getTime()));for(let i=0,o=s.length;i<o;i+=1){const o=s[i];let l=o.dateStart,c=o.dateEnd;o.dateStart=l=new Date(Math.max(e.dateStart.getTime(),l.getTime())),o.dateEnd=c=new Date(Math.min(e.dateEnd.getTime(),c.getTime())),a&&a.dateEnd.getTime()>l.getTime()&&(o.dateStart=l=new Date(a.dateEnd.getTime()+1e3),l.getTime()>=c.getTime())||l.getTime()>c.getTime()||(o.duration=t._convertDuration(n?t._getWorkingTime(l,c):c.getTime()-l.getTime(),!0),a=o,r.push(o))}r.length<2?delete e.segments:(r[0].dateStart=new Date(e.dateStart),r[r.length-1].dateEnd=new Date(e.dateEnd),e.segments=r)}_validateTaskDuration(e){const t=this;let i=t._convertDuration(parseFloat(e.duration))||0,n=t._convertDuration(parseFloat(e.minDuration))||0,a=t._convertDuration(parseFloat(e.maxDuration))||0;n&&a&&(a=Math.max(n,a)),i&&(n?i=Math.max(n,i):a&&(i=Math.min(i,a))),e.duration=t._convertDuration(i,!0),e.minDuration=t._convertDuration(n,!0),e.maxDuration=t._convertDuration(a,!0)}_validateTaskDates(e,t){const i=this,n=i._convertDuration(e.minDuration),a=i._convertDuration(e.maxDuration);let s=i._convertDuration(e.duration);if(void 0!==e.minDateStart&&(e.minDateStart=i._validateDate(e,"minDateStart")),void 0!==e.maxDateStart&&(e.maxDateStart=i._validateDate(e,"maxDateStart")),e.minDateStart&&e.maxDateStart&&(e.maxDateStart=new Date(Math.max(e.minDateStart.getTime(),e.maxDateStart.getTime()))),void 0!==e.minDateEnd&&(e.minDateEnd=i._validateDate(e,"minDateEnd")),void 0!==e.maxDateEnd&&(e.maxDateEnd=i._validateDate(e,"maxDateEnd")),e.minDateEnd&&e.maxDateEnd&&(e.maxDateEnd=new Date(Math.max(e.minDateEnd.getTime(),e.maxDateEnd.getTime()))),e.dateStart=i._validateDate(e,"dateStart"),e.dateEnd=i._validateDate(e,"dateEnd"),e.dateStart||(e.minDateStart?e.dateStart=e.minDateStart:e.maxDateStart?e.dateStart=e.maxDateStart:e.dateStart=i.dateStart),e.dateEnd||(e.minDateEnd?e.dateEnd=e.minDateEnd:e.maxDateEnd&&(e.dateEnd=e.maxDateEnd)),e.minDateStart&&(e.dateStart=new Date(Math.max(e.minDateStart.getTime(),e.dateStart.getTime()))),e.maxDateStart&&(e.dateStart=new Date(Math.min(e.maxDateStart.getTime(),e.dateStart.getTime()))),e.minDateEnd&&(e.dateEnd=new Date(Math.max(e.minDateEnd.getTime(),e.dateEnd.getTime()))),e.maxDateEnd&&(e.dateEnd=new Date(Math.min(e.maxDateEnd.getTime(),e.dateEnd.getTime()))),e.dateStart&&(i.min&&(s=Math.min(e.dateStart.getTime()-i.min.getTime(),s),e.duration=i._convertDuration(s,!0)),i.max&&(s=Math.min(i.max.getTime()-e.dateStart.getTime(),s),e.duration=i._convertDuration(s,!0))),!e.dateStart&&s&&e.dateEnd&&(e.dateStart=new Date(e.dateEnd.getTime()-s)),"task"!==e.type||e.dateStart&&!isNaN(e.dateStart.getTime())||!t||(e.dateStart=new Date(t.dateStart)),n&&e.dateStart)if(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)){const t=i._getTaskWorkingDateEnd(e,n);e.dateEnd=new Date(Math.max(e.dateEnd?e.dateEnd.getTime():0,t.getTime()))}else e.dateEnd=new Date(Math.max(e.dateEnd?e.dateEnd.getTime():0,e.dateStart.getTime()+n));if(s&&e.dateStart&&(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?e.dateEnd=i._getTaskWorkingDateEnd(e,s):e.dateEnd=new Date(e.dateStart.getTime()+s)),s||a){let t;t=i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?i._getTaskWorkingDateEnd(e,Math.max(s,a)):new Date(e.dateStart.getTime()+Math.max(s,a)),e.dateEnd.getTime()>t.getTime()&&(e.dateEnd=t)}"task"===e.type&&!e.dateEnd&&t&&(e.dateEnd=new Date(t.dateEnd)),e.dateStart=i._minMaxDateValidator(e.dateStart),e.dateEnd=i._minMaxDateValidator(e.dateEnd),"milestone"===e.type&&(e.dateStart=i._validateDate(e,"dateStart"),e.dateEnd=i._validateDate(e,"dateEnd"),e.dateStart=e.dateEnd=new Date(Math.max(e.dateStart?e.dateStart.getTime():0,e.dateEnd?e.dateEnd.getTime():0))),(e.dateStart||e.dateEnd||"project"!==e.type||e.synchronized)&&("milestone"!==e.type&&e.dateStart&&(e.dateEnd&&e.dateStart.getTime()>e.dateEnd.getTime()||!e.dateEnd)&&(e.dateEnd=new Date(e.dateStart.getTime()+36e5*("day"===i.view?1:24))),e.dateStart&&e.dateEnd&&(e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0)))}_validateTaskPlannedDates(e){const t=this;if(!e)return;const i=e.type,n=e.planned;if("milestone"===i||!n)return;const a=t._validateDate(n,"dateStart"),s=t._validateDate(n,"dateEnd");a&&s&&(n.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(a,s):s.getTime()-a.getTime(),!0))}_synchronizeProjectDates(e,t){const i=this;if(e){void 0===t&&(t=i._getProjectTasks(e));for(let a=0,s=t.length;a<s;a+=1){const s=t[a];e.synchronized&&(s.dateStart&&(e.dateStart=n(s,"dateStart","min")),s.dateEnd&&(e.dateEnd=n(s,"dateEnd","max")),s.minDateStart&&(e.minDateStart=n(s,"minDateStart","max")),s.maxDateStart&&(e.maxDateStart=n(s,"maxDateStart","min")),s.minDateEnd&&(e.minDateEnd=n(s,"minDateEnd","max")),s.maxDateEnd&&(e.maxDateEnd=n(s,"maxDateEnd","min")),e.dateStart&&e.dateEnd&&(e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0)))}e.$&&i._synchronizeProjectDates(e.$.project,t)}function n(t,i,n){const a=e[i];let s=t[i];return void 0===a?new Date(s):s instanceof Date?new Date(Math[n](a.getTime(),s.getTime())):void 0}}_synchronizeProjectVisibility(e,t){const i=this;e&&e.hidden&&!t.hidden&&(e.hidden=t.hidden,e.$&&i._synchronizeProjectVisibility(e.$.project,e))}_mouseWheelHandler(e){const t=this,i=(t.shadowRoot||t).querySelector(".smart-task-popup-window");if(i&&i.modal&&i.opened)return void e.stopPropagation();if(t.disabled||!t.computedHorizontalScrollBarVisibility&&!t.computedVerticalScrollBarVisibility)return;if(e.shiftKey)return void t._handleHorizontalScroll(e);const n=t.$.resourceSplitterItem;t.$.mainSplitter.contains(n)&&n.contains(e.target)?t._handleVerticalScroll(e,!0):t.$.taskSplitterItem.contains(e.target)&&t._handleVerticalScroll(e)}_handleVerticalScroll(e,t){const i=this;let n,a,s,r;if(t){if(n=i.$.resourceVerticalScrollBar,n.classList.contains("smart-hidden")||n.disabled)return!0;a=n.value,s=n.max,r=i._resourceScrollView}else{if(!i.computedVerticalScrollBarVisibility||i.$.verticalScrollBar.disabled)return!0;a=i.scrollTop,s=i.scrollHeight,r=i}if(0===a&&e.deltaY<0||a===s&&e.deltaY>0)return void e.stopPropagation();const o=i.$[t?"resourceTable":"taskTable"];if(e.stopPropagation(),e.preventDefault(),a+=i._getScrollCoefficient(e,i.offsetHeight),r){const e=o.$.virtualizationContainer;e.scrollHeight!==r.scrollHeight&&(e.scrollHeight=r.scrollHeight),r.scrollTo(a,void 0)}o.scrollTop=a,i._hoveredItem&&i._handleTableItemHover()}_handleHorizontalScroll(e){const t=this;if(!t.computedHorizontalScrollBarVisibility)return!0;const i=t.scrollLeft;(0===i&&e.deltaX<0||i===t.scrollHeight&&e.deltaX>0)&&e.stopPropagation(),e.stopPropagation(),e.preventDefault(),t.scrollWidth>0&&t.scrollTo(void 0,t.scrollLeft+t._getScrollCoefficient(e,t.offsetWidth))}_handleHeaderTemplate(e="task"){const t=this;if(!("content"in document.createElement("template")))return void t.error(t.localize("htmlTemplateNotSuported",{elementType:t.nodeName.toLowerCase()}));const i=t.$[`${e}SplitterItemHeader`],n=t.$[`${e}SplitterItem`],a="task"===e?"headerTemplate":"resourcePanelHeaderTemplate";let s=t[a];if(n.removeAttribute("show-header"),i.innerHTML="",!s)return;if("function"==typeof s)return s(i,{}),void(i.innerHTML?n.setAttribute("show-header",""):n.removeAttribute("show-header"));if("string"==typeof s&&(s=document.getElementById(s)),null===s||!("content"in s))return void t.error(t.localize("invalidTemplate",{elementType:t.nodeName.toLowerCase(),property:a}));let r=document.importNode(s.content,!0);if(n.setAttribute("show-header",""),t.shadowRoot)return i.innerHTML="<slot></slot>",void t.appendChild(r);i.appendChild(r)}_handleCollapseExpandMethods(e,t){const i=this,n=i._tasks;if(null==e||!n||!n.length)return;const a=i._getValidItemAndIndex(e);if(!a||!a.item)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"collapse",argumentName:"task"}));let s=a.item;"project"!==s.type&&(s=s.$.project),s&&(s.hidden?s.expanded="expand"===t:i.$.taskTable["expand"===t?"expandRow":"collapseRow"](s.$.id))}_getValidItemAndIndex(e,t="task"){const i=this,n="task"===t?i._tasks:i._resources;let a;if(null==e||!n||!n.length)return{};if("string"==typeof e||"number"==typeof e){const t=e.toString();let i,s;for(let a=0,r=n.length;a<r;a+=1){const r=n[a];if(!i){const n=r.id;if(null!=n&&n.toString&&n.toString()===t){i=r,e=a;break}}r.$.id===t&&(s=r,e=a)}a=i||s}else"object"==typeof e&&(a=n[i._getItemIndex(e,t)],e=n.indexOf(a));return{item:a,index:e}}_horizontalScrollbarHandler(e){const t=this,i=t._getScrollLeft(e.detail.value);e.stopPropagation&&e.stopPropagation(),t.$.timelineHeader.scrollLeft=t.$.taskTimelineContainer.scrollLeft=i,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=i),t._recycle(e),e.context.min!==e.context.value?e.context.max===e.context.value&&(t._handleInfiniteTimeline(),t.$.fireEvent("scrollRightReached")):t.$.fireEvent("scrollLeftReached")}_verticalScrollbarHandler(e){const t=this,i=e.target,n=Math.round(e.detail.value);e.stopPropagation&&e.stopPropagation(),i&&i===t.$.resourceVerticalScrollBar?t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=n:(t.$.taskTimelineContainer.scrollTop=n,t.$.taskTable.scrollTop=n),t._recycle(e),e.context.max!==e.context.value?e.context.min===e.context.value&&t.$.fireEvent("scrollTopReached"):t.$.fireEvent("scrollBottomReached")}_handleInfiniteTimeline(){const e=this,t=e._timelineCells;if(!e.infiniteTimeline||!t||!t.length)return;const i=e.infiniteTimelineStep,n=t[t.length-1].date;switch(e.view){case"year":n.setMonth(n.getMonth()+i);break;case"month":n.setDate(n.getDate()+7*i);break;case"week":n.setDate(n.getDate()+i);break;case"day":n.setHours(n.getHours()+i)}e.set("dateEnd",n),e._createTimelineCells(),e._recycleTimelineTasks(!0),e.$.mainSplitter.contains(e.$.resourceSplitter)&&e._refreshResourceTimeline(),e._refresh()}_nonworkingDayValidator(e,t){return this._nonworkingDateTimeValidator(e,t)}_nonworkingTimeValidator(e,t){return this._nonworkingDateTimeValidator(e,t,!0)}_nonworkingDateTimeValidator(e,t,i){const n=this,[a,s,r]=i?[0,23,24]:[0,6,7];let o=[];function l(e){let t=Math.max(a,Math.min(s,parseInt(e[0]))),i=Math.max(a,Math.min(s,parseInt(e[1])));if(!isNaN(t)&&!isNaN(i)){for(;t!==i;)o.push(t),t=t===s?a:++t;o.push(t)}return o}for(let e=0;e<t.length;e++){const i=t[e];"number"!=typeof i||isNaN(i)?"string"==typeof i?o=l(i.split("-").map((e=>parseInt(e)))):Array.isArray(i)&&(o=l(i)):o.push(Math.max(a,Math.min(s,parseInt(i))))}return o.length===r&&(o.pop(),n.warn(n.localize("invalidNonworkingRange",{elementType:n.nodeName.toLowerCase(),property:i?"nonworkingHours":"nonworkingDays"}))),o}});
90
+ Smart("smart-gantt-chart",class extends Smart.ScrollViewer{static get properties(){return{adjustToNonworkingTime:{value:!1,type:"boolean"},autoSchedule:{value:!1,type:"boolean"},autoScheduleStrictMode:{value:!1,type:"boolean"},autoScrollStep:{value:5,type:"number"},columnMenu:{value:!1,type:"boolean"},columnMinWidth:{value:"50px",type:"any"},columnResize:{value:!1,type:"boolean"},columnResizeFeedback:{value:!1,type:"boolean"},currentTimeIndicator:{value:!1,type:"boolean"},currentTimeIndicatorInterval:{value:1,validator:"_currentTimeIndicatorIntervalValidator",type:"number"},dataExport:{value:{exportFiltered:{value:!1,type:"boolean"},itemType:{value:"task",type:"string"},fileName:{value:"smartGanttChart",type:"string?"}},type:"object"},dataSource:{value:[],type:"any",reflectToAttribute:!1},dateEnd:{value:"",type:"any",validator:"_dateValidator"},dateStart:{value:"",type:"any",validator:"_dateValidator"},dateMarkers:{value:[],reflectToAttribute:!1,type:"array"},dayFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},disableAutoScroll:{value:!1,type:"boolean"},disableTaskDrag:{value:!1,type:"boolean"},disableTaskProgressChange:{value:!1,type:"boolean"},disableTaskResize:{value:!1,type:"boolean"},disableSelection:{value:!1,type:"boolean"},disableSegmentDrag:{value:!1,type:"boolean"},disableSegmentResize:{value:!1,type:"boolean"},disableWindowEditor:{value:!1,type:"boolean"},durationUnit:{value:"milisecond",allowedValues:["day","week","hour","minute","second","milisecond"],type:"string"},filterRow:{value:!1,type:"boolean"},groupByResources:{value:!1,type:"boolean"},headerTemplate:{value:null,type:"any"},hourFormat:{value:"default",allowedValues:["default","2-digit","numeric"],type:"string"},hideDateMarkers:{value:!1,type:"boolean"},hideTimelineHeaderDetails:{value:!1,type:"boolean"},hideResourcePanel:{value:!1,type:"boolean"},showSelectionColumn:{value:!1,type:"boolean"},infiniteTimeline:{value:!1,type:"boolean"},infiniteTimelineStep:{value:5,type:"number"},inverted:{value:!1,type:"boolean"},keyboardNavigation:{value:!1,type:"boolean"},messages:{extend:!0,value:{en:{duplicateIds:"{{elementType}}: DataSource contains duplicate ids. Tasks should have unique ids. The following ids are duplicating: {{duplicates}}.",invalidNonworkingRange:"{{elementType}}: Invalid {{property}} value. {{property}} should not contain all possible days/hours because it will result in an endless timeline. The value has been validated by removing the last item from the new value range.",invalidValue:"{{elementType}}: Invalid {{property}} value. {{property}} should be of type {{typeOne}} or {{typeTwo}}.",incorrectArgument:"{{elementType}}: Incorrect argument {{argumentName}} in method {{methodName}}.",outOfBounds:"{{elementType}}: Out of bounds argument {{argumentName}} in method {{methodName}}.",missingReference:"{{elementType}}: Missing reference to {{file}} in method {{methodName}}.",alreadyExists:"{{elementType}}: The item already exists when calling the {{methodName}} method.",notExisting:"{{elementType}}: The item does not exists when calling the {{methodName}} method.",notAProject:"{{elementType}}: The {{argumentName}} argument in {{methodName}} method does not reference an item of type 'project'.",noId:"smartGanttChart requires an id in order to save/load/clear a state.",ok:"Ok",add:"Add",remove:"Remove",cancel:"Cancel",delete:"Delete",confirm:"{{componentName}} will be deleted permanently, <b>are you sure? </b>",taskColumnLabel:"Task Name",resourceColumnLabel:"Resource Name",deleteLink:"Delete link",unassigned:"Unassigned",generalTab:"General",dependencyTab:"Dependency",segmentsTab:"Segments",segment:"Segment",dependencyValidation:"*The Task cannot be connected to itself.",segmentsCountValidation:"*Segmented Tasks must have at least 2 segments. ",segmentConflictError:'*The Segment "{{label}}" is in conflict, because it starts on/before and ends on/after the {{dateConflict}} of Segment "{{conflictLabel}}." ',segmentStartError:'*The Segment "{{label}}" cannot start before it ends and cannot end before it starts.',segmentEndError:'*The Segment "{{label}}" cannot start when it ends.',segmentRangeError:'*The Segment "{{label}}" is out of Task date range. The first segment must start when the task starts and the last segment must end when the task ends.',label:"Label",duration:"Duration",dateStart:"Date Start",dateEnd:"Date End",id:"Id",name:"Name",type:"Type",lag:"Lag",startToStart:"Start-To-Start",endToStart:"End-To-Start",endToEnd:"End-To-End",startToEnd:"Start-To-End",overdue:"Overdue",weeks:"week(s)",days:"day(s)",hours:"hour(s)",minutes:"minute(s)",seconds:"second(s)",miliseconds:"milisecond(s)",task:"Task",resource:"Resource",assignments:"Assignments",startTask:"Task Start",endTask:"Task End",deadline:"Deadline"}},type:"object"},monthFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},max:{value:new Date(2100,0,1),type:"any",validator:"_dateValidator"},min:{value:new Date(1900,0,1),type:"any",validator:"_dateValidator"},nonworkingDays:{value:[],type:"array",validator:"_nonworkingDayValidator"},nonworkingHours:{value:[],type:"array",validator:"_nonworkingTimeValidator"},popupWindowCustomizationFunction:{value:null,reflectToAttribute:!1,type:"function?"},popupWindowTabs:{value:["general","dependency","segments"],reflectToAttribute:!1,type:"array"},progressLabelFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resizeHandlesVisibility:{allowedValues:["auto","hidden","visible"],value:"auto",type:"string"},resourceColumns:{value:[{label:"resourceColumnLabel",value:"label"}],type:"array",reflectToAttribute:!1},resourceFiltering:{value:!1,type:"boolean"},resourceGroupFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resourcePanelHeaderTemplate:{value:null,type:"any"},resourcePanelMin:{value:100,type:"any"},resourcePanelSize:{value:"",type:"any"},resourcePanelRefreshRate:{value:0,reflectToAttribute:!1,type:"number"},resourceTimelineFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},resourceTimelineMode:{allowedValues:["diagram","histogram","custom"],value:"diagram",type:"string"},resourceTimelineView:{allowedValues:["hours","tasks","custom"],value:"hours",type:"string"},selectedTaskIds:{value:[],type:"array"},selectedResourceIds:{value:[],type:"array"},shadeUntilCurrentTime:{value:!1,type:"boolean"},showBaseline:{value:!1,type:"boolean"},showProgressLabel:{value:!1,type:"boolean"},snapToNearest:{value:!1,type:"boolean"},sortFunction:{value:null,type:"function?",reflectToAttribute:!1},sortMode:{value:"none",allowedValues:["none","one","many"],type:"string"},taskColumns:{value:[{label:"taskColumnLabel",value:"label"}],type:"array",reflectToAttribute:!1},taskFiltering:{value:!1,type:"boolean"},taskPanelMin:{value:200,type:"any"},taskPanelSize:{value:"",type:"any"},timelineHeaderFormatFunction:{value:null,reflectToAttribute:!1,type:"function?"},timelineMin:{value:200,type:"any"},treeMin:{value:100,type:"any"},treeSize:{value:"20%",type:"any"},tooltip:{value:{enabled:{value:!1,type:"boolean"},arrow:{value:!1,type:"boolean"},delay:{value:50,type:"number"},offset:{value:[0,5],type:"array"}},type:"object"},verticalScrollBarVisibility:{type:"string",value:"auto",allowedValues:["auto","disabled","hidden","visible"]},view:{value:"year",allowedValues:["day","week","month","year"],type:"any"},yearFormat:{value:"numeric",allowedValues:["2-digit","numeric"],type:"string"},weekFormat:{value:"long",allowedValues:["long","numeric"],type:"string"}}}template(){return'<div id="container" role="presentation">\n <smart-splitter id="mainSplitter" auto-fit-mode="end" keep-proportions-on-resize right-to-left="[[rightToLeft]]" animation="[[animation]]" orientation="horizontal">\n <smart-splitter-item id="taskSplitterItem" class="smart-task-splitter-item">\n <div id="taskSplitterItemHeader" class="smart-task-panel-header"></div>\n <smart-splitter id="taskSplitter" class="smart-task-splitter" auto-fit-mode="end">\n <smart-splitter-item id="tableSplitterItem">\n <smart-table right-to-left="[[rightToLeft]]" wait id="taskTable" class="smart-task-table" virtualization animation="none" deferred-scroll-delay="0" ></smart-table>\n </smart-splitter-item>\n <smart-splitter-item id="timelineSplitterItem" class="smart-timeline-splitter-item">\n <div id="timeline" class="smart-timeline">\n <div id="timelineHeader" class="smart-timeline-header" role="rowgroup">\n <div id="timelineHeaderContent" class="smart-timeline-header-content">\n <div class="smart-timeline-view-details" id="timelineViewDetails" role="row"></div>\n <div class="smart-timeline-view-cells" id="timelineViewCells" role="row"></div>\n </div>\n </div>\n <div id="taskTimelineContainer" class="smart-timeline-content-container">\n <div id="timelineContent" class="smart-timeline-content">\n <div id="taskTimelineCellsContainer" class="smart-timeline-cells-container" aria-hidden="true"></div>\n <div id="taskIndicatorsContainer" class="smart-timeline-indicators-container" role="group"></div>\n <div id="timelineConnectionsContainer" class="smart-timeline-connections-container" role="group"></div>\n <div id="timelineBaselinesContainer" class="smart-timeline-baselines-container" role="group"></div>\n <div id="timelineTasksContainer" class="smart-timeline-tasks-container" role="group"></div>\n <div id="timelineMarkers" class="smart-timeline-markers-container" role="group"></div>\n <div id="timelineDeadlines" class="smart-timeline-deadlines-container" role="group"></div>\n </div>\n </div>\n </div>\n <smart-scroll-bar id="verticalScrollBar" class="smart-timeline-scroll-bar" orientation="vertical"\n right-to-left="[[rightToLeft]]" aria-controls="[[id]]">\n </smart-scroll-bar>\n </smart-splitter-item>\n </smart-splitter>\n </smart-splitter-item>\n </smart-splitter>\n <smart-scroll-bar wait id="horizontalScrollBar" class="smart-timeline-scroll-bar"></smart-scroll-bar>\n </div>'}static get listeners(){return{down:"_downHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler","document.dragstart":"_dragStartHandler","container.wheel":"_mouseWheelHandler","horizontalScrollBar.change":"_horizontalScrollbarHandler","verticalScrollBar.change":"_verticalScrollbarHandler","resourceVerticalScrollBar.change":"_verticalScrollbarHandler","mainSplitter.resizeEnd":"_resizeEventHandler","mainSplitter.resize":"_resizeEventHandler",move:"_moveHandler","mainSplitter.change":"_tableChangeHandler","mainSplitter.filter":"_tableSortFilterHandler","mainSplitter.sort":"_tableSortFilterHandler","mainSplitter.columnResize":"_tableColumnResizeHandler","taskTable.group":"_taskTableGroupEventHandler","taskTable.collapse":"_taskTableExpandHandler","taskTable.expand":"_taskTableExpandHandler","taskTable.keydown":"_taskTableKeyDownHandler"}}static get styleUrls(){return["smart.ganttchart.css"]}attached(){const e=this;if(super.attached(),e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e.$.taskSplitterItem,e.$.horizontalScrollBar,e.$.verticalScrollBar)),!e._resourceScrollView&&e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._resourceScrollView=new Smart.Utilities.Scroll(e.$.resourceSplitterItem,e.$.horizontalScrollBar,e.$.resourceVerticalScrollBar)),e.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);e.$.timelineHeader.scrollLeft=e.$.taskTimelineContainer.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineHeader.scrollLeft=e.$.resourceTimelineContent.scrollLeft=t)}if(e.scrollTop){const t=e.scrollTop;e.$.taskTimelineContainer.scrollTop=t,e.$.timelineContent.scrollTop=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollTop=t)}const t=["taskPopupWindow","connectionPopupWindow","confirmPopupWindow"];for(let i=0;i<t.length;i++){const n=t[i];if(e.$[n]&&e.$[n].opened){const t=e["$"+n];e._handleModal(!0),t.listen("close",e._popupWindowCloseHandler.bind(e)),t.listen("closing",e._popupWindowClosingHandler.bind(e)),t.listen("open",e._popupWindowOpenHandler.bind(e)),t.listen("click",e._popupWindowClickHandler.bind(e)),t.listen("change",e._popupWindowChangeHandler.bind(e)),t.listen("transitionend",e._popupWindowTransitionendHandler.bind(e)),e.getShadowRootOrBody().appendChild(e.$[n])}}e._handleTooltipEvents(!0),e._currentTimeIndicatorInterval||!e.currentTimeIndicator&&!e.shadeUntilCurrentTime||e._setCurrentTimeIndicators()}detached(){const e=this;super.detached(),e._scrollView&&(e._scrollView.unlisten(),delete e._scrollView),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView);const t=["taskPopupWindow","connectionPopupWindow","confirmPopupWindow"];e._handleModal();for(let i=0;i<t.length;i++){const n=t[i],a=e["$"+n];e.$[n]&&e.$[n].remove(),a&&(a.unlisten("open"),a.unlisten("close"),a.unlisten("closing"),a.unlisten("click"),a.unlisten("change"),a.unlisten("transitionend"))}e._handleTooltipEvents(),clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval}propertyChangedHandler(e,t,i){const n=this;switch(e){case"adjustToNonworkingTime":for(let e=0;e<n._tasks.length;e++){const t=n._tasks[e],i=t.$.project;n._validateTaskDates(t,i),n._validateTaskSegments(t),n._synchronizeProjectDates(t,i),n._refreshTableColumnsData(t,["dateEnd","duration"])}n._refreshTimeline();break;case"animation":break;case"autoSchedule":i?n._autoSchedule():n._autoScheduleRestore();break;case"autoScheduleStrictMode":i&&(n._autoSchedule(),n._refreshTimeline());break;case"columnMinWidth":case"columnResizeFeedback":case"columnResize":{const t=n.$.taskTable,a=n.$.resourceTable;t[e]=i,a&&(a[e]=i);break}case"currentTimeIndicator":case"shadeUntilCurrentTime":n._setCurrentTimeIndicators();break;case"dataSource":n.scrollLeft=n.scrollTop=0,n._createTasks(),n._refreshTableDataSource(),n._createTimeline(),n._createResourceTimeline(),n._setAriaControls();break;case"dateMarkers":n._createDateMarkers();break;case"hideDateMarkers":n._recycleDateMarkers();break;case"disableSelection":i?(n.$.taskTree.selectionMode="none",n.$.resourceTree.selectionMode="none",n._unselectAll("task"),n._unselectAll("resource")):(n.$.taskTree.selectionMode="zeroOrOne",n.$.resourceTree.selectionMode="zeroOrOne");break;case"durationUnit":for(let e=0;e<n._tasks.length;e++){const t=n._tasks[e],i=t.$.project;n._validateTaskDuration(t),n._validateTaskDates(t,i),n._validateTaskSegments(t),n._synchronizeProjectDates(t,i)}n._createTimelineCells(),n._insertTimelineTasks(),n.taskColumns.some((e=>(e.value+"").toLowerCase().indexOf("duration")>-1))&&n._refreshTableDataSource();break;case"filterRow":n.$.taskTable[e]=i;break;case"groupByResources":n._setTable(n.$.taskTable),n._createTimelineContent(),n._recycleTimelineTasks(),n._refresh();break;case"infiniteTimeline":i?n._scrollView.hScrollBar.value===n._scrollView.hScrollBar.max&&n._handleInfiniteTimeline():n.set("dateEnd","");break;case"keyboardNavigation":n.$.taskTable[e]=i,n.$.resourceTable&&(n.$.resourceTable[e]=i);break;case"popupWindowTabs":case"popupWindowCustomizationFunction":{const e=n.$.taskPopupWindow;e&&(e.opened&&(e.close(),delete e._target),e.clear());break}case"taskFiltering":n.$.taskTable.filtering=i,n._refresh();break;case"resourceFiltering":{const e=n.$.resourceTable;e&&(e.filtering=i,n._refresh());break}case"tooltip_enabled":{const e=n.$.tooltip;e&&(i||e.remove(),n._handleTooltipEvents(i));break}case"tooltip_arrow":case"tooltip_delay":case"tooltip_offset":{const t=n.$.tooltip;t&&(t[e.replace("tooltip_","")]=i);break}case"headerTemplate":n._handleHeaderTemplate();break;case"inverted":if(n._handleInverted(),n.scrollLeft){const e=n._getScrollLeft(n.scrollLeft);n.$.timelineHeader.scrollLeft=n.$.taskTimelineContainer.scrollLeft=e,n.$.mainSplitter.contains(n.$.resourceTimelineHeader)&&(n.$.resourceTimelineHeader.scrollLeft=n.$.resourceTimelineContent.scrollLeft=e)}break;case"rightToLeft":Array.from(n.querySelectorAll("smart-splitter, smart-table, smart-scroll-bar")).forEach((t=>t[e]=i)),n.closeWindow(),n._handleInverted(),n._refreshTimeline();break;case"dateStart":case"dateEnd":n._refreshTimeline();break;case"messages":case"locale":case"dayFormat":case"hourFormat":case"timelineHeaderFormatFunction":case"monthFormat":case"yearFormat":n._refreshHeaderDate(!0),n._refreshColumnsHeaders(),n._recycleResourceHeaderCells();break;case"hideResourcePanel":n._createResourceTimeline(),n._refreshTimeline();break;case"nonworkingDays":case"nonworkingHours":n._refreshAfterWorkingTimeChange();break;case"selectedTaskIds":n.$.taskTable.selected=n._getSelection("task",i);break;case"selectedResourceIds":n.$.resourceTable&&(n.$.resourceTable.selected=n._getSelection("resource",i));break;case"resourceColumns":n._setTable(n.$.resourceTable),n._highlightAssignedItem("task",n._getSelection("task",n.selectedTaskIds));break;case"resourcePanelHeaderTemplate":n._handleHeaderTemplate("resource");break;case"resourceTimelineView":case"resourceTimelineMode":case"resourceTimelineFormatFunction":n.$.mainSplitter.contains(n.$.resourceSplitter)&&n._resources.forEach((e=>n._refreshResourceTimelineContent(e)));break;case"showProgressLabel":case"progressLabelFormatFunction":n._tasks.forEach((e=>n._setTaskBarProgress(e)));break;case"sortFunction":n.$.taskTable.sort=i,n.$.resourceTable&&(n.$.resourceTable.sort=i);break;case"showSelectionColumn":n.$.taskTable.hideSelectionColumn=!i,n.$.resourceTable&&(n.$.resourceTable.hideSelectionColumn=!i);break;case"columnMenu":case"hideSelectionColumn":case"sortMode":n.$.taskTable[e]=i,n.$.resourceTable&&(n.$.resourceTable[e]=i);break;case"taskColumns":n._setTable(n.$.taskTable);break;case"timelineMin":n.$.timelineSplitterItem.min=i,n.$.taskSplitter.refresh(),n.$.mainSplitter.contains(n.$.resourceSplitter)&&n._synchronizeSplitters(n.$.taskSplitter,n.$.resourceSplitter);break;case"treeMin":case"treeSize":{const t=e.toLowerCase().indexOf("size")>-1?"size":"min";n.$.tableSplitterItem[t]=i,n.$.taskSplitter.refresh(),n.$.mainSplitter.contains(n.$.resourceSplitter)&&n._synchronizeSplitters(n.$.taskSplitter,n.$.resourceSplitter);break}case"taskPanelMin":case"taskPanelSize":case"resourcePanelSize":case"resourcePanelMin":{const t=e.indexOf("Min")>-1?"min":"size",a=e.indexOf("resource")>-1?"resource":"task";n.$.mainSplitter.contains(n.$.resourceSplitter)&&(n.$[`${a}SplitterItem`][t]=i,n.$.taskSplitterItem._setSize("size",n.taskPanelSize),n.refresh());break}case"unfocusable":n._setFocusable();break;case"view":n._refreshTimeline(t);break;default:super.propertyChangedHandler(e,t,i)}}_predefPropertyGetter(e){const t=this;Object.defineProperty(t,e,{get:function(){switch(e){case"dataSource":{if(t.context===t)return t.properties[e].value;const i=function(e){if(!e.length)return e;for(let n=0;n<e.length;n++){const a=e[n];let s=t._getProjectTasks(a);s&&Array.isArray(s)&&(s=i(s.filter((e=>e.$&&e.$.project===a)))),e[n]=t._cloneObject(a),s&&s.length?e[n].tasks=s:delete e[n].tasks}return e},n=t.properties[e].value;return n instanceof Smart.DataAdapter?n:i(n.slice(0))}case"dateStart":case"dateEnd":{const i=t._timelineCells;if(i.length){const n=t._getCellDateRange({_date:i["dateStart"===e?0:i.length-1].date});return new Date(n[e])}return t.properties[e].value}default:return t.properties[e].value}},set(i){t.updateProperty(t,t._properties[e],i)}})}ready(){this._customScrollView=!0,super.ready()}render(){const e=this,t=window.getComputedStyle(e),i=Smart.Utilities.Core;e._isMobile=i.isMobile,e._isFirefox=i.Firefox,e._taskBarMinWidth=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-task-min-width"))||0,e._taskDefaultHeight=parseFloat(t.getPropertyValue("--smart-gantt-chart-task-default-height"))||30,e._timelineCellSize=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-cell-size"))||0,e._timelineCellMinSize=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-cell-min-size"))||0,e._taskConnectionWidth=parseFloat(t.getPropertyValue("--smart-gantt-chart-timeline-task-connection-width"))||1,e._baselineProportion=parseFloat(t.getPropertyValue("--smart-gantt-chart-baseline-proportion"))||0,e._predefPropertyGetter("dataSource"),e._predefPropertyGetter("dateStart"),e._predefPropertyGetter("dateEnd"),e.$.tableSplitterItem.size=e.treeSize,e.$.tableSplitterItem.min=e.treeMin,e.$.timelineSplitterItem.min=e.timelineMin,e._setScrollBars(),e._handleHeaderTemplate(),e._handleInverted(!0),e._createTasks(),e._setTable(),e._createTimeline(),e._createResourceTimeline(),e._setAriaControls(),e._setFocusable(),e.checkLicense(),(e.shadowRoot||e._isFirefox)&&requestAnimationFrame((()=>e.refresh())),super.render()}refresh(e){const t=this;if(e)return t._refreshTimeline(),t._setTable(t.$.taskTable),void t._createResourceTimeline();t.isRendered&&t._resizeEventHandler()}addFilter(e,t){const i=this;if(!i.taskFiltering&&!i.resourceFiltering||!(t instanceof Smart.Utilities.FilterGroup))return;Array.isArray(e)||(e="object"==typeof e?[e]:[]);const n=i.taskColumns,a=i.resourceColumns,s=i.$.taskTable,r=i.$.resourceTable;for(let i=0;i<e.length;i++){const o=e[i],l=o.type,[c,d]="resource"===l||a.includes(o)?[r,a]:[s,n],m=d.find((e=>o.value&&e.value===o.value));m&&c.addFilter(m.value,t)}}clearSelection(){this._unselectAll("task"),this._unselectAll("resource")}static get requires(){return{"Smart.Splitter":"smart.splitter.js","Smart.Tree":"smart.tree.js","Smart.Window":"smart.window.js"}}ensureVisible(e,t="task"){const i=this,n=i._getValidItemAndIndex(e,t);(e=n?n.item:void 0)&&(i._ensureVisible(e,t),i._scrollTo(e.dateStart,!0))}removeAllConnections(){const e=this;e.isCompleted&&(e.$.timelineConnectionsContainer.innerHTML="",e._connections=[],e._tasks.map((e=>e.connections=[])))}removeConnection(){const e=this,t=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted)return;let i;if(1===t.length){if("string"==typeof t[0]){const e=document.getElementById(t[0]);e&&(i=e.getAttribute("connection-id"))}i||(i=(t[0]+"").split("-"),i=e._getValidConnectionId(i[0],i[1],i[2],"removeConnection"))}else 3===t.length&&(i=e._getValidConnectionId(t[0],t[1],t[2],"removeConnection"));i&&(e._removeConnection(i),e.$.fireEvent("itemRemove",{type:"connection",id:`${i[0]}-${i[1]}-${i[2]}`,item:{source:i[0],target:i[1],type:i[2]}}))}removeTaskConnection(e,t){const i=this;if(!i.isCompleted)return;if((e+="").indexOf("-")>-1&&!t){const i=e.split("-");t=i[1],e=i[0]}const n=i._getValidItemAndIndex(e),a=i._getValidItemAndIndex(t);e=n?n.index:void 0,t=a?a.index:void 0,isNaN(e)?i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"removeTaskConnection",argumentName:"taskEndIndex"})):i._removeConnection(""+e+(isNaN(t)?"":t))}beginUpdate(){this._isUpdating={started:!0,type:{}},this.$.fireEvent("beginUpdate")}endUpdate(){const e=this;function t(){e._refreshTableDataSource(),e._createTimelineContent(),e._recycleTimelineTasks(),e._setAriaControls();const t=e._resources;for(let i=0;i<t.length;i++)e._refreshTableColumnsData(t[i],void 0,"resource")}function i(){if(e.hideResourcePanel)return;e._refreshTableDataSource("resource"),e._recycleResourceHeaderCells(),e._createResourceTimelineContent(),e._refresh();const t=e._tasks;for(let i=0;i<t.length;i++)e._refreshTableColumnsData(t[i])}if(!e._isUpdating)return;const n=1===Object.keys(e._isUpdating.type).length?Object.keys(e._isUpdating.type)[0]:void 0;let a,s;switch(e._selected&&({task:a,resource:s}=e._selected),delete e._isUpdating,n){case"task":t();break;case"resource":i();break;default:t(),i()}a&&(e._refreshSelectedItems("task",a),e.$.taskTable.selected=e._getSelection("task",e.selectedTaskIds)),s&&(e._refreshSelectedItems("resource",s),e.$.resourceTable.selected=e._getSelection("resource",e.selectedResourceIds)),e.$.fireEvent("endUpdate")}clearFilters(e){this._resetFromAction(e,"clearFilters")}clearSort(e){const t=this;"task"!==e&&"resource"!==e?(t._resetFromAction("task","clearSort"),t._resetFromAction("resource","clearSort")):t._resetFromAction(e,"clearSort")}clearTasks(){this._clearTasks()}_clearTasks(){const e=this;e._selected&&delete e._selected.task,e.set("selectedTaskIds",[]),e._tasks=[],e._timelineCells=[],e._timelineVCells=[],e._timelineHeaderCells=[],e.$.timelineContent.style.width="",e.$.container.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e.$.timelineViewDetails.innerHTML="",e.$.timelineViewCells.innerHTML="",e.$.taskTimelineCellsContainer.innerHTML="",e.$.timelineConnectionsContainer.innerHTML="",e.$.timelineTasksContainer.innerHTML="",e.$.taskIndicatorsContainer.innerHTML="",e.$.timelineContent.style.height="",delete e._hoveredItem,e.$.taskTable.dataSource=[],e._closeTooltip(),e.closeWindow(),e._refresh()}clearResources(){const e=this;e._unselectAll("resource"),e._resources=[],e.$.resourceTable&&(e.$.resourceTable.dataSource=[]),e.$.resourceTimelineCellsContainer.innerHTML="",e._tasks.forEach((t=>{t.resources=[],e._refreshTableColumnsData(t,["resources"])})),e._refreshTimeline(),e._createResourceTimeline()}createConnection(){const e=this,t=e._tasks;let i,n=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted||0===t.length)return;if(i=1===n.length?(n[0]+"").split("-"):n,!e._getValidConnectionId(i[0],i[1],i[2],"createConnection"))return;const a=parseInt(i[3]);e._connectTask([i[0],i[1],i[2],isNaN(a)?0:a]),e._recycleConnections(),e.$.fireEvent("itemInsert",{type:"connection",item:{source:i[0],target:i[1],type:i[2],lag:a}})}collapse(e){this._handleCollapseExpandMethods(e,"collapse")}expand(e){this._handleCollapseExpandMethods(e,"expand")}exportData(e,t){const i=this;if(!Smart.Utilities.DataExporter)return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"smart.export.js"}));try{new JSZip}catch(e){return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"jszip.min.js"}))}if("pdf"===e&!window.pdfMake)return void i.error(i.localize("missingReference",{elementType:i.nodeName.toLowerCase(),methodName:"exportData",file:"pdfMake.min.js"}));const n="task"===i.dataExport.itemType?i.$.taskTable:i.$.resourceTable;return n?n.exportData(e,i.dataExport.fileName,i.dataExport.exportFiltered,t):void 0}print(){const e=this,t=e.dataExport.fileName;e.dataExport.fileName=null;const i=e.exportData("html"),n=window.open("","","width=800,height=500"),a=n.document.open(),s='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+i+"</body></html>";try{a.write(s),a.close(),setTimeout((function(){n.print(),n.close()}),100)}catch(e){}e.dataExport.fileName=t}getConnectionDetails(e){const t=this;if("string"!=typeof e)return;const i=t._getConnectionObjById(e);if(!i)return;const n=i.startTask,a=i.endTask,s={startTask:t._cloneObject(i.startTask),endTask:t._cloneObject(i.endTask),startTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,endTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,type:i.type};return void 0!==i.lag&&(s.lag=i.lag),s}getConnections(){const e=this;return e._connections.map((t=>{const i=t.startTask,n=t.endTask;return{id:t.startIndex+"-"+t.endIndex+"-"+t.type,startTask:e._cloneObject(i),endTask:e._cloneObject(n),startIndex:t.startIndex,startTaskId:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,endTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,endIndex:t.endIndex,type:t.type,lag:t.lag}}))}getState(){const e=this,t=e._getTasksJSON(!0)||[];return{tasks:JSON.parse(JSON.stringify(t)),selectedTaskIds:e.selectedTaskIds.slice(0),resources:JSON.parse(JSON.stringify(e._resources.slice(0))),scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}get tasks(){return this.isReady?this.getTasks():[]}get resources(){return this.isReady?this.getResources():[]}getTask(e){const t=this,i=t._getValidItemAndIndex(e);if(i.item)return t._cloneObject(i.item)}getTasks(){const e=this,t=e._tasks;return e.isReady&&t&&t.length?t.map((t=>e._cloneObject(t))):[]}getResource(e){const t=this,i=t._getValidItemAndIndex(e,"resource");if(i.item)return t._cloneObject(i.item)}getResources(){const e=this,t=e._resources;return e.isReady&&t&&t.length?t.map((t=>e._cloneObject(t))):[]}getItemPath(e){if(!e||void 0===e.type)return;const t="string"==typeof e.type?"task":"resource",i=this._getValidItemAndIndex(e,t);return i.item?i.item.$.id:void 0}getTaskIndex(e){const t=this;return"string"==typeof e?t._getTaskIndexById(e):t._getItemIndex(e,"task")}getTaskProject(e){const t=this;if((e=t._tasks[t._getItemIndex(e,"task")])&&e.$&&e.$.project)return t._cloneObject(e.$.project)}getTaskConnections(e){const t=this._getValidItemAndIndex(e,"task");return t&&t.item?this._getTaskConnections(t.item).taskConnections.map((e=>({target:e.endIndex,type:e.type,lag:e.lag}))):[]}getResourceIndex(e){return this._getItemIndex(e,"resource")}getResourceTasks(e){const t=this._getValidItemAndIndex(e,"resource");if(e=t?t.item:void 0)return this._getTasksAssigned(e)}getSelectedIds(){const e=this,t=e.selectedTaskIds,i=e.selectedResourceIds;return e.disableSelection||!t.length&&!i.length?null:{task:t.slice(),resources:i.slice()}}getSelectedTasks(){return this._getSelectedItems("task")}getSelectedResources(){return this._getSelectedItems("resource")}getWorkingHours(){const e=this.nonworkingHours;let t=[];for(let i=0,n=23;i<n;i+=1)e.indexOf(i)<0&&t.push(i);return t}isWorkingDay(e){return e=new Date(e),!isNaN(e.getTime())&&this.nonworkingDays.indexOf(e.getDay())<0}clearState(){const e=this;e.id?window.localStorage.removeItem("smartGanttChart"+e.id):e.warn(e.localize("noId"))}loadState(e){const t=this;if(!e){if(!t.id)return;e=JSON.parse(window.localStorage.getItem("smartGanttChart"+t.id))}if(!e)return;let i=JSON.stringify(e.tasks),n=JSON.stringify(e.selectedTaskIds),a=JSON.stringify(e.resources);if(i&&(i=JSON.parse(i)),n&&(n=JSON.parse(n)),a&&(a=JSON.parse(a)),t._noChangeEvent=!0,Array.isArray(i)&&(t._createTasks(i),t.set("dataSource",i)),Array.isArray(a)){let e=a;for(let i=0;i<e.length;i++){const e=a[i];let n=t._resources.find((t=>t.id&&t.id.toString()===e.id.toString()))||{};t._setResource(n,e),Object.values(n).length&&!t._resources.includes(n)&&t._resources.push(n)}t._refreshItemIds("resource")}"number"==typeof e.scrollLeft&&(t.scrollLeft=e.scrollLeft),"number"==typeof e.scrollTop&&(t.scrollTop=e.scrollTop),t._setTable(t.$.taskTable),t._createTimeline(),t._createResourceTimeline(),Array.isArray(n)&&(t.$.taskTable.selected=t._getSelection("task",n)),delete t._noChangeEvent}saveState(){const e=this;e.id?window.localStorage.setItem("smartGanttChart"+e.id,JSON.stringify(e.getState())):e.warn(e.localize("noId"))}insertTask(e,t,i){const n=this;if("object"!=typeof e)return void n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:"insertTask",argumentName:"newTask"}));const a=n._tasks;if(a.indexOf(e)>-1)return void n.error(n.localize("alreadyExists",{elementType:n.nodeName.toLowerCase(),methodName:"insertTask"}));const s=n._createTasks([e],!0);if(!a)return;let r,o,l;const c=n._getSelection("task",n.selectedTaskIds);if("string"==typeof i&&i.indexOf(!1)){const e=i.split(".");i=parseInt(e.slice(-1)),null==t&&(t=e.slice(0,-1).join("."))}if("string"==typeof t?(r=a.find((e=>e.id&&e.id.toString()===t)),r||(r=n._getItemByTableId("task",t))):"number"==typeof t&&(r=a[t]),r){if("project"!==r.type)return void n.error(n.localize("notAProject",{elementType:n.nodeName.toLowerCase(),argumentName:"project",methodName:"insertTask"}));s[0].$.project=r}return n._synchronizeProjectVisibility(s[0].$.project,s[0]),n._insertTasks(s,r,i),n._refreshItemIds(),n._refreshConnectionIds(),n._isUpdating?(n._isUpdating.type.task=!0,void(n._isUpdating.type.resource=!0)):(n._selected&&n._selected.task&&n._setSelection("task",l=n._selected.task.map((e=>e.$.id))),n._refreshTableDataSource(),n._refreshTimeline(),l&&c.toString()!==l.toString()&&(n.$.taskTable.selected=l.slice(0)),n._refreshTaskResources(o),n._ensureVisible(o),n.$.fireEvent("itemInsert",{type:"task",item:n._cloneObject(s[0])}),s[0].id||s[0].$.id+"")}openWindow(e){const t=this;if(t.disableWindowEditor)return;if("string"==typeof e){if(e.indexOf(".")>-1){const i=t._getVCellById("task",e),n=i?i.task:void 0;return void(n&&t._openPopupWindow(n))}if(e.indexOf("-")>-1){let e=(arguments[0]+"").split("-");if(e=t._getValidConnectionId(e[0],e[1],e[2],"openEditor"),e)return void t._openPopupWindow(e)}}const i=t._getValidItemAndIndex(e);i&&t._openPopupWindow(i.item)}closeWindow(){const e=this,t=["confirm","task","connection"];for(let i=0;i<t.length;i++){const n=e.$[t[i]+"PopupWindow"];n&&(n.close(),delete n._target)}}updateTask(e,t){const i=this,n=i._getValidItemAndIndex(e),a=n?n.item:void 0;"object"==typeof a?"object"==typeof t?i._updateTask(a,t):i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"updateTask",argumentName:"taskDetails"})):i.error(i.localize("notExisting",{elementType:i.nodeName.toLowerCase(),methodName:"updateTask",argumentName:"newTask"}))}removeTask(e){const t=this,i=t._tasks,n=t._getValidItemAndIndex(e),a=n?n.item:void 0;i&&i.length&&("object"==typeof a?t._removeTask(a):t.error(t.localize("notExisting",{elementType:t.nodeName.toLowerCase(),methodName:"removeTask",argumentName:"index"})))}setWorkTime(e){this._setWorkTime(e,(function(e,t){for(let i=0,n=e.length;i<n;i+=1){const n=parseInt(e[i]),a=t.indexOf(n);a>-1&&t.splice(a,1)}return t}))}selectTask(e){this._handleItemSelection(e,"task")}selectResource(e){const t=this;t.$.mainSplitter.contains(t.$.resourceTable)&&t._handleItemSelection(e,"resource")}sort(e){const t=this;if("none"===t.sortMode)return;Array.isArray(e)||(e="object"==typeof e?[e]:[]);const i=t.taskColumns,n=t.resourceColumns,a=t.$.taskTable,s=t.$.resourceTable;for(let t=0;t<e.length;t++){const r=e[t],o="desc"===r.sortOrder?"desc":"asc",[l,c]="resource"===r.type||n.includes(r)?[s,n]:[a,i],d=c.find((e=>r.value&&e.value===r.value));d&&l.sortBy(d.value,o)}}unselectTask(e){this._handleItemSelection(e,"task",!0)}unselectResource(e){const t=this;t.$.mainSplitter.contains(t.$.resourceTable)&&t._handleItemSelection(e,"resource",!0)}unsetWorkTime(e){this._setWorkTime(e,(function(e,t){for(let i=0,n=e.length;i<n;i+=1){const n=parseInt(e[i]);t.indexOf(n)<0&&t.push(n)}return t}),!0)}hideTooltip(){this._closeTooltip()}showTooltip(e,t){this._openTooltip(e,void 0,t)}_getSelectedItems(e="task"){const t=this,i=t[`_${e}s`],n=t._getSelection(e,"task"===e?t.selectedTaskIds:t.selectedResourceIds);if(!n.length)return[];let a=[];for(let e=0,s=i.length;e<s;e+=1){const s=i[e];n.indexOf(s.$.id)>-1&&a.push(t._cloneObject(s))}return a}_getTasksAssigned(e){const t=this,i=t._tasks||[];let n=[];for(let a=0;a<i.length;a++){const s=i[a];!s.disableResources&&s.resources.find((t=>t===e.id))&&n.push(t._cloneObject(s))}return n}_getItemIndex(e,t){t||(t="task");const i=this[`_${t}s`];if(e instanceof HTMLElement&&e.classList.contains("smart-timeline-task"))return i.indexOf(e._cellObj[`_${t}`]);const n="resource"===t?["id","label","value","progress"]:["id","label","type","class","dateStart","dateEnd","resources","connections"];if("object"==typeof e)for(let t=0;t<i.length;t++)if(n.every((n=>Array.isArray(e[n])?JSON.stringify(e[n])===JSON.stringify(i[t][n]):n.indexOf("date")>-1?new Date(e[n]).getTime()===new Date(i[t][n]).getTime():e[n]===i[t][n])))return i.indexOf(i[t]);return-1}_handleItemSelection(e,t="task",i){const n=this,a=n._getValidItemAndIndex(e,t);if(a.item){const s=a.item,r=n._getSelection(t,"task"===t?n.selectedTaskIds:n.selectedResourceIds);if(e=s.$.id,i){const i=r.indexOf(e);i>-1&&(r.splice(i,1),n.$[`${t}Table`].selected=r)}else r.indexOf(e)<0&&(r.push(e),n.$[`${t}Table`].selected=r);return"string"==typeof s.id||"number"==typeof s.id?s.id:s.$.id}}_refreshAfterWorkingTimeChange(){const e=this;if(e.adjustToNonworkingTime)for(let t=0;t<e._tasks.length;t++){const i=e._tasks[t],n=i.$.project;e._validateTaskDates(i,n),e._synchronizeProjectDates(i,n),e._refreshTableColumnsData(i,["dateEnd","duration"])}e._refreshTimeline()}_refreshItemIds(e="task"){const t=this[`_${e}s`];if(!t)return;let i={},n=0;for(let e=0,a=t.length;e<a;e+=1){const a=t[e],s=a.$.project;if(void 0!==s){const e=s.$.id;i[e]||(i[e]=0),a.$.id=e+"."+i[e],i[e]++}else a.$.id=n+"",n++}}_refreshConnectionIds(){const e=this._tasks,t=this._connections;if(t&&t.length)for(let i=0,n=t.length;i<n;i+=1){const a=t[i],s=e.indexOf(a.startTask),r=e.indexOf(a.endTask);(s<0||r<0)&&(t.splice(i,1),n--),a.startIndex=s,a.endIndex=r}}_refreshSelectedItems(e="task",t){const i=this,n=i[`_${e}s`];if(n&&(!t&&i._selected&&i._selected[e]&&(t=i._selected[e]),t)){for(let e=0,i=t.length;e<i;e+=1){const a=t[e];(n.indexOf(a)<0||a.hidden)&&(t.splice(e,1),e-=1,i--)}i._setSelection(e,t.map((e=>e.$.id)))}}_resetFromAction(e="task",t="clearSort"){const i=this;function n(){i.$.taskTable[t](),i._createTimelineContent(),i._recycleTimelineTasks()}function a(){const e=i.$.resourceTable;e&&(e[t](),i._createResourceTimelineVCells(),i._recycleResourceContent())}"resource"===e?a():"task"===e?n():(n(),a())}_setWorkTime(e,t,i){const n=this;if("object"!=typeof e)return;let a,s=e.days,r=e.hours;null!=s&&(Array.isArray(s)||(s=[s]),s=n._nonworkingDayValidator(void 0,s),a=t(s,i?n.nonworkingDays:[0,1,2,3,4,5,6]),n.set("nonworkingDays",7===a.length?[]:a),n._refreshAfterWorkingTimeChange()),null!=r&&(Array.isArray(r)||(r=[r]),r=n._nonworkingTimeValidator(void 0,r),a=t(r,i?n.nonworkingHours:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]),n.set("nonworkingHours",24===a.length?[]:a),n._refreshAfterWorkingTimeChange())}_getValidConnectionId(e,t,i,n){const a=this,s=a._tasks,r=0===n.indexOf("_");let o;if("string"==typeof e&&(o=a._getTaskIndexById(e),o>=0&&(e=o)),"string"==typeof t&&(o=a._getTaskIndexById(t),o>=0&&(t=o)),e=parseInt(e),t=parseInt(t),i=parseInt(i),isNaN(e)||isNaN(t)||e===t)r||a.error(a.localize("incorrectArgument",{elementType:a.nodeName.toLowerCase(),methodName:n,argumentName:"taskIndex"}));else if(e>=s.length||e<0||t>=s.length||t<0)r||a.error(a.localize("outOfBounds",{elementType:a.nodeName.toLowerCase(),methodName:n,argumentName:"taskIndex"}));else{if(!(isNaN(i)||i<0||i>3))return r?[e,t,i]:e+"-"+t+"-"+i;r||a.error(a.localize("incorrectArgument",{elementType:a.nodeName.toLowerCase(),methodName:n,argumentName:"connectionType"}))}}_autoSchedule(e){const t=this,i=t._tasks;if(t.autoSchedule){e?Array.isArray(e)||(e=[e]):e=i;for(let i=0;i<e.length;i++){const n=e[i];"project"===n.type&&n.synchronized||(n.minDateStart=n.minDateEnd=void 0,t._autoScheduleTasks(n))}t._isUpdateRequired&&(t._createTimelineCells(),t._recycleTimelineTasks(!0),delete t._isUpdateRequired)}}_getTaskConnections(e){const t=this._tasks,i=this._connections;let n=[],a=[];if(t&&t.length&&i&&i.length){const s=t.indexOf(e);for(let e=0;e<i.length;e+=1){const t=i[e];t.startIndex===s?n.push(t):t.endIndex===s&&a.push(t)}}return{taskConnections:n,connectedTasks:a}}_autoScheduleTasks(e){const t=this,i=t._tasks,n=t._getTaskConnections(e),a=n.taskConnections,s=n.connectedTasks;let r,o,l;for(let n=0;n<a.length;n++)t._isAutoScheduled(e,i[a[n].endIndex],!0);for(let n=0;n<s.length;n++){const a=s[n],c=i[a.startIndex],d=a.type,m=a.lag,u=e.$.project;c&&"project"===c.type&&c.synchronized||(0===d||1===d?(l=new Date((0===d?c.dateStart:c.dateEnd).getTime()+m),e.minDateStart=new Date(e.minDateStart?Math.max(e.minDateStart.getTime(),l.getTime()):l),o=e.minDateStart.getTime()-e.dateStart.getTime(),r=new Date(e.dateEnd.getTime()+(t.autoScheduleStrictMode?o:Math.max(0,o))),r.getTime()!==e.dateEnd.getTime()&&(e.dateEnd=r,t._isUpdateRequired=!0),t.autoScheduleStrictMode&&e.minDateStart.getTime()!==e.dateStart.getTime()&&(e.dateStart=e.minDateStart,t._isUpdateRequired=!0)):(l=new Date((2===d?c.dateEnd:c.dateStart).getTime()+m),e.minDateEnd=new Date(e.minDateEnd?Math.min(e.minDateEnd.getTime(),l.getTime()):l),o=e.minDateEnd.getTime()-e.dateEnd.getTime(),r=new Date(e.dateStart.getTime()+(t.autoScheduleStrictMode?o:Math.max(0,o))),r.getTime()!==e.dateStart.getTime()&&(e.dateStart=r,t._isUpdateRequired=!0),t.autoScheduleStrictMode&&e.minDateEnd.getTime()!==e.dateEnd.getTime()&&(e.dateEnd=e.minDateEnd,t._isUpdateRequired=!0)),t._validateTaskDates(e,u),t._synchronizeProjectDates(e,u))}for(let e=0;e<a.length;e++){const n=i[a[e].endIndex];!n||"project"===n.type&&n.synchronized||(n.minDateStart=n.minDateEnd=void 0,t._autoScheduleTasks(n))}}_autoScheduleRestore(e,t){const i=this._tasks;e||(e=i),Array.isArray(e)||(e=[e]);for(let n=0;n<e.length;n++){const a=e[n];i.indexOf(e[n])>-1&&(t?0===t||1===t?a.minDateStart=void 0:a.minDateEnd=void 0:a.minDateStart=a.minDateEnd=void 0)}}_autoScroll(e){const t=this,i=t.hasAttribute("dragged"),n=t.hasAttribute("resized");function a(a,s){if(!t._dragDetails)return clearInterval(t._scrollInterval),t._scrollInterval=void 0,void delete t._autoScrolling;t._autoScrolling=!0,s?i||(t.scrollTop-=t.autoScrollStep*a,t._dragDetails.coordinates.y+=t.autoScrollStep*a):(t.scrollLeft-=(t.rightToLeft?-1:1)*t.autoScrollStep*a,t._dragDetails.coordinates.x+=t.autoScrollStep*a),i?t._handleTaskBarDrag(e):n&&t._handleTaskBarResize(e)}if(t.disableAutoScroll||!e||!i&&!n&&!t.hasAttribute("connecting-task"))return;const s=t.$.timeline.getBoundingClientRect();t._scrollInterval&&clearInterval(t._scrollInterval),t._scrollInterval=setInterval((function(){(t.scrollLeft||t.rightToLeft)&&e.clientX<=s.left+20?a(1):t.scrollLeft!==(t.rightToLeft?0:t.scrollWidth)&&e.clientX>=s.left+s.width-20?a(-1):t.scrollTop&&e.clientY<=s.top+20?a(1,!0):t.scrollTop!==t.scrollHeight&&e.clientY>=s.top+s.height-20?a(-1,!0):(clearInterval(t._scrollInterval),t._scrollInterval=void 0,delete t._autoScrolling)}),1)}_checkTaskBarResizability(e){const t=this;let i=e.originalEvent.target;t.shadowRoot&&i===t&&(i=e.originalEvent.composedPath()[0]);const n=t.$.timeline;if(!i.closest)return void n.removeAttribute("task-bar-hovered");let a,s=i.closest(".smart-timeline-row")||i.closest(".smart-timeline-task");if(t.disabled||t.disableTaskResize||!s||!n.contains(s))return void n.removeAttribute("task-bar-hovered");const r=s._cellObj.task,o=t._getTaskDOMIndex(r);if(s.classList.contains("smart-timeline-row")?a=t.$.timelineTasksContainer.children[o]:s.classList.contains("smart-timeline-task")&&(a=s,s=t.$.taskTimelineCellsContainer.children[o]),!a||a.classList.contains("milestone")||r.synchronized||r.disableResize)return;const l=i.closest(".smart-task-segment"),c=r.segments?r.segments.length:1;if(i.classList&&i.classList.contains("smart-task-connection-point")||l&&(c>1&&t.disableSegmentResize||l._segmentObj&&l._segmentObj.disableResize))return void n.removeAttribute("task-bar-hovered");const d=e.pageX-window.pageXOffset,m="visible"===t.resizeHandlesVisibility||t._isMobile?20:5,u=(l||a).getBoundingClientRect(),h=s.getBoundingClientRect(),g=Math.min(m,d-h.left),f=Math.min(m,h.left+h.width-d);Math.round(u.left)+g>=d&&Math.round(u.left)-g<=d?n.setAttribute("task-bar-hovered","left"):Math.round(u.left+u.width)+f>=d&&Math.round(u.left+u.width)-f<=d?n.setAttribute("task-bar-hovered","right"):n.removeAttribute("task-bar-hovered")}_onShadowDomLoaded(e,t,i){requestAnimationFrame((function n(){const a=(e.shadowRoot||e.getRootNode()).querySelectorAll("link");for(let e=0;e<a.length;e++)if(-1!==a[e].href.indexOf(t))return void i();requestAnimationFrame(n)}))}_getConnectionObjById(e){const t=this._connections;if(!e||!t||!t.length)return;const i=e.split("-"),n=parseInt(i[0]),a=parseInt(i[1]),s=parseInt(i[2]);for(let e=0,i=t.length;e<i;e+=1){const i=t[e];if(i.startIndex===n&&i.endIndex===a&&i.type===s)return i}}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),i=[e.$.taskPopupWindow,e.$.connectionPopupWindow,e.$.confirmPopupWindow];for(let n=0;n<i.length;n++){const a=i[n];if(!a||!t.contains(a))continue;const s=e.getBoundingClientRect();a.opened||(a.style.left=a.style.top=""),e._isMobile?(a.setAttribute("mobile",""),a.style.left=s.left+window.pageXOffset+"px",a.style.top=s.top+window.pageYOffset+"px",a.style.width=s.width+"px",a.style.height=s.height+"px"):(a.style.left=Math.max(s.left+window.pageXOffset,s.left+window.pageXOffset+s.width/2-a.offsetWidth/2)+"px",a.style.top=Math.max(s.top+window.pageYOffset,s.top+window.pageYOffset+s.height/2-a.offsetHeight/2)+"px")}}_openPopupWindow(e,t){const i=this;function n(){function t(){i._positionWindow(),s.opened?(s.bringToFront(),s._onOpenCallback?s._onOpenCallback():s._handleActiveState()):s.open()}if(i.popupWindowCustomizationFunction?i.popupWindowCustomizationFunction(s,a,"connection"===a?e.startIndex+"-"+e.endIndex+"-"+e.type:i._cloneObject(e)):s._onOpenCallback=()=>{const e=(s.shadowRoot||s).querySelectorAll(".smart-gantt-chart-popup-window-editor .smart-input, .smart-popup-window-button");(e[0]||e[1]||s).focus({preventScroll:!0}),s._handleActiveState()},i._setPopupWindowTemplate("header",a,e),i._setPopupWindowTemplate("footer",a,e),i._setPopupWindowTemplate("content",a,e),!i._popupWindow[a+"PopupWindow"]){const e=i["$"+a+"PopupWindow"];e.unlisten("transitionend"),e.unlisten("open"),e.unlisten("close"),e.unlisten("closing"),e.unlisten("click"),e.unlisten("change"),e.listen("transitionend",i._popupWindowTransitionendHandler.bind(i)),e.listen("open",i._popupWindowOpenHandler.bind(i)),e.listen("close",i._popupWindowCloseHandler.bind(i)),e.listen("closing",i._popupWindowClosingHandler.bind(i)),e.listen("click",i._popupWindowClickHandler.bind(i)),e.listen("change",i._popupWindowChangeHandler.bind(i))}s.shadowRoot?(s.importStyle(Smart.Utilities.Core.getScriptLocation()+Smart.StyleBaseUrl.replace("/scoped/","/smart.textbox.css")),i._onShadowDomLoaded(s,"smart.window.css",t)):t();const n=(i.getAttribute("aria-owns")||"")+" "+s.id;i.setAttribute("aria-owns",n.trim()),i._popupWindow[a+"PopupWindow"]=s}if(e&&e.classList)if(e.classList.contains("smart-task-connection"))e=i._getConnectionObjById(e.getAttribute("connection-id"));else if("TR"===e.nodeType){const t=e?"task":"resource",n=i._getVCellById(t,e.getAttribute("row-id"));e=n?n[t]:void 0}else e=e._cellObj.task;if(!e||e.isGroup)return;const a=t?"confirm":"string"==typeof e.type?"task":"connection",s=i._createPopupWindow(a);!t&&i.$.fireEvent("opening",{target:s,type:a}).defaultPrevented||(i._closeTooltip(),s._target=e,i._popupWindow||(i._popupWindow={}),s.parentElement||i.getShadowRootOrBody().appendChild(s),s.isCompleted?n():s.whenReady((()=>n())))}_createPopupWindow(e){const t=this,i=e+"PopupWindow";if(t.$[i])return t.$[i];const n=document.createElement("smart-window");return n.classList.add("smart-"+e+"-popup-window"),n.classList.add("smart-gantt-chart-popup-window"),n.setAttribute("smart-id",i),t.$[i]=n,t["$"+i]=Smart.Utilities.Extend(n),n.rightToLeft=t.rightToLeft,n.theme=t.theme,n.animation=t.animation,n.disableSnap=!0,n.headerButtons=["close"],n}_popupWindowOpenHandler(e){const t=this,i=t["$"+e.target.getAttribute("smart-id")];if(i){const n=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";t._handleModal(!0),t.$.fireEvent(e.type,Object.assign({type:n,target:e.target},e.detail)),i.unlisten("open")}}_popupWindowClosingHandler(e){const t=this["$"+e.target.getAttribute("smart-id")];if(!t)return;const i=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";this.$.fireEvent(e.type,{target:e.target,type:i}).defaultPrevented?e.preventDefault():t.unlisten(e.type)}_popupWindowCloseHandler(e){const t=this,i=e.target.getAttribute("smart-id"),n=t["$"+i];if(n){const a=e.target.classList.contains("smart-confirm-popup-window")?"confirm":e.target.classList.contains("smart-connection-popup-window")?"connection":"task";if(t._handleModal(),t.$.fireEvent(e.type,Object.assign({type:a,target:e.target},e.detail)),n.unlisten("close"),n.unlisten("click"),t.hasAttribute("aria-owns")){const e=t.getAttribute("aria-owns").replace(t._popupWindow[i].id,"").trim();e?t.setAttribute("aria-owns",e):t.removeAttribute("aria-owns")}delete t._popupWindow[i];const s=Object.keys(t._popupWindow);1===s.length&&t._popupWindow.confirmPopupWindow&&(delete t._popupWindow.confirmPopupWindow._target,t._popupWindow.confirmPopupWindow.close()),s.length?requestAnimationFrame((()=>{const e=t._popupWindow[s[s.length-1]];e&&e.focus()})):t.keyboardNavigation&&t.$.taskTable.focus({preventScroll:!0})}}_popupWindowTransitionendHandler(e){const t=this,i=e.target;i instanceof Smart.Window&&!i.opened&&"visibility"===e.propertyName&&(t["$"+i.getAttribute("smart-id")].unlisten("transitionend"),i.parentElement&&i.parentElement.removeChild(i))}_handleModal(e){const t=this;let i=(t.shadowRoot||t).querySelector(".smart-popup-window-modal");e?(i||(i=document.createElement("div"),i.classList.add("smart-popup-window-modal")),i.parentElement||(t.$.container.appendChild(i),t.setAttribute("modal",""))):i&&i.parentElement&&Object.keys(t._popupWindow).length<2&&(i.parentElement.removeChild(i),t.removeAttribute("modal"))}_findTaskEditor(e,t){if(!e||!t)return;const i=t.children;for(let t=0,n=i.length;t<n;t+=1){const n=i[t];if(n.getAttribute("value")===e)return n}}_createTaskEditor(e,t,i){const n=this,a=e.value,s=t[e.value];let r,o,l=i.find((e=>e._label===a));if(l)r=l.querySelector(".smart-gantt-chart-label-container"),o=l.lastElementChild;else{const t="editorLabel"+Math.floor(65536*(1+Math.random())).toString(16).substring(1);if(r=document.createElement("div"),r.classList.add("smart-gantt-chart-label-container"),r.innerHTML=`<label id="${t}"></label>`,"deadline"===a){const e=document.createElement("span");e.classList.add("smart-popup-window-editor-toggle"),r.appendChild(e)}if(l=document.createElement("div"),l.classList.add("smart-gantt-chart-popup-window-editor"),l.setAttribute("value",a||""),l._label=a,e.customEditor)return l.appendChild(e.customEditor(a,s)),l;if("number"==typeof s||"string"==typeof s)o=document.createElement("input"),o.classList.add("smart-input");else if(s instanceof Date||"deadline"===a)Smart.DateTimePicker?(o=document.createElement("smart-date-time-picker"),o.locale=n.locale,o.dropDownAppendTo="body",o.calendarButton=!0,o.dropDownDisplayMode="auto",o.enableMouseWheelAction=!0,o.formatString="yyyy-MMM-dd HH:mm:ss"):(o=document.createElement("input"),o.type="datetime-local");else if(Array.isArray(s))if(Smart.DropDownList)o=document.createElement("smart-drop-down-list"),o.virtualized=!0,o.dropDownAppendTo="body",o.selectionMode="zeroOrMany";else{o=document.createElement("input"),o.classList.add("smart-input");const e=document.createElement("datalist");e.id="resourceList",o.setAttribute("list",e.id),l.appendChild(e)}o&&o.setAttribute("aria-labelledby",t)}if(!l.parentElement)return r&&l.appendChild(r),o&&l.appendChild(o),l;n._setPopupWindowEditors(e,t,l)}_setAriaControls(){this.setAttribute("role","treegrid")}_setPopupWindowEditors(e,t,i){const n=this,a=i.querySelector("label"),s=i.querySelector(".smart-popup-window-editor-toggle"),r=i.lastElementChild,o=e.value+"",l=o.split(/(?=[A-Z])/).join(" "),c=t[o];if(e.customEditor)e.setCustomEditorValue&&e.setCustomEditorValue(i,l,c);else{if(a.innerHTML=n.localize(e.value)||l.charAt(0).toUpperCase()+l.slice(1),s)if("deadline"===o){const e=null==c?"add":"remove";r.classList[e]("smart-hidden"),s.textContent=n.localize(e)}else s.remove();if("number"==typeof c)r.value=parseFloat(c);else if("string"==typeof c)r.value=c;else if(c instanceof Date)r.value=new Date(c);else if(Array.isArray(c)){const e=n._resources;if(r.placeholder=n.localize("unassigned"),Smart.DropDownList&&r instanceof Smart.DropDownList)r.dataSource=e.map((e=>({label:e.label,value:e.id}))),r.selectedValues=t.disableResources?[]:t.resources.map((e=>e.toString()));else{let n=i.querySelector("datalist"),a=document.createDocumentFragment();n.innerHTML="";for(let t=0;t<e.length;t++){const i=e[t],n=document.createElement("option");n.value=i.id,n.innerHTML=i.label,a.appendChild(n)}r.value=t.resources.toString(),n.appendChild(a)}}"project"===t.type&&t.synchronized&&["duration","date"].indexOf(l.toLowerCase())>-1||"resources"===l&&t.disableResources?r.disabled=!0:r.disabled=!!e.disableEdit,r.rightToLeft=n.rightToLeft,r.animation=n.animation,r.theme=n.theme}}_setupPopupWindowTabs(e,t){const i=this,n=i.popupWindowTabs,a="milestone"===t.type,s=[{label:i.localize("generalTab"),value:"general"},{label:i.localize("dependencyTab"),value:"dependency"},{label:i.localize("segmentsTab"),value:"segments"}];let r=e.querySelector(".smart-gantt-chart-popup-window-tabs");r||(r=document.createElement("smart-tabs"),r.classList.add("smart-gantt-chart-popup-window-tabs"),e.clear(),e.appendChild(r)),r.animation=i.animation,r.rightToLeft=i.rightToLeft,r.theme=i.theme;const o=r.getTabs().slice(0);for(let e=0,t=s.length;e<t;e+=1){const t=s[e],i=t.value;let l=o[e];n.indexOf(i)<0?l&&r.removeChild(l):(l||(l=document.createElement("smart-tab-item"),r.appendChild(l)),l.label=t.label,l.setAttribute("value",i||""),l.disabled=a&&"segments"===i)}return r}_setPopupWindowContent(e,t){const i=this,n=i.$[e+"PopupWindow"],a=[].slice.call(n.querySelectorAll(".smart-gantt-chart-popup-window-editor"));if(n.content&&(!n.content.innerHTML||a.length))if("task"===e&&t){const e=i.taskColumns;let s=[];const r=i._setupPopupWindowTabs(n,t);0!==r.selectedIndex&&(r.selectedIndex=0);const o=r.getTabs()[0];if("general"!==o.getAttribute("value"))return void i._handleTabsContent(o,n);"string"==typeof o.content?o.content="":o.content.innerHTML="";for(let n=0;n<e.length;n++){const r=e[n],l=r.value;if(void 0===t[l]&&"deadline"!==l||"overdue"===l)continue;let c=i._findTaskEditor(l,o);c||(c=i._createTaskEditor(r,t,a),o.appendChild(c)),i._setPopupWindowEditors(r,t,c),s.push(c)}for(let e=0,t=a.length;e<t;e+=1){const t=a[e];s.indexOf(t)<0&&t.remove()}t.id&&n.setAttribute("aria-controls",t.id)}else if("confirm"===e){if(n.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("confirm",{componentName:"The task"})+"</div >",i._popupWindow){const e=Object.keys(i._popupWindow);e.length&&n.setAttribute("aria-controls",i._popupWindow[e[e.length-1]].id)}}else{const e=t.startTask,a=t.endTask;n.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("deleteLink")+"<b> "+e.label+" - "+a.label+"?</b></div>"}}_setPopupWindowTemplate(e,t,i){const n=this,a=n.$[t+"PopupWindow"];if("content"!==e){if(a[e+"Template"]||(a[e+"Template"]=n._createPopupWindowTemplate(e,t)),"header"===e&&i&&"string"==typeof i.type){const e=(a.shadowRoot||a).querySelector(".smart-popup-window-label");e&&(e.innerHTML=i.label)}else if("footer"===e){const e=(a.shadowRoot||a).querySelectorAll(".smart-popup-window-button");for(let i=0;i<e.length;i++){const a=e[i];a.innerHTML="task"===t?'<span class="smart-icon"></span>':"",a.theme=n.theme,a.rightToLeft=n.rightToLeft,a.animation=n.animation,a.disabled=!1,a.classList.contains("ok")?(a.innerHTML+=n.localize("ok"),a.setAttribute("aria-label","ok")):a.classList.contains("cancel")?(a.innerHTML+=n.localize("cancel"),a.setAttribute("aria-label","cancel")):a.classList.contains("delete")&&(a.innerHTML+=n.localize("delete"),a.setAttribute("aria-label","delete"));const s=a.querySelector(".smart-ripple");s&&s.parentElement.removeChild(s)}}}else n._setPopupWindowContent(t,i)}_createPopupWindowTemplate(e,t){const i=this,n=document.createElement("template");if("footer"===e)switch(t){case"task":n.innerHTML=`<smart-button class="smart-popup-window-button ok primary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button cancel"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button delete secondary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>`;break;case"connection":case"confirm":n.innerHTML=`<smart-button class="smart-popup-window-button ok primary"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>\n <smart-button class="smart-popup-window-button cancel"\n animation="${i.animation}" theme="${i.theme}" ${i.rightToLeft?"right-to-left":""}>\n </smart-button>`}else"header"!==e||"task"!==t&&"confirm"!==t||(n.innerHTML='<span class="smart-popup-window-label"></span>');return n}_handleTabsContent(e,t){const i=this,n=t._target;if(!e|!n)return;const a=e.getAttribute("value");if("general"===a)return;let s=e.querySelector(".smart-gantt-popup-window-table"),r=e.querySelector(".smart-gantt-window-table-buttons"),o=e.querySelector(".smart-gantt-window-validation-message");r||(r=document.createElement("div"),r.classList.add("smart-gantt-window-table-buttons"),r.innerHTML=`<smart-button class="smart-gantt-chart-button" action="add">${i.localize("add")}</smart-button>\n <smart-button class="smart-gantt-chart-button" disabled action="delete">${i.localize("delete")}</smart-button>`,e.insertBefore(r,s)),s||(s=document.createElement("smart-table"),s.classList.add("smart-gantt-popup-window-table"),s.editing=!0,s.editMode="row",s.keyboardNavigation=!0,s.wait=!0,s.hideSelectionColumn=!0,s.selection=!0,s.selectionMode="one",s.columnMinWidth="10px",s.addEventListener("rowEndEdit",(r=>{const o=r.detail.row;switch(a){case"dependency":{const e=i._tasks,t=o.name,a=e.indexOf(n),r=e.findIndex((e=>e.$.id===t));r>-1&&s.updateRow(o.$.id,{id:`${r}-${a}-${o.type}`});break}case"segments":{const e=o.dateStart,t=o.dateEnd;e.getTime&&t.getTime&&s.updateRow(o.$.id,{duration:parseFloat(i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e,t):t.getTime()-e.getTime(),!0).toFixed(2))});break}}i._applyTableValidation(e,s,t),i._isPopupWindowTableModified=!0})),e.innerHTML&&(e.innerHTML=""),e.appendChild(s));const l=i._getTabsTableData(a,n);s.selected.length&&(s.selected=[]),s.dataSource=l.source,s.columns=l.columns,s.wait=!1,delete i._isPopupWindowTableModified,o||(o=document.createElement("label"),o.classList.add("smart-gantt-window-validation-message"),e.appendChild(o)),o.textContent=""}_applyTableValidation(e,t,i){const n=this,a=e.getAttribute("value"),s=e.querySelector(".smart-gantt-window-validation-message"),r=i.querySelector(".smart-popup-window-button.ok"),o=t.dataSource,l=o.length;if(!s)return void(r&&(r.disabled=!1));if(!l)return s.textContent="",void(r&&(r.disabled=!1));let c="";if("segments"===a)if(l<2)c=n.localize("segmentsCountValidation");else{const e=i._target,t=e.dateStart.getTime(),a=e.dateEnd.getTime();let s={};for(let e=0;e<l;e+=1){const i=o[e],r=i.label,l=i.dateStart.getTime(),d=i.dateEnd.getTime();for(let e in s){const t=s[e],a=t.timeStart,r=t.timeEnd,o=l<=a&&d>=a,m=l<=r&&d>=r;(o||m)&&(c+=n.localize("segmentConflictError",{dateConflict:o?"dateStart":"dateEnd",label:i.label,conflictLabel:t.label})+"\r\n")}l>d?c+=n.localize("segmentStartError",{label:i.label})+"\r\n":l===d&&(c+=n.localize("segmentEndError",{label:i.label})+"\r\n"),(l<t||d>a)&&(c+=n.localize("segmentRangeError",{label:i.label})+"\r\n"),void 0===s[e]&&(s[e]={label:r,timeStart:l,timeEnd:d})}}else if("dependency"===a)for(let e=0;e<l;e+=1){const t=o[e].id.split("-");t[0]===t[1]&&(c+=n.localize("dependencyValidation")+"\r\n")}s.textContent=c,r&&(r.disabled=c.length>0)}_getTabsTableData(e,t){const i=this;if("dependency"===e){const e=i._getTaskConnections(t).connectedTasks,n={connectionTypes:[{label:i.localize("startToStart"),value:0},{label:i.localize("endToStart"),value:1},{label:i.localize("endToEnd"),value:2},{label:i.localize("startToEnd"),value:3}],tasks:(()=>{const e=i._tasks;let n=[];for(let i=0,a=e.length;i<a;i+=1){const a=e[i];a!==t&&n.push({value:a.$.id,label:a.label})}return n})()};return{source:new window.Smart.DataAdapter({dataSource:e&&e.length?e.map((e=>({id:e.startIndex+"-"+e.endIndex+"-"+e.type,name:e.startTask.$.id||"",type:e.type,lag:e.lag||0}))):[],dataFields:["id: any","name: any","type: number","lag: number"]}),columns:[{label:i.localize("id"),dataField:"id",dataType:"any",autoWidth:!1,allowEdit:!1},{label:i.localize("name"),dataField:"name",dataType:"any",width:"35%",autoWidth:!1,editor:i._getColumnEditorSetup("name",n),formatFunction:e=>{const t=n.tasks.find((t=>t.value===e.value));t&&(e.value=t.label)}},{label:i.localize("type"),dataField:"type",dataType:"number",width:"25%",autoWidth:!1,editor:i._getColumnEditorSetup("type",n),formatFunction:e=>{const t=n.connectionTypes.find((t=>t.value===e.value));t&&(e.value=t.label)}},{label:i.localize("lag"),dataField:"lag",dataType:"number",autoWidth:!1}]}}if("segments"===e){const e={task:t};return{source:new window.Smart.DataAdapter({dataSource:t.segments,dataFields:["label: string","dateStart: date","dateEnd: date","duration: number"]}),columns:[{label:i.localize("name"),dataField:"label",dataType:"string",autoWidth:!1,width:"20%"},{label:i.localize("dateStart"),dataField:"dateStart",dataType:"date",autoWidth:!1,editor:i._getColumnEditorSetup("dateStart",e),formatFunction:e=>{e.value=i._formatDate(e.data.dateStart)}},{label:i.localize("dateEnd"),dataField:"dateEnd",dataType:"date",autoWidth:!1,editor:i._getColumnEditorSetup("dateEnd",e),formatFunction:e=>{e.value=i._formatDate(e.data.dateEnd)}},{label:i.localize("duration"),dataField:"duration",dataType:"number",autoWidth:!1,width:"15%",allowEdit:!1}]}}return{source:[],columns:[]}}_getColumnEditorSetup(e,t){const i=this;switch(e){case"dateStart":case"dateEnd":return{template:'<smart-date-time-picker drop-down-append-to="body" wait></smart-date-time-picker>',onInit:(e,n,a,s)=>{const r=t.task;s||(s=new Date(r.dateStart)),a.rightToLeft=i.rightToLeft,a.animation=i.animation,a.theme=i.theme,a.min=r.dateStart,a.max=r.dateEnd,a.locale=i.locale,a.calendarButton=!0,a.dropDownDisplayMode="auto",a.enableMouseWheelAction=!0,a.formatString="yyyy-MMM-dd HH:mm:ss",a.value=new Date(Math.max(r.dateStart.getTime(),Math.min(r.dateEnd.getTime(),s.getTime()))),a.removeAttribute("wait")},getValue:e=>e.value.toDate()};case"name":return{template:'<smart-drop-down-list virtualized drop-down-append-to="body" wait></smart-drop-down-list>',onInit:(e,n,a,s)=>{a.rightToLeft=i.rightToLeft,a.animation=i.animation,a.theme=i.theme,a.dataSource=t.tasks,a.selectedValues=[s],a.removeAttribute("wait")},getValue:e=>e.selectedValues[0]};case"type":return{template:"<smart-input wait></smart-input>",onInit:(e,n,a,s)=>{const r=t.connectionTypes,o=r.find((e=>e.value===s));a.readonly=!0,a.rightToLeft=i.rightToLeft,a.animation=i.animation,a.theme=i.theme,a.dropDownButtonPosition="right",a.dataSource=r,a.value=(o||r[0]).label+"",a.removeAttribute("wait")},getValue:e=>{if(e.selectedValues.length)return e.selectedValues[0];const i=t.connectionTypes.find((t=>t.label===e.value));return i?i.value:void 0}}}}_popupWindowChangeHandler(e){const t=this,i=e.target,n=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0);if(n._target)if(i.classList.contains("smart-gantt-chart-popup-window-tabs")){const a=n.querySelector(".smart-popup-window-button.ok");a&&(a.disabled=!1),t._handleTabsContent(i.getTabs()[e.detail.index],n)}else if(i.classList.contains("smart-gantt-popup-window-table")){const e=i.closest("smart-tab-item").querySelector('.smart-gantt-chart-button[action="delete"]');e&&(e.disabled=0===i.selected.length)}}_popupWindowClickHandler(e){const t=this;let i=(e.originalEvent||e).target;i.shadowRoot&&(i=(e.originalEvent||e).composedPath()[0]);const n=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0),a=n._target;if(i.closest(".smart-popup-window-button.cancel"))return t._popupWindow&&t._popupWindow.confirmPopupWindow&&n!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),n.close(),void delete n._target;if(i.closest(".smart-popup-window-button.ok")){if(n===t.$.connectionPopupWindow&&"number"==typeof a.type)t._removeConnection(a.startIndex+"-"+a.endIndex+"-"+a.type);else if(n===t.$.confirmPopupWindow){const e=a;void 0!==e.$._resourceId?t._removeResource(e):t._removeTask(e),n.close(),t.$.taskPopupWindow&&t.$.taskPopupWindow.close(),delete n._target}else{const e=n.shadowRoot||n,i=e.querySelectorAll(".smart-gantt-chart-popup-window-editor"),s=a;let r={};for(let e=0;e<i.length;e++){const n=i[e]._label,a=t.taskColumns.find((e=>e.value===n));if(a.customEditor&&a.getCustomEditorValue)r[n]=a.getCustomEditorValue(i[e]);else{const t=i[e].lastElementChild;let a;if(!t)continue;if(t.classList.contains("smart-hidden")){r[n]=void 0;continue}a=Smart.DateTimePicker&&t instanceof Smart.DateTimePicker?t.value.toDate?t.value.toDate():t.value:t instanceof HTMLInputElement&&"datetime-local"===t.type?new Date(t.value):Smart.DropDownList&&t instanceof Smart.DropDownList?t.selectedValues.slice(0):t.hasAttribute("list")?t.value.split(",").map((e=>e.trim())):t.value,a instanceof Date&&isNaN(a.getTime())&&(a=void 0),null!=a&&(r[n]=a)}}if(void 0!==s.$._resourceId)t._updateResource(s,r);else{const i=r.dateStart?r.dateStart:void 0,n=r.dateEnd?r.dateEnd:void 0;if((i&&i.getTime&&i.getTime()!==s.dateStart.getTime()||n&&n.getTime&&n.getTime()!==s.dateEnd.getTime())&&(r.duration=void 0),t._isPopupWindowTableModified){const i=e.querySelectorAll(".smart-gantt-popup-window-table");for(let e=0,n=i.length;e<n;e+=1){const n=i[e];n.closest('.smart-tab-item[value="dependency"]')?t._updateTaskDependencies(n,s):n.closest('.smart-tab-item[value="segments"]')&&t._updateTaskSegments(n,s)}}t._updateTask(s,r)}}return t._popupWindow&&t._popupWindow.confirmPopupWindow&&n!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),n.close(),void delete n._target}if(i.closest(".smart-popup-window-button.delete"))return void t._openPopupWindow(n._target,!0);if(i.closest(".smart-popup-window-editor-toggle")){const e=i.closest('.smart-gantt-chart-popup-window-editor[value="deadline"]'),n=e?e.lastElementChild:void 0;if(n){const e=n.classList.contains("smart-hidden")?"remove":"add";n.classList[e]("smart-hidden"),i.textContent=t.localize(e)}return}const s=i.closest(".smart-gantt-chart-button");if(s){const e=i.closest("smart-tab-item"),r=e.querySelector(".smart-gantt-popup-window-table");if(!r)return;const o=s.getAttribute("action"),l=e.getAttribute("value"),c=a;switch(o){case"add":{let e;e="segments"===l?{label:`${t.localize("segment")} ${r.dataSource.length+1}`,dateStart:new Date(c.dateStart),dateEnd:new Date(c.dateEnd),duration:parseFloat((c.duration||0).toFixed(2))}:{id:"",name:"",type:0,lag:0},r.addRow(e),r.beginEdit(r.rows.length-1),t._isPopupWindowTableModified=!0;break}case"delete":{const e=r.selected;r.beginUpdate();for(let t=0,i=e.length;t<i;t+=1)r.removeRow(e[t]);r.endUpdate(),t._isPopupWindowTableModified=!0;break}}t._applyTableValidation(e,r,n)}}_updateTaskDependencies(e,t){const i=this,n=i._tasks.indexOf(t),a=i._getTaskConnections(t).connectedTasks,s=e.rows;for(let e=0,t=a.length;e<t;e+=1){const t=a[e];i._removeConnection(`${t.startIndex}-${t.endIndex}-${t.type}`)}for(let e=0,t=s.length;e<t;e+=1){const t=s[e].data,a=t.name,r=t.type;if(!i._getValidConnectionId(a,n,r,"_"))continue;const o=parseInt(t.lag);i._connectTask([a,n,r,isNaN(o)?0:o])}i._recycleConnections()}_updateTaskSegments(e,t){const i=e.rows;let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e].data,a=t.label,s=new Date(t.dateStart),r=new Date(t.dateEnd);isNaN(s)||isNaN(r)||n.push({label:"string"==typeof a?a:"",dateStart:s,dateEnd:r})}t.segments=n,this._validateTaskSegments(t)}_createTasks(e,t){const i=this,n={},a=[];e||(e=i.dataSource),i.dataSource instanceof Smart.DataAdapter&&(e=i._parseAdapterData(i.dataSource.toArray())),t||i.clearTasks();let s=[];if(function e(r,o){let l=[];if(!r||0===r.length)return[];for(let c=0;c<r.length;c++){let d,m=r[c];if("object"!=typeof m)continue;if(m=i._validateTaskProperties(m,o),!m)continue;const u=m.tasks,h=m.id;m.$.project=o,m.$.id=o?o.$.id+"."+c:c+"","string"!=typeof h&&"number"!=typeof h||(n[h]?a.push(h):n[h]=1),u instanceof Array&&u.length>0&&(m.synchronized&&(m.dateStart=m.minDateStart=m.maxDateStart=void 0,m.dateEnd=m.minDateEnd=m.maxDateEnd=void 0),m.type="project",d=e(u,m),d.length&&(m.hidden=!d.some((e=>!e.hidden)),m.hidden?d.forEach((e=>e.hidden=m.hidden)):i._synchronizeProjectVisibility(o,m))),(!m.type||["project","task","milestone"].indexOf(m.type)<0)&&(m.type="task"),o&&"project"===m.type&&d&&d.length>0?(l.push(m),l=l.concat(d)):(o||((t&&"project"===m.type&&m.synchronized||m.dateStart&&m.dateEnd&&!isNaN(m.dateStart.getTime())&&!isNaN(m.dateEnd.getTime()))&&s.push(m),d&&(s=s.concat(d))),l.push(m))}return o&&i._synchronizeProjectDates(o,l),l}(e),t)return s.slice(0);a.length&&console.warn(i.localize("duplicateIds",{elementType:i.nodeName.toLowerCase(),duplicates:a.toString()})),i._tasks=s.slice(0),i._handleResources()}_createTimeline(){const e=this;e._tasks&&0!==e._tasks.length?(delete e.__tasks,e._createConnections(),e._autoSchedule(),e._createTimelineCells(),e._insertTimelineTasks(),e.$.taskSplitter.refresh()):e._clearTasks()}_createConnections(){const e=this,t=e._tasks;e._connections=[];for(let i=0,n=t.length;i<n;i+=1)t[i].connections&&e._handleTaskConnections(i)}_createTooltip(){const e=this,t=e.tooltip;let i=e.$.tooltip;if(t.enabled)return i||(e.$.tooltip=i=document.createElement("smart-tooltip"),i.classList.add("smart-gantt-chart-tooltip"),i.setAttribute("smart-id","tooltip")),e.$tooltip||e._handleTooltipEvents(!0),i.rightToLeft=e.rightToLeft,i.theme=e.theme,i.openMode="manual",i.arrow=t.arrow,i.delay=t.delay,i.parentElement||e.$.container.appendChild(i),i;i&&(i.close(),i.remove())}_handleTooltipEvents(e){const t=this,i=t.$.tooltip;if(!i)return;let n=t.$tooltip;e?(n=t.$tooltip=Smart.Utilities.Extend(i),n.listen("close",t._tooltipVisibilityHandler.bind(t)),n.listen("closing",t._tooltipVisibilityHandler.bind(t)),n.listen("open",t._tooltipVisibilityHandler.bind(t)),n.listen("opening",t._tooltipVisibilityHandler.bind(t))):n&&(n.unlisten("close"),n.unlisten("closing"),n.unlisten("open"),n.unlisten("opening"),delete t.$tooltip)}_toggleTooltip(e){const t=this;if(t._dragDetails||!t.tooltip.enabled||!t.$.container.contains(e.target))return void t._closeTooltip();const i=t.getRootNode(),n={"smart-task-segment":null,"smart-timeline-task":null,"smart-gantt-chart-task-indicator":null,"smart-resource-timeline-view-cell":null,"smart-task-connection":null},a=(i.host?i.host.shadowRoot:i).elementsFromPoint(e.clientX,e.clientY);let s;for(let e=0,t=a.length;e<t;e+=1){const t=a[e],i=t.classList;if(i.contains("smart-task-container"))n["smart-timeline-task"]=t.closest(".smart-timeline-task");else for(let e in n)i.contains(e)&&(n[e]=t)}if(n["smart-task-segment"]){const e=n["smart-timeline-task"],t=e?e._cellObj.task:void 0;s=t&&t.segments&&t.segments.length?n["smart-task-segment"]:e}else if(n["smart-gantt-chart-task-indicator"])s=n["smart-gantt-chart-task-indicator"];else for(let e in n)if(n[e]){s=n[e];break}s?t._openTooltip(s,e):t._closeTooltip()}_getConnectionTypeName(e){const t=this;switch(e){case 0:return t.localize("startToStart");case 1:return t.localize("endToStart");case 2:return t.localize("endToEnd");case 3:return t.localize("startToEnd");default:return""}}_getSegmentTask(e){const t=this._tasks;for(let i=0,n=t.length;i<n;i+=1){const n=t[i];if(Array.isArray(n.segments)&&n.segments.indexOf(e)>-1)return n}}_getTooltipContent(e){const t=this;if(!e)return;const i=e.classList;let n,a;if(i.contains("smart-task-segment")){if(a=e._segmentObj,a){let e=a.label;if(void 0===e){const i=t._getSegmentTask(a);i&&(e=i.label)}n=`<label><b>${t.localize("segment")}</b>: ${e||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(a.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(a.dateEnd)||""}</label>`}}else if(i.contains("smart-timeline-task"))a=e._cellObj.task,a&&!a.segments&&(n=`<label><b>${t.localize("task")}</b>: ${a.label||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(a.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(a.dateEnd)||""}</label>`);else if(i.contains("smart-gantt-chart-task-indicator"))a=e._indicatorObj,a&&(n=a.label||"");else if(i.contains("smart-resource-timeline-view-cell")){if(!e.hasAttribute("load"))return;const i=e.closest(".smart-timeline-cell");if((e=e.closest(".smart-timeline-row"))&&e._cellObj&&(a=e._cellObj.resource),a){const s=t._getResourceTasks(a),r="hours"===t.resourceTimelineView?"h":"",o=t._tasks,l=t.$.resourceTimelineViewCells.children,c=Array.from(e.children).findIndex((e=>e===i));n=`<label><b>${t.localize("resource")}</b>: ${a.label||""}</label>\n <label><b>${t.localize("assignments")}</b>:</label>`;for(let e=0,i=s.length;e<i;e+=1){const i=s[e],d=o.indexOf(i),m=t._getResourceCellCapacity({cellDateRange:t._getCellDateRange(l[c]),cellTaskIndexAssigned:[d],index:c,resource:a,task:i,cellIndex:c});void 0!==m&&(n+=`<label>${t.localize("task")} #${d}: (${parseFloat(m.capacity.toFixed(1))}${r}) ${i.label||""}</label>`)}}}else i.contains("smart-task-connection")&&(a=t.getConnectionDetails(e.getAttribute("connection-id")),void 0!==a&&(n=`<label><b>${t.localize("startTask")}</b>: ${a.startTask.label||""}</label>\n <label><b>${t.localize("endTask")}</b>: ${a.endTask.label||""}</label>\n <label><b>${t.localize("type")}</b>: ${t._getConnectionTypeName(a.type)||""}</label>`,a.lag&&(n+=`<label><b>${t.localize("lag")}</b>: ${parseFloat(a.lag.toFixed(1))}</label>`)));return a?a.tooltip?a.tooltip+"":n||"":void 0}_openTooltip(e,t,i){const n=this,a=n.tooltip;if(i="string"==typeof i?i:n._getTooltipContent(e),!(a.enabled&&i&&e&&e.nodeName))return void n._closeTooltip();const s=n.$.tooltip||n._createTooltip();let r,o;if(i&&s.value!==i&&(s.value=i),s.selector=e,t&&t.pageX){const i=document.body.getBoundingClientRect(),n=e.getBoundingClientRect(),l=a,c=l.offset[0]||0,d=l.offset[1]||0,m=s.offsetWidth,u=s.offsetHeight;let h="bottom";"absolute"!==s.position&&(s.position="absolute",s.offset=[]),o=Math.min(i.left+i.width-m,t.pageX-m/2-c),r=n.top-u-d,r<i.top&&(r=n.bottom+d,h="top"),o<i.left&&(o=i.left+c,h="left"),h!==s.arrowDirection&&(s.arrowDirection=h),s.style.left=o+"px",s.style.top=r+"px"}else"auto"!==s.position&&(s.position="auto",s.offset=a.offset);s.visible||(n.getShadowRootOrBody().appendChild(s),s.open())}_closeTooltip(){const e=this.$.tooltip;e&&e.visible&&e.close()}_tooltipVisibilityHandler(e){const t=this,i=e.type,n=t.$.tooltip;e.target===n&&(e.stopPropagation(),t._fireTooltipVisibilityEvent(e)?e.preventDefault():"opening"===i?n.classList.remove("smart-visibility-hidden"):"closing"===i&&(n.hasAnimation?n.addEventListener("transitionend",(()=>{n.visible||(n.classList.add("smart-visibility-hidden"),n.style.top=n.style.left=0,t.$.container.appendChild(n))}),{once:!0}):t.$.container.appendChild(n)))}_fireTooltipVisibilityEvent(e){const t=this,i=e.type,n=t.$.tooltip,a=e.detail.owner;let s={target:n,owner:a};if(a)if(a.classList.contains("smart-task-connection")){s.type="connection";const e=t.getConnectionDetails(a.getAttribute("connection-id"));e&&(s.item=e)}else if(a.classList.contains("smart-gantt-chart-task-indicator"))s.type="indicator",a._indicatorObj&&(s.item=t._cloneObject(a._indicatorObj));else if(a.classList.contains("smart-task-segment"))s.type="segment",a._segmentObj&&(s.item=t._cloneObject(a._segmentObj));else if(a.classList.contains("smart-timeline-task"))s.type="task",a._cellObj&&a._cellObj.task&&(s.item=t._cloneObject(a._cellObj.task));else if(a.classList.contains("smart-resource-timeline-view-cell")){s.type="resource";const e=a.closest(".smart-timeline-row");e._cellObj&&(s.item=t._cloneObject(e._cellObj.resource))}let r=t.getAttribute("aria-owns")||"";switch(i){case"open":t.setAttribute("aria-owns",(r+" "+n.id).trim()),t.$.fireEvent(i,s);break;case"close":r=r.replace(n.id,"").trim(),r?t.setAttribute("aria-owns",r):t.removeAttribute("aria-owns"),t.$.fireEvent(i,s);break;case"closing":case"opening":if(t.$.fireEvent(i,s).defaultPrevented)return!0}}_parseAdapterData(e){let t={};for(let i=0,n=e.length;i<n;i+=1){const n=e[i],a=Object.assign({},n),s=n.parent,r=n.$.id;if(s&&s!==n){const e=s.$.id;t[e]||(t[e]=Object.assign({},s));const i=t[e];i.tasks||(i.tasks=[]),i.tasks.push(a)}else t[r]=a;delete a.parent,delete a.children,delete a.$}return Object.values(t)}_handleTaskConnections(e){const t=this,i=t._tasks;let n;if("number"==typeof e&&(n=e,e=i[e]),!e)return;void 0===n&&(n=i.indexOf(e));const a=e.connections,s=i.length;for(let e=0;e<a.length;e++){const i=a[e],r=t._getTaskIndexById(i.target);null==r||isNaN(r)||r<0||r>=s||r===n||t._connectTask([n,r,i.type,i.lag])}delete e.connections}_insertTasks(e,t,i){const n=this,a=n._tasks;if(t){const s=n._getProjectTasks(t,!0);if(s.length){const t=s[s.length-1];let r,o;"number"==typeof i&&i<s.length?r=s[i=Math.max(0,i)]:(r=t,o=!0);const l=n._getProjectTasks(r);i=o&&l.length?a.indexOf(l[l.length-1]):a.indexOf(r),a.splice.apply(a,[i+(o?1:0),0].concat(e))}else a.splice.apply(a,[a.indexOf(t)+1,0].concat(e))}else"number"==typeof i?(i+="",(i=a.findIndex((e=>e.$.id===i)))<0&&(i=a.length)):i=a.length,a.splice.apply(a,[i,0].concat(e))}_insertTimelineTasks(){const e=this,t=e._timelineVCells;t&&t.length?(e._recycleTimelineTasks(),e._refresh()):e._resetTimeline()}_recycleTimelineTasks(e){const t=this,i=t.$.taskIndicatorsContainer,n=i.children,a=t.$.taskTimelineCellsContainer.childElementCount,s=t._timelineVCells;for(;i.childElementCount>a;)i.firstElementChild.remove();if(t._closeTooltip(),!s||!s.length)return;const r=s.indexOf(t._getFirstContentCellInView()),o=t._getSelection("task",t.selectedTaskIds),l={timelineStart:t.dateStart.getTime(),timelineEnd:t.dateEnd.getTime()};for(let i=0,c=a;i<c;i++){const a=n[i],c=s[r+i];if(!c){a&&a.remove();continue}const d=c.task;t._snapToNearestDates(d),t._recycleTaskBars(c,i,o),t._setTimelineTaskBar(c,i),t._setTimelineTaskBaseline(c,i),t._setTaskBarProgress(d,i),t._setTaskBarLabel(d,i),t._setTaskIndicators(c,i,l),t._setTaskDeadline(c,i,l),e&&t._refreshTableColumnsData(d)}t._recycleConnections()}_ensureVisible(e,t="task"){const i=this;if(null==e)return;let n,a="task"===t?i._timelineVCells:i._timelineResourceVCells;n||(n=i.$[`${t}Table`]);const s=a.find((i=>i[t]===e));if(!s)return;let r,o;if("task"===t){const t=i._getTimelineTaskCellByDate(e.dateStart);if(r=i.$.taskTimelineContainer.offsetHeight,o=i,t){const e=i.scrollLeft,n=i.$.taskTimelineContainer.offsetWidth;t.left+t.width>e+n?i.scrollLeft=Math.max(0,t.left+t.width-n):t.left<e&&(i.scrollLeft=Math.max(0,t.left))}}else r=i.$.resourceTimelineContent.offsetHeight,o=i._resourceScrollView;const l=o.scrollTop;s.top+s.height>l+r?o.scrollTop=Math.max(0,s.top+s.height-r):s.top<l&&(o.scrollTop=Math.max(0,s.top))}_isTaskExpanded(e,t){if(!e||!e.$)return;let i,n=e.$[this.groupByResources?"group":"project"];if(!n)return!0;for(;n;){if(i=n.expanded,!i)return!1;if(n=n.$.project,n===t)break}return i}_getItemByTreeIndex(e,t,i){if(!t)return;const n=t.split(".");let a=this[`_${e}s`].filter((e=>!e.$.project))[t.split(".")[0]];if(a){if(!a[`${e}s`]||!a[`${e}s`].length)return i?null:a;for(let t=1;t<n.length;t++){const s=a[`${e}s`].filter((e=>!e.hidden&&e.$.project===a))[n[t]];if(!s||i&&"project"!==s.type)break;if(a=s,"project"!==a.type)break}return i?a&&"project"===a.type?a:void 0:a}}_getItemByTableId(e,t,i){if(null==t)return;const n=this[`_${e}s`];let a;for(let e=0,i=n.length;e<i;e+=1){const i=n[e];if(i.$.id===t){a=i;break}}return a?i?"project"===a.type?a:void 0:a:void 0}_tableChangeHandler(e){const t=e.target;(t.classList.contains("smart-task-table")||t.classList.contains("smart-resource-table"))&&(e.stopPropagation(),this._handleTableSelection(t===this.$.taskTable?"task":"resource",t.selected))}_tableColumnResizeHandler(e){const t=e.target,i=e.detail,n=t.classList.contains("smart-task-table");if(!n&&!t.classList.contains("smart-resource-table"))return;e.stopPropagation();const a=i.dataField,s=this[(n?"task":"resource")+"Columns"].find((e=>e.value===a));s&&(s.size=i.width),this.$.fireEvent("columnResize",i)}_tableSortFilterHandler(e){const t=this,i=e.target;let n;i.classList.contains("smart-task-table")?(n="task",t._createTimelineContent(),t._recycleTimelineTasks()):i.classList.contains("smart-resource-table")&&(n="resource",t._createResourceTimelineContent(),t._recycleResourceContent()),n&&(t._refresh(),e.stopPropagation(),t.$.fireEvent(e.type,Object.assign({type:n},e.detail)))}_taskTableExpandHandler(e){const t=this,i=e.target;if(!i.classList.contains("smart-task-table")&&!i.classList.contains("smart-resource-table"))return;const n=i===t.$.taskTable?"task":"resource";if(e.stopPropagation(),!t[`${n}s`]||!t[`${n}s`].length)return;const a=e.detail.record.itemId,s=t._getItemByTableId(n,a,!0);s&&(delete t._hoveredItem,s.expanded="collapse"!==e.type,t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks(),t.$.fireEvent(e.type,{item:t._cloneObject(s),id:s.id||s.$.id,index:t._tasks.indexOf(s),label:s.label,value:s.value}))}_taskTableKeyDownHandler(e){const t=this,i=e.key;if(t.keyboardNavigation&&!t.disabled&&!t.readonly)switch(i){case"Delete":case"Enter":{const e=t.$.taskTable._focusedCell;if(!e||!e.closest)return;const n=e.closest("tbody tr");if(!n)return;const a=t._getVCellById("task",n.getAttribute("row-id"));a&&t._openPopupWindow(a.task,"Delete"===i);break}}}_getVCellById(e="task",t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let n=0,a=i.length;n<a;n+=1){const a=i[n][e];if(a.$&&a.$.id===t)return i[n]}}_getGroupVCellByPath(e,t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let n=0,a=i.length;n<a;n+=1){const a=i[n][e];if(a.$&&a.$.id===t)return i[n]}}_taskTableGroupEventHandler(e){const t=this,i=e.detail.action,n=e.target;if(["collapse","expand"].indexOf(i)<0||!n.classList.contains("smart-task-table")&&!n.classList.contains("smart-resource-table"))return;const a=n===t.$.taskTable?"task":"resource",s=t.$.taskTable._getGroupByIndex(e.detail.path),r=t._getGroupVCellByPath(a,s.$.id);if(!r||!r[a].isGroup)return;const o=r[a];e.stopPropagation(),o.expanded="collapse"!==i,t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks(),t.$.fireEvent(i,{isGroup:!0,item:t._cloneObject(o),id:o.$.id,label:o.label})}_resetTimeline(){const e=this,t=e.$.taskTimelineContainer;if(e.$.taskTimelineCellsContainer.innerHTML="",e.$.timelineTasksContainer.innerHTML="",e.$.timelineConnectionsContainer.innerHTML="",e.$.timelineContent.style.height="",e.$.taskIndicatorsContainer.innerHTML="",e.rightToLeft&&e.scrollLeft!==t.scrollLeft){const i=e._getScrollLeft(e.scrollLeft);t.scrollLeft=i,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=i)}e._closeTooltip(),e.$.container.style.removeProperty("--smart-gantt-chart-task-timeline-content-height")}_refreshTimeline(e){const t=this;e||(e=t.view);const i=t._getDateFromCell(t.scrollLeft,t._getFirstCellObjInView(),e),n=t.scrollTop;t.scrollLeft=0,t.scrollTop=0,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&t._resourceScrollView&&(t._resourceScrollView.scrollLeft=0),t._resetTimeline(),t._createTimelineCells(),t._recycleTimelineTasks(!0),t.$.mainSplitter.contains(t.$.resourceSplitter)&&t._refreshResourceTimeline(),t._refresh(),t._scrollTo(i),t.scrollTop=n}_scrollTo(e,t){const i=this,n=i._timelineCells;let a;if(void 0!==e&&!isNaN(new Date(e).getTime()))for(let s=0;s<n.length;s++){const r=n[s],o=r.date;switch(i.view){case"year":if(o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()){if(t){a=r.left;break}let i=new Date(e);i.setMonth(e.getMonth()+1),i.setDate(0),i=i.getDate(),a=r.left+(e.getDate()-1)/i*r.width}break;case"month":{let i=new Date(o),n=new Date(o);i.setDate(i.getDate()-i.getDay()),n.setDate(n.getDate()+(6-n.getDay())+1),n.setMilliseconds(n.getMilliseconds()-1),e.getTime()>=i.getTime()&&e.getTime()<=n.getTime()&&(a=r.left+(t||t?0:e.getDay()/7*r.width));break}case"week":o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate()&&(a=r.left+parseFloat(e.getHours()+"."+e.getMinutes()+e.getSeconds())/24*r.width);break;case"day":o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate()&&o.getHours()===e.getHours()&&(a=r.left+(t?0:parseFloat(e.getMinutes()+e.getSeconds())/60*r.width))}if(void 0!==a)return i.scrollLeft=a,void(i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=i.$.resourceTimelineContent.scrollLeft=a,i._refreshResourceTimeline()))}}_updateConnection(e,t){const i=this,n=i._tasks,[a,s,r,o]=e,l=n[a],c=n[s];if(!l||!c||"number"!=typeof r)return;let d=i._connections,m=-1;d||(d=i._connections=[]);for(let e=0,t=d.length;e<t;e+=1){const t=d[e],i=t.startIndex,n=t.endIndex;if(i===a&&n===s||i===s&&n===a){m=e;break}}if(!t){if(m<0)d.push({startTask:n[a],endTask:n[s],startIndex:a,endIndex:s,type:r,lag:o});else{const e=d[m];if(!e)return;if(e.startIndex=a,e.startTask=n[a],e.endIndex=s,e.endTask=n[s],e.type=r,o!==e.lag){const t=parseInt(o);isNaN(t)||(e.lag=t)}}return!0}m>-1&&d.splice(m,1)}_createTimelineCells(){const e=this,t=e._tasks,i=new Date(e.properties.dateStart.value),n=new Date(e.properties.dateEnd.value);let a,s;if(isNaN(i.getTime())||(a=i),isNaN(n.getTime())||(s=n),t.length>0){let e=t[0].dateStart,i=t[0].dateEnd;for(let n=0;n<t.length;n++)t[n].dateStart&&t[n].dateEnd&&(e||(e=t[n].dateStart),i||(i=t[n].dateEnd),e.getTime()>t[n].dateStart.getTime()&&(e=t[n].dateStart),i.getTime()<t[n].dateEnd.getTime()&&(i=t[n].dateEnd));(!a||a.getTime()>e.getTime())&&(a=e),(!s||s.getTime()<i.getTime())&&(s=i)}a&&s&&(a=e._minMaxDateValidator(a),s=e._minMaxDateValidator(s),e._createTimelineHeader(a,e._getCellsCount(a,s)),e._createTimelineContent(),e._createDateMarkers(),e._refresh())}_getCellsCount(e,t,i){let n,a,s,r,o,l,c=new Date(e),d=new Date(t);const m=t.getFullYear()-e.getFullYear();if(a=n=Math.round(m)+1,"year"===i)return{year:a};if(c.setHours(c.getHours(),0,0,0),d.setHours(d.getHours(),0,0,0),l=Math.floor((t.getTime()-e.getTime())/36e5),l>0){let e=new Date(c);if(l=1,c.getFullYear()!==d.getFullYear()){let t=new Date(c.getFullYear()+1,0,1,0,0,0,0);for(;e.getTime()!==t.getTime();){const t=e.getTime();e.setHours(e.getHours()+1),e.getTime()===t&&e.setHours(e.getHours()+2),l++}const i=d.getFullYear()-t.getFullYear();for(let t=0;t<i;t++){const t=e.getFullYear();l+=24*((t%100==0?t%400==0:t%4==0)?366:365)-1,e.setFullYear(t+1)}}for(;e.getTime()<d.getTime();){const t=e.getTime();e.setHours(e.getHours()+1),e.getTime()===t&&e.setHours(e.getHours()+2),l++}}if("hour"===i)return{hour:l};if(c.setHours(0,0,0,0),d.setHours(23,59,59,999),o=n=Math.round((d.getTime()-c.getTime())/864e5),"day"===i)return{day:o};if(c.setDate(c.getDate()-c.getDay()),d.setDate(d.getDate()+6-d.getDay()),r=n=Math.round((d.getTime()-c.getTime())/6048e5),"week"===i)return{week:r};if("month"===this.view&&(0!==e.getDay()&&(e=new Date(e.setDate(e.getDate()-e.getDay()))),6!==t.getDay()&&(t=new Date(t.setDate(t.getDate()+6-t.getDay())))),e.getFullYear()!==t.getFullYear()){n=12-e.getMonth();const i=t.getFullYear();for(let a=e.getFullYear()+1;a<=i;a++)n+=a===t.getFullYear()?t.getMonth()+1:12}else n=t.getMonth()-e.getMonth()+1;return s=Math.ceil(n),"months"===i?{month:s}:("day"===this.view&&0===l&&(l=1),{year:a,month:s,week:r,day:o,hour:l})}_recycleTaskBars(e,t,i){const n=this,a=e.task,s=n.$.timelineTasksContainer,r=n.$.taskTimelineCellsContainer,o="project"===a.type&&a.synchronized,l=a.type,c=a.$.id,d=s.children[t],m=r.children[t];m._cellObj=e,m.setAttribute("row-id",c),m.style.top=e.top+"px",m.removeAttribute("hover"),d.removeAttribute("hover"),d.classList.contains(l)||(d.innerHTML="milestone"===l?'<div class="smart-task-container" aria-hidden="true">\n <div class="smart-task-connection-point start"></div>\n <div class="smart-task-segments"></div>\n <div class="smart-task-connection-point end"></div>\n </div>':'<div class="smart-task-container" aria-hidden="true">\n <div class="smart-task-connection-point start"></div>\n <div class="smart-task-segments"></div>\n <div class="smart-timeline-task-progress-thumb"></div>\n <div class="smart-task-connection-point end"></div>\n </div>'),n._recycleSegments(a,d),delete d._cellStart,delete d._cellEnd,a.disableDrag||o&&!a.dragProject?d.setAttribute("disable-drag",""):d.removeAttribute("disable-drag"),a.disableResize||o?d.setAttribute("disable-resize",""):d.removeAttribute("disable-resize"),a.isGroup?d.setAttribute("resource-group",""):d.removeAttribute("resource-group"),i&&(i.indexOf(c)>-1?(d.setAttribute("selected",""),m.setAttribute("selected","")):(d.removeAttribute("selected"),m.removeAttribute("selected"))),a.id?d.id=a.id:d.id="ganttTask"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),d._cellObj=e,d.className="smart-timeline-task "+l,d.setAttribute("row-id",c),a.class&&d.classList.add(a.class),d.setAttribute("aria-label",a.label+" Start date: "+n._toISODate(a.dateStart)+", End date: "+n._toISODate(a.dateEnd)),d.setAttribute("aria-selected","false")}_toISODate(e){const t=e.getFullYear(),i=e.getMonth()+1,n=e.getDate();return t+"-"+(i<10?"0"+i:i)+"-"+(n<10?"0"+n:n)}_recycleSegments(e,t){const i=this,n=t.querySelector(".smart-task-segments");let a,s=e.segments;if(!n)return;for(Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);n.childElementCount>s.length;)n.children[0].remove();const r=document.createDocumentFragment(),o=n.children,l="milestone"===e.type?'<div class="smart-timeline-task-fill"></div>':'<div class="smart-timeline-task-fill">\n <div class="smart-timeline-task-progress"></div>\n </div>\n <div class="smart-timeline-task-label"></div>';for(let t=0,n=s.length;t<n;t+=1){const n=s[t];let c=o[t];n.dateStart=new Date(Math.max(e.dateStart.getTime(),n.dateStart.getTime())),n.dateEnd=new Date(Math.min(e.dateEnd.getTime(),n.dateEnd.getTime())),c?(delete c._cellStart,delete c._cellEnd):(c=document.createElement("div"),c.classList.add("smart-task-segment"),c.innerHTML=l,r.appendChild(c)),n.disableDrag?c.setAttribute("disable-drag",""):c.removeAttribute("disable-drag"),n.disableResize?c.setAttribute("disable-resize",""):c.removeAttribute("disable-resize"),c._segmentObj=n,c.setAttribute("aria-label",(n.label||"")+" Start date: "+i._toISODate(n.dateStart)+", End date: "+i._toISODate(n.dateEnd)),a=c}r.childElementCount&&n.appendChild(r),i._setTaskBarDeadline(e,a)}_createCells(e){let t,i=document.createDocumentFragment();for(let n=0;n<e;n++)t=document.createElement("div"),t.classList.add("smart-timeline-view-cell"),t.setAttribute("role","columnheader"),i.appendChild(t);return i}_getTimelineVisibleCellsCount(){const e=this,t=e._timelineCells;if(!t)return;const i=e._getFirstCellObjInView();if(!i)return t.length;const n=1-(i.left+i.width-e.scrollLeft)/t[0].width;return Math.min(t.length,Math.ceil(parseFloat((e.$.timeline.offsetWidth/i.width).toFixed(2))+n))}_getHeaderVisibleCellsCount(){const e=this;if(!e._timelineHeaderCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,n=e._timelineHeaderCells;let a=0;for(let e=0;e<n.length;e++){const s=n[e];s.left+s.width>t&&s.left<i+t&&a++}return a}_refreshHeaderDate(e){const t=this,i=t._getCellsViewType(),n=t.$.timelineHeader.scrollLeft,a=t.$.timelineViewCells.children,s=t._timelineCells;let r;t._refreshHeaderDetailsDate(e);for(let e=0;e<s.length;e++){const t=s[e];if(n<=t.left+t.width){r=e;break}}for(let n=0;n<a.length;n++){const o=a[n],l=s[r];if(!l)break;r++;const c=l.date;o.innerHTML=`<div>${t._getDateString(new Date(c),i)}</div>`,e||(o._date=new Date(c),o.style.width=l.width+"px",o.style[t.rightToLeft?"right":"left"]=l.left+"px",l.weekend?o.setAttribute("weekend",""):o.removeAttribute("weekend"),l.nonworking?o.setAttribute("nonworking",""):o.removeAttribute("nonworking"))}}_getDateString(e,t,i){const n=this,a=["2-digit","numeric"][n.dayFormat]||"numeric";let s;return"year"===t?s=e.toLocaleDateString(n.locale,{year:n.yearFormat}):"month"===t?s=e.toLocaleDateString(n.locale,{month:n.monthFormat}):"week"===t?s="numeric"!==n.weekFormat&&i?e.toLocaleDateString(n.locale,{day:a,month:n.monthFormat,year:n.yearFormat}):n._getWeekNumber(e):"day"===t?s=e.toLocaleDateString(n.locale,"day"===n.view?{day:a,month:n.monthFormat,year:n.yearFormat}:["long","short","narrow"].indexOf(n.dayFormat)>-1?{weekday:n.dayFormat}:{day:n.dayFormat}):"hour"===t&&(s="default"===n.hourFormat?e.toLocaleTimeString(n.locale,{hour12:!1}):e.toLocaleDateString(n.locale,{hour:n.hourFormat})),n.timelineHeaderFormatFunction?n.timelineHeaderFormatFunction(new Date(e),t,i,s):s}_refreshHeaderDetailsDate(e){const t=this,i=t.view,n=t.scrollLeft,a=t.$.timelineViewDetails.children,s=t._timelineHeaderCells;let r;for(let e=0;e<s.length;e++){const t=s[e];if(n<=t.left+t.width){r=e;break}}for(let n=0;n<a.length;n++){const o=s[r],l=a[n];let c=new Date(o.date);"week"===t.view&&c.setDate(c.getDate()-c.getDay()),r++,c=new Date(Math.max(o.date.getTime(),c.getTime())),l.innerHTML=`<div>${t._getDateString(c,i,!0)}</div>`,e||(l._date=c,l.style[t.rightToLeft?"right":"left"]=o.left+"px",l.style.width=o.width+"px")}}_getWeekNumber(e){let t,i=new Date(e.getFullYear(),0,1),n=Math.round((e.getTime()-i.getTime()-6e4*(e.getTimezoneOffset()-i.getTimezoneOffset()))/864e5)+1,a=i.getDay();return a=a>=0?a:a+7,a<4?(t=Math.floor((n+a-1)/7)+1,t>52&&(i=new Date(e.getFullYear()+1,0,1),a=i.getDay(),a=a>=0?a:a+7,t=a<4?1:53)):t=Math.round((n+a-1)/7),t}_convertDuration(e,t){if(!e)return 0;let i;switch(this.durationUnit){case"day":i=864e5;break;case"hour":i=36e5;break;case"minute":i=6e4;break;case"second":i=1e3;break;case"milisecond":return e;case"week":i=6048e5}return Math.max(0,t?e/i:e*i)}_createTimelineHeader(e,t){const i=this,n=i._getCellsViewType();if(!e){const t=i.$.timelineViewCells.children;if(0===t.length)return;e=t[0]._date}if("day"!==i.view&&e.setHours(0,0,0,0),i.$.timelineContent.offsetWidth===i.$.timeline.offsetWidth&&i._timelineCells&&i._timelineCells[0]&&i._timelineCells[0].date.getTime()===e.getTime()&&i._timelineCells.length===t[i._getCellsViewType()])i._refresh();else{if(i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width="",i._createTimelineCellsObj(e,t),i._createTimelineHeaderCellsObj(e,t),i.$.timelineViewDetails.innerHTML="",i.$.timelineViewDetails.appendChild(i._createCells(i._getHeaderVisibleCellsCount())),i.$.timelineViewCells.innerHTML="",i.$.timelineViewCells.appendChild(i._createCells(i._getTimelineVisibleCellsCount())),i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width=Math.max(t[n]*i._timelineCells[0].width,i.$.timeline.parentElement.offsetWidth)+"px",i.scrollLeft){const e=i._getScrollLeft(i.scrollLeft);i.$.timelineHeader.scrollLeft=e,i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=e)}i._refreshHeaderDate(),i._setCurrentTimeIndicators()}}_createTimelineContent(){const e=this,t=e.$.container,i=e.$.timelineContent,n=e._taskDefaultHeight,a=e.$.taskTimelineContainer,s=e.scrollLeft;if(i.style.height="",t.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e._createTimelineVCells(n),i.style.height=e._timelineVCells.length*n+"px",t.style.setProperty("--smart-gantt-chart-task-timeline-content-height",e.$.timeline.offsetHeight+"px"),s||s!==a.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);a.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=t)}e.scrollTop&&(a.scrollTop=e.scrollTop),e._recycleContentCells()}_createDateMarkers(){const e=this,t=e.dateMarkers;let i=[];delete e._markers;for(let n=0,a=t.length;n<a;n+=1){const a=t[n],s=e._dateValidator(void 0,a.date);if(s){const e={date:s},t=a.label,n=a.className;("string"==typeof t||"number"==typeof t&&!isNaN(t))&&(e.label=t),"string"==typeof n&&(e.className=n),i.push(e)}}i.length&&(e._markers=i),e._recycleDateMarkers()}_createTimelineRowCells(e,t){const i=this,n=e.children,a=e.querySelectorAll(".smart-task-bar-limiter"),s=document.createDocumentFragment(),[r,o]=i.rightToLeft?["right","left"]:["left","right"];t||(t=i.$.timelineViewCells.children);for(let e=0,t=a.length;e<t;e+=1)a[e].remove();const l=t.length;for(;e.childElementCount>l;)e.lastElementChild.remove();for(let t=e.childElementCount;t<l;t+=1){const e=document.createElement("div");e.classList.add("smart-timeline-cell"),s.appendChild(e)}s.childElementCount&&e.appendChild(s);for(let e=0;e<l;e+=1){const i=t[e],a=n[e];i.hasAttribute("weekend")?a.setAttribute("weekend",""):a.removeAttribute("weekend"),i.hasAttribute("nonworking")?a.setAttribute("nonworking",""):a.removeAttribute("nonworking"),a.style[o]=i.style[o],a.style[r]=i.style[r],a.style.width=i.style.width}for(let t=0,i=a.length;t<i;t+=1)e.appendChild(a[t])}_recycleTimelineRowCells(){const e=this,t=e.$.timelineViewCells.children,i=e.$.taskTimelineCellsContainer.children;for(let n=0,a=i.length;n<a;n+=1)e._createTimelineRowCells(i[n],t)}_createTimelineVCells(e){const t=this,i=t._tasks,n=t.$.taskTable.rows,a=t.groupByResources;let s=0,r={};t._timelineVCells=[];for(let o=0,l=n.length;o<l;o++){const l=n[o].data;let c=i[l.itemIndex];if(a)if(!c&&l.groupDataField){const e=l.$.id;c={$:{id:e,project:void 0},label:t._formatResourceGroupLabel(l.label),value:l.label,expanded:l.expanded,synchronized:!0,isGroup:!0,type:"project"},r[e]=c}else l.parent?(c.$.group=r[l.parent.$.id],t._synchronizeProjectDates(c.$.group,[c])):delete c.$.group;else delete c.$.group;!c.hidden&&t._isTaskExpanded(c)&&(t._timelineVCells.push({top:s,height:e,task:c}),s=parseFloat((s+e).toFixed(2)))}}_getCellsViewType(){switch(this.view){case"year":return"month";case"month":return"week";case"week":return"day";case"day":return"hour"}}_createTimelineCellsObj(e,t){const i=this,n=i._getCellsViewType();t=t[n];const a=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<a&&(s=a/t),s=parseFloat(s.toFixed(2)),i._timelineCells=[];for(let e=0;e<t;e++){const e={left:r,width:s};if("year"===n)o.setMonth(0),e.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===n)o.setDate(1),e.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===n)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),e.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===n)i.nonworkingDays.indexOf(o.getDay())>-1&&(e.nonworking=!0),o.setHours(0,0,0,0),e.date=new Date(o),o.setDate(o.getDate()+1),e.weekend=0===e.date.getDay()||6===e.date.getDay();else if("hour"===n){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(e.nonworking=!0),o.setHours(o.getHours(),0,0,0),e.date=new Date(o);const t=o.getTime();o.setHours(o.getHours()+1),t===o.getTime()&&o.setHours(o.getHours()+2),e.weekend=0===e.date.getDay()||6===e.date.getDay()}i._timelineCells.push(e),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderCellsObj(e,t){const i=this,n=i.view;let a=0,s=new Date(e);t=t[n],i._timelineHeaderCells=[];for(let e=0;e<t;e++){const t={};switch(t.date=new Date(s),n){case"year":s.setFullYear(s.getFullYear()+1);break;case"month":s.setDate(1),s.setMonth(s.getMonth()+1);break;case"week":s.setDate(s.getDate()+7);break;case"day":s.setDate(s.getDate()+1)}a=i._refreshViewDetailCell(t,a,e),i._timelineHeaderCells.push(t)}}_minMaxDateValidator(e){if(!e||isNaN(e.getTime()))return e;const t=new Date(this.min),i=new Date(this.max);return t&&(e=new Date(Math.max(t.getTime(),e.getTime()))),i&&(e=new Date(Math.min(i.getTime(),e.getTime()))),e}_dateValidator(e,t){const i=this;let n;if(t instanceof Date)return i._minMaxDateValidator(t);if(Smart.Utilities.DateTime&&t instanceof Smart.Utilities.DateTime)return i._minMaxDateValidator(t.toDate());if("string"!=typeof t)return i._minMaxDateValidator(e);{const e=/\d+:\d+:\d+/;if("new Date()"===t.trim()||"new Smart.Utilities.DateTime()"===t.trim())return i._minMaxDateValidator(new Date);if(isNaN(Date.parse(t))){const i=/(\d+[,-.\/]{1}\s*\d+[,-.\/]{1}\s*\d+)/;if(i.test(t)){const a=i.exec(t)[0].replace(/[,-.\/]/g,",").split(",");if(3===a.length){const[i,s]=parseInt(a[0])<parseInt(a[2])?[a[0],a[2]]:[a[2],a[0]];if(n=new Date(parseInt(s),parseInt(a[1])-1,parseInt(i)),e.test(t)){const i=e.exec(t)[0].split(":");n.setHours(i[0]||0,i[1]||0,i[2]||0)}t=n}}}else n=new Date(Date.parse(t)),e.test(t)||n.setHours(0,0,0,0),t=n}return i._minMaxDateValidator(new Date(t))}_currentTimeIndicatorIntervalValidator(e,t){return Math.max(1,t)}_getTaskBarPositionLimits(e,t){const i=this;function n(e){const t=i._getTimelineTaskCellByDate(e);if(t)return t.left+i._getTimelineTaskOffset(t,e)||0}return{min:n(e["min"+t]),max:n(e["max"+t])}}_getTimelineTaskOffset(e,t){if(!e)return;let i,n;switch(this.view){case"year":{const a=t.getHours()/24+t.getMinutes()/1440+t.getSeconds()/86400;i=new Date(e.date.getFullYear(),e.date.getMonth()+1,0),n=(t.getDate()-1+a)/i.getDate()*e.width;break}case"month":n=t.getDay()/7*e.width;break;case"week":n=parseFloat(t.getHours()+t.getMinutes()/60+t.getSeconds()/3600)/24*e.width;break;case"day":n=parseFloat(t.getMinutes()+t.getSeconds()/60)/60*e.width}return n}_getTaskBarSizeLimits(e,t){const i=this,n=i._getTaskBarDateRange(e);let a,s=0,r=i._convertDuration(e._cellObj.task.minDuration)||i._getMinDuration(e,t),o=i._convertDuration(e._cellObj.task.maxDuration);function l(a,s){if(!a)return;let r,o;"left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft?(a*=-1,o=n.dateEnd):o=n.dateStart,s&&Math.abs(r)===Math.abs(a)&&(r=0);let l=i._getTaskWorkingDateEnd({dateStart:o},a);const c=l.getTime()+60*(l.getTimezoneOffset()-o.getTimezoneOffset())*1e3,d=i._getTimelineTaskCellByDate(new Date(c));if(!d)return;const m=i._getTimelineTaskOffset(d,new Date(c));return i.rightToLeft?"left"===t?m-(i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth-d.left):i.$.timelineContent.offsetWidth-e.offsetLeft-d.left-m:"left"===t?e.offsetLeft+e.offsetWidth-d.left-m:d.left-e.offsetLeft+m}if("left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft){const t=e._cellObj.task.maxDateStart,i=e._cellObj.task.minDateStart;i&&(s=60*(i.getTimezoneOffset()-n.dateEnd.getTimezoneOffset())*1e3,a=Math.abs(i.getTime()-n.dateEnd.getTime())+s,o=o?Math.min(a,o):a),t&&(s=60*(t.getTimezoneOffset()-n.dateEnd.getTimezoneOffset())*1e3,a=Math.abs(t.getTime()-n.dateEnd.getTime())+s,r=r?Math.max(a,r):a)}else{const t=e._cellObj.task.maxDateEnd,i=e._cellObj.task.minDateEnd;i&&(s=60*(i.getTimezoneOffset()-n.dateStart.getTimezoneOffset())*1e3,a=Math.abs(i.getTime()-n.dateStart.getTime())+s,r=r?Math.max(a,r):a),t&&(s=60*(t.getTimezoneOffset()-n.dateStart.getTimezoneOffset())*1e3,a=Math.abs(t.getTime()-n.dateStart.getTime())+s,o=o?Math.min(a,o):a)}return o&&(r=Math.min(r,o)),{min:l(r,!0),max:l(o)}}_getMinDuration(e,t){const i=this,n=i._taskBarMinWidth;if(!n||!i._timelineCells||0===i._timelineCells.length)return;const a=e._cellObj.task;let s,r,o=1;r=i.rightToLeft?parseFloat(e.style.right)||i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth:parseFloat(e.style.left)||e.offsetLeft,"left"===t?(s=a.dateEnd,r+=parseFloat(e.style.width)||e.offsetWidth,o=-1):s=a.dateStart;const l=r+o*n;let c;for(let e=0;e<i._timelineCells.length;e++){const t=i._timelineCells[e];if(l<t.left)break;c=t}const d=i._getDateFromCell(l,c);return d?Math.abs(s.getTime()-d.getTime()):void 0}_createDelimiter(e,t){const i=this,n=i._dragDetails,a=n.segment,s=e.slice(0,3),r=document.createElement("div");if(r.classList.add("smart-task-bar-limiter",e),e.indexOf("date")>-1){if(!n[s]||!n[s].left)return;const[e,t]=a?[a.element,a.originalPosition.x]:[n.timelineTask,0],o=i.$.taskTimelineCellsContainer.children[i._getTaskDOMIndex(n.task)];s.indexOf("max")>-1?r.style.width=o.offsetWidth-n[s].left-t-e.offsetWidth+"px":r.style.width=n[s].left+t+"px"}else{if(!n[s].width)return;r.style["left"===t?"right":"left"]=n[s].width+"px"}return r}_doubleClickHandler(e){const t=this;let i=e.target;if(t.disabled||t.disableWindowEditor)return;t.shadowRoot&&i===t&&(i=e.composedPath()[0]);let n=i.closest?i.closest(".smart-task-connection"):void 0;if(n)t._openPopupWindow(n);else if(n=i.closest(".smart-timeline-task")||i.closest(".smart-table tbody tr[row-id]"),n&&t.$.taskSplitter.contains(n))if(n.classList.contains("smart-timeline-task"))t._openPopupWindow(n._cellObj.task);else{const e=t._getVCellById("task",n.getAttribute("row-id"));e&&t._openPopupWindow(e.task)}}_checkDoubleClick(e){const t=this;let i=e.target;if(t.shadowRoot&&i===t&&(i=e.composedPath()[0]),void 0===t._dblClickDetails&&(t._dblClickDetails={clicks:0}),clearTimeout(t._dblClickDetails.timeOut),i!==t._dblClickDetails.target&&(t._dblClickDetails.clicks=0),t._dblClickDetails.target=i,t._dblClickDetails.clicks++,t._dblClickDetails.timeOut=setTimeout((function(){t._dblClickDetails&&(t._dblClickDetails.clicks=0)}),250),2===t._dblClickDetails.clicks)return t._doubleClickHandler(e),t._dblClickDetails.clicks=0,!0}_downHandler(e){const t=this,i=e.originalEvent,n=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target,a=n.closest?n.closest(".smart-timeline-row")||n.closest(".smart-timeline-task"):null;if(e.stopPropagation(),delete t._itemClickDetails,t._dragDetails)return delete t._dragDetails,void t._setConnectionFeedback();const s=t.$.taskSplitter.contains(n)?"task":"resource";if((n.closest(".smart-timeline-content")||n.closest(`.smart-${s}-table`))&&requestAnimationFrame((()=>t.$[`${s}Table`].focus({preventScroll:!0}))),t._itemClickDetails={target:n},!t._isMobile&&0!==e.button)return;if(!a){if(n.classList.contains("smart-popup-window-modal")){if(t._popupWindow){const e=Object.keys(t._popupWindow);requestAnimationFrame((()=>t._popupWindow[e[e.length-1]].focus()))}return}return void((n.closest(".smart-table tbody tr[row-id]")&&!n.classList.contains("smart-arrow")||n.closest(".smart-task-connection"))&&t._checkDoubleClick(i))}if(n.closest(".smart-resource-timeline-view-cell")||t.disabled)return;const r=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===a._cellObj.task));if(!r)return;const o=r._cellObj.task;if(!o)return;const l=t.$.timeline.getAttribute("task-bar-hovered");if(r.getElementsByClassName("smart-timeline-task-fill")[0]||l){if((n.closest(".smart-timeline-task-fill")||r.classList.contains("milestone")&&n.closest(".smart-task-container"))&&t._checkDoubleClick(i))return;const a=n.closest(".smart-timeline-task-progress-thumb"),s=e.pageX-window.pageXOffset,c=e.pageY-window.pageYOffset,d=t._dragDetails={},m=t.rightToLeft;let u,h=n.closest(".smart-task-segment");if(l&&!h){const e=r.querySelectorAll(".smart-task-segment");d.segments=e,h="left"===l&&!m||"right"===l&&m?e[0]:e[e.length-1]}if(d.target=(a||n).className,d.timelineTask=r,d.task=r._cellObj.task,d.taskDimensions={width:r.offsetWidth,height:r.offsetHeight,left:r.offsetLeft,top:r.offsetTop},d.coordinates={x:s,y:c},!e.ctrlKey&&h&&o.segments&&o.segments.length>1&&!t.disableSegmentDrag){const e=h.getBoundingClientRect(),t=h._segmentObj,i=d.task.segments,n=i.indexOf(t);d.segment={element:h,dimensions:{width:e.width,left:h.offsetLeft},offset:{x:s-e.left},originalSize:{width:e.width},isFirstSegment:0===n,isLastSegment:n===i.length-1,min:{},max:{}},u=d.segment.dimensions}const g=d.taskDimensions;t.rightToLeft?(g.right=t.$.timelineContent.offsetWidth-(g.left+g.width),d.originalPosition={x:g.right,y:g.top},d.segment&&(u.right=g.width-(u.left+u.width),d.segment.originalPosition={x:u.right})):(d.originalPosition={x:g.left,y:g.top},d.segment&&(d.segment.originalPosition={x:u.left}));const f=(a||r).getBoundingClientRect();if(d.offset={x:s-f.left,y:c-f.top},d.originalSize={width:g.width,height:g.height},a||!a&&"project"===o.type&&o.synchronized&&!o.dragProject)return void(n.closest(".smart-task-connection-point")&&(d.timelineTask=void 0,d.relatedConnections={}));("visible"===t.resizeHandlesVisibility||t._isMobile&&"auto"===t.resizeHandlesVisibility)&&(n.closest(".smart-timeline-task-fill")?t._checkTaskBarResizability(e):t.$.timeline.removeAttribute("task-bar-hovered")),d.min={},d.max={},t._setDragLimits(n)}}_documentMoveHandler(e){const t=this;if(!t._dragDetails||!t._dragDetails.target){let i=e.originalEvent.target;t.shadowRoot&&i===t&&(i=e.originalEvent.composedPath()[0]);const n=i.closest&&i.closest(".smart-table tbody tr[row-id]");return n&&n.data?t._handleTableItemHover(n.data.itemId,i):t._handleTimelineHover(e),t._checkTaskBarResizability(e),void t._toggleTooltip(e.originalEvent)}if(t._dragDetails.target.includes("smart-task-connection-point"))return t._setConnectionFeedback(e),t._handleTimelineHover(e),void t._autoScroll(e);if(t._dragDetails.target.includes("smart-timeline-task-progress-thumb"))t._handleTaskProgressChange(e);else if(t._autoScroll(e),!t._autoScrolling)if(t.$.timeline.hasAttribute("task-bar-hovered"))t._handleTaskBarResize(e);else if(t._dragDetails.target.includes("smart-timeline-task-fill")){const i=t._dragDetails.task;if(!i||i.disableDrag||"project"===i.type&&i.synchronized&&!i.dragProject)return;t._handleTaskBarDrag(e)}}_documentUpHandler(e){const t=this,i=e.originalEvent;let n=i.target;if(t._upHandler(),!t._dragDetails)return void t._handleItemClick(i);if(t._scrollView.disableSwipeScroll=t._touchmoveInside=!1,t.shadowRoot&&n===t&&(n=i.composedPath()[0]),t.hasAttribute("connecting-task")){const i=t._connectTask(e),n=t._tasks;if(t._setConnectionFeedback(),i){const e=i.taskStart,a=i.taskEnd,[s,r,o]=[n.indexOf(i.taskStart),n.indexOf(i.taskEnd),i.type];t.$.fireEvent("connectionEnd",{id:`${s}-${r}-${o}`,startIndex:s,startTaskId:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,endIndex:r,endTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,type:o}),t._autoSchedule(i.taskStart)}return t._isMobile&&t._handleTimelineHover(e,!0),void delete t._dragDetails}const a=t._dragDetails.task;if(!a)return void delete t._dragDetails;let s;const r=t._dragDetails.segment?t._dragDetails.segment.element:void 0;if(s||(s=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===a))),t.hasAttribute("dragged")){t._snapToNearest(s,r),r||t._checkWorkingDays(s,r),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),t._autoSchedule(a),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(a)):(t.snapToNearest||t.nonworkingDays.length>0||t.nonworkingHours.length>0)&&t._refreshAssignedResources(a),t.removeAttribute("dragged");const e={id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),dateStart:new Date(a.dateStart),dateEnd:new Date(a.dateEnd)};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("dragEnd",e)}else if(t.hasAttribute("progress-change"))t._resourceTreeRefreshTimeout&&(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(a,["progress"])),t.removeAttribute("progress-change"),t.$.fireEvent("progressChangeEnd",{id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),progress:a.progress||0});else if(t.hasAttribute("resized")){t._snapToNearest(s,r),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(a,["workload"])):t.snapToNearest&&t._refreshAssignedResources(a,["workload"]),t.removeAttribute("resized");const e={id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),dateStart:a.dateStart,dateEnd:a.dateEnd};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("resizeEnd",e),t._autoSchedule(a)}else n.closest(".smart-timeline-task")===s&&(t._select("task",a.$.id,!0),delete t._dragDetails,t._handleItemClick(i));const o=t.$.timelineContent.querySelectorAll(".smart-task-bar-limiter");for(let e=0,t=o.length;e<t;e+=1)o[e].remove();delete t._dragDetails}_handleItemClick(e){const t=this,i=e.target;if(t._dragDetails||!t._itemClickDetails||t._itemClickDetails.target!==i)return void delete t._itemClickDetails;let n,a,s;if(i.closest(".smart-timeline-task-fill"))a=i.closest(".smart-timeline-task")._cellObj.task,s="task";else if(n=i.closest(".smart-task-connection"),n)a=n.getAttribute("connection-id").split("-"),a={source:a[0],target:a[1],type:a[2]},s="connection";else if(n=i.closest(".smart-table tbody tr"),n){const e=t._getVCellById(s,n.getAttribute("row-id"));s=t.$.taskTable.contains(n)?"task":"resource",a=e?e[s]:void 0}if(!a)return;const r={originalEvent:e,type:s,item:t._cloneObject(a)};r.id="connection"===s?`${a.source}-${a.target}-${a.type}`:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,delete t._itemClickDetails,t.$.fireEvent("itemClick",r)}_moveHandler(e){const t=this;t._isMobile||e.stopPropagation(),(t.hasAttribute("dragged")||t.hasAttribute("progress-change"))&&"touchmove"===e.originalEvent.type&&e.originalEvent.preventDefault()}_handleTableItemHover(e,t){const i=this,n=i._hoveredItem;let a,s;if(t&&([a,s]=i.$.taskSplitter.contains(t)?[i.$.taskTable,"task"]:[i.$.resourceTable,"resource"]),n&&"itemType"===n.type&&n.id===e)return;const r=i.$.mainSplitter.querySelectorAll("table tbody tr[hover]");for(let e=0;e<r.length;e++)r[e].removeAttribute("hover");if(void 0===e)return void i._handleTimelineHover({target:i});if(!a)return;i._setTableHoverState(a,e);const o=i.$["task"===s?"taskTimelineCellsContainer":"resourceTimelineCellsContainer"].children;for(let t=0,n=o.length;t<n;t+=1){const n=o[t];if(n._cellObj[s].$.id===e){i._handleTimelineHover({target:n});break}}}_setTableHoverState(e,t){const i=this;e||(e=i.$.taskTable);const n=e===i.$.taskTable?"task":"resource",a=e.querySelectorAll("table tbody tr");if(!i._isMobile&&i[n+"Columns"].length)for(let e=0;e<a.length;e++){let i=a[e];const n=i.data;n&&n.itemId===t&&i.setAttribute("hover","")}}_checkWorkingDays(e){const t=this,i=t._dragDetails;if(!(i&&i._taskDuration||t._timelineCells.length))return;if(!e.classList||!e.classList.contains("smart-timeline-task")||!t.hasAttribute("dragged")||0===t.nonworkingDays.length&&0===t.nonworkingHours.length||!i||!i._taskDuration)return;const n=e._cellObj,a=n.task,s=t._getTaskWorkingDateEnd(a),r=a.segments;let o=new Date(t._timelineCells[t._timelineCells.length-1].date);if("year"===t.view?(o.setMonth(o.getMonth()+1),o.setDate(0),o.setHours(23,59,59,999)):"month"===t.view?(o.setDate(o.getDate()+6-o.getDay()),o.setHours(23,59,59,999)):"week"===t.view?o.setHours(23,59,59,999):o.setHours(o.getHours(),59,59,999),s&&(a.dateEnd=a.maxDateEnd?new Date(Math.min(s.getTime(),a.maxDateEnd.getTime())):s),a.dateEnd=new Date(Math.min(o.getTime(),a.dateEnd.getTime())),a.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(a.dateStart,a.dateEnd):a.dateEnd.getTime()-a.dateStart.getTime(),!0),r&&r.length>1){for(let e=0,i=r.length;e<i;e+=1)t._snapToNearestDates(r[e],!0);t._validateTaskSegments(a),a.segments.length!==r.length&&t._recycleSegments(a,e),t._setTaskBarSegments(n,e,!0),t._setTaskBarProgress(a)}t._setTimelineTaskBar(n,void 0,!0),t._refreshTaskConnections(n.task),t._refreshTableColumnsData(a,["dateEnd","duration","overdue"])}_getTaskWorkingDateEnd(e,t){const i=this;if(!e||!e.dateStart)return;let n,a,s=new Date(e.dateStart);if(t||(t=i._dragDetails?i._dragDetails._taskDuration:i._getWorkingTime(e.dateStart,e.dateEnd)),!i.adjustToNonworkingTime)return new Date(e.dateStart.getTime()+t);const r=t<0?-1:1,o=i.nonworkingDays,l=i.nonworkingHours;for(t=Math.abs(t);t>0;){const e=Math.min(t,36e5-(60*s.getMinutes()*1e3+1e3*s.getSeconds()+s.getMilliseconds()));if(o.indexOf(s.getDay())>-1)a=new Date(s),a.setHours(0,0,0,0),a.setDate(s.getDate()+1*r),n=Math.min(e,a.getTime()-s.getTime()),s=new Date(s.getTime()+n);else if(l.indexOf(s.getHours())>-1){a=new Date(s);const t=a.getTime();a.setHours(s.getHours()+1*r,0,0,0),t===a.getTime()&&a.setHours(s.getHours()+2*r,0,0,0),n=Math.min(e,a.getTime()-s.getTime()),s=new Date(s.getTime()+n)}else t-=e,s=new Date(s.getTime()+r*e)}return s}_createConnectingElement(e,t,i,n,a){const s=this;if(!s._connectionDetails||!s._connectionDetails.start)return;const r=s._connectionDetails,o=r.type,l=s.$.timelineConnectionsContainer;let c=r.connections.shift();c||(c=document.createElement("div"),c.classList.add("smart-task-connection")),c.style.width=c.style.width="","horizontal"===n?(c.style.width=Math.abs(i)+"px",c.style.height=""):(c.style.width="",c.style.height=Math.abs(i)+"px"),c.style[s.rightToLeft?"left":"right"]="",c.style[s.rightToLeft?"right":"left"]=e+"px",c.style.top=t+"px",c.setAttribute("connection-id",r.id);const d=r.start.task.label,m=0===o||3===o?"start":"end",u=r.end.task.label,h=0===o||1===o?"start":"end";if(c.setAttribute("aria-label","Connection between "+d+" ("+m+") and "+u+" ("+h+")"),a){let e=0===o||1===o?"right":"left";s.rightToLeft&&(e="left"===e?"right":"left"),c.setAttribute("arrow-direction",e)}else c.removeAttribute("arrow-direction");c.parentElement||l.appendChild(c)}_getConnectionType(e,t){if(!e||!t)return;let i,n;return"string"==typeof e?i=!e.includes("end"):e instanceof HTMLElement&&(i=!e.classList.contains("end")),"string"==typeof t?n=t.includes("end"):t instanceof HTMLElement&&(n=t.classList.contains("end")),i&&!n?0:i||n?!i&&n?2:i&&n?3:void 0:1}_setConnectionFeedback(e){const t=this,i=t._dragDetails;if(!i||!i.target||!e){const e=t._connectionFeedback;return e&&e.parentElement&&e.remove(),t.removeAttribute("connecting-task"),void delete t._connectionFeedback}if(!i.target||!i.target.includes("smart-task-connection-point"))return;const n=i.task,a=i.taskDimensions;if(!n)return;if(!t.hasAttribute("connecting-task")){if(t.$.fireEvent("connectionStart",{startIndex:t._tasks.indexOf(n)}).defaultPrevented)return void delete t._dragDetails.target;t.setAttribute("connecting-task",""),t._isMobile&&(t._scrollView.disableSwipeScroll=t._touchmoveInside=!0)}const s="milestone"===n.type,r=t.rightToLeft;let o=s?-1*a.height/2:0;t._dragDetails.target.includes("end")&&(o=s?-1*o:a.width),t._connectionFeedback||(t._connectionFeedback=document.createElement("div"),t._connectionFeedback.classList.add("smart-task-connection-feedback"));const l=t._dragDetails.coordinates.x+(r?-1:1)*o,c=t._dragDetails.coordinates.y,d=t._dragDetails.offset.x-(r?a.width:0),m=t._dragDetails.offset.y,u=e.pageX-window.pageXOffset+d,h=e.pageY-window.pageYOffset+m-a.height/2;r?(t._connectionFeedback.style.left="",t._connectionFeedback.style.right=a.right+o+"px"):(t._connectionFeedback.style.left=a.left+o+"px",t._connectionFeedback.style.right=""),t._connectionFeedback.style.top=a.top+a.height/2+"px",t._connectionFeedback.style.width=Math.sqrt(Math.pow(Math.abs(u-l),2)+Math.pow(Math.abs(h-c),2))+"px",t._connectionFeedback.style.transform=t.rightToLeft?"rotate("+180*(Math.atan2(c-h,l-u)||0)/Math.PI+"deg)":"rotate("+180*(Math.atan2(h-c,u-l)||0)/Math.PI+"deg)",t._connectionFeedback.parentElement||t.$.timelineContent.appendChild(t._connectionFeedback)}_connectTask(e){const t=this,i=t._tasks;let n,a,s,r,o,l,c,d,m;if(e.originalEvent){const r=e.originalEvent;let o=t._isMobile?document.elementFromPoint(r.pageX-window.pageXOffset,r.pageY-window.pageYOffset):r.target;if(!(t._dragDetails&&t._dragDetails.target&&o&&o.classList))return;if(t.shadowRoot&&o===t&&(o=t._isMobile?t.shadowRoot.elementFromPoint(r.pageX-window.pageXOffset,r.pageY-window.pageYOffset):r.composedPath()[0]),n=t._dragDetails.target.includes("smart-task-connection-point")?t._dragDetails.target:void 0,a=o.classList.contains("smart-task-connection-point")?o:void 0,n&&(l=t._dragDetails.task),a)s=a.closest(".smart-timeline-task");else if(t._isMobile&&o.classList.contains("smart-timeline-task-fill")&&(s=o.closest(".smart-timeline-task"),s)){const e=r.pageX-window.pageXOffset-s.getBoundingClientRect().left;a=s.querySelector(".smart-task-connection-point."+(e>=s.offsetWidth/2?"end":"start"))}if(!l||!s)return;c=s._cellObj.task;for(let e=0,t=i.length;e<t;e+=1){const t=i[e];if(t!==l)if(t!==c){if(void 0!==d&&void 0!==m)break}else m=e;else d=e}}else{if(!e||e.length<3)return;const n=t._getValidConnectionId(e[0],e[1],e[2],"_connectTask");if(void 0===n)return;[d,m]=[parseInt(n[0]),parseInt(n[1])],[l,c]=[i[d],i[m]],r=parseInt(e[2]),o=e[4]||0}if(!l||!c||l===c||l.isGroup||c.isGroup||t._isAutoScheduled(l,c)||t.hasAttribute("dragged")||t.hasAttribute("resized"))return;void 0===r&&(r=t._getConnectionType(n,a));let u=t._connections;return u||(t._connections=u=[]),t._updateConnection([d,m,r,o])?(e.originalEvent&&t._recycleConnections([{startIndex:d,endIndex:m,type:r}]),e.originalEvent&&t.$.fireEvent("itemInsert",{type:"connection",item:{source:d,target:m,type:r}}),{taskStart:l,taskEnd:c,type:r}):void 0}_recycleConnections(e){const t=this,i=t._tasks;if(e?Array.isArray(e)||(e=[e]):e=t._connections,!i||!i.length||!e)return;const n=t.$.timelineTasksContainer.children,a=t.$.timelineConnectionsContainer;let s,r=[];if(n.length){const a=n[0],o=(()=>{let e=[];for(let t=0,a=n.length;t<a;t+=1)e.push(i.indexOf(n[t]._cellObj.task));return e})(),l=a.querySelector(".smart-task-connection-point."+(t.rightToLeft?"end":"start")),c=t._baselineProportion,d=t.showBaseline?t._taskDefaultHeight/c:0;s={top:l.offsetTop,width:l.offsetWidth},s.offset=Math.abs(l.offsetLeft)-s.width;for(let n=0,a=e.length;n<a;n+=1){const a=e[n],l=a.startIndex,c=a.endIndex;if(o.indexOf(l)<0&&o.indexOf(c)<0)continue;const m=i[l],u=i[c],{vCellStart:h,vCellEnd:g}=t._getTasksVCell(m,u);if(!h||!g)continue;const f=a.type,p={start:{width:s.width,top:s.top,index:l,task:m},end:{width:s.width,top:s.top,index:c,task:u},type:f},_=t._getTaskBarDetails(h,t._getTimelineCellByDate(m.dateStart),t._getTimelineCellByDate(m.dateEnd)),T=t._getTaskBarDetails(g,t._getTimelineCellByDate(u.dateStart),t._getTimelineCellByDate(u.dateEnd));"milestone"===m.type&&(_.width=h.height-d),"milestone"===u.type&&(T.width=h.height-d),p.start.left=0===f||3===f?-1*(s.width+s.offset):_.width+s.offset,p.end.left=0===f||1===f?-1*(s.width+s.offset):T.width+s.offset,t._connectionDetails=p,_.height=T.height=h.height-d,_.type=m.type,T.type=u.type,t._setConnectionDetails(_,T),t._createTaskConnection(),r.push(t._connectionDetails.id),delete t._connectionDetails}}if(arguments.length)return;const o=Array.from(a.children);for(let e=0,t=o.length;e<t;e+=1){const t=o[e];r.indexOf(t.getAttribute("connection-id"))<0&&t.remove()}}_getTasksVCell(e,t){const i=this._timelineVCells;let n,a;for(let s=0,r=i.length;s<r;s+=1){const r=i[s];if(r.task===e&&(n=r),r.task===t&&(a=r),n&&a)break}return{vCellStart:n,vCellEnd:a}}_isAutoScheduled(e,t,i){const n=this,a=n._tasks;let s={};if(n.autoSchedule)return e instanceof HTMLElement&&(e=e._cellObj.task),t instanceof HTMLElement&&(t=t._cellObj.task),function e(t,r){const o=n._getTaskConnections().taskConnections,l=a.indexOf(t);s[l]=!0;for(let t=0;t<o.length;t++){const c=o[t],d=c.endIndex;if(d===r)return i&&n._removeConnection(l+"-"+d+"-"+c.type,!0),!0;if(!s[d]&&e(a[d],r))return!0}}(t,a.indexOf(e))}_setConnectionDetails(e,t){const i=this;if(!i._connectionDetails)return;const n=i._connectionDetails,a=n.start,s=n.end,r=n.type;if(!a||!s)return;let o,l=e.width,c=t.width,d=e.left,m=t.left,u=e.top,h=t.top,g=a.left,f=s.left;const p=a.index,_=s.index;if("milestone"===e.type&&(l=e.height,d-=l/2),"milestone"===t.type&&(c=t.height,m-=c/2),n.id=p+"-"+_+"-"+r,!n.connectionStartOffset||!n.connectionEndOffset){switch(r){case 0:g=Math.abs(g)-a.width,f=Math.abs(f)-s.width;break;case 1:g-=l,f=Math.abs(f)-s.width;break;case 2:g-=l,f-=c;break;default:g=Math.abs(g)-a.width,f-=c}n.start.offset=g+=a.width/2,n.end.offset=f+=s.width/2}if(0===r&&d>m||1===r&&d+l+g>m-f&&h>u||2===r&&m+c>d+l||3===r&&(d-g<m+c+f&&h>u||d-g>m+c+f&&u>h)){o=!0;let i=e;e=t,t=i,i=g,g=f,f=i,i=l,l=c,c=i,i=d,d=m,m=i,i=u,u=h,h=i}let T=d,k=m;!o&&1===r||o&&3===r?T+=l:!o&&3===r||o&&1===r?k+=c:2===r&&(T+=l,k+=c);let b=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+p+"-"+_+'-"]');0===b.length&&(b=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+_+"-"+p+'"]')),n.connections=[].slice.call(b),n.start.x=T,n.start.y=u+a.top,n.end.x=k,n.end.y=h+s.top,n.type=r,n.inverted=o}_createTaskConnection(){const e=this,t=e._connectionDetails;if(!t)return;const i=2*e._taskConnectionWidth,n=t.start.x,a=t.start.y,s=t.start.offset,r=t.start.top,o=t.end.x,l=t.end.y,c=t.end.offset,d=t.type,m=t.inverted,u=!m&&3===d||m&&1===d,h=!m&&1===d||m&&3===d;let g,f,p,_=n,T=o;u?(_=n-c,T=o+c):h&&(_=n+s,T=o-c);const k=_<=T&&u,b=_>=T&&h,y=2===d||h;!function c(u){g!==o&&(u?"horizontal"===u?(p=g-o+(k?-1:1)*s,g=_>T?g-Math.abs(p):g,e._createConnectingElement(g,f,(_===T?0:Math.abs(p))+(y?i:0),"horizontal"),g=_<T?g-p:g,c("vertical")):(p=Math.abs(f-l),f+=a<l?0:-1*p,g-=m&&1===d||!m&&3===d&&a>l?i:0,e._createConnectingElement(g,f,p,"vertical"),c()):(g?(p=Math.abs(g-o),g>=o&&(g+=-1*p,p+=i),e._createConnectingElement(g,f+(a<l?Math.abs(f-l):0),p,"horizontal",!t.inverted),g=o):(g=n,f=a,(0===d||!m&&3===d||m&&1===d)&&(g-=s),e._createConnectingElement(g,f,s,"horizontal",t.inverted),y&&(g+=s-i),k||b?(e._createConnectingElement(g,f-=a>l?r:0,r,"vertical"),f+=a<l?r:0):c("vertical")),c("horizontal")))}(),t.connections.map((e=>e.parentElement.removeChild(e)))}_getTaskIndexById(e,t){const i=this;if(t||(t=i._tasks),"number"==typeof e)return isNaN(parseInt(e))?-1:parseInt(e);if("object"==typeof e)return i._getItemIndex(e,"task");for(let i=0,n=t.length;i<n;i+=1)if(t[i].id===e)return i;return-1}_refreshTaskConnections(e){const t=this,i=e instanceof HTMLElement?e._cellObj.task:e,n=t._tasks.indexOf(i);if(void 0===n||e.classList&&e.classList.contains("smart-visibility-hidden"))return;let a;if(t._dragDetails&&(a=t._dragDetails.relatedConnections[n]),!a){a=[];const e=t._connections;if(!e||!e.length)return;for(let t=0,i=e.length;t<i;t+=1){const i=e[t];i.startIndex!==n&&i.endIndex!==n||a.push(i)}t._dragDetails&&(t._dragDetails.relatedConnections[n]=a)}t._recycleConnections(a)}_dragStartHandler(e){const t=this,i=e.target.closest;(t._dragDetails||i&&i.call(t,"smart-gantt-chart")===t)&&e.preventDefault()}_getFirstCellObjInView(e){const t=this;if(e||(e=t._timelineCells),!e)return;const i=Math.abs(t.scrollLeft);let n,a;for(let t=0;t<e.length;t++){const s=e[t];if(s.left+s.width>i){n=s;break}a=s}return!n&&a&&(n=i>a.left?a:e[0]),n}_getFirstContentCellInView(e="task"){const t=this;let i,n,a,s;if("task"===e?(i=t._timelineVCells,n=t.scrollTop):(i=t._timelineResourceVCells,n=t.$.resourceVerticalScrollBar.value),!i)return 0;for(let e=0;e<i.length;e++){const t=i[e];if(t.top+t.height>n){a=t;break}s=t}return!a&&s&&(a=n>s.left?s:i[0]),a}_getProjectTasks(e,t){const i=this,n=i.groupByResources&&e.isGroup?"group":"project",a=i._tasks;if(!e||"project"!==e.type)return[];let s=[];for(let r=0,o=a.length;r<o;r+=1){const o=a[r];o.$[n]===e&&(s.push(o),"project"!==o.type||t||(s=s.concat(i._getProjectTasks(o,t))))}return s}_getSubTaskLimits(e){const t=this;if(!e)return;const i=e._cellObj.task,n=t._getProjectTasks(i);let a,s;if(!n.length)return;let r=n[0],o=n[0];for(let e=0;e<n.length;e++){const t=n[e];n[e].dateEnd&&n[e].dateStart&&(r.dateStart||(r=t[e]),o.dateEnd||(o=t[e]),n[e].dateEnd.getTime()>o.dateEnd.getTime()&&(o=n[e]),n[e].dateStart.getTime()<r.dateStart.getTime()&&(r=n[e]))}const l=t.$.timelineContent.offsetWidth;let c,d,m;if(r&&(c=t._getTimelineSubTaskOffset(r),c&&(d=c.left,m=c.width,a=Math.max(0,t.rightToLeft?l-e.offsetLeft-e.offsetWidth-(l-d-m):e.offsetLeft-d))),o&&(c=t._getTimelineSubTaskOffset(o),c))if(d=c.left,m=c.width,t.rightToLeft){const t=l-e.offsetLeft-e.offsetWidth;s=Math.max(t,t+l-(l-d))}else s=Math.max(e.offsetLeft,e.offsetLeft+l-(d+m));return{min:a,max:s}}_getTimelineSubTaskOffset(e){const t=this,i=t.$.timelineTasksContainer.children[t._tasks.filter((e=>!e.hidden)).indexOf(e)];let n,a,s;if(i)n=i.offsetLeft,s=i.offsetWidth;else{const i=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);i&&(n=i.left+t._getTimelineTaskOffset(i,e.dateStart)||0),r&&(a=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0),s=a-n}return{left:n,width:s}}_getTaskDragLimits(e){const t=this,i=t._dragDetails,n=i.segment?i.segment.element:void 0,a=n&&n.previousElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateStart"),s=n&&n.nextElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateEnd"),r=t._dragDetails.taskDimensions;let o={};return(a.min||s.min)&&(o.min=Math.max(a.min||0,Math.max(0,(s.min||0)-r.width))),s.max&&(o.max=Math.max(0,s.max-r.width)),a.max&&(o.max=o.max?Math.min(a.max,o.max):a.max),o}_getTaskBarDateRange(e){if(!e)return;const t=this,i=e.classList.contains("milestone"),n=parseFloat(e.style.width)||e.offsetWidth,a=i?n/2:n,s=t.rightToLeft?parseFloat(e.style.right)||t.$.timelineContent.offsetWidth-e.offsetLeft-a:parseFloat(e.style.left)||e.offsetLeft,r=e._cellStart,o=e._cellEnd,l=e._cellObj.task,c=l.minDateStart,d=l.maxDateEnd;let m,u;return m=t._getDateFromCell(s,r),!c||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(m=new Date(Math.max(c.getTime(),m.getTime()))),u=i?new Date(m):t._getDateFromCell(s+a,o),!d||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(u=new Date(Math.min(d.getTime(),u.getTime()))),{dateStart:m,dateEnd:u}}_getTaskBarDetails(e,t,i){const n=this,a=e.task;if(!e)return;let s=new Date(a.dateStart);const r=new Date(a.dateEnd);if(!n._dragDetails&&n.snapToNearest){let s,r,o=a.dateStart,l=a.dateEnd;const c=new Date(t.date),d=n._getDateFromCell(t.left+t.width,t),m=new Date(i.date),u=n._getDateFromCell(i.left+i.width,i);return s=d.getTime()-o.getTime()>=d.getTime()-c.getTime()?t.left:t.left+t.width,"milestone"!==a.type&&(r=u.getTime()-l.getTime()>=l.getTime()-m.getTime()?i.left-s:i.left-s+i.width),{left:s,width:r,top:e.top}}let o,l,c,d,m,u;switch(n.view){case"year":{c=new Date(s.getFullYear(),s.getMonth()+1,0).getDate(),d=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();const e=s.getHours()/24+s.getMinutes()/1440+s.getSeconds()/86400,n=r.getHours()/24+r.getMinutes()/1440+r.getSeconds()/86400;o=t.left+(s.getDate()-1+e)/c*t.width,l=i.left+(r.getDate()-1+n)/d*i.width-o;break}case"month":m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*(t.width/7),u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*(t.width/7),o=t.left+s.getDay()/7*t.width+m,l=i.left+r.getDay()/7*i.width-o+u;break;case"week":m=parseFloat(s.getHours()+"."+s.getMinutes()+s.getSeconds())/24*t.width,u=parseFloat(r.getHours()+"."+r.getMinutes()+r.getSeconds())/24*t.width,o=t.left+m,l=i.left+(u-m)-t.left;break;case"day":m=parseFloat(s.getMinutes()+s.getSeconds()/60)/60*t.width,u=parseFloat(r.getMinutes()+r.getSeconds()/60)/60*t.width,o=t.left+m,l=i.left+(u-m)-t.left}return{width:"milestone"===a.type?"":l,left:o,top:e.top}}_snapToNearestDates(e,t){const i=this;if(!i.snapToNearest)return;if(e.classList&&e._cellObj&&(e=e._cellObj.task),!e)return;let n=e.dateStart,a=e.dateEnd;const{cellStart:s,cellEnd:r}={cellStart:i._getTimelineCellByDate(n),cellEnd:i._getTimelineCellByDate(a)},o=new Date(s.date),l=i._getDateFromCell(s.left+s.width,s),c=new Date(r.date),d=i._getDateFromCell(r.left+r.width,r);if(n=l.getTime()-n.getTime()>=l.getTime()-o.getTime()?o:l,"milestone"!==e.type&&(a=d.getTime()-a.getTime()>=d.getTime()-c.getTime()?c:d),e.dateEnd=a,a.getTime()<n.getTime()&&(n=new Date(a)),e.dateStart=n,e.duration=e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0),!t&&e.segments&&e.segments.length>1){const t=e.segments;for(let e=0,n=t.length;e<n;e+=1)i._snapToNearestDates(t[e],!0);i._validateTaskSegments(e)}}_getTimelineTaskCellByDate(e){if(!e)return;const t=this,i=t.view,n=t._timelineCells;for(let a=0;a<n.length;a++){const s=n[a];if(t._isDateInCell(s.date,e,i))return s}}_isDateInCell(e,t,i){switch(i){case"year":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth())return!0;break;case"month":{let i=new Date(e);if(i.setDate(i.getDate()+(6-i.getDay())+1),i.setMilliseconds(i.getMilliseconds()-1),t.getTime()>=e.getTime()&&t.getTime()<=i.getTime())return!0;break}case"week":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())return!0;break;case"day":if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()&&e.getHours()===t.getHours())return!0}}_handleInverted(e){const t=this;function i(e){e||(e="task");const i=t.$[`${e}Splitter`];if(!t.$.mainSplitter.contains(i))return;const[n,a,s,r,o]="task"===e?[t.$.tableSplitterItem,t.$.timelineSplitterItem,t,t.$.taskTimelineContainer,"scrollTop"]:[t.$.resourceTableItem,t.$.resourceTimelineSplitterItem,t.$.resourceVerticalScrollBar,t.$.resourceTimelineContent,"value"],l=t.treeSize!==n.size?n.style[i._measurements.dimension]:t.treeSize;n.size="",i.removeChild(a),t.inverted&&!t.rightToLeft||!t.inverted&&t.rightToLeft?i.insertBefore(a,n):i.appendChild(a),n.size=l,r.scrollTop=s[o]}(!e||t.inverted||t.rightToLeft)&&(i("task"),i("resource"))}_createResourceTimeline(){const e=this;if(e._handleResourcePanelVisibility(),e.$.taskSplitterItem._setSize("size",e.taskPanelSize),!e._resources||!e.$.mainSplitter.contains(e.$.resourceTable))return;const t=e.$.resourceSplitterItemHeader.innerHTML;(e.resourcePanelHeaderTemplate&&!t||!e.resourcePanelHeaderTemplate&&t)&&e._handleHeaderTemplate("resource"),e._setTable(e.$.resourceTable),e._recycleResourceHeaderCells(),e._createResourceTimelineContent(),e._synchronizeSplitters(e.$.taskSplitter,e.$.resourceSplitter),e.$.resourceTimelineContent.scrollLeft=e.$.resourceTimelineHeader.scrollLeft=e.$.timelineHeader.scrollLeft,e.$.resourceSplitter.refresh(),e._refresh(),e._highlightAssignedItem("task",e._getSelection("task",e.selectedTaskIds))}_createResourceTimelineContent(){const e=this,t=e._timelineVCells,i=t.length?t[0].height:e._taskDefaultHeight;e._createResourceTimelineVCells(i);const n=e._timelineResourceVCells.length*i;e.$.resourceTimelineCellsContainer.style.height=n+"px",e.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",n+"px"),e._recycleResourceContent()}_recycleResourceContent(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e._timelineResourceVCells,i=e.$.resourceTimelineCellsContainer,n=e._getFirstContentCellInView("resource"),a=e.$.tooltip;if(a&&i.contains(a.selector)&&e._closeTooltip(),!n)return void(i.innerHTML="");const s=t.indexOf(n),r=n.height,o=1-(n.top+r-Math.abs(e.$.resourceVerticalScrollBar.value))/r,l=t?t.length:0,c=!e.$.resourceSplitter.offsetHeight,d=e.$.resourceTimelineContent.offsetHeight,m=!c&&d?Math.min(l,Math.ceil((parseFloat((d/r).toFixed(2))+o).toFixed(2))):l,u=i.children,h=e.$.timelineViewCells.children,g=document.createDocumentFragment();for(;i.childElementCount>m;)i.lastElementChild.remove();for(let t=0;t<m;t+=1){let i=u[t];i||(i=document.createElement("div"),i.classList.add("smart-timeline-row"),g.appendChild(i)),e._createTimelineRowCells(i,h)}g.childElementCount&&i.appendChild(g);const f=i.children,p=e._getSelection("resource",e.selectedResourceIds);for(let i=0;i<m;i+=1){const n=t[s+i],a=f[i];if(!n){a&&a.remove();continue}const r=n.resource,o=r.$.id;p.indexOf(o)>-1?a.setAttribute("selected",""):a.removeAttribute("selected"),a._cellObj=n,a.setAttribute("row-id",o),a.style.top=n.top+"px",e._refreshResourceTimelineContent(r,a)}}_createResourceTimelineVCells(e){const t=this,i=t._resources,n=t.$.resourceTable.rows,a=t._timelineResourceVCells=[];let s=0;if(void 0===e){const i=t._timelineVCells;e=i.length?i[0].height:t._taskDefaultHeight}for(let t=0,r=n.length;t<r;t+=1){const r=i[n[t].data.itemIndex];r.hidden||(a.push({top:s,height:e,resource:r}),s=parseFloat((s+e).toFixed(2)))}}_handleResourcePanelVisibility(){const e=this,t=e.$.container,i=e._resources.filter((e=>!e.hidden)),n=e.$.mainSplitter,a=e.$.resourceSplitterItem,s=e.$.taskSplitterItem;if(!i||!i.length||e.hideResourcePanel)return a&&!a.size&&(a._size=a.style[n._measurements.dimension]),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView),s.size="",s.min="",e.$.resourceTable&&e.$.resourceTable.clearSelection(),n.contains(a)&&(n.removeChild(a),e._refresh()),e._highlightAssignedItem("resource"),void t.removeAttribute("show-resource-panel");n.contains(a)||(s.min=e.taskPanelMin,e._createResourcePanel(),e._setupResourcePanel(),e._resourceScrollView=new Smart.Utilities.Scroll(e.$.resourceSplitterItem,e.$.horizontalScrollBar,e.$.resourceVerticalScrollBar)),t.setAttribute("show-resource-panel",""),e._synchronizeSplitters(e.$.taskSplitter,e.$.resourceSplitter)}_createResourcePanel(){const e=this,t=e.$.mainSplitter;let i=e.$.resourceSplitterItem;if(!i){i=document.createElement("smart-splitter-item"),i.classList.add("smart-resource-splitter-item"),i.innerHTML=`<div smart-id="resourceSplitterItemHeader" class="smart-resource-panel-header"></div>\n <smart-splitter smart-id="resourceSplitter" wait class="smart-resource-splitter" auto-fit-mode="end">\n <smart-splitter-item smart-id="resourceTableItem" class="smart-resource-table-item">\n <smart-table wait smart-id="resourceTable" class="smart-resource-table" virtualization deferred-scroll-delay="0"></smart-table>\n </smart-splitter-item>\n <smart-splitter-item smart-id="resourceTimelineSplitterItem" class="smart-timeline-splitter-item">\n <div class="smart-timeline" smart-id="resourceTimeline">\n <div class="smart-timeline-container" role="presentation">\n <div class="smart-timeline-header" smart-id="resourceTimelineHeader" role="rowgroup">\n <div class="smart-timeline-view-cells" smart-id="resourceTimelineViewCells" role="row"></div>\n </div>\n <div smart-id="resourceTimelineContent" class="smart-timeline-content" role="rowgroup">\n <div smart-id="resourceTimelineCellsContainer" class="smart-timeline-cells-container" aria-hidden="true"></div>\n </div>\n </div>\n </div>\n <smart-scroll-bar wait smart-id="resourceVerticalScrollBar" class="smart-timeline-scroll-bar smart-resource-scroll-bar" \n orientation="vertical" aria-controls="[[${e.id||""}]]">\n </smart-scroll-bar>\n </smart-splitter-item>\n </smart-splitter>`,t.contains(i)||t.appendChild(i);const n=Smart.Utilities,a=i.querySelectorAll(".smart-resource-panel-header, .smart-resource-splitter, .smart-resource-table-item, \n .smart-resource-table, .smart-timeline-splitter-item, .smart-timeline, .smart-timeline-header, .smart-timeline-view-cells, .smart-timeline-content,\n .smart-timeline-cells-container, .smart-timeline-scroll-bar"),[s,r,o,l,c,d,m,u,h,g,f]=a;e.$.resourceSplitterItem=i,e.$resourceSplitterItem=n.Extend(i),e.$.resourceSplitterItemHeader=s,e.$resourceSplitterItemHeader=n.Extend(s),e.$.resourceSplitter=r,r.hasResizeObserver=!1,r.wait=!1,e.$resourceSplitter=n.Extend(r),e.$.resourceTableItem=o,e.$resourceTableItem=n.Extend(o),e.$.resourceTable=l,l.hasResizeObserver=!1,e.$resourceTable=n.Extend(l),e.$.resourceTimelineSplitterItem=c,e.$resourceTimelineSplitterItem=n.Extend(c),e.$.resourceTimelineViewCells=u,e.$resourceTimelineViewCells=n.Extend(u),e.$.resourceTimeline=d,e.$resourceTimeline=n.Extend(d),e.$.resourceTimelineContent=h,e.$resourceTimelineContent=n.Extend(h),e.$.resourceTimelineHeader=m,e.$resourceTimelineHeader=n.Extend(m),e.$.resourceTimelineCellsContainer=g,e.$resourceTimelineCellsContainer=n.Extend(g),e.$.resourceVerticalScrollBar=f,e.$resourceVerticalScrollBar=n.Extend(f)}}_setupResourcePanel(){const e=this,t=e.rightToLeft,i=e.$.resourceSplitterItem,n=e.$.resourceTableItem,a=e.$.resourceTable,s=e.$.resourceTimelineSplitterItem,r=e.$.resourceVerticalScrollBar;e.$.mainSplitter.contains(i)?([e.$.resourceSplitter,a,e.$.resourceVerticalScrollBar].forEach((e=>e.rightToLeft=t)),a.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,a.$.virtualizationContainer.verticalScrollBarVisibility="hidden",a.$.virtualizationContainer.disabled=!0,n.size=e.treeSize,n.min=e.treeMin,s.min=e.timelineMin,i.min=e.resourcePanelMin,i.size=i._size||e.resourcePanelSize,r.hasStyleObserver=!1,r.hasResizeObserver=!1,r.wait=!1):e.$.mainSplitter.appendChild(i)}_refreshResourceTimeline(){const e=this;e._resources&&e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._recycleResourceHeaderCells(),e._recycleResourceContent())}_getResourceCellWorkTime(e,t){const i=e.dateStart,n=e.dateEnd,a=t.dateStart,s=t.dateEnd,r=e.dateStart.getTime()<a.getTime()?a:i,o=n.getTime()>s.getTime()?s:n,l=Math.round(this._getWorkingTime(r,o)/36e5);return{value:Math.max(0,l),max:r.getTime()===a.getTime()&&o.getTime()===s.getTime()?l:Math.round(this._getWorkingTime(a,s)/36e5)}}_refreshResourceTimelineContent(e,t){const i=this,n=i._resources.indexOf(e),a=i._getResourceTasks(e);if(t||(t=(()=>{const t=i.$.resourceTimelineCellsContainer.children;for(let i=0,n=t.length;i<n;i+=1){const n=t[i];if(n._cellObj&&n._cellObj.resource===e)return n}})()),n<0||!t||!t.childElementCount)return;let s=t.children;const r=i.$.resourceTimelineViewCells.children,o=i._tasks.filter((e=>!e.hidden));for(let t=0,l=s.length;t<l;t+=1){const l=s[t];let c,d=l.firstElementChild;a.length&&!e.hidden?(d?(d.classList.remove("hide-left-border","hide-right-border"),d.removeAttribute("load"),d.innerHTML=d.style.height=""):(d=document.createElement("div"),d.classList.add("smart-resource-timeline-view-cell"),c=!0),e.class&&d.classList.add(e.class),i._setResourceCellLoad({cell:d,cellIndex:t,resource:e,resourceCell:l,resourceIndex:n,resourceTasks:a,tasks:o,viewCells:r}),d.hasAttribute("load")?c&&l.appendChild(d):d.remove()):d&&d.remove()}}_setResourceCellLoad(e){const t=this,i=t.resourceTimelineFormatFunction,{cell:n,cellIndex:a,resource:s,resourceCell:r,resourceIndex:o,resourceTasks:l,tasks:c,viewCells:d}=e;let m={};for(let e=0,u=l.length;e<u;e+=1){const u=l[e];if(u.hidden)continue;const h=c.indexOf(u),g=t._getCellDateRange(d[a]),{dateStart:f,dateEnd:p}=g;if(!f||f.getTime()>=u.dateEnd.getTime()||p.getTime()<=u.dateStart.getTime())continue;if(m[a]&&m[a].indexOf(h)<0?m[a].push(h):m[n]||(m[a]=[h]),"custom"===t.resourceTimelineMode){i&&(n.innerHTML=i.call(t,m[a]||[],o,new Date(f))||"");continue}const _=t._getResourceCellCapacity({cell:n,cellDateRange:g,cellTaskIndexAssigned:m,index:o,resource:s,task:u,cellIndex:a});if(!_)continue;const{capacity:T,maxCapacity:k}=_,b=parseFloat(((parseFloat(n.getAttribute("load"))||0)+(T||0)).toFixed(1));b>k?n.classList.add("warning"):n.classList.remove("warning"),"histogram"!==t.resourceTimelineMode?b&&n.setAttribute("load",b):t._setCellHistogram({cell:n,load:b,maxCapacity:k,previousViewCell:r.previousElementSibling})}}_getResourceCellCapacity(e){const t=this,i=t.resourceTimelineView,{cell:n,cellDateRange:a,cellTaskIndexAssigned:s,index:r,resource:o,task:l,cellIndex:c}=e;let d,m;if("tasks"===i)d=1,m=o.maxCapacity;else if("hours"===i){const e=t._getResourceCellWorkTime(l,a),i=e.max/24;d=parseFloat((e.value/e.max*o.capacity*i).toFixed(1)),m=Math.min(e.max,parseFloat((o.maxCapacity*i).toFixed(1)))}else{const e=t.resourceTimelineFormatFunction;if(!e)return;let i=e.call(t,s[c]||[],r,new Date(a.dateStart));if(null!=i)if(i="object"!=typeof i?[i]:Object.values(i),2===i.length)d=parseFloat(i[0])||0,m=parseFloat(i[1])||0;else if(1===i.length)return void(n&&n.setAttribute("load",i[0]))}return{capacity:d,maxCapacity:m}}_setCellHistogram(e){const{load:t,cell:i,maxCapacity:n,previousViewCell:a}=e,s=Math.min(100,100*parseFloat((t/n).toFixed(2))),r=a?a.firstElementChild:void 0;if(r){const e=parseFloat(r.style.height)||0;s?e===s?(i.classList.add("hide-left-border"),r.classList.add("hide-right-border")):e>s?(i.classList.add("hide-left-border"),r.classList.remove("hide-right-border")):e<s&&(i.classList.remove("hide-left-border"),r.classList.add("hide-right-border")):(i.classList.remove("hide-left-border"),r.classList.remove("hide-right-border"))}i.style.height=s+"%",t&&i.setAttribute("load",t+"/"+n)}_recycleResourceHeaderCells(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e.$.resourceTimelineViewCells,i=t.children,n=e.$.timelineViewCells.children;let a=document.createDocumentFragment();for(;i.length>n.length;)i[0].remove();for(let e=0;e<n.length;e++){const t=n[e];let s=i[e];s||(s=t.cloneNode(!0),a.appendChild(s)),s.style.left=t.style.left,s.style.right=t.style.right,s.style.width=t.style.width,s.innerHTML=t.innerHTML,s._date=t._date,t.hasAttribute("weekend")?s.setAttribute("weekend",""):s.removeAttribute("weekend"),t.hasAttribute("nonworking")?s.setAttribute("nonworking",""):s.removeAttribute("nonworking")}a.childElementCount&&t.appendChild(a),e.$.resourceTimelineCellsContainer.style.width=e.$.resourceTimelineViewCells.style.width=e.$.timelineContent.style.width}_refreshResourceScrollBar(){const e=this,t=e.$.resourceVerticalScrollBar;if(!e.$.mainSplitter.contains(e.$.resourceSplitter))return;const i=Math.max(0,e.$.resourceTimelineCellsContainer.offsetHeight-e.$.resourceTimelineContent.offsetHeight);0===i&&"visible"===e.verticalScrollBarVisibility?(t.max=1,e.scrollHeight||e.$container.removeClass("vscroll")):i&&e.$container.addClass("vscroll"),t.max=i,t.disabled="disabled"===e.verticalScrollBarVisibility||e.disabled||i<=0,!e.$.container.classList.contains("vscroll")&&t.disabled?t.classList.add("smart-hidden"):(t.classList.remove("smart-hidden"),t.refresh(),e.$.container.classList.contains("hscroll")?e.$.horizontalScrollBar.classList.add("bottom-corner"):e.$.container.classList.contains("vscroll")||e.$.horizontalScrollBar.classList.remove("bottom-corner"))}_handleResources(e){const t=this,i=e?[e]:t._tasks;t._resources||(t._resources=[]);for(let e=0;e<i.length;e++){let n=i[e].resources;Array.isArray(n)||(n=[n].reduce(((e,t)=>e.concat(t)),[]));for(let a=0;a<n.length;a++){let s=n[a];if("object"!=typeof s||!s||void 0===s.id||null===s.id){"number"==typeof s&&(n[a]=s+"");continue}let r=t._resources.find((e=>e.id&&e.id.toString()===s.id.toString()))||{};t._setResource(r,s,i[e]),n[a]=r.id,Object.values(r).length&&!t._resources.includes(r)&&t._resources.push(r)}}t._refreshItemIds("resource");const n=t._resources;for(let e=0,i=n.length;e<i;e+=1)t._refreshResource(n[e])}_refreshAssignedResources(e,t=[]){const i=this;if(!e.$.id||i._tasks.indexOf(e)<0)return;const n=i._getTaskResources(e);for(let e=0;e<n.length;e++){const a=n[e];let s=[];i.resourceColumns.forEach((e=>{void 0!==e.formatFunction&&s.push(e.value)})),s.concat(t),i.$.mainSplitter.contains(i.$.resourceSplitter)&&i._refreshResourceTimelineContent(a),t.includes("workload")?i._refreshResource(a,"workload"):t.includes("progress")&&i._refreshResource(a,"progress"),s.length&&i._refreshTableColumnsData(a,s,"resource")}}_refreshResource(e,t){const i=this;if(!i._resources.length)return;const n=i._getResourceTasks(e),a=864e5;switch(t){case"progress":e.progress=parseFloat((n.reduce(((e,t)=>e+t.progress),0)/n.length).toFixed(2));break;case"workload":e.workload=parseFloat((i._convertDuration(n.reduce(((e,t)=>e+t.duration),0))/a*e.maxCapacity).toFixed(2));break;default:e.progress=parseFloat((n.reduce(((e,t)=>e+t.progress),0)/n.length).toFixed(2)),e.workload=parseFloat((i._convertDuration(n.reduce(((e,t)=>e+t.duration),0))/a*e.maxCapacity).toFixed(2))}i.$.mainSplitter.contains(i.$.resourceSplitter)&&i._refreshResourceTimelineContent(e)}_setResource(e,t){if(t&&"object"==typeof t)return e.id?e.id=e.id.trim():e.id=(t.id+"").trim(),e.$||(e.$={}),e.class=t.class||e.class,e.minCapacity=t.minCapacity||e.minCapacity||0,e.maxCapacity=t.maxCapacity||e.maxCapacity||24,e.progress=t.progress||e.progress||0,e.capacity=t.capacity||e.capacity||8,e.type=t.type||e.type,e.hidden=!!("boolean"==typeof t.hidden?t.hidden:e.hidden),e.workload=e.workload||0,t.label?e.label=t.label:void 0===e.label&&(e.label=""),t.value&&(e.value=t.value),e}insertResource(e,t){const i=this,n=Array.from(arguments).filter((e=>void 0!==e));let a,s=i._resources;if(1===n.length&&(t=n[0]),"object"!=typeof t)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"insertResources",argumentName:"resource"}));if(t.id&&s.find((e=>e.id&&e.id.toString()===t.id.toString())))return void i.updateResource(t.id,t);if(t.assignedTo&&(a=[t.assignedTo].reduce(((e,t)=>e.concat(t,[])))),!(t=i._setResource({},t)))return;i._refreshItemIds("resource"),s=i._resources;const r=i._getValidItemAndIndex(e,"resource").index;if(r<0?s.push(t):s.splice(r,0,t),i._tasks.length){if(void 0!==a){Array.isArray(a)||(a=[a]);for(let e=0,n=a.length;e<n;e+=1){const n=i._getValidItemAndIndex(a[e],"task");if(n){const e=n.item;!e||e.disableResources||e.resources.includes(t.id.toString())||e.resources.push(t.id)}}if(i._isUpdating)return void(i._isUpdating.type.resource=!0);i._highlightAssignedItem("task",i._getSelection("task",i.selectedTaskIds)),i._refreshResource(t)}if(i._isUpdating)return i._isUpdating.type.resource=!0,void(i._isUpdating.type.task=!0);if(i.groupByResources)i._refreshTableDataSource(),i._refreshTimeline();else if(i.taskColumns.find((e=>"resources"===e.value))){const e=i._tasks.filter((e=>e.resources.includes(t.id)));for(let t=0;t<e.length;t++)i._refreshTableColumnsData(e[t],["resources"])}}i._isUpdating?i._isUpdating.type.resource=!0:(i._createResourceTimeline(),i.$.fireEvent("itemInsert",{type:"resource",item:i._cloneObject(t)}))}_insertTimelineResource(e,t,i){const n=this,a=n.$.resourceTimelineCellsContainer,s=document.createElement("div");s.classList.add("smart-timeline-row"),s._resource=t,n._refreshResourceTimelineContent(t,s),n.$.resourceTimelineCellsContainer.insertBefore(s,e>-1?a.children[e]:void 0),n.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",a.offsetHeight+"px"),n._refreshResourceScrollBar(),n._insertNewTreeItem(e,t,i,"resource"),n.$.resourceTree.refresh(),n._highlightAssignedItem("task",n._getSelection("task",n.selectedTaskIds))}updateResource(e,t){if(void 0===e)return;const i=this._getValidItemAndIndex(e,"resource");i&&i.item&&this._updateResource(i.item,t)}removeResource(e){if(void 0===e)return;const t=this._getValidItemAndIndex(e,"resource");t&&t.item&&this._removeResource(t.item)}_getResourceTasks(e){const t=this._resources,i=this._tasks;if(!e||!t.length||!i.length)return;let n=[];for(let t=0;t<i.length;t++)i[t].resources.includes(e.id)&&n.push(i[t]);return n}_getTaskResources(e){const t=this;if(!e)return[];const i=[e.resources].reduce(((e,t)=>e.concat(t)),[]);let n=[];for(let e=0;e<i.length;e++){const a=t._resources.find((t=>t.id&&t.id.toString()===i[e].toString()));a&&n.push(a)}return n}_resourceValidator(e,t){const i=this;return Array.isArray(t)||t instanceof Smart.ObservableArray||"number"==typeof t||"string"==typeof t||null==t?t:(i.error(i.localize("invalidValue",{elementType:i.nodeName.toLowerCase(),property:"resources",typeOne:"array",typeTwo:"number"})),null)}_handleTaskProgressChange(e){const t=this,i=t._dragDetails.task,n=t._dragDetails.timelineTask;if(t.disableTaskProgressChange)return;if(!t.hasAttribute("progress-change")){if(t.$.fireEvent("progressChangeStart",{id:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,item:t._cloneObject(i),progress:i.progress||0}).defaultPrevented)return void delete t._dragDetails.target;t._closeTooltip(),t.setAttribute("progress-change",""),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}const{left:a,width:s}=n.getBoundingClientRect(),r=e.pageX-window.pageXOffset;t._dragDetails.progress||(t._dragDetails.progress=i.progress/100*s),t._dragDetails.progress=Math.max(0,Math.min(s,t._dragDetails.progress+(t.rightToLeft?-1:1)*(r-t._dragDetails.coordinates.x))),t._dragDetails.coordinates.x=Math.max(a+t._dragDetails.offset.x,Math.min(a+s+t._dragDetails.offset.x,r));const o=t._dragDetails.task.progress=t._dragDetails.progress/s*100;i.progress=parseFloat(o.toFixed(2)),t._setTaskBarProgress(i,n),t._refreshTableColumnsData(i,["progress"]),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(i,["progress"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleTaskSegmentDrag(e){const t=this,i=t._dragDetails,n=i.segment,a=n.element,s=a._segmentObj;if(!s||s.disableDrag)return;const r=i.task,o=t._dragDetails.timelineTask,l=n.isFirstSegment,c=n.isLastSegment,d=t.rightToLeft,m=d?"right":"left";i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===r)));const u=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{id:"string"==typeof r.id||"number"==typeof r.id?r.id:r.$.id,item:t._cloneObject(r),dateStart:r.dateStart,dateEnd:r.dateEnd,segment:t._cloneObject(s)}).defaultPrevented)return void delete i.timelineTask;if(t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0,l||c){const e=t._createDelimiter("min-date"),i=t._createDelimiter("max-date");e&&u.appendChild(e),i&&u.appendChild(i)}}if(l){const n=i.size?i.size.width:i.originalSize.width;t._handleTaskResize(e,d?"right":"left"),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const a=i.size.width-n,s=i.segments;for(let e=0,t=s.length;e<t;e+=1){const t=s[e];0!==e&&(t.style[m]=(parseFloat(t.style[m])||t.offsetLeft)+a+"px")}}else{if(!c)return void t._handleSegmentDrag(e);{const s=n.dimensions;t._handleTaskResize(e,d?"left":"right"),a.style[m]=i.size.width-s.width+"px"}}t._refreshTask(o,[a]),t._refreshProject(r.$.project),t.groupByResources&&t._refreshProject(r.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(o._cellObj.task),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleSegmentDrag(e){const t=this,i=t._dragDetails,n=i.segment,a=n.element,s=i.task,r=t._dragDetails.timelineTask,o=t.rightToLeft,l=o?"right":"left";i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===s)));const c=i.timelineRow,{left:d}=c.getBoundingClientRect(),m=i.taskDimensions.left;n.position||(n.position={x:n.originalPosition.x});const u=r.offsetWidth,h=e.pageX-window.pageXOffset;let g=0,f=n.min.left||0,p=n.max.left;o&&(f=u-(f+n.dimensions.width),p=u-p),n.position.x=Math.max(f,Math.min(p,n.position.x+(o?-1:1)*(h-i.coordinates.x))),void 0!==p&&(g=o?m+n.min.left:m+n.max.left,n.position.x=Math.min(p,n.position.x)),f=m+(o?n.max.left-n.dimensions.width:f),i.coordinates.x=Math.max(d+n.offset.x+f,Math.min(d+n.offset.x+g,h)),a.style[l]=n.position.x+"px",t._refreshTaskSegments(r,[a])}_handleTaskBarDrag(e){const t=this;if(t.disableTaskDrag)return;const i=t._dragDetails;if(Math.abs(e.pageX-i.coordinates.x)<=5)return void(t._scrollView.disableSwipeScroll=!0);if(i.segment)return void t._handleTaskSegmentDrag(e);const n=i.task,a=i.timelineTask;i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const s=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:n.dateStart,dateEnd:n.dateEnd}).defaultPrevented)return void delete i.timelineTask;t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0;const e=t._createDelimiter("min-date"),a=t._createDelimiter("max-date");e&&s.appendChild(e),a&&s.appendChild(a)}i.position||(i.position={x:i.originalPosition.x,y:i.originalPosition.y});const r=s.getBoundingClientRect().left,o=s.offsetWidth,l=a.offsetWidth,c=i.min.left||0,d=i.max.left,m=e.pageX-window.pageXOffset,u=t.rightToLeft;let h=0;i.position.x=Math.max(c,Math.min(o-l,i.position.x+(u?-1:1)*(m-i.coordinates.x))),void 0!==d&&(i.position.x=Math.min(d,i.position.x),h=o-l-d),i.coordinates.x=u?Math.max(r+i.offset.x+h,Math.min(r+o-(l-i.offset.x+c),m)):Math.max(r+i.offset.x+c,Math.min(r+o-(l-i.offset.x+h),m));const g=n.dateStart.getTime(),f=n.dateEnd.getTime();a.style[u?"right":"left"]=i.position.x+"px",t._refreshTask(a),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),"project"===n.type&&n.dragProject&&t._refreshProjectTasks(n,{startTime:n.dateStart.getTime()-g,endTime:n.dateEnd.getTime()-f}),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(a._cellObj.task),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleTaskBarResize(e){const t=this;if(t.disableTaskResize)return;const i=t._dragDetails;if(i.segment)return void t._handleTaskSegmentResize(e);const n=i.timelineTask,a=i.task;if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{id:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,item:t._cloneObject(a),dateStart:a.dateStart,dateEnd:a.dateEnd}).defaultPrevented)return void t.$.timeline.removeAttribute("task-bar-hovered");t.setAttribute("resized",""),t._closeTooltip(),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}t._handleTaskResize(e,t.$.timeline.getAttribute("task-bar-hovered")),t._updateSegmentsOnTaskResize(),t._refreshTask(n),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(n._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_updateSegmentsOnTaskResize(){const e=this,t=e._dragDetails,i=t.task,n=t.timelineTask;if(!i||!i.segments)return;let a;t&&t.segments?a=t.segments:t.segments=a=n.querySelectorAll(".smart-task-segment");const s=a.length,r=t.size.width,o=e.rightToLeft?"right":"left";for(let t=0;t<s;t+=1){const i=a[t],n=i.style.width?parseFloat(i.style.width):i.offsetWidth,l=i.style[o]?parseFloat(i.style[o]):0;if(l+n>r){const t=r-(l+n),a=n+t;a<e._taskBarMinWidth&&(i.style[o]=l+t+"px"),i.style.width=a+"px"}else t===s-1&&(i.style.width=r-l+"px")}}_handleTaskSegmentResize(e){const t=this,i=t._dragDetails,n=i.segment,a=n.element,s=a._segmentObj;if(!s||s.disableResize)return;const r=i.task,o=t._dragDetails.timelineTask,l=n.isFirstSegment,c=n.isLastSegment,d=t.rightToLeft,m=d?"right":"left";if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{id:"string"==typeof r.id||"number"==typeof r.id?r.id:r.$.id,item:t._cloneObject(r),dateStart:r.dateStart,dateEnd:r.dateEnd,segment:t._cloneObject(s)}).defaultPrevented)return void t.$.timeline.removeAttribute("task-bar-hovered");t.setAttribute("resized",""),t._closeTooltip(),t._scrollView.disableSwipeScroll=t._touchmoveInside=!0}const u=t.$.timeline.getAttribute("task-bar-hovered");if(l&&("left"===u&&!d||"right"===u&&d)){const s=i.size?i.size.width:i.originalSize.width;void 0===n.size&&(n.size={width:n.originalSize.width}),t._handleTaskResize(e,u),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const r=i.size.width-s,l=i.segments;for(let e=0,t=l.length;e<t;e+=1){const t=l[e];0!==e&&(t.style[m]=(parseFloat(t.style[m])||t.offsetLeft)+r+"px")}a.style.width=(n.size.width+=r)+"px"}else{if(!c||!("right"===u&&!d||"left"===u&&d))return t._handleSegmentResize(e,u),void t._refreshTaskSegments(o,[a]);{const s=i.size?i.size.width:i.originalSize.width;void 0===n.size&&(n.size={width:n.originalSize.width}),t._handleTaskResize(e,u),a.style.width=(n.size.width+=i.size.width-s)+"px"}}t._refreshTask(o,[a]),t._refreshProject(r.$.project),t.groupByResources&&t._refreshProject(r.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(o._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_handleSegmentResize(e,t){const i=this,n=i._dragDetails,a=n.task,s=n.segment,r=s.element,o=i.rightToLeft,l=n.taskDimensions.left;n.timelineRow||(n.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===a)));const c=n.timelineRow;s.position||(s.position={x:s.originalPosition.x}),s.size||(s.size={width:s.originalSize.width});const d=e.pageX-window.pageXOffset;let m=s.size.width,u=s.min.width||0,h=s.max.width,g=s.min.left||0,f=s.max.left,p=r.offsetLeft,{left:_}=c.getBoundingClientRect(),T="object"==typeof e?d-n.coordinates.x:e;if(_+=l,"left"===t&&!o||"right"===t&&o)if(o){const e=n.taskDimensions.width;T=T<0?-1*Math.min(Math.abs(T),m-u):Math.min(h-m,Math.abs(T)),m=Math.max(u,Math.min(h,m+T)),r.style.left="",r.style.right=(p=Math.max(e-g,(parseFloat(r.style.right)||c.offsetWidth-p-m)-T))+"px",n.coordinates.x=Math.max(_+e-p+u,Math.min(_+e-p,d))}else T=T>0?Math.min(T,m-(u||0)):-1*Math.min(h-m,Math.abs(T)),m=Math.max(u,Math.min(p+m,m-T)),r.style.right="",r.style.left=(p=Math.max(g,(parseFloat(r.style.left)||p)+T))+"px",n.coordinates.x=Math.max(_+g+u,Math.min(_+p+m-u,d));else o?(T<0&&(T=-1*Math.min(h-m,Math.abs(T))),m=Math.max(u,Math.min(p+m,m-T)),f-=s.dimensions.width,n.coordinates.x=Math.max(_+f,Math.min(_+f+h,d))):(T>0&&(T=Math.min(h-m,T)),m=Math.max(u,Math.min(h,m+T)),n.coordinates.x=Math.max(_+p+u,Math.min(_+p+h,d)));r.style.width=(s.size.width=m)+"px"}_handleTaskResize(e,t){const i=this,n=i._dragDetails,a=n.task;n.position||(n.position={x:n.originalPosition.x,y:n.originalPosition.y}),n.size||(n.size={width:n.originalSize.width}),n.timelineRow||(n.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===a)));const s=n.timelineRow,r=n.timelineTask,o=n.segment,l=e.pageX-window.pageXOffset;let c=n.size.width,d=n.min.width||0,m=n.max.width,u=s.getBoundingClientRect().left,h=i.rightToLeft,g="object"==typeof e?l-n.coordinates.x:e;if("left"===t&&!h||"right"===t&&h)if(o&&(h?(u-=o.dimensions.width-o.offset.x,d=Math.max(o.max.left+o.min.width,d)):(u+=o.offset.x,d=Math.max(n.taskDimensions.width-o.max.left+o.min.width,d))),h){g<0?g=-1*Math.min(Math.abs(g),c-(d||0)):void 0!==m&&(g=Math.min(m-c,Math.abs(g))),c=n.size.width=Math.max(d,Math.min(s.offsetWidth-r.offsetLeft,c+g));const e=r.offsetLeft;r.style.left="",r.style.right=(n.position.x=Math.max(0,(parseFloat(r.style.right)||s.offsetWidth-r.offsetLeft-r.offsetWidth)-g))+"px",n.coordinates.x=Math.max(u+r.offsetLeft+d,Math.min(u+e+c,l))}else g>0?g=Math.min(g,c-(d||0)):void 0!==m&&(g=-1*Math.min(m-c,Math.abs(g))),c=n.size.width=Math.max(d,Math.min(r.offsetLeft+c,c-g)),r.style.right="",r.style.left=(n.position.x=Math.max(0,(parseFloat(r.style.left)||r.offsetLeft)+g))+"px",n.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+c-d,l));else h?(o&&(u+=o.offset.x,d=Math.max(n.taskDimensions.width-o.min.left+o.min.width,d)),g<0&&void 0!==m&&(g=-1*Math.min(m-c,Math.abs(g))),c=n.size.width=Math.max(d,Math.min(r.offsetLeft+r.offsetWidth,c-g)),r.style.width=n.size.width+"px",n.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+c-d,l))):(o&&(u-=o.dimensions.width-o.offset.x,d=Math.max(o.min.left+o.min.width,d)),g>0&&void 0!==m&&(g=Math.min(m-c,g)),c=n.size.width=Math.max(d,Math.min(s.offsetWidth-r.offsetLeft,c+g)),n.coordinates.x=Math.max(u+r.offsetLeft+d,Math.min(u+r.offsetLeft+(m||c),l)));r.style.width=n.size.width+"px"}_handleTimelineConnectionHover(e){const t=this;if(!(t.shadowRoot||t).contains(e))return;const i=t.$.timelineConnectionsContainer.children,n=e.closest(".smart-task-connection");if(n||!t.$.timelineConnectionsContainer.querySelector(".smart-task-connection[hover]")){if(n){const e=n.getAttribute("connection-id");for(let t=0;t<i.length;t++){const n=i[t];n.getAttribute("connection-id")===e?n.setAttribute("hover",""):n.removeAttribute("hover")}t._hoveredConnectionTasks=n.tasks}}else for(let e=0;e<i.length;e++)i[e].removeAttribute("hover")}_resetItemHover(){const e=this;if(e._hoveredItem){const t=e.$.mainSplitter.querySelectorAll(".smart-timeline-task[hover], .smart-timeline-row[hover], tr[hover]");for(let e=0;e<t.length;e++)t[e].removeAttribute("hover");e.$.timeline.removeAttribute("task-bar-hovered"),delete e._hoveredItem}}_handleTimelineHover(e,t){const i=this,n=i._isMobile;if(!e||n)return void i._resetItemHover();const a=e.originalEvent||e;let s="task",r=a.pageX&&n?document.elementFromPoint(a.pageX-window.pageXOffset,a.pageY-window.pageYOffset):a.target;if(a.pageX&&i.shadowRoot&&r===i&&(r=a.pageX&&n?i.shadowRoot.elementFromPoint(a.pageX-window.pageXOffset,a.pageY-window.pageYOffset):a.composedPath()[0]),!r||!r.closest||r===i||t)return void i._resetItemHover();i.$.resourceSplitter&&i.$.resourceSplitter.contains(r)?s="resource":i._handleTimelineConnectionHover(r);let o=r.closest(".smart-timeline-row")||r.closest(".smart-timeline-task");if(!o||!(i.shadowRoot||i).contains(o))return void i._resetItemHover();const l=o._cellObj[s],c=l.$.id,d=i._hoveredItem;if(!(d&&d.type===s&&d.id===c||(i._resetItemHover(),l.isGroup||("task"===s&&o.classList.contains("smart-timeline-row")&&(o=i.$.timelineTasksContainer.querySelector(`.smart-timeline-task[row-id="${c}"]`)),!o||i._connectionFeedback&&o.contains(i._connectionFeedback)||(o.setAttribute("hover",""),i._hoveredItem={id:c,type:s},n))))){const e=("task"===s?i.$.taskTimelineCellsContainer:i.$.resourceTimelineCellsContainer).querySelector(`.smart-timeline-row[row-id="${c}"]`);e&&(e.setAttribute("hover",""),i._handleTableItemHover(c,r))}}_getScrollLeft(e){return this.rightToLeft?e*=-1:e}_synchronizeSplitters(e,t){if(this.$.mainSplitter.contains(this.$.resourceSplitter)){const i=e._measurements,n=e.items,a=t.items,[s,r,o]=[i.dimension,i.minDimension,i.maxDimension],[l,c]=[a[0],n[0]],[d,m]=[a[1],n[1]];t.keepProportionsOnResize=!0,t.setAttribute("orientation-change",""),[r,o,s].forEach((e=>{const t=e===s?"size":e===r?"min":"max";l.set(t,""),d.set(t,""),l[t]=c.style[e],d[t]=m.style[e]})),t.removeAttribute("orientation-change"),t.keepProportionsOnResize=!1}}_resizeEventHandler(e){const t=this,i=t.$.taskSplitter;function n(e){e.refresh(),e===i&&t._synchronizeSplitters(i,t.$.resourceSplitter)}if(e&&"resizeEnd"===e.type){if(e.target===t.$.taskTreeSplitter||e.target===t.$.resourceTreeSplitter)return void n(e.target);e.target===t.$.resourceSplitter&&t._synchronizeSplitters(t.$.resourceSplitter,i)}if(!t._timelineCells)return void t._refresh();t.$.mainSplitter.refresh(),n(i);const a=t._getScrollLeft(t.scrollLeft);t._autoSchedule(),t._createTimelineCells(),t._recycleTimelineTasks(),t._recycleTimelineRowCells(),t._refreshResourceTimeline(),t._refresh(),t.$.taskTable.refresh(),t.$.timelineHeader.scrollLeft=t.$.taskTimelineContainer.scrollLeft=a,t.$.taskTable.scrollTop=t.$.taskTimelineContainer.scrollTop=t.scrollTop,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=a,t.$.resourceTable.refresh(),t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=t.$.resourceVerticalScrollBar.value),t._positionWindow()}_recycle(e){const t=this,i=e&&"horizontal"===e.context.orientation;if(e&&!i||(t._recycleHeaderCells(t.$.timelineViewCells),t._recycleHeaderCells(t.$.timelineViewDetails),t._recycleResourceContent()),i)return;if(t._recycleResourceContent(),t._recycleContentCells(),t._recycleTimelineTasks(),!e)return;const n=Math.round(e.detail.value);e.target!==t.$.resourceVerticalScrollBar?t._refreshTableScrollTop(t.$.taskTable,n):t._refreshTableScrollTop(t.$.resourceTable,n)}_recycleContentCells(){const e=this,t=e._getFirstContentCellInView(),i=e.$.taskTimelineCellsContainer,n=e.$.timelineTasksContainer;if(!t)return void(i.innerHTML=n.innerHTML="");const a=t.height,s=1-(t.top+a-Math.abs(e.scrollTop))/a,r=e._timelineVCells?e._timelineVCells.length:0,o=!e.$.taskSplitter.offsetHeight,l=e.$.taskTimelineContainer.offsetHeight,c=!o&&l?Math.min(r,Math.ceil((parseFloat((l/a).toFixed(2))+s).toFixed(2))):r,d=e.$.timelineViewCells.children,m=document.createDocumentFragment();for(;i.childElementCount>c;)i.lastElementChild.remove();for(;n.childElementCount>c;)n.lastElementChild.remove();for(let t=i.childElementCount;t<c;t+=1){const t=document.createElement("div");t.classList.add("smart-timeline-row"),e._createTimelineRowCells(t,d),m.appendChild(t)}m.childElementCount&&i.appendChild(m);for(let e=n.childElementCount;e<c;e+=1){const e=document.createElement("div");e.classList.add("smart-timeline-task"),m.appendChild(e)}m.childElementCount&&n.appendChild(m)}_getCellIndexByDate(e){const t=this._timelineCells;let i=[];if(e&&e.length&&t){Array.isArray(e)||(e=[e]);for(let t=0,n=e.length;t<n;t+=1){const n=e[t];e[t]=n.getTime?n.getTime():n,i[t]=-1}for(let n=0,a=t.length;n<a;n+=1){const a=t[n],s=e.indexOf(a.date.getTime());if(s>-1&&(i[s]=n,i.every((e=>-1!==e))))break}return 1===i.length?i[0]:i}}_recycleDateMarkers(){const e=this,t=e.$.timelineMarkers,i=e._markers;if(!i||e.hideDateMarkers)return void(t.childElementCount&&(t.innerHTML=""));const n=e.$.timelineViewCells.children,a=n[0]._date,s=n[n.length-1]._date,[r,o]=e._getCellIndexByDate([a,s]);if(!a||!s)return;const l=a.getTime(),c=e._getCellDateRange({_date:s}).dateEnd.getTime(),d=t.children,[m,u]=e.rightToLeft?["right","left"]:["left","right"],h=document.createDocumentFragment();let g=0;for(let t=0,n=i.length;t<n;t+=1){const n=i[t],a=i[t].date,s=a.getTime();if(s<l||s>c)continue;const f=e._getTimelineCellByDate(a,r,o);if(f){const t=f.left+e._getTimelineTaskOffset(f,a),i=n.label,s=n.className;let r=d[g];r||(r=document.createElement("div"),h.appendChild(r)),r.className="smart-gantt-chart-date-marker",void 0!==i&&(r.firstElementChild||(r.innerHTML='<div class="smart-gantt-chart-marker-label"></div>'),r.firstElementChild.textContent=i+""),void 0!==s&&r.classList.add(s),r.style[u]="",r.style[m]=t+"px",g++}}for(h.childElementCount&&t.insertBefore(h,t.firstElementChild);d.length>g;)d[d.length-1].remove()}_refreshTableScrollTop(e,t){this.$.mainSplitter.contains(e)&&void 0!==t&&(e.scrollTop=t)}_recycleHeaderCells(e){const t=this,i=e.children,n=t.scrollLeft,a=e===t.$.timelineViewCells,s=a?t._timelineCells:t._timelineHeaderCells;if(!s.length)return;let r=document.createDocumentFragment();for(;i.length;)r.appendChild(e.firstElementChild);const o=t._getFirstCellObjInView(s),l=1-(o.left+o.width-Math.abs(n))/s[0].width,c=r.children.length,d=a?Math.ceil((parseFloat((t.$.timeline.offsetWidth/o.width).toFixed(2))+l).toFixed(2)):t._getHeaderVisibleCellsCount();if(c>d)for(;r.children.length&&r.children.length!==d;)r.removeChild(r.firstElementChild);else if(c<d){const e=t._createCells(d-c);for(;e.children.length;)r.appendChild(e.firstElementChild)}const m=[t.rightToLeft?"right":"left"],u=a?t._getCellsViewType():t.view;let h=s.indexOf(o);for(let e=0;e<r.children.length;e++){const i=r.children[e],n=s[h];if(!n)break;let o=new Date(n.date);a||"week"!==t.view||(o.setDate(o.getDate()-o.getDay()),o=new Date(Math.max(n.date.getTime(),o.getTime()))),i.style[m]=n.left+"px",i.style.width=n.width+"px",i._date=o,i.innerHTML=`<div>${t._getDateString(o,u,!a)}</div>`,n.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),n.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),h++}e.appendChild(r),a&&(t._recycleTimelineRowCells(),t._recycleResourceHeaderCells(),t._recycleDateMarkers(),t._setTodayCell())}_refresh(){const e=this;let t="disabled"===e.verticalScrollBarVisibility;function i(){const t=e.$.timelineHeader,i=t.scrollWidth-t.offsetWidth;return i>0&&"hidden"!==e.horizontalScrollBarVisibility||"visible"===e.horizontalScrollBarVisibility?e.$container.addClass("hscroll"):e.$container.removeClass("hscroll"),i}function n(){let i=Math.max(0,e.$.timelineContent.offsetHeight-e.$.taskTimelineContainer.offsetHeight);return i>0&&"hidden"!==e.verticalScrollBarVisibility||"visible"===e.verticalScrollBarVisibility?e.$container.addClass("vscroll"):e.$.mainSplitter.contains(e.$.resourceSplitter)?(i=1,t=!0,e.$.resourceVerticalScrollBar.max||e.$container.removeClass("vscroll")):e.$container.removeClass("vscroll"),i}const a=e.scrollWidth,s=e.scrollHeight;let r=i(),o=n();o&&s===o||(r=i()),r&&a===r||(o=n()),e.scrollWidth=r,e.scrollHeight=o,e.$.verticalScrollBar.disabled=t,e.$.horizontalScrollBar.refresh(),e.$.verticalScrollBar.refresh(),e.$.mainSplitter.contains(e.$.resourceSplitter)&&(e._refreshResourceScrollBar(),e._refreshTableScrollTop(e.$.resourceTable))}_refreshProjectTasks(e,t){const i=this,n=i._getProjectTasks(e);if(!n.length)return;const a=i.nonworkingDays,s=i.nonworkingHours,r=i._timelineVCells;for(let e=0,o=n.length;e<o;e++){const o=n[e];if(o){const e=i._getTaskDOMIndex(o),n=r[e],l=o.segments;if(o.dateStart=new Date(Math.max(i.dateStart.getTime(),o.dateStart.getTime()+t.startTime)),o.dateEnd=new Date(Math.min(i.dateEnd.getTime(),o.dateEnd.getTime()+t.endTime)),o.duration=i._convertDuration(a.length>0||s.length>0?i._getWorkingTime(o.dateStart,o.dateEnd):o.dateEnd.getTime()-o.dateStart.getTime(),!0),l&&l.length>1){for(let e=0,i=l.length;e<i;e+=1){const i=l[e];i.dateStart=new Date(i.dateStart.getTime()+t.startTime),i.dateEnd=new Date(i.dateEnd.getTime()+t.endTime)}i._validateTaskSegments(o)}n&&(i._recycleTaskBars(n,e),i._setTimelineTaskBar(n,e),l&&l.length>1&&i._setTaskBarProgress(o),i._refreshTaskConnections(o),i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"]))}}}_refreshProject(e){const t=this;function i(e){let i,n,a;if(e instanceof HTMLElement)i=e.offsetLeft,a=e.offsetWidth;else if(e){const s=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);s&&r&&(i=s.left+t._getTimelineTaskOffset(s,e.dateStart)||0,n=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0,a=n-i)}return[i,a]}if(!e)return;const n=t.groupByResources&&e.isGroup?"group":"project";if(e.synchronized)for(;e&&e.synchronized;){const a=t._getProjectTasks(e);let s=a[0],r=a[0];for(let e=0;e<a.length;e++)s.dateStart.getTime()>=a[e].dateStart.getTime()&&(s=a[e]),r.dateEnd.getTime()<=a[e].dateEnd.getTime()&&(r=a[e]);const o=t.$.timelineTasksContainer.children,l=t.$.timelineContent.offsetWidth;let c,d,m;for(let t=0,i=o.length;t<i;t+=1){const i=o[t],n=i._cellObj?i._cellObj.task:void 0;n&&(n===e?c=i:n===s?d=i:n===e&&(m=i))}if(!c){s&&(e.dateStart=s.dateStart),r&&(e.dateEnd=r.dateEnd),e=e.$[n];continue}s&&(e.dateStart=s.dateStart);let[u,h]=i(d||s);void 0!==u&&void 0!==h&&(t.rightToLeft?(c.style.width=c.offsetWidth-(l-u-h-(l-c.offsetLeft-c.offsetWidth))+"px",c.style.right=d?d.style.right:u+"px"):(c.style.width=c.offsetWidth-(u-c.offsetLeft)+"px",c.style.left=d?d.style.left:u+"px")),r&&(e.dateEnd=r.dateEnd),[u,h]=i(m||r),void 0!==u&&void 0!==h&&(t.rightToLeft?c.style.width=Math.max(0,c.offsetWidth-(l-c.offsetLeft-(l-u)))+"px":c.style.width=Math.max(0,c.offsetWidth-(c.offsetLeft+c.offsetWidth-(u+h)))+"px"),t._refreshTask(c),e=e.$[n]}else t._refreshProject(e.$[n])}_refreshTask(e,t){const i=this,n=i._getTaskBarCellRange(e),a=n.cellStart,s=n.cellEnd;if(!n||!a||!s)return;e._cellStart=a,e._cellEnd=s;const r=i._getTaskBarDateRange(e);if(!r)return;const o=e._cellObj.task;if(Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===o))){if(o.dateStart=r.dateStart,o.dateEnd=r.dateEnd,o.duration=o.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(o.dateStart,o.dateEnd):o.dateEnd.getTime()-o.dateStart.getTime(),!0),e.setAttribute("aria-label",o.label+" Start date: "+i._toISODate(o.dateStart)+", End date: "+i._toISODate(o.dateEnd)),i._refreshTaskConnections(e),t)Array.isArray(t)&&i._refreshTaskSegments(e,t);else{const t=i._dragDetails;let n;e.classList.contains("task")?t&&t.segments?n=t.segments:t.segments=n=e.querySelectorAll(".smart-task-segment"):n=e.querySelectorAll(".smart-task-segment"),i._refreshTaskSegments(e,n)}i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"])}}_refreshTaskSegments(e,t){const i=this,n=e._cellObj.task;if(!n||!n.segments||!n.segments.length)return void i._setTaskBarDeadline(n,t?t[0]:void 0);const a=i.nonworkingDays.length>0||i.nonworkingHours.length>0,s=i.rightToLeft,r=s?"right":"left",o=parseFloat(e.style[r])||e.offsetLeft;let l;for(let n=0,c=t.length;n<c;n+=1){const c=t[n],d=c._segmentObj,m=i._getSegmentCellRange(c),u=m.cellStart,h=m.cellEnd;if(!m||!u||!h)continue;const g=parseFloat(c.style.width)||c.offsetWidth,f=o+parseFloat(c.style[r])||(s?(parseFloat(e.style.width)||e.offsetWidth)-(c.offsetLeft+c.offsetWidth):c.offsetLeft);c._cellStart=u,c._cellEnd=h,l=c;let p=i._getDateFromCell(f,u),_=i._getDateFromCell(f+g,h);d.dateStart=p,d.dateEnd=_,d.duration=i._convertDuration(a?i._getWorkingTime(p,_):_.getTime()-p.getTime(),!0),e.setAttribute("aria-label",(d.label||"")+" Start date: "+i._toISODate(p)+", End date: "+i._toISODate(_))}i._setTaskBarProgress(n,e),i._setTaskBarDeadline(n,l)}_refreshTaskResources(e,t=[]){const i=this;if(e&&(t||(t=i._getTaskResources(e)),t.length))for(let e=0;e<t.length;e++){const n=t[e];i._refreshResource(n),i._refreshTableColumnsData(n,void 0,"resource")}}_refreshTableColumnsData(e,t,i){const n=this;if(i||(i="task"),!e)return;const a=n[`${i}Columns`],s=n.$[`${i}Table`];if(!n.$.mainSplitter.contains(s))return;const r=e.$.id;t=t?t.map((e=>a.find((t=>t.value===e)))):a;for(let i=0;i<t.length;i++){const a=t[i];a&&s.setValue(r,a.value,n._formatColumnData(e,a))}n.$[`${i}Splitter`].refresh()}_removeConnection(e,t){const i=this,n=i.$.connectionPopupWindow,a=i.$.timelineConnectionsContainer;if(e.classList&&e.classList.contains("smart-task-connection")?e=e.getAttribute("connection-id"):e+="",void 0===e)return;const s=a.querySelectorAll('.smart-task-connection[connection-id^="'+e+(e.indexOf("-")<0?"-":"")+'"]'),r=i._tasks,o=e.split("-"),l=parseInt(o[1]);for(let e=0;e<s.length;e++)a.removeChild(s[e]);let c;const d=parseInt(o[0]),m=parseInt(o[1]),u=parseInt(o[2]);if(n&&void 0!==n._target&&"number"==typeof n._target.type){const t=n._target;c=t.startIndex+"-"+t.endIndex+"-"+t.type===e}i._updateConnection([d,m,u],!0),!t&&i.autoSchedule&&(i._autoScheduleRestore(r[l],parseInt(o[2])),i._autoSchedule(r[l])),c&&i.$.fireEvent("itemRemove",{type:"connection",id:`${d}-${m}-${u}`,item:{source:d,target:m,type:u}})}_removeTaskConnections(e,t){const i=this,n=i._connections;if(n&&n.length){for(let t=0,i=n.length;t<i;t+=1)n[t].startTask===e&&(n.splice(t,1),i--);e.connections=[],t&&i._recycleConnections()}}_removeTask(e){const t=this,i=t._tasks;if(!e||!i||!i.length)return;const n=t._getSelection("task",t.selectedTaskIds),a=t.$.taskPopupWindow;let s;if(t._highlightAssignedItem("task",[e]),a&&a._target===e&&a.close(),"project"===e.type){const n=t._getProjectTasks(e);for(let e=0,t=n.length;e<t;e+=1)i.splice(i.indexOf(n[e]),1)}if(i.splice(i.indexOf(e),1),t._refreshItemIds(),t._refreshConnectionIds(),t._isUpdating)return t._isUpdating.type.task=!0,void(t._isUpdating.type.resource=!0);t._refreshSelectedItems(),t._refreshTableDataSource(),t._refreshTimeline(),t._selected&&t._selected.task&&(s=t._selected.task.map((e=>e.$.id)),n.toString()!==s.toString()&&(t.$.taskTable.selected=t._getSelection("task",t.selectedTaskIds))),t.$.fireEvent("itemRemove",{type:"task",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:t._cloneObject(e)})}_removeResource(e){const t=this,i=t._resources,n=i.indexOf(e);if(e&&!(n<0)){if(t._isUpdating)return i.splice(n,1),t._isUpdating.type.resource=!0,void(t._isUpdating.type.task=!0);if(i.splice(n,1),t.groupByResources)t._refreshTableDataSource(),t._createTimelineContent(),t._refresh(),t._recycleTimelineTasks();else if(t.taskColumns.find((e=>"resources"===e.value))){const i=t._tasks.filter((t=>t.resources.includes(e.id)));for(let e=0;e<i.length;e++)t._refreshTableColumnsData(i[e],["resources"])}if(!i.filter((e=>!e.hidden)).length)return t._createResourceTimeline(),t._resizeEventHandler(),void a();t._refreshResourceTimeline(),t._refreshTableDataSource("resource"),t.$.mainSplitter.contains(t.$.resourceSplitter)?(t._refreshResourceScrollBar(),t._resizeEventHandler(),a()):a()}function a(){t.$.fireEvent("itemRemove",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:t._cloneObject(e)})}}_updateTask(e,t){const i=this,n=i._tasks;if(!e||!n||!n.length)return;const a=i.$.taskPopupWindow,s=i._getSelection("task",i.selectedTaskIds);a&&a._target===e&&a.close();let r,o=i._getTaskResources(e);for(let a in t){let s=e[a],l=t[a];if("type"===a&&s!==l&&["task","project","milestone"].indexOf(l)>-1&&"project"===s){const t=i._getProjectTasks(e);for(let e=0,i=t.length;e<i;e+=1)n.splice(n.indexOf(t[e]),1);delete e.tasks}if("project"!==e.type||!e.synchronized||!(a.toLowerCase().indexOf("date")>-1||a.toLowerCase().indexOf("duration")>-1))if("dateEnd"===a&&new Date(s).getTime()!==new Date(l).getTime()&&(r=!0),"tasks"!==a)"connections"===a&&(i._removeTaskConnections(e),i._handleTaskConnections(e)),e[a]=l,"resources"===a&&(i._handleResources(e),e.disableResources||(o=o.concat(i._getTaskResources(e)),o=o.filter(((e,t)=>o.indexOf(e)===t)))),"milestone"!==e.type||"dateStart"!==a&&"dateEnd"!==a||(e.dateEnd=e.dateStart=l);else if("project"===e.type){const t=i._getProjectTasks(e);for(let e=0,i=t.length;e<i;e+=1)n.splice(n.indexOf(t[e]),1);const a=i._createTasks(l,!0);for(let t=0,i=a.length;t<i;t+=1)a[t].$.project=e;i._insertTasks(a,e,n.indexOf(e))}}r&&delete e.duration;const l=e.$,c=e.$.project;if(i._validateTaskProperties(e,c),e.$=l,c&&i._synchronizeProjectDates(c),"project"===e.type&&e.hidden&&i._getProjectTasks(e).forEach((t=>t.hidden=e.hidden)),i._synchronizeProjectVisibility(e.$.project,e),i._refreshItemIds(),i._refreshConnectionIds(),i._isUpdating)return void(i._isUpdating.type.task=!0);let d;i._selected&&i._selected.task&&i._setSelection("task",d=i._selected.task.map((e=>e.$.id))),i._refreshTableDataSource(),i._refreshTimeline(),i._ensureVisible(e),d&&s.toString()!==d.toString()&&(i.$.taskTable.selected=d.slice(0)),i._refreshTaskResources(e,o),i._highlightAssignedItem("task",i._getSelection("task",i.selectedTaskIds)),i.$.fireEvent("itemUpdate",{type:"task",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)})}_updateResource(e,t){const i=this;if(!e)return;const n=e.hidden;if(i._setResource(e,t),i._isUpdating)i._isUpdating.type.resource=!0;else{if(i.groupByResources)i._refreshTableDataSource(),i._refreshTimeline();else if(i.taskColumns.find((e=>"resources"===e.value))){const t=i._tasks.filter((t=>t.resources.includes(e.id)));for(let e=0;e<t.length;e++)i._refreshTableColumnsData(t[e],["resources"])}if(n!==e.hidden)return i._createResourceTimeline(),void i.$.fireEvent("itemUpdate",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)});if(i._refreshTableColumnsData(e,void 0,"resource"),i.$.mainSplitter.contains(i.$.resourceTimelineCellsContainer)){const t=i.$.resourceTimelineCellsContainer.children;for(let n=0;n<t.length;n++){const a=t[n];a._resource===e&&i._refreshResourceTimelineContent(e,a)}}i.$.fireEvent("itemUpdate",{type:"resource",id:"string"==typeof e.id||"number"==typeof e.id?e.id:e.$.id,item:i._cloneObject(e)})}}_select(e="task",t){const i=this;if(i.disableSelection||!t)return void i._unselectAll(e);let n,a;"task"===e?(n="selectedTaskIds",a=i._tasks):(n="selectedResourceIds",a=i._resources);const s=a.findIndex((e=>e.$.id===t)),r=i._getSelection(e,i[n]);s<0||(r.indexOf(t)>-1?i.$[`${e}Table`].unselect(t):i.$[`${e}Table`].select(t))}_handleTableSelection(e="task",t){const i=this;if(i.disableSelection||!t.length)return void i._unselectAll(e);let n,a,s,r,o,l=i._selected;l||(l=i._selected={});const c=t[t.length-1],d=l[e]=[];"task"===e?(o=i._tasks,n="selectedTaskIds",a=i.$.taskTimelineCellsContainer.children,s=i.$.timelineTasksContainer.children):(o=i._resources,n="selectedResourceIds",a=i.$.resourceTimelineCellsContainer.children,s=[]);for(let e=0,i=o.length;e<i;e+=1){const i=o[e];t.indexOf(i.$.id)>-1&&d.push(i)}for(let i=0,n=a.length;i<n;i+=1){const n=a[i],o=s[i],l=n._cellObj[e].$.id;c===l&&(r=s[i]),t.indexOf(l)>-1?(n.setAttribute("selected",""),n.setAttribute("aria-selected","true"),o&&o.setAttribute("selected","")):(n.removeAttribute("selected"),n.setAttribute("aria-selected","false"),o&&o.removeAttribute("selected"))}const m=i[n].slice(0);if(i._setSelection(e,t),!i._tableChangeEventFired){const n=document.scrollingElement||document.documentElement,a=n.scrollLeft,s=n.scrollTop;i._highlightAssignedItem(e,t),i.$[`${e}Table`].focus({preventScroll:!0}),window.scrollTo(a,s)}if("task"===e&&r){const e=r._cellStart;if(i.scrollLeft>e.left||e.left+r.offsetWidth>i.scrollLeft+i.$.timeline.offsetWidth){const t=i._timelineCells.indexOf(e);i._scrollTo((i._timelineCells[t-1]?i._timelineCells[t-1]:e).date)}}i._noChangeEvent||i.$.fireEvent("change",{type:e,value:i[n].slice(0),oldValue:m})}_setSelection(e="task",t){const i=this;let[n,a]="task"===e?[i._tasks,"selectedTaskIds"]:[i._resources,"selectedResourceIds"],s=[];for(let e=0,i=t.length;e<i;e+=1){const i=t[e],a=n.find((e=>e.$.id===i));a&&s.push(void 0!==a.id?a.id:i)}i.set(a,s)}_getSelection(e="task",t){const i="task"===e?this._tasks:this._resources;let n=t.slice(0);if(!t||!t.length)return n;for(let e=0,a=i.length;e<a;e+=1){const a=i[e],s=t.indexOf(a.id);s>-1&&(n[s]=a.$.id)}return n}_highlightAssignedItem(e,t){const i=this,[n,a]="task"===e?["resource","_getTaskResources"]:["task","_getResourceTasks"],s=i.$[`${n}Table`],r=i[`_${n}s`];if(!s||!i.$.mainSplitter.contains(s)||!r.length)return;t&&Array.isArray(t)||(t=[]);let o=[];for(let n=0,s=t.length;n<s;n+=1){const s=i._getValidItemAndIndex(t[n],e);s&&(o=o.concat(i[a](s.item).filter((e=>!e.hidden))))}i._tableChangeEventFired=!0,s.selected=o.map((e=>e.$.id)),o.length&&i._ensureVisible(o[0],n),delete i._tableChangeEventFired}_selectResource(e){const t=this,i=t._resources.indexOf(e);if(i<0)return void t._unselectAll("resource");const n=t.$.resourceTimelineCellsContainer.children[i];n&&n.hasAttribute("selected")?t._unselectAllTasks():t.$.resourceTree.focus({preventScroll:!0})}_snapToNearest(e,t){const i=this;if(!(i.snapToNearest&&e&&e.classList&&e.classList.contains("smart-timeline-task")&&e._cellObj))return;const n=e._cellObj.task,a=n.segments;if(t&&t.classList.contains("smart-task-segment")){const n=a.indexOf(t._segmentObj),s=0===n,r=n===a.length-1;if(i._handleSnapToNearestSegment(e,t,s?"first":r?"last":void 0),i._refreshTaskSegments(e,[t]),!s&&!r)return;i._refreshTask(e,!0)}else i._handleSnapToNearest(i._getTaskBarCellRange(e),e),i._refreshTask(e);if(a&&a.length>1){for(let e=0,t=a.length;e<t;e+=1)i._snapToNearestDates(a[e],!0);i._validateTaskSegments(n),n.segments.length!==a.length&&i._recycleSegments(n,e),i._setTaskBarSegments(e._cellObj,e,!0),i._setTaskBarProgress(n)}if("project"!==n.type||!n.dragProject)return;const s=i._getProjectTasks(n);if(s&&Array.isArray(s))for(let e=0;e<s.length;e++){const t=i.$.timelineTasksContainer.children[i._tasks.indexOf(s[e])];t&&i._snapToNearest(t)}}_handleSnapToNearestSegment(e,t,i){const n=this,a=n.rightToLeft,s=a?"right":"left",r=parseFloat(e.style[s])||0,o=t,l=n._getSegmentCellRange(t),c=l.cellStart,d=l.cellEnd,m="first"===i,u="last"===i;let h=parseFloat(o.style.width)||o.offsetWidth,g=parseFloat(o.style[s])||0,f=r+g;if(n.hasAttribute("dragged")){const t=d.width-(f+h-d.left);let n;if(f-c.left<=t?(n=c.left-r,o.style[s]=Math.max(0,m?0:n)+"px"):(n=g+t,o.style[s]=Math.max(0,m?0:n)+"px"),i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&(e.style[s]=r+(n-g)+"px"),e.style.width=t+(m?-1:1)*(n-g)+"px"}}else if(n.hasAttribute("resized")){const t=c===d?n._taskBarMinWidth:0;let l;if("left"===n.$.timeline.getAttribute("task-bar-hovered")){if(l=f-c.left,l-=l>=c.width/2?c.width-t:0,f-=l,o.style[s]=Math.max(0,m?0:f-r)+"px",l=f+h>d.left+d.width/2?d.left+d.width-(f+h):d.left-(f+h),o.style.width=Math.max(t,h+l)+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&!a&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&a&&(e.style.width=t+l+"px")}}else if(f>c.left+c.width/2?(f=c.left+c.width,o.style[s]=Math.max(0,m?0:f-r)+"px"):(f=c.left,o.style[s]=Math.max(0,m?0:f-r)+"px"),l=f+h-d.left,l=-1*(l-(l>=c.width/2?d.width:t)),o.style.width=h+l+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&a&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&!a&&(e.style.width=t+l+"px")}}}_handleSnapToNearest(e,t){const i=this;if(!e)return;const n=i.rightToLeft?"right":"left",a=e.cellStart,s=e.cellEnd;let r=parseFloat(t.style.width)||t.offsetWidth,o=parseFloat(t.style[n])||0;if(i.hasAttribute("dragged")){const e=s.width-(o+r-s.left);o-a.left<=e?t.style[n]=a.left+"px":t.style[n]=o+e+"px"}else if(i.hasAttribute("resized")){const e=a===s?i._taskBarMinWidth:0;let l;"left"===i.$.timeline.getAttribute("task-bar-hovered")?(l=o-a.left,l-=l>=a.width/2?a.width-e:0,t.style[n]=(o-=l)+"px",l=o+r>s.left+s.width/2?s.left+s.width-(o+r):s.left-(o+r),t.style.width=Math.max(e,r+l)+"px"):(o>a.left+a.width/2?t.style[n]=a.left+a.width+"px":t.style[n]=a.left+"px",o=parseFloat(t.style[n])||0,l=o+r-s.left,l=-1*(l-(l>=a.width/2?s.width:e)),t.style.width=r+l+"px")}}_setDragLimits(e){const t=this,i=t._dragDetails;if(!i)return;const n=i.timelineTask;if(!n||!e)return;const a=t.$.timeline.getAttribute("task-bar-hovered"),s=n._cellObj.task;if(a){if(s.disableResize)return void delete t._dragDetails;const e=t._getTaskBarSizeLimits(n,a);i.min.width=e.min,i.max.width=e.max,t._setSegmentLimits(a);const r=t._createDelimiter("min",a),o=t._createDelimiter("max",a);r&&n.appendChild(r),o&&n.appendChild(o)}else if(e.closest(".smart-task-connection-point"))i.timelineTask=void 0;else if(e.closest(".smart-timeline-task")===n){let e;if(t._connections){const i=t._tasks.indexOf(n._cellObj.task);e=t._connections.some((e=>e.startIndex===i||e.endIndex===i))}if(s.disableDrag||e&&t.autoSchedule&&t.autoScheduleStrictMode)return void delete i.target;i._taskDuration=t._getWorkingTime(s.dateStart,s.dateEnd),n.classList.contains("milestone")&&(i.target="smart-timeline-task-fill");const a=t._getTaskDragLimits(n),r=t.rightToLeft?t.$.timelineContent.offsetWidth-n.offsetLeft-n.offsetWidth:n.offsetLeft;if(void 0!==a.min&&(i.min.left=a.min,"project"===n._cellObj.task.type&&a.min>r&&(i.min.left=r)),void 0!==a.max&&(i.max.left=a.max,"project"===n._cellObj.task.type&&a.max<r&&(i.max.left=r)),"project"===s.type&&s.dragProject&&!t.synchronized){const e=t._getSubTaskLimits(n);void 0!==e.min&&(i.min.left=i.min.left?Math.max(i.min.left,e.min):e.min),void 0!==e.max&&(i.max.left=i.max.left?Math.min(i.max.left,e.max):e.max)}else"milestone"===s.type&&(i.target="smart-timeline-task-fill");t._setSegmentLimits()}else i.timelineTask=void 0;i.relatedConnections={}}_setSegmentLimits(e){const t=this,i=t._dragDetails;if(!i||!i.segment)return;const n=i.segment;if(n){const a=n.element,s=n.dimensions,r=a.previousElementSibling,o=a.nextElementSibling;if(n.min.width=e?t._taskBarMinWidth:0,t.rightToLeft){if(r)n.min.left="left"===e?s.left+s.width:r.offsetLeft-(e?0:s.width),"right"===e&&(n.max.width=r.offsetLeft-s.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"right");i.min.width=e.min,i.max.width=e.max}if(o)n.max.left="right"===e?n.dimensions.left:o.offsetLeft+o.offsetWidth+s.width,e&&"left"!==e||(n.max.width=s.left+s.width-(o.offsetLeft+o.offsetWidth));else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}}else{if(r)n.min.left="right"===e?s.left:r.offsetLeft+r.offsetWidth+(e||o?0:s.width),"left"===e&&(n.max.width=s.left+s.width-n.min.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}if(o)n.max.left="left"===e?s.left+s.width:o.offsetLeft-s.width,e&&"right"!==e||(n.max.width=o.offsetLeft-s.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"right");i.min.width=e.min,i.max.width=e.max}}}}_setScrollBars(){const e=this;e._scrollView||(e._scrollView=new Smart.Utilities.Scroll(e.$.taskSplitterItem,e.$.horizontalScrollBar,e.$.verticalScrollBar));const t=e._scrollView.vScrollBar,i=e._scrollView.hScrollBar;i.$.addClass("smart-hidden"),t.$.addClass("smart-hidden"),t.hasStyleObserver=!1,i.hasStyleObserver=!1,t.hasResizeObserver=!1,i.hasResizeObserver=!1,t.rightToLeft=i.rightToLeft=e.rightToLeft,i.wait=!1,e._refresh()}_getWorkingTime(e,t){const i=this;if(!e||!t)return;if(!i.adjustToNonworkingTime)return t.getTime()-e.getTime();const n=i.nonworkingHours,a=i.nonworkingDays;function s(e,t){let i,s,r=t.getTime()-e.getTime(),o=new Date(e),l=0;for(;r>0;){const e=Math.min(r,36e5-(60*o.getMinutes()*1e3+1e3*o.getSeconds()+o.getMilliseconds()));if(a.indexOf(o.getDay())>-1)s=new Date(o),s.setHours(0,0,0,0),s.setDate(o.getDate()+1),i=Math.min(e,s.getTime()-o.getTime()),o=new Date(o.getTime()+i),r-=i;else if(n.indexOf(o.getHours())>-1){s=new Date(o);const t=s.getTime();s.setHours(o.getHours()+1,0,0,0),t===s.getTime()&&s.setHours(o.getHours()+2,0,0,0),i=Math.min(e,s.getTime()-o.getTime()),o=new Date(o.getTime()+i),r-=i}else l+=e,r-=e,o=new Date(o.getTime()+e)}return l}if(e.getFullYear()===t.getFullYear())return s(e,t);let r=new Date(e.getFullYear()+1,0,1,0,0,0,0),o=s(e,r);if(t.getFullYear()>r.getFullYear()){const e=Math.max(0,t.getFullYear()-r.getFullYear());for(let t=0;t<e;t++){let e=i._getWorkingDaysBetweenDays(r);o+=60*(24*e-e*i.nonworkingHours.length)*60*1e3,r.setFullYear(r.getFullYear()+1)}}return o+=s(r,t),o}_getWorkingDaysBetweenDays(e){const t=this,i=e.getFullYear(),n=(i%100==0?i%400==0:i%4==0)?366:365;let a=new Date(e),s=0;for(let e=0;e<n;e++)t.nonworkingDays.indexOf(a.getDay())<0&&s++,a.setDate(a.getDate()+1);return s}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.tabIndex=-1:e.tabIndex=e.tabIndex>0?e.tabIndex:0}_setTaskBarLabel(e,t){const i=this;void 0===t&&(t=i._getTaskDOMIndex(e));const n=i.$.timelineTasksContainer.children[t];if(!n)return;const a=n.querySelector(".smart-task-segments").children;let s=e.segments;Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);for(let i=0,n=s.length;i<n;i+=1){const n=s[i],r=a[i],o=r?r.getElementsByClassName("smart-timeline-task-label")[0]:void 0;if(!o)continue;o.firstElementChild||(o.innerHTML="<div></div>");let l=o.firstElementChild;"string"==typeof n.label||"number"==typeof n.label?l.textContent=n.formatFunction?n.formatFunction(n.label||"",t)||"":n.label||"":l.textContent=e.formatFunction?n.formatFunction(e.label||"",t)||"":e.label||""}}_setTaskBarProgress(e,t){const i=this;if("number"==typeof t?t=i.$.timelineTasksContainer.children[t]:void 0===t&&(t=i.$.timelineTasksContainer.children[i._getTaskDOMIndex(e)]),!t||!e)return;let n=e.progress;const a=t.querySelector(".smart-timeline-task-progress-thumb");if(!a)return;n=Math.min(100,Math.max(0,n))||0;const s=e.dateStart.getTime(),r=e.dateEnd.getTime(),o=t.querySelector(".smart-task-segments").children;let l,c,d=e.segments,m=0;d&&d.length||(d=[e]);for(let e=0,t=d.length;e<t;e+=1){const t=d[e],i=o[e],a=i?i.querySelector(".smart-timeline-task-progress"):void 0;if(!a)continue;const u=(t.dateStart.getTime()-s)/(r-s)*100,h=(t.dateEnd.getTime()-s)/(r-s)*100,g=Math.max(0,Math.min(100,(n-u)/(h-u)*100));a.style.width=g+"%",a.removeAttribute("value"),i.removeAttribute("show-progress-label"),n>=u?(m=Math.max(u,Math.min(n,h)),l=a,c=i):l||(l=a,c=i)}if(a.style[i.rightToLeft?"left":"right"]="",a.style[i.rightToLeft?"right":"left"]=m+"%",!l||!i.showProgressLabel)return;const u=i.progressLabelFormatFunction;c.setAttribute("show-progress-label",""),l.setAttribute("value",u?u(n)+"":parseFloat(n.toFixed(2))+"%")}_setTaskDeadline(e,t,i){const n=this,a=e.task,{timelineStart:s,timelineEnd:r}=i,o=a.deadline,l=n.$.timelineDeadlines,c=l.children,d=o&&o.getTime&&!isNaN(o.getTime())?o.getTime():void 0;let m;for(let e=0,i=c.length;e<i;e+=1){const i=c[e];if(parseInt(i.getAttribute("task-index"))===t){m=i;break}}if(!d||d<s||d>r)return void(m&&m.remove());const u=n._getTimelineCellByDate(o),[h,g]=n.rightToLeft?["right","left"]:["left","right"];m||(m=document.createElement("div"),m.classList.add("smart-gantt-chart-task-deadline"),m.setAttribute("task-index",t),l.appendChild(m)),m.setAttribute("date",o.toString()),m.setAttribute("title",n._formatDate(o)),m.style.top=e.top+"px",m.style[g]="",m.style[h]=u.left+(n._getTimelineTaskOffset(u,o)||0)+"px"}_setTaskBarDeadline(e,t){const i=this,n=e.deadline;if(!n||!n.getTime||isNaN(n)||!t)return;const a=e.deadline.getTime()-e.dateEnd.getTime();if(!e.deadline||a>0)return t.removeAttribute("deadline"),void(e.overdue=!1);e.overdue=!0,t.setAttribute("deadline",`${i.localize("overdue")}: ${Math.round(i._convertDuration(Math.abs(a),!0))} ${i.durationUnit+"s"}`)}_setTaskIndicators(e,t,i){const n=this,a=e.task,{timelineStart:s,timelineEnd:r}=i,[o,l]=n.rightToLeft?["right","left"]:["left","right"],c=n.$.taskIndicatorsContainer,d=c.children,m=a.indicators;let u;for(let e=0,i=d.length;e<i;e+=1){const i=d[e];if(parseInt(i.getAttribute("task-index"))===t){u=i;break}}if(!Array.isArray(m))return void(u&&u.remove());const h=document.createDocumentFragment(),g=document.createDocumentFragment();u||(u=document.createElement("div"),u.classList.add("smart-gantt-chart-indicator"),u.setAttribute("task-index",t),h.appendChild(u));const f=u.children;for(;f.childElementCount>m.length;)f.firstElementChild.remove();for(let t=0,i=m.length;t<i;t+=1){let i=f[t];const a=m[t],c=a.date;if(!c||!c.getTime){i&&i.remove();continue}const d=c.getTime();if(d<s||d>r){i&&i.remove();continue}const u=n._getTimelineCellByDate(c),h=a.label,p=a.className,_=a.icon;i||(i=document.createElement("div"),g.appendChild(i)),i.className="smart-gantt-chart-task-indicator",i._indicatorObj=a;const T=i.classList;"string"==typeof p&&T.add(p),_?(T.add("icon"),i.style.setProperty("--smart-gantt-chart-indicator-icon",`'${_}'`)):T.contains("icon")&&(T.remove("icon"),i.style.removeProperty("--smart-gantt-chart-indicator-icon")),i.textContent=h||"",i.style.top=e.top+"px",i.style[l]="",i.style[o]=u.left+(n._getTimelineTaskOffset(u,c)||0)+"px"}g.childElementCount&&u.appendChild(g),h.childElementCount&&c.appendChild(h)}_setTimelineTaskBar(e,t,i){const n=this,a=e.task,s=void 0===t?n._getTaskDOMIndex(a):t,r=n.$.timelineTasksContainer.children,o=r[s];let l,c;if(0===r.length||!o||!o.classList||!o.classList.contains("smart-timeline-task"))return;const d=a.dateStart instanceof Date?a.dateStart:new Date(a.dateStart),m=a.dateEnd instanceof Date?a.dateEnd:new Date(a.dateEnd);if(l=!i&&o._cellStart||n._getTimelineCellByDate(d),c=!i&&o._cellEnd||n._getTimelineCellByDate(m),!l||!c)return void o.classList.add("smart-visibility-hidden");o._cellStart=l,o._cellEnd=c,o.classList.remove("smart-visibility-hidden");const u=n._getTaskBarDetails(e,l,c);u&&(o.style[n.rightToLeft?"left":"right"]="",o.style[n.rightToLeft?"right":"left"]=u.left+"px",o.style.width=u.width?u.width+"px":"",o.style.top=u.top+"px"),n._setTaskBarSegments(e,o,i)}_setTimelineTaskBaseline(e,t){const i=this,n=e.task,a=i.$.timelineBaselinesContainer;if(!i.showBaseline)return void(a.innerHTML&&(a.innerHTML=""));const s=n.planned,r=a.children;let o;for(let e=0,i=r.length;e<i;e+=1){const i=r[e];if(parseInt(i.getAttribute("task-index"))===t){o=i;break}}if(!s||"milestone"===n.type||!s.dateStart||!s.dateEnd)return void(o&&o.remove());const l=s.dateStart,c=s.dateEnd,d=i._getTimelineCellByDate(l),m=i._getTimelineCellByDate(c);if(!d||!m)return;o||(o=document.createElement("div"),o.classList.add("smart-gantt-chart-task-baseline"),o.setAttribute("task-index",t),a.appendChild(o));const[u,h]=i.rightToLeft?["right","left"]:["left","right"],g=i._getTaskBarDetails(e,d,m);if(g){const e=o.style;e.width=g.width?g.width+"px":"",e.top=g.top+"px",e[u]=g.left+"px",e[h]=""}o.setAttribute("aria-label",n.label+" Start date: "+i._toISODate(l)+", End date: "+i._toISODate(c))}_setTaskBarSegments(e,t,i){const n=this,a=e.task,s=t.querySelector(".smart-task-segments").children;let r,o,l=a.segments;if(Array.isArray(l)&&l&&l.length&&"task"===a.type||(l=[a]),1===l.length){const e=s[0].style;return void(e.right=e.left=e.width="")}const c=n.rightToLeft,d=parseFloat(t.style[c?"right":"left"]);let m;for(let e=0,t=l.length;e<t;e+=1){const t=l[e],a=s[e];if(!a)continue;const u=t.dateStart instanceof Date?t.dateStart:new Date(t.dateStart),h=t.dateEnd instanceof Date?t.dateEnd:new Date(t.dateEnd);r=!i&&a._cellStart||n._getTimelineCellByDate(u),o=!i&&a._cellEnd||n._getTimelineCellByDate(h),a._cellStart=r,a._cellEnd=o;const g=n._getTaskBarDetails({task:t},r,o);g&&(a.style[c?"left":"right"]="",a.style[c?"right":"left"]=Math.max(0,g.left-d)+"px",a.style.width=g.width+"px"),m=a}n._setTaskBarDeadline(a,m)}_setCurrentTimeIndicators(){const e=this;if(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval,e.currentTimeIndicator||e.shadeUntilCurrentTime)e._refreshTimeIndicators(),e._currentTimeIndicatorInterval=setInterval(e._refreshTimeIndicators.bind(e),1e3*e.currentTimeIndicatorInterval);else{const t=e.$.timelineIndicatorsContainer;t&&t.remove()}}_refreshTimeIndicators(){const e=this,t=new Date,i=e.view,n=e._getTodayCellObj(t);let a=e.$.timelineIndicatorsContainer;if(!n)return a&&a.remove(),clearInterval(e._currentTimeIndicatorInterval),void delete e._currentTimeIndicatorInterval;a||(e.$.timelineIndicatorsContainer=a=document.createElement("div"),a.classList.add("smart-gantt-chart-time-indicators-container"),a.setAttribute("role","presentation"));const s=new Date(n.date);let r,o,l=t.getMinutes();switch(i){case"year":{const e=new Date(t.getFullYear(),t.getMonth()+1,1,0,0,0,0);e.setDate(0),l+=24*t.getDate()*60,r=24*e.getDate()*60;break}case"month":l+=24*(t.getDay()+1)*60,r=10080;break;case"week":l+=60*t.getHours(),r=1440;break;case"day":r=s.getHours()+60}o={cellObj:n,minutes:l,max:r,today:t},e._refreshCurrentTimeShader(o),e._refreshCurrentTimeIndicator(o),a.childElementCount||(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval),a.parentElement||e.$.timelineContent.appendChild(a)}_refreshCurrentTimeIndicator(e){const t=this,i=t.$.timelineIndicatorsContainer;let n=i.querySelector(".smart-gantt-chart-current-time-indicator");if(!t.currentTimeIndicator||!e)return void(n&&n.remove());const{cellObj:a,minutes:s,max:r}=e;n||(n=document.createElement("div"),n.classList.add("smart-gantt-chart-current-time-indicator")),t.rightToLeft?n.style.right=a.left+a.width*(s/r)+"px":n.style.left=a.left+a.width*(s/r)+"px",n.setAttribute("aria-label","Current Time Indicator"),n.parentElement||i.appendChild(n),t._setTodayCell(a.date)}_refreshCurrentTimeShader(e){const t=this.$.timelineIndicatorsContainer;let i=t.querySelector(".smart-gantt-chart-current-time-shader");if(!this.shadeUntilCurrentTime||!e)return void(i&&i.remove());const{cellObj:n,minutes:a,max:s}=e;i||(i=document.createElement("div"),i.classList.add("smart-gantt-chart-current-time-shader")),i.style.width=n.left+n.width*(a/s)+"px",i.setAttribute("aria-label","Current Time Shader"),i.parentElement||t.appendChild(i)}_setTodayCell(e){const t=this;if(e)e instanceof Date&&(e=e.getTime());else{let i=0;e=new Date,"day"===t.view&&(i=e.getHours()),e.setHours(i,0,0,0),e=e.getTime()}if("number"!=typeof e)return;const i=t.$.timelineViewCells.children;for(let t=0;t<i.length;t++){const n=i[t],a=new Date(n._date);a&&(a.getTime()===e?n.setAttribute("current",""):n.removeAttribute("current"))}}_getTodayCellObj(e){const t=this.view,i=this._timelineCells;e&&e.getTime||(e=new Date);for(let n=0,a=i.length;n<a;n+=1){const a=i[n],s=a.date;switch(t){case"year":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth())return a;break;case"month":{const t=new Date(e);if(t.setDate(e.getDate()-e.getDay()),e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&t.getDate()===s.getDate())return a;break}case"week":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate())return a;break;case"day":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate()&&s.getHours()===e.getHours())return a}}}_getTaskDOMIndex(e){const t=this.$.timelineTasksContainer.children;if(!e||void 0===e.$.id)return-1;for(let i=0,n=t.length;i<n;i+=1)if(t[i]._cellObj.task===e)return i;return-1}_getTimelineCellByDate(e,t,i){const n=this,a=n._timelineCells;if(!a||0===a.length)return;const s=a.length-1;i=Math.min(s,"number"==typeof i?i:s);for(let s=t=Math.min(i,Math.max(0,"number"==typeof t?t:0));s<=i;s++){const t=a[s];if(!t)continue;const i=t.date;switch(n.view){case"year":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth())return t;break;case"month":{const n=new Date(i);let a=new Date(i);if(a.setDate(a.getDate()+(6-a.getDay())+1),a.setMilliseconds(a.getMilliseconds()-1),e.getTime()>=n.getTime()&&e.getTime()<=a.getTime())return t;break}case"week":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate())return t;break;case"day":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours())return t}}const r=a[0],o=a[a.length-1];return e.getTime()<r.date.getTime()?r:e.getTime()>o.date.getTime()?o:void 0}_refreshViewDetailCell(e,t,i){const n=this,a=n._timelineCells,s=e.date;let r=0,o=0===i?0:void 0;for(void 0===t&&(t=0);t<a.length;t++){const e=a[t],i=n._getCellWidth(e,s);if(i)void 0===o&&(o=e.left+e.width-i),r+=i;else if(e.date.getTime()>s.getTime())break}return n._isLastWeekCellNotFull&&(delete n._isLastWeekCellNotFull,t--),e.width=r,e.left=o,t}_getCellWidth(e,t){const i=this,n=e.date,a=(e,t)=>e.getFullYear()===t.getFullYear(),s=(e,t)=>e.getMonth()===t.getMonth(),r=e.width;switch(i.view){case"month":{let e=new Date(n),o=new Date(e),l=0;for(o.setDate(o.getDate()+(6-e.getDay())+1),o.setMilliseconds(o.getMilliseconds()-1);e.getTime()<=o.getTime();)a(e,t)&&s(e,t)&&l++,e.setDate(e.getDate()+1);if(0===l)return;return i._isLastWeekCellNotFull=l/7!=1,r*l/7}case"year":if(a(n,t))return r;break;case"week":{const e=new Date(t),i=new Date(t);if(e.setDate(t.getDate()-t.getDay()),i.setDate(t.getDate()+(6-t.getDay())),n.getTime()>=e.getTime()&&n.getTime()<=i.getTime())return r;break}case"day":if(a(n,t)&&s(n,t)&&n.getDate()===t.getDate())return r}}_getCellByOffsetLeft(e){const t=this._timelineCells;if(!e)return;let i;for(let n=0;n<t.length&&!(t[n].left>=e);n++)i=t[n];return i}_unselectAll(e,t){const i=this,n=i.$[`${e}TimelineCellsContainer`];let a;delete i._selected;const s=n.querySelectorAll(".smart-timeline-row[selected]");for(let e=0;e<s.length;e++)s[e].removeAttribute("selected");if("task"===e){a="selectedTaskIds";const e=i.$.timelineTasksContainer.querySelectorAll(".smart-timeline-task[selected]");for(let t=0;t<e.length;t++)e[t].removeAttribute("selected"),e[t].setAttribute("aria-selected","false")}else a="selectedResourceIds";if(i[`_${e}TreeChangeEventFired`]||i.$[e+"Table"].clearSelection(),i._highlightAssignedItem(e),t)return;const r=i[a].slice(0);r.length&&(i[a]=[],i._noChangeEvent||i.$.fireEvent("change",{value:[],oldValue:r,type:e}))}_getSegmentCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-task-segment"))return;const i=e.closest(".smart-timeline-task");if(!i)return;let n,a,s=i._cellStart,r=i._cellEnd;s&&r||({cellStart:s,cellEnd:r}=t._getTaskBarCellRange(i));const o=t.rightToLeft,l=parseFloat(e.style.width)||e.offsetWidth,c=t._timelineCells;let d=parseFloat(i.style[o?"right":"left"]);d&&!isNaN(d)||(d=i.offsetLeft,o&&(d=t.$.timelineContent.offsetWidth-d));const m=d+parseFloat(e.style[o?"right":"left"])||(o?(parseFloat(i.style.width)||i.offsetWidth)-(e.offsetLeft+e.offsetWidth):e.offsetLeft),u=parseFloat((m+l).toFixed(2));for(let e=c.indexOf(s),t=c.indexOf(r);e<=t;e++){const t=c[e],i=t.left,s=t.width,r=parseFloat((i+s).toFixed(2));if(m>=i&&m<=r&&(n=t),!a&&u>i&&u<=r&&(a=t),n&&a)break}return n||(n=a||c[0]),a||(a=c[c.length-1]),{cellStart:n,cellEnd:a}}_getTaskBarCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-timeline-task"))return;let i=parseFloat(e.style.width)||e.offsetWidth;const n=t._timelineCells,a=t.$.timelineContent,s=parseFloat(e.style[t.rightToLeft?"right":"left"])||(t.rightToLeft?(parseFloat(a.style.width)||a.offsetWidth)-(e.offsetLeft+e.offsetWidth):e.offsetLeft);let r,o;e.classList.contains("milestone")&&(i/=2);const l=parseFloat((s+i).toFixed(2));for(let e=0;e<n.length;e++){const t=n[e],i=t.left,a=t.width,c=parseFloat((i+a).toFixed(2));if(s>=i&&s<=c&&(r=t),!o&&l>i&&l<=c&&(o=t),r&&o)break}return r||(r=e.classList.contains("milestone")&&o?o:n[0]),o||(o=n[n.length-1]),{cellStart:r,cellEnd:o}}_getDateFromCell(e,t,i){if(!t)return new Date;const n=this,a=new Date(t.date);let s,r=0,o=0,l=new Date(a);switch(l.setHours(0,0,0,0),i||(i=n.view),i){case"year":s=new Date(a.getFullYear(),a.getMonth()+1,0).getDate(),r=1,l.setDate(s);break;case"month":r=a.getDate(),s=7,l.setDate(l.getDate()+6);break;case"week":s=1,r=a.getDate();break;case"day":s=1/24,r=a.getDate(),o=a.getHours()}l.setHours(23,59,59,999);const c=parseFloat(((e-t.left)/t.width*s).toFixed(12)),d=Math.min(s,Math.floor(c)),m=c%1*24,u=Math.floor(m),h=60*Math.abs(m-u),g=Math.floor(h),f=60*Math.abs(h-g),p=Math.floor(f),_=1e3*Math.abs(f-p),T=Math.floor(_),k=new Date(a.getFullYear(),a.getMonth(),r+d,o+u,g,p,T);return k.getTime()>l?l:k}_getCellDateRange(e){if(!e||!e._date)return;const t=new Date(e._date);let i=new Date(t);switch(i.setHours(0,0,0,0),this.view){case"year":i.setDate(1),i.setMonth(i.getMonth()+1),i.setDate(0);break;case"month":i.setDate(i.getDate()+6);break;case"day":return i.setHours(t.getHours(),59,59,999),{dateStart:t,dateEnd:i}}return i.setHours(23,59,59,999),{dateStart:t,dateEnd:i}}_getTasksJSON(){const e=this;let t=e._tasks;return function t(i,n){if(!i)return;let a=[];for(let s=0;s<i.length;s++){const r=i[s];let o;if(!r.$.project&&!n||r.$.project===n){const i=e._getTaskConnections(r).taskConnections;o=e._cloneObject(r,!0),i.length&&(o.connections=i.map((e=>{const t={target:e.endIndex,type:e.type};return e.lag&&(t.lag=e.lag),t}))),o.tasks=t(e._getProjectTasks(r),r),delete o.$,a.push(o)}}return a}(t)}_cloneObject(e,t){let i={};for(let n in e){let a=e[n];"tasks"!==n&&("connections"!==n?a instanceof Date?i[n]=t?a.toISOString():new Date(a):i[n]=a:i[n]=JSON.parse(JSON.stringify(a)))}return t||delete i.$,i}_setTable(e){const t=this;e||(e=t.$.taskTable);const[i,n]=e===t.$.taskTable?[t.taskColumns,"task"]:[t.resourceColumns,"resource"];if(!t.contains(e))return;if(!i.length)return void(t.$[n+"Table"].dataSource=[]);const a=t._getTableColumns(n);"task"===n&&(e.filterRow=t.filterRow,[e.grouping,e.groupFormatFunction]=t.groupByResources?[!0,t._formatResourceGroups.bind(t)]:[!1,null]),e.isRendered&&e.resetState("expanded"),e.style.setProperty("--smart-table-row-height",""),e.columns=a,e.dataSource=t._getTableDataSource(n,a),e.wait&&(t.$.taskTable.hasResizeObserver=!1,e.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,e.$.virtualizationContainer.verticalScrollBarVisibility="hidden",e.$.virtualizationContainer.disabled=!0,e.columnMinWidth=t.columnMinWidth,e.columnResize=t.columnResize,e.columnResizeFeedback=t.columnResizeFeedback,e.filtering=t[`${n}Filtering`],e.sort=t.sortFunction,e.sortMode=t.sortMode,e.keyboardNavigation=t.keyboardNavigation,e.selectionByHierarchy=!1,e.selection=!t.disableSelection,e.hideSelectionColumn=!t.showSelectionColumn,e.onKeyboardScroll=(i,n)=>{const a=e===t.$.taskTable?t:t._resourceScrollView;n!==a.scrollTop&&(a.scrollTop=n)},e.wait=!1),e.$.virtualizationContainer.scrollTop="task"===n?t.scrollTop:t.$.resourceVerticalScrollBar.value,t._refresh()}_formatResourceGroups(e){const t=this,i=t._resources,n=e.data.data.resources.split(",");let a=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";n.indexOf(s)>-1&&a.push(t.label||t.value||t.id)}t.resourceGroupFormatFunction?e.template=t.resourceGroupFormatFunction(n):e.template="<strong>"+(a.length?a.join(", "):t.localize("unassigned"))+"</strong>"}_formatResourceGroupLabel(e){const t=this,i=t._resources,n=e.split(",");if(!e)return t.localize("unassigned");let a=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";n.indexOf(s)>-1&&a.push(t.label||t.value||t.id)}return a.length?a.join(", "):t.localize("unassigned")}_getTableColumns(e="task"){const t=this,i=["dateStart","dateEnd","minDateStart","maxDateStart","minDateEnd","maxDateEnd"],n=["progress","capacity","workload","maxCapacity","minCapacity"];let a="task"===e?t.taskColumns:t.resourceColumns,s=[];"task"===e&&t.groupByResources&&!a.find((e=>"resources"===e.value))&&(a=a.slice(0),a.push({label:"",value:"resources",hidden:!0}));for(let r=0,o=a.length;r<o;r++){const o=a[r],l=o.value,c={};c.label=t.localize(o.label)||o.label,c.dataField=l,l.startsWith("date")||i.indexOf(l)>-1?c.dataType="date":c.dataType="overdue"===l?"boolean":l.startsWith("duration")||n.indexOf(l)>-1?"number":"string",o.hidden&&(c.visible=!1),"function"==typeof o.formatFunction?c.formatFunction=i=>{const n=t._getValidItemAndIndex(i.data.itemId,e).item,a=i.column.toLowerCase();let s=i.value;a.indexOf("date")>-1?s=new Date(s):"resources"===a&&(s=s?s.split(","):[]),i.template=o.formatFunction.call(t,s,n?t._cloneObject(n):void 0)}:["date","number"].indexOf(c.dataType)>-1?c.formatFunction=i=>{const n=t._getValidItemAndIndex(i.data.itemId,e).item,a=t._formatColumnData(t._cloneObject(n),o);i.template=a}:"overdue"===l&&(c.formatFunction=e=>{const t=e.cell;e.value+""=="true"?t.setAttribute("overdue",""):t.removeAttribute("overdue"),e.value=""},c.width=t._taskDefaultHeight),o.size&&(c.width=o.size),s.push(c)}return s}_getTableDataSource(e="task",t){const i=this,n="task"===e?i._getTableData(i._tasks,i.taskColumns,e):i._getTableData(i._resources,i.resourceColumns,e),a=i.groupByResources,s=(()=>{let e=[];e.push("itemId: string"),e.push("projectId: string"),e.push("itemIndex: number"),a&&e.push("resources: string");for(let i=0,n=t.length;i<n;i+=1){const n=t[i];e.push(`${n.dataField}: ${n.dataType}`)}return e})();return i.groupByResources?new window.Smart.DataAdapter({dataFields:s,dataSource:n,groupBy:["resources"],id:"itemId"}):new window.Smart.DataAdapter({dataFields:s,dataSource:n,keyDataField:"itemId",parentDataField:"projectId",id:"itemId"})}_refreshTableDataSource(e="task"){const t=this,i="task"===e?t.$.taskTable:t.$.resourceTable;t.contains(i)&&(i.resetState("expanded"),i.dataSource=t._getTableDataSource(e,t._getTableColumns(e)))}_refreshColumnsHeaders(e){const t=this;e||(e="task");const i=t.$[`${e}Table`].columns,n=t[`${e}Columns`];for(let e=0,a=i.length;e<a;e++)i[e].label=t.localize(n[e].label)||n[e].label;!arguments.length&&t.$.mainSplitter.contains(t.$.resourceSplitter)&&t._refreshColumnsHeaders("resource")}_getTaskResourceIds(e){const t=e.resources,i=this._resources.map((e=>e.id));let n=[];if(Array.isArray(t))for(let e=0,a=t.length;e<a;e+=1){const a=t[e].id||t[e];i.indexOf(a)>-1&&n.push(a)}return n.sort()}_getTableData(e,t,i){const n=this,a=n.groupByResources;i||(i="task");const s=t.map((e=>e.value));let r=[],o=[];for(let l=0,c=e.length;l<c;l+=1){const c=e[l];if(c.hidden||a&&c.disableResources)continue;const d={},m=c.$.project,u=n._getTaskResourceIds(c);for(let e=0,a=s.length;e<a;e+=1)d[s[e]]=n._formatColumnData(c,t[e],i);d.expanded=a||c.expanded,d.itemId=c.$.id||c.id||"",d.itemIndex=l,u&&u.length?d.resources=u.toString():delete d.resources,c.$&&m&&(m.$.id?d.projectId=c.$.project.$.id:o.push(((e,t)=>{e.projectId=t.$.id}).bind(null,c,m))),r.push(d)}for(let e=0,t=o.length;e<t;e+=1)o[e]();return r}_formatColumnData(e,t){const i=this,n=t.value;let a=e[n];if(n){const e=(n+"").toLowerCase();if(e.indexOf("date")>-1||t.dateFormat)return i._formatDate(a,t);if(e.indexOf("duration")>-1||t.numberFormat){const e=parseFloat(a.toFixed(1));return t.numberFormat?i._formatNumber(e,t.numberFormat):e}}return null!=a?a.toString():i.localize("unassigned")}_formatDate(e,t){const i=this;if(e=Date.parse(e),!isNaN(e)){let n=t?t.dateFormat:void 0;if("string"==typeof n)return new Smart.Utilities.DateTime(new Date(e)).toString(n);if("object"==typeof n)n=t.dateFormat;else{const e=i.view;n={year:"numeric",month:"2-digit",day:"numeric"},["day","week"].indexOf(e)>-1&&(n.hour="numeric",n.minute="numeric",n.second="numeric")}return new Intl.DateTimeFormat(i.locale,n).format(new Date(e))}}_formatNumber(e,t,i){const n=this;if("object"==typeof t)return new Intl.NumberFormat(n.locale,t).format(""+e);i||(i={percentSymbol:"%",currencySymbol:"$",currencySymbolPosition:"before",decimalSeparator:".",thousandsSeparator:","});const a=e=>"number"==typeof e&&isFinite(e);if(""===t||null===t)return e;let s;a(e)||(e*=1),t.length>1&&(s=parseInt(t.slice(1),10));let r={},o=t.charAt(0).toUpperCase();switch(r.thousandsSeparator=i.thousandsSeparator,r.decimalSeparator=i.decimalSeparator,o){case"D":case"d":case"F":case"f":r.decimalPlaces=s;break;case"N":case"n":r.decimalPlaces=0;break;case"C":case"c":r.decimalPlaces=s,"before"===i.currencySymbolPosition?r.prefix=i.currencySymbol:r.suffix=i.currencySymbol;break;case"P":case"p":r.suffix=i.percentSymbol,r.decimalPlaces=s;break;default:throw"Bad number format specifier: "+o}if(a(e)){const t=e<0;let i=e+"";const n=r.decimalSeparator?r.decimalSeparator:".";let s;if(a(r.decimalPlaces)){var l=r.decimalPlaces,c=Math.pow(10,l);if(i=(e*c).toFixed(0)/c+"",s=i.lastIndexOf("."),l>0)for(s<0?(i+=n,s=i.length-1):"."!==n&&(i=i.replace(".",n));i.length-1-s<l;)i+="0"}else{let t=e+"";s=t.lastIndexOf("."),s>0&&void 0===l&&"."!==n&&(t=t.replace(".",n))}if(r.thousandsSeparator){const e=r.thousandsSeparator;s=i.lastIndexOf(n),s=s>-1?s:i.length;let a=i.substring(s),o=-1;for(var d=s;d>0;d--)o++,o%3==0&&d!==s&&(!t||d>1)&&(a=e+a),a=i.charAt(d-1)+a;i=a}return i=r.prefix?r.prefix+i:i,i=r.suffix?i+r.suffix:i,i}return e}_validateDate(e,t){return e[t]=this._dateValidator(void 0,e[t]),e[t]&&!isNaN(e[t].getTime())||(e[t]=void 0),e[t]}_validateTaskProperties(e,t){const i=this;if(e.$={},e.tasks instanceof Array&&e.tasks.length>0?e.type="project":(!e.type||["project","task","milestone"].indexOf(e.type)<0)&&(e.type="task"),i._validateTaskDuration(e),void 0===e.hidden&&t&&(e.hidden=t.hidden),e.hidden=!!e.hidden,void 0===e.resources?e.resources=[]:e.resources=[e.resources].reduce(((e,t)=>e.concat(t)),[]),"project"===e.type?e.expanded=!!e.expanded:delete e.expanded,e.progress=Math.min(Math.max(0,parseFloat(e.progress)||0),100),i._validateTaskDates(e,t),i._validateTaskSegments(e),i._validateTaskIndicators(e),i._validateTaskPlannedDates(e),e.deadline){const t=i._validateDate(e,"deadline");!t||isNaN(t.getTime())?delete e.deadline:e.dateEnd&&(e.overdue=e.deadline.getTime()-e.dateEnd.getTime()<0)}else e.overdue=!1,delete e.deadline;if(!e.dateStart&&!e.dateEnd&&"project"===e.type&&!e.synchronized)return;const n=e.connections;if(n instanceof Array){for(let e=0;e<n.length;e++){const t=n[e],i=t.target="string"==typeof t.target?t.target:parseInt(t.target),a=t.type=parseInt(t.type);null==i||"number"==typeof i&&isNaN(i)||isNaN(a)?(n.splice(n.indexOf(t),1),e--):t.lag=parseInt(t.lag)||0}e.connections=e.connections.map((e=>Object.assign({},e)))}else e.connections=[];return e.class=e.class?e.class+"":"",e.class=void 0!==e.class&&null!==e.class?e.class:"",e}_validateTaskIndicators(e){const t=this,i=e.indicators;if(!i||!Array.isArray(i)||!i.length)return void delete e.indicators;let n=[];for(let e=0,a=i.length;e<a;e+=1){const a=i[e];if("object"!=typeof a)continue;const s=t._validateDate(a,"date");s&&s.getTime&&!isNaN(s.getTime())&&n.push(a)}e.indicators=n}_validateTaskSegments(e){const t=this,i=e.segments;if(!i||!Array.isArray(i)||i.length<2||"task"!==e.type)return void delete e.segments;const n=t.nonworkingDays.length>0||t.nonworkingHours.length>0;let a,s=[],r=[];for(let e=0,n=i.length;e<n;e+=1){const n=i[e];if("object"!=typeof n)continue;let a=parseFloat(n.duration);isNaN(a)&&delete n.duration,t._validateTaskDates(n),n.dateStart&&n.dateEnd&&s.push(n)}s.sort(((e,t)=>e.dateStart.getTime()-t.dateStart.getTime()));for(let i=0,o=s.length;i<o;i+=1){const o=s[i];let l=o.dateStart,c=o.dateEnd;o.dateStart=l=new Date(Math.max(e.dateStart.getTime(),l.getTime())),o.dateEnd=c=new Date(Math.min(e.dateEnd.getTime(),c.getTime())),a&&a.dateEnd.getTime()>l.getTime()&&(o.dateStart=l=new Date(a.dateEnd.getTime()+1e3),l.getTime()>=c.getTime())||l.getTime()>c.getTime()||(o.duration=t._convertDuration(n?t._getWorkingTime(l,c):c.getTime()-l.getTime(),!0),a=o,r.push(o))}r.length<2?delete e.segments:(r[0].dateStart=new Date(e.dateStart),r[r.length-1].dateEnd=new Date(e.dateEnd),e.segments=r)}_validateTaskDuration(e){const t=this;let i=t._convertDuration(parseFloat(e.duration))||0,n=t._convertDuration(parseFloat(e.minDuration))||0,a=t._convertDuration(parseFloat(e.maxDuration))||0;n&&a&&(a=Math.max(n,a)),i&&(n?i=Math.max(n,i):a&&(i=Math.min(i,a))),e.duration=t._convertDuration(i,!0),e.minDuration=t._convertDuration(n,!0),e.maxDuration=t._convertDuration(a,!0)}_validateTaskDates(e,t){const i=this,n=i._convertDuration(e.minDuration),a=i._convertDuration(e.maxDuration);let s=i._convertDuration(e.duration);if(void 0!==e.minDateStart&&(e.minDateStart=i._validateDate(e,"minDateStart")),void 0!==e.maxDateStart&&(e.maxDateStart=i._validateDate(e,"maxDateStart")),e.minDateStart&&e.maxDateStart&&(e.maxDateStart=new Date(Math.max(e.minDateStart.getTime(),e.maxDateStart.getTime()))),void 0!==e.minDateEnd&&(e.minDateEnd=i._validateDate(e,"minDateEnd")),void 0!==e.maxDateEnd&&(e.maxDateEnd=i._validateDate(e,"maxDateEnd")),e.minDateEnd&&e.maxDateEnd&&(e.maxDateEnd=new Date(Math.max(e.minDateEnd.getTime(),e.maxDateEnd.getTime()))),e.dateStart=i._validateDate(e,"dateStart"),e.dateEnd=i._validateDate(e,"dateEnd"),e.dateStart||(e.minDateStart?e.dateStart=e.minDateStart:e.maxDateStart?e.dateStart=e.maxDateStart:e.dateStart=i.dateStart),e.dateEnd||(e.minDateEnd?e.dateEnd=e.minDateEnd:e.maxDateEnd&&(e.dateEnd=e.maxDateEnd)),e.minDateStart&&(e.dateStart=new Date(Math.max(e.minDateStart.getTime(),e.dateStart.getTime()))),e.maxDateStart&&(e.dateStart=new Date(Math.min(e.maxDateStart.getTime(),e.dateStart.getTime()))),e.minDateEnd&&(e.dateEnd=new Date(Math.max(e.minDateEnd.getTime(),e.dateEnd.getTime()))),e.maxDateEnd&&(e.dateEnd=new Date(Math.min(e.maxDateEnd.getTime(),e.dateEnd.getTime()))),e.dateStart&&(i.min&&(s=Math.min(e.dateStart.getTime()-i.min.getTime(),s),e.duration=i._convertDuration(s,!0)),i.max&&(s=Math.min(i.max.getTime()-e.dateStart.getTime(),s),e.duration=i._convertDuration(s,!0))),!e.dateStart&&s&&e.dateEnd&&(e.dateStart=new Date(e.dateEnd.getTime()-s)),"task"!==e.type||e.dateStart&&!isNaN(e.dateStart.getTime())||!t||(e.dateStart=new Date(t.dateStart)),n&&e.dateStart)if(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)){const t=i._getTaskWorkingDateEnd(e,n);e.dateEnd=new Date(Math.max(e.dateEnd?e.dateEnd.getTime():0,t.getTime()))}else e.dateEnd=new Date(Math.max(e.dateEnd?e.dateEnd.getTime():0,e.dateStart.getTime()+n));if(s&&e.dateStart&&(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?e.dateEnd=i._getTaskWorkingDateEnd(e,s):e.dateEnd=new Date(e.dateStart.getTime()+s)),s||a){let t;t=i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?i._getTaskWorkingDateEnd(e,Math.max(s,a)):new Date(e.dateStart.getTime()+Math.max(s,a)),e.dateEnd.getTime()>t.getTime()&&(e.dateEnd=t)}"task"===e.type&&!e.dateEnd&&t&&(e.dateEnd=new Date(t.dateEnd)),e.dateStart=i._minMaxDateValidator(e.dateStart),e.dateEnd=i._minMaxDateValidator(e.dateEnd),"milestone"===e.type&&(e.dateStart=i._validateDate(e,"dateStart"),e.dateEnd=i._validateDate(e,"dateEnd"),e.dateStart=e.dateEnd=new Date(Math.max(e.dateStart?e.dateStart.getTime():0,e.dateEnd?e.dateEnd.getTime():0))),(e.dateStart||e.dateEnd||"project"!==e.type||e.synchronized)&&("milestone"!==e.type&&e.dateStart&&(e.dateEnd&&e.dateStart.getTime()>e.dateEnd.getTime()||!e.dateEnd)&&(e.dateEnd=new Date(e.dateStart.getTime()+36e5*("day"===i.view?1:24))),e.dateStart&&e.dateEnd&&(e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0)))}_validateTaskPlannedDates(e){const t=this;if(!e)return;const i=e.type,n=e.planned;if("milestone"===i||!n)return;const a=t._validateDate(n,"dateStart"),s=t._validateDate(n,"dateEnd");a&&s&&(n.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(a,s):s.getTime()-a.getTime(),!0))}_synchronizeProjectDates(e,t){const i=this;if(e){void 0===t&&(t=i._getProjectTasks(e));for(let a=0,s=t.length;a<s;a+=1){const s=t[a];e.synchronized&&(s.dateStart&&(e.dateStart=n(s,"dateStart","min")),s.dateEnd&&(e.dateEnd=n(s,"dateEnd","max")),s.minDateStart&&(e.minDateStart=n(s,"minDateStart","max")),s.maxDateStart&&(e.maxDateStart=n(s,"maxDateStart","min")),s.minDateEnd&&(e.minDateEnd=n(s,"minDateEnd","max")),s.maxDateEnd&&(e.maxDateEnd=n(s,"maxDateEnd","min")),e.dateStart&&e.dateEnd&&(e.duration=i._convertDuration(i.nonworkingDays.length>0||i.nonworkingHours.length>0?i._getWorkingTime(e.dateStart,e.dateEnd):e.dateEnd.getTime()-e.dateStart.getTime(),!0)))}e.$&&i._synchronizeProjectDates(e.$.project,t)}function n(t,i,n){const a=e[i];let s=t[i];return void 0===a?new Date(s):s instanceof Date?new Date(Math[n](a.getTime(),s.getTime())):void 0}}_synchronizeProjectVisibility(e,t){const i=this;e&&e.hidden&&!t.hidden&&(e.hidden=t.hidden,e.$&&i._synchronizeProjectVisibility(e.$.project,e))}_mouseWheelHandler(e){const t=this,i=(t.shadowRoot||t).querySelector(".smart-task-popup-window");if(i&&i.modal&&i.opened)return void e.stopPropagation();if(t.disabled||!t.computedHorizontalScrollBarVisibility&&!t.computedVerticalScrollBarVisibility)return;if(e.shiftKey)return void t._handleHorizontalScroll(e);const n=t.$.resourceSplitterItem;t.$.mainSplitter.contains(n)&&n.contains(e.target)?t._handleVerticalScroll(e,!0):t.$.taskSplitterItem.contains(e.target)&&t._handleVerticalScroll(e)}_handleVerticalScroll(e,t){const i=this;let n,a,s,r;if(t){if(n=i.$.resourceVerticalScrollBar,n.classList.contains("smart-hidden")||n.disabled)return!0;a=n.value,s=n.max,r=i._resourceScrollView}else{if(!i.computedVerticalScrollBarVisibility||i.$.verticalScrollBar.disabled)return!0;a=i.scrollTop,s=i.scrollHeight,r=i}if(0===a&&e.deltaY<0||a===s&&e.deltaY>0)return void e.stopPropagation();const o=i.$[t?"resourceTable":"taskTable"];if(e.stopPropagation(),e.preventDefault(),a+=i._getScrollCoefficient(e,i.offsetHeight),r){const e=o.$.virtualizationContainer;e.scrollHeight!==r.scrollHeight&&(e.scrollHeight=r.scrollHeight),r.scrollTo(a,void 0)}o.scrollTop=a,i._hoveredItem&&i._handleTableItemHover()}_handleHorizontalScroll(e){const t=this;if(!t.computedHorizontalScrollBarVisibility)return!0;const i=t.scrollLeft;(0===i&&e.deltaX<0||i===t.scrollHeight&&e.deltaX>0)&&e.stopPropagation(),e.stopPropagation(),e.preventDefault(),t.scrollWidth>0&&t.scrollTo(void 0,t.scrollLeft+t._getScrollCoefficient(e,t.offsetWidth))}_handleHeaderTemplate(e="task"){const t=this;if(!("content"in document.createElement("template")))return void t.error(t.localize("htmlTemplateNotSuported",{elementType:t.nodeName.toLowerCase()}));const i=t.$[`${e}SplitterItemHeader`],n=t.$[`${e}SplitterItem`],a="task"===e?"headerTemplate":"resourcePanelHeaderTemplate";let s=t[a];if(n.removeAttribute("show-header"),i.innerHTML="",!s)return;if("function"==typeof s)return s(i,{}),void(i.innerHTML?n.setAttribute("show-header",""):n.removeAttribute("show-header"));if("string"==typeof s&&(s=document.getElementById(s)),null===s||!("content"in s))return void t.error(t.localize("invalidTemplate",{elementType:t.nodeName.toLowerCase(),property:a}));let r=document.importNode(s.content,!0);if(n.setAttribute("show-header",""),t.shadowRoot)return i.innerHTML="<slot></slot>",void t.appendChild(r);i.appendChild(r)}_handleCollapseExpandMethods(e,t){const i=this,n=i._tasks;if(null==e||!n||!n.length)return;const a=i._getValidItemAndIndex(e);if(!a||!a.item)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"collapse",argumentName:"task"}));let s=a.item;"project"!==s.type&&(s=s.$.project),s&&(s.hidden?s.expanded="expand"===t:i.$.taskTable["expand"===t?"expandRow":"collapseRow"](s.$.id))}_getValidItemAndIndex(e,t="task"){const i=this,n="task"===t?i._tasks:i._resources;let a;if(null==e||!n||!n.length)return{};if("string"==typeof e||"number"==typeof e){const t=e.toString();let i,s;for(let a=0,r=n.length;a<r;a+=1){const r=n[a];if(!i){const n=r.id;if(null!=n&&n.toString&&n.toString()===t){i=r,e=a;break}}r.$.id===t&&(s=r,e=a)}a=i||s}else"object"==typeof e&&(a=n[i._getItemIndex(e,t)],e=n.indexOf(a));return{item:a,index:e}}_horizontalScrollbarHandler(e){const t=this,i=t._getScrollLeft(e.detail.value);e.stopPropagation&&e.stopPropagation(),t.$.timelineHeader.scrollLeft=t.$.taskTimelineContainer.scrollLeft=i,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=i),t._recycle(e),e.context.min!==e.context.value?e.context.max===e.context.value&&(t._handleInfiniteTimeline(),t.$.fireEvent("scrollRightReached")):t.$.fireEvent("scrollLeftReached")}_verticalScrollbarHandler(e){const t=this,i=e.target,n=Math.round(e.detail.value);e.stopPropagation&&e.stopPropagation(),i&&i===t.$.resourceVerticalScrollBar?t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=n:(t.$.taskTimelineContainer.scrollTop=n,t.$.taskTable.scrollTop=n),t._recycle(e),e.context.max!==e.context.value?e.context.min===e.context.value&&t.$.fireEvent("scrollTopReached"):t.$.fireEvent("scrollBottomReached")}_handleInfiniteTimeline(){const e=this,t=e._timelineCells;if(!e.infiniteTimeline||!t||!t.length)return;const i=e.infiniteTimelineStep,n=t[t.length-1].date;switch(e.view){case"year":n.setMonth(n.getMonth()+i);break;case"month":n.setDate(n.getDate()+7*i);break;case"week":n.setDate(n.getDate()+i);break;case"day":n.setHours(n.getHours()+i)}e.set("dateEnd",n),e._createTimelineCells(),e._recycleTimelineTasks(!0),e.$.mainSplitter.contains(e.$.resourceSplitter)&&e._refreshResourceTimeline(),e._refresh()}_nonworkingDayValidator(e,t){return this._nonworkingDateTimeValidator(e,t)}_nonworkingTimeValidator(e,t){return this._nonworkingDateTimeValidator(e,t,!0)}_nonworkingDateTimeValidator(e,t,i){const n=this,[a,s,r]=i?[0,23,24]:[0,6,7];let o=[];function l(e){let t=Math.max(a,Math.min(s,parseInt(e[0]))),i=Math.max(a,Math.min(s,parseInt(e[1])));if(!isNaN(t)&&!isNaN(i)){for(;t!==i;)o.push(t),t=t===s?a:++t;o.push(t)}return o}for(let e=0;e<t.length;e++){const i=t[e];"number"!=typeof i||isNaN(i)?"string"==typeof i?o=l(i.split("-").map((e=>parseInt(e)))):Array.isArray(i)&&(o=l(i)):o.push(Math.max(a,Math.min(s,parseInt(i))))}return o.length===r&&(o.pop(),n.warn(n.localize("invalidNonworkingRange",{elementType:n.nodeName.toLowerCase(),property:i?"nonworkingHours":"nonworkingDays"}))),o}});
91
91
 
92
92
  /***/ }),
93
93
 
@@ -150,7 +150,7 @@ Smart("smart-splitter-item",class extends Smart.ContentElement{static get proper
150
150
  /***/ 5523:
151
151
  /***/ (() => {
152
152
 
153
- Smart("smart-table",class extends Smart.ContentElement{static get properties(){return{autoLoadState:{value:!1,type:"boolean"},autoSaveState:{value:!1,type:"boolean"},columnGroups:{value:null,type:"array?"},columnMinWidth:{value:"50px",type:"any"},columnReorder:{value:!1,type:"boolean"},columnResize:{value:!1,type:"boolean"},columnResizeFeedback:{value:!1,type:"boolean"},columnResizeNormalize:{value:!1,type:"boolean"},columns:{value:[],type:"any?",reflectToAttribute:!1},columnSizeMode:{value:"default",allowedValues:["auto","default"],type:"string"},conditionalFormatting:{value:null,type:"array?",reflectToAttribute:!1},conditionalFormattingButton:{value:!1,type:"boolean"},deferredScrollDelay:{value:1,type:"number"},dataRowId:{value:null,type:"string?"},dataSource:{value:null,type:"any?",reflectToAttribute:!1},dataSourceSettings:{value:{autoGenerateColumns:{value:!1,type:"boolean"},sanitizeHTML:{value:"blackList",allowedValues:["all","blackList","none"],type:"string"},sanitizeHTMLRender:{value:"text",allowedValues:["text","html"],type:"string"},root:{value:"",type:"string"},record:{value:"",type:"string"},keyDataField:{value:"",type:"string"},parentDataField:{value:"",type:"string"},childrenDataField:{value:"",type:"string"},groupBy:{value:[],type:"array"},dataFields:{value:[],type:"array"},mapChar:{value:".",type:"string"},id:{value:"",type:"string"},virtualDataSource:{value:null,type:"any"},virtualDataSourceOnExpand:{value:null,type:"any"}},type:"object"},dataTransform:{value:null,type:"function?",reflectToAttribute:!1},editing:{value:!1,type:"boolean"},editMode:{value:"cell",allowedValues:["cell","row"],type:"string"},expandHierarchy:{value:!1,type:"boolean"},filtering:{value:!1,type:"boolean"},columnMenu:{value:!1,type:"boolean"},filterRow:{value:!1,type:"boolean"},filterTemplate:{value:null,type:"string?"},filterOperator:{value:"and",type:"string?"},footerRow:{value:null,type:"string?"},formulas:{value:!1,type:"boolean"},freezeFooter:{value:!1,type:"boolean"},freezeHeader:{value:!1,type:"boolean"},grouping:{value:!1,type:"boolean"},groupFormatFunction:{value:null,type:"any"},headerRow:{value:null,type:"any"},hideSelectionColumn:{value:!1,type:"boolean"},keyboardNavigation:{value:!1,type:"boolean"},loadColumnStateBehavior:{value:"implementationOnly",allowedValues:["stateOnly","implementationOnly","intersection"],type:"string"},messages:{value:{en:{add:"Add condition",all:"All columns",apply:"Apply",between:"Between",cancel:"Cancel",clearFilter:"Clear filter",close:"Close",column:"Column:",condition:"Condition:",conditionalFormatting:"Conditional Formatting",CONTAINS:"contains",CONTAINS_CASE_SENSITIVE:"contains (case sensitive)",DOES_NOT_CONTAIN:"does not contain",DOES_NOT_CONTAIN_CASE_SENSITIVE:"does not contain (case sensitive)",EMPTY:"empty",ENDS_WITH:"ends with",ENDS_WITH_CASE_SENSITIVE:"ends with (case sensitive)",EQUAL:"equal",equal:"Equal To",EQUAL_CASE_SENSITIVE:"equal (case sensitive)",filterCondition:"Filter condition",filterPlaceholder:"Filter",firstButton:"First",fontFamily:"Font family:",fontSize:"Font size:",format:"Format:",formatColumn:"Format Column",GREATER_THAN:"greater than",GREATER_THAN_OR_EQUAL:"greater than or equal",greaterThan:"Greater Than",highlight:"Highlight",invalidValue:"Invalid value",itemsPerPage:"Items per page:",lastButton:"Last",LESS_THAN:"less than",LESS_THAN_OR_EQUAL:"less than or equal",lessThan:"Less Than",nextButton:"Next",NOT_EMPTY:"not empty",NOT_EQUAL:"not equal",NOT_NULL:"not null",notEqual:"Not Equal To",NULL:"null",ok:"OK",previousButton:"Previous",remove:"Remove condition",secondValue:"Second value:",STARTS_WITH:"starts with",STARTS_WITH_CASE_SENSITIVE:"starts with (case sensitive)",summaryPrefix:"of",text:"Text",value:"Value:",with:"with",columnMenuItemSortAsc:"Sort Ascending",columnMenuItemSortDesc:"Sort Descending",columnMenuItemReset:"Reset",columnMenuItemRemoveSort:"Remove Sort",columnMenuItemFilter:"Show rows where:",columnMenuItemRemoveFilter:"Remove Filter",columnMenuItemColumns:"Columns",grouping:"Group field name is not found in the dataFields collection!"}},type:"object",extend:!0},onCellRender:{value:null,type:"function?",reflectToAttribute:!1},onColumnRender:{value:null,type:"function?",reflectToAttribute:!1},onInit:{value:null,type:"function?",reflectToAttribute:!1},pageSize:{value:10,allowedValues:[10,25,50],type:"int"},pageIndex:{value:0,type:"int"},paging:{value:!1,type:"boolean"},rowDetailTemplate:{value:null,type:"string?"},selected:{value:[],type:"array",reflectToAttribute:!1},selection:{value:!1,type:"boolean"},selectionMode:{value:"many",type:"string",allowedValues:["one","many","extended"]},selectionByHierarchy:{value:!0,type:"boolean"},sort:{value:null,type:"function?",reflectToAttribute:!1},sortMode:{value:"none",type:"string",allowedValues:["none","one","many"]},stateSettings:{value:["columns","expanded","filtered","grouped","selected","sorted"],type:"array"},tooltip:{value:!1,type:"boolean"},virtualization:{value:!1,type:"boolean"}}}static get listeners(){return{resize:"_resizeHandler","conditionalFormattingButton.click":"_conditionalFormattingButtonClickHandler","filterInput.keyup":"_filterInputKeyupHandler","pager.change":"_pagerChangeHandler","pager.pageSizeChanged":"_pagerPageSizeChanged","tableContainer.change":"_tableContainerChangeHandler","tableContainer.click":"_tableContainerClickHandler","tableContainer.down":"_tableContainerDownHandler","tableContainer.focus":"_tableContainerFocusHandler","tableContainer.pointerover":"_tableContainerPointeroverHandler","document.down":"_documentDownHandler","document.keydown":"_tableContainerKeydownHandler","document.keyup":"_tableContainerKeyupHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler"}}template(){return Smart.Templates[this.nodeName]&&delete Smart.Templates[this.nodeName],this.virtualization?'<div id="container" class="smart-container" role="presentation">\n <div id="header" class="smart-table-header" role="toolbar">\n <smart-input id="filterInput" class="underlined" animation="[[animation]]" locale="[[locale]]" right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-input>\n <div id="filterTemplateContainer" class="smart-table-filter-template-container smart-hidden"></div>\n <smart-button id="conditionalFormattingButton" class="smart-table-toolbar-button conditional-formatting" animation="[[animation]]" right-to-left="[[rightToLeft]]" theme="[[theme]]" aria-label="Conditional Formatting"></smart-button>\n </div>\n <smart-scroll-viewer style="opacity: 0.99" id="virtualizationContainer" class="smart-table-virtualization-container" right-to-left="[[rightToLeft]]" theme="[[theme]]">\n <table id="tableContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-table-container">\n <content></content>\n </table>\n </smart-scroll-viewer>\n <smart-pager id="pager" animation="[[animation]]" locale="[[locale]]" page-index="[[pageIndex]]" page-size="[[pageSize]]" pages-count="null" show-first-last-navigation-buttons show-page-size-selector show-prev-next-navigation-buttons show-summary right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-pager>\n <div id="loadingIndicatorContainer" class="smart-loader-container smart-hidden" aria-label="Loading">\n <span id="loadingIndicator" class="smart-loader" role="presentation"></span>\n </div>\n </div>':'<div id="container" class="smart-container" role="presentation">\n <div id="header" class="smart-table-header" role="toolbar">\n <smart-input id="filterInput" class="underlined" animation="[[animation]]" locale="[[locale]]" right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-input>\n <div id="filterTemplateContainer" class="smart-table-filter-template-container smart-hidden"></div>\n <smart-button id="conditionalFormattingButton" class="smart-table-toolbar-button conditional-formatting" animation="[[animation]]" right-to-left="[[rightToLeft]]" theme="[[theme]]" aria-label="Conditional Formatting"></smart-button>\n </div>\n <table id="tableContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-table-container">\n <content></content>\n </table>\n <smart-pager id="pager" animation="[[animation]]" locale="[[locale]]" page-index="[[pageIndex]]" page-size="[[pageSize]]" pages-count="null" show-first-last-navigation-buttons show-page-size-selector show-prev-next-navigation-buttons show-summary right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-pager>\n <div id="loadingIndicatorContainer" class="smart-loader-container smart-hidden" aria-label="Loading">\n <span id="loadingIndicator" class="smart-loader" role="presentation"></span>\n </div>\n </div>'}resetState(e){const t=this;switch(e){case"expanded":t._expandedIds=[],t._state.expanded=[];break;case"selected":t._selectedIds=[],t._disabledSelection=[],t._selectableGroupRecords=[],t.set("selected",[]),t._state.selected=[];break;default:t._dblclickObject={numberOfClicks:0},t._expandedIds=[],t._selectedIds=[],t._disabledSelection=[],t._selectableGroupRecords=[],t._state={expanded:[],selected:[],sorted:[]},t.set("selected",[])}}render(){this._render(),super.render()}_render(){const e=this,t=getComputedStyle(e);if(e.setAttribute("role","presentation"),e.$.tableContainer.id=e.id+"TableContainer",e._cachedWidth=e.offsetWidth,e._cachedHeight=e.offsetHeight,e._defaults={fontFamily:t.fontFamily,fontSize:t.fontSize,text:e._toHex(t.color),highlight:e._toHex(t.backgroundColor)},e._isMobile=Smart.Utilities.Core.isMobile,e._autoScrollCoefficient=Smart.Utilities.Core.Browser.Firefox?8:Smart.Utilities.Core.Browser.Edge?16:4,e._dblclickObject={numberOfClicks:0},e._expandedIds=[],e._selectedIds=[],e._disabledSelection=[],e._selectableGroupRecords=[],e._state={expanded:[],selected:[],sorted:[]},e._rowHeight=parseFloat(t.getPropertyValue("--smart-table-row-height")),e._rowDetailHeight=parseFloat(t.getPropertyValue("--smart-table-row-detail-height")),e._animation=e.animation,e._setFocusable(),e.selection&&e.$.tableContainer.setAttribute("aria-multiselectable",!0),e.virtualization){const t=e.$.virtualizationContainer,a=e;t&&(t._mouseWheelHandler=function(e){const l=t;if(!l.disabled&&(l.computedHorizontalScrollBarVisibility||l.computedVerticalScrollBarVisibility)){if(e.shiftKey&&l.computedHorizontalScrollBarVisibility){const t=l.scrollLeft;if(0===t&&e.deltaX<0||t===l.scrollHeight&&e.deltaX>0)return;return e.stopPropagation(),e.preventDefault(),void(l.scrollWidth>0&&l.scrollTo(void 0,l.scrollLeft+l._getScrollCoefficient(e,l.offsetWidth)))}if(l.computedVerticalScrollBarVisibility){const t=l.scrollTop;if(0===t&&e.deltaY<0||t===l.scrollHeight&&e.deltaY>0)return;if(e.stopPropagation(),e.preventDefault(),l.scrollHeight>0){let t=3*a._rowHeight;e.deltaY<=0&&(t=-3*a._rowHeight),Math.abs(e.deltaY)>=100?l.scrollTop+=t:l.scrollTop+=e.deltaY}}}},t._verticalScrollbarHandler=function(t){0===e.deferredScrollDelay?e._onVerticalChange(t):(e._verticalScrollTimer&&(clearTimeout(e._verticalScrollTimer),delete e._verticalScrollTimer),e._verticalScrollTimer=setTimeout((()=>{e._onVerticalChange(t),delete e._verticalScrollTimer}),e.deferredScrollDelay))}),t.hasStyleObserver=!1,t.$.verticalScrollBar.hasStyleObserver=!1,t.$.horizontalScrollBar.hasStyleObserver=!1,e.freezeHeader=!0,e.freezeFooter=!0}e.isRendered?e.innerHTML&&e.innerHTML.trim().length>1?e._initDataSourceFromHTML():e._fullRefresh():(e._createElement(),setTimeout((()=>{const t=e.querySelectorAll("tr[row-id]");if(t.length>0){let a=!1;for(let l=0;l<t.length;l++){const i=t[l];e._rowHeight<i.offsetHeight&&(e._rowHeight=i.offsetHeight,a=!0)}a&&(e.style.setProperty("--smart-table-row-height",e._rowHeight+"px"),e._refreshDataRows())}}),500),e.columnMenu&&(e._initialState=e.getState()),super.render())}_initDataSourceFromHTML(){const e=this,t=e.context;e.context=e,e.hasAttribute("smart-blazor")&&(e.$.tableContainer.innerHTML="");const a=e.columns;e.dataSource=null,e.rows=null,e.columns=null;const l=e.querySelectorAll("th");let i=[],n=[],r=[];for(let e=0;e<l.length;e++){const t=l[e].innerHTML.trim();let a={label:t,dataField:t,dataType:"string"};i.push(a),n.push(t)}if(0===l.length&&a&&a.length>0)for(let e=0;e<a.length;e++){const t=a[e];let l={label:t.label,dataField:t.dataField,dataType:t.dataType};t.width&&(l.width=t.width),t.allowResize&&(l.allowResize=t.allowResize),t.allowFilter&&(l.allowFilter=t.allowFilter),t.allowSort&&(l.allowSort=t.allowSort),t.allowHide&&(l.allowHide=t.allowHide),t.allowMenu&&(l.allowMenu=t.allowMenu),t.freeze&&(l.freeze=t.freeze),t.responsivePriority&&(l.responsivePriority=t.responsivePriority),t.columnGroup&&(l.columnGroup=t.columnGroup),i.push(l),n.push({name:t.dataField,dataType:t.dataType})}const o=e.querySelectorAll("tr");for(let e=0;e<o.length;e++){const t={},a=o[e].querySelectorAll("td");if(a.length>0){for(let e=0;e<i.length;e++)t[i[e].dataField]=a[e].innerHTML.trim();r.push(t)}}const s=new Smart.DataAdapter({dataSource:r,expandHierarchy:e.expandHierarchy,dataFields:n,id:e.dataRowId});e.$.tableContainer.innerHTML="",e.columns=i,e.context=t,e.dataSource=s}attached(){const e=this;super.attached(),e.isCompleted&&e._dialog&&(e._addDialogHandlers(),e.getShadowRootOrBody().appendChild(e._dialog)),e.isRendered&&e.isCompleted&&e.endUpdate()}detached(){const e=this;if(super.detached(),e._focusedCell&&!e.$.tableContainer.contains(e._focusedCell)&&delete e._focusedCell,!e._dialog)return;e._detachCachedTemplates();const t=e._dialog;t.removeEventListener("change",e._dialogEventHandler),t.removeEventListener("clear",e._dialogEventHandler),t.removeEventListener("click",e._dialogEventHandler),t.removeEventListener("close",e._dialogEventHandler),t.removeEventListener("filter",e._dialogEventHandler),t.remove()}addFilter(e,t){const a=this,l=a.columnByDataField[e];l&&!1!==l.allowFilter&&t instanceof Smart.Utilities.FilterGroup!=0&&(e=l.dataField,a._clearSortByRow&&a._clearSortByRow(!0),a._designerFiltersApplied&&a._clearDesignerFilters(),a._filterInfo.appliedFilters||(a._filterInfo.appliedFilters={}),a._filterInfo.appliedFilters[e]=t,a._refreshFilters("add"),a.$.filterInput&&t&&!a.filterRow&&!a.columnMenu&&(a.$.filterInput.value=t.filters[t.filters.length-1].value,a._filterInfo.query=a.$.filterInput.value),a._originalDynamicColumnsOrder&&(a._originalDynamicColumnsOrder=a._dynamicColumns.map((e=>e.id))))}addGroup(e){const t=this;if(!t.grouping)return;const a=t.columnByDataField[e];if(!a||!1===a.allowGroup)return;const l=t.dataSource,i=l.groupBy;e=a.dataField,-1===i.indexOf(e)&&(i.push(e),l.refreshHierarchy(),t._getSelectableGroupRecords(),t._fullRefresh(),t._updateState("grouped"),t._doNotFireEvent||t.$.fireEvent("group",{action:"add",dataField:e}))}beginEdit(e,t){const a=this;if(!a.editing)return;const l=a.columnByDataField[t];if(t=l?l.dataField:void 0,"cell"===a.editMode&&!t||l&&!1===l.allowEdit)return;const i=a.rowById[e];if(!i)return;const n=i.data.$.id;a._editing&&a.endEdit(),a._beginEdit({rowId:n,rowObject:i,dataField:t})}cancelEdit(){const e=this,t=e._editing;if(t){for(let a=0;a<t.cells.length;a++){const l=t.cells[a];l.editor.contains(e.getRootNode().activeElement)&&e._focusCell(l.element),l.editor.remove(),e._setCellContent(l.element,e._formatCellValue(t.row,e.columnByDataField[l.dataField],l.element)),l.element.classList.remove("editing")}delete e._editing}}clearFilters(e=null){const t=this,a=t._filterInfo;(a.inputFilters||a.rowFilters||a.appliedFilters)&&(t._clearFilterInput(),t._clearRowFilters(e),delete t._filterInfo.appliedFilters,t.dataSource.virtualDataSource||t.dataSource.clearFilter(),t._fullRefresh("filter"),t._updateState("filtered"),t._doNotFireEvent||t.$.fireEvent("filter",{action:"remove"}))}clearGrouping(){const e=this,t=e.dataSource;0!==t.groupBy.length&&(t.groupBy=[],t.refreshHierarchy(),e._getSelectableGroupRecords(),e._fullRefresh(),e._updateState("grouped"),e.$.fireEvent("group",{action:"remove"}))}clearSelection(){this._clearSelection(!0)}collapseAllRows(){const e=this;e._isExpandCollapseForbidden()||function t(a){for(let l=0;l<a.length;l++){const i=a[l];i.leaf||(i.children&&t(i.children),i.expanded&&e.collapseRow(i.$.id))}}(e["smart-table"===e.nodeName.toLowerCase()?"dataSource":"rows"].boundHierarchy)}collapseGroup(e){const t=this;if(!t.grouping||0===t.dataSource.groupBy.length)return;const a=t._getGroupByIndex(e);if(!a||!a.expanded)return;const l=t.$.tableContainer.querySelector(`tr[row-id="${a.$.id}"]:not([unused])`);if(!l){a.expanded=!1;let e=a.$.id;return e=e.replace("Item","").replace(/_/gi,"."),void t.$.fireEvent("group",{action:"collapse",path:e,dataField:a.groupDataField,label:a.label})}if(t._isCollapsed(a))return l.setAttribute("aria-expanded",!1),l.classList.remove("expanded"),void(a.expanded=!1);t._hierarchyArrowClickHandler(l)}collapseRow(e){const t=this;if(t._isExpandCollapseForbidden())return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e],l=a.data||a;if(!a||l.leaf||!l.expanded)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);return i?t._isCollapsed(l)?(i.setAttribute("aria-expanded",!1),i.classList.remove("expanded"),l.expanded=!1,t._expandedIds=t._expandedIds.filter((e=>e!==l.$.id)),t._updateState("expanded"),void t.$.fireEvent("collapse",{record:l})):void t._hierarchyArrowClickHandler(i):(l.expanded=!1,t._expandedIds=t._expandedIds.filter((e=>e!==l.$.id)),void t._updateState("expanded"))}collapseRowDetails(e){const t=this;if(!t.rowDetailTemplate)return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e],l=a.data||a;if(!a||!l)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);if(!i)return;const n=i.nextElementSibling;n&&n.classList.contains("smart-table-row-detail")&&!n.classList.contains("collapsed")&&t._toggleRowDetail(i,l.$.id)}collapseAllRowDetails(){const e=this;if(!e.rowDetailTemplate||!e.dataSource)return;let t=e.dataSource.boundSource;t||(t=e.$.tableContainer.querySelectorAll("tr[row-id]:not([unused])"));for(let a=0;a<t.length;a++)e.collapseRowDetails(t[a].$.id)}expandAllRowDetails(){const e=this;if(!e.rowDetailTemplate||!e.dataSource)return;let t=e.dataSource.boundSource;t||(t=e.$.tableContainer.querySelectorAll("tr[row-id]:not([unused])"));for(let a=0;a<t.length;a++)e.expandRowDetails(t[a].$.id)}updateRow(e,t,a){const l=this,i=l.rowById?l.rowById[e]:l.rows.dataItemById[e];if(!i)return;const n=l._selectedIds.slice(0);l._editing=!0,l.__updatedRows=!0;let r=[];l.dataSource&&l.dataSource.groupBy&&l.dataSource.groupBy.toArray&&(r=l.dataSource.groupBy.toArray().slice(0));const o=l.dataSource.boundSource.canNotify;l.dataSource.boundSource.canNotify=!1;const s=e=>{if(i.data[e]=t[e],l.dataSource.id&&i&&i.data&&i.data.$&&(i.data.$.id=t[l.dataSource.id]),i&&i.data.$&&void 0!==i.data.$.index){const a=i.data.$.index,n=l.dataSource.dataSource,o=()=>{const a=t[e];if(null==a){const t=l.columnByDataField[e];return t?"number"===t.dataType?0:"boolean"!==t.dataType&&("date"===t.dataType?new Date:""):""}return a};if(n&&n[a]&&(n[a][e]=o()),l.dataSource[a]){if(r.length>0&&!l._dirtyHierarchy&&l.dataSource[a][e]!==o()&&r.indexOf(e)>=0){const e=l._getExpandedGroups(l.dataSource.boundHierarchy);l._dirtyHierarchy=e}l.dataSource[a][e]=o()}}};for(let e=0;e<l.columns.length;e++){const a=l.columns[e];void 0!==t[a.dataField]&&s(a.dataField)}if(a){const e=l.dataSource.dataFields;if(e)for(let t=0;t<e.length;t++)e[t].map?s(e[t].map):s(e[t].name)}l._editing=!1,l.dataSource.boundSource.canNotify=o,l.__updating||(l.dataSource.refreshHierarchy(),l._fullRefresh(void 0,n,"update"))}addRow(e){const t=this;let a=[];const l=t.dataSource.boundSource.canNotify;if(t.dataSource.boundSource.canNotify=!1,t._editing=!0,t.__updatedRows=!0,t.dataSource&&t.dataSource.groupBy&&t.dataSource.groupBy.toArray&&(a=t.dataSource.groupBy.toArray().slice(0),a.length>0&&t.dataSource.beginUpdate()),a.length>0)t.dataSource?t.dataSource.add(e,!0):t._addNewRow(e,0);else if(t.dataSource)if(t.dataSource.boundHierarchy&&t.$.tableContainer&&"treegrid"===t.$.tableContainer.getAttribute("role")){const a=e[t.dataSource.parentDataField];t.dataSource.add(e,a)}else t.dataSource.add(e,!0);else t._addNewRow(e,0);t.dataSource.boundSource.canNotify=l,t._editing=!1,a.length>0||t.dataSource.boundHierarchy&&t.$.tableContainer&&"treegrid"===t.$.tableContainer.getAttribute("role")?(t._dataSourceUpdatingTimer&&clearTimeout(t._dataSourceUpdatingTimer),t._dataSourceUpdatingTimer=setTimeout((()=>{t._doNotFireEvent=!0;const e=t._getExpandedGroups(t.dataSource.boundHierarchy);a.forEach((e=>t.addGroup(e))),t.dataSource.endUpdate(),t._restoreExpandedGroups(e),t._fullRefresh("update"),t._doNotFireEvent=!1}),50)):(t._dataSourceUpdatingTimer&&clearTimeout(t._dataSourceUpdatingTimer),t._dataSourceUpdatingTimer=setTimeout((()=>{t._doNotFireEvent=!0,t._fullRefresh("update"),t._doNotFireEvent=!1})))}removeRow(e){const t=this,a=t.rowById?t.rowById[e]:t.rows.dataItemById[e];if(!a){if(t.dataSource&&t.dataSource.dataItemById){const a=t.dataSource.dataItemById[e];if(a){const l=void 0!==a.$?a.$.index:0;t.dataSource.removeAt(l),t._selectedIds.indexOf(e)>=0&&(t._selectedIds.splice(t._selectedIds.indexOf(e),1),t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:"remove"})),t.virtualization&&t.__updating||t._fullRefresh("update")}}return}const l=a.data||a,i=void 0!==l.$?l.$.index:0,n=t.dataSource.boundSource.canNotify;t.dataSource.boundSource.canNotify=!1,t._editing=!0,t.__updatedRows=!0;let r=[];t.dataSource&&t.dataSource.groupBy&&t.dataSource.groupBy.toArray&&(r=t.dataSource.groupBy.toArray().slice(0),r.length>0&&t.dataSource.beginUpdate()),t._doNotFireEvent=!0,t._sortColumns&&t._sortColumns.length?t.dataSource.remove(l):t.dataSource.removeAt(i),t._selectedIds.indexOf(e)>=0&&(t._selectedIds.splice(t._selectedIds.indexOf(e),1),t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:"remove"})),t._doNotFireEvent=!1,t.dataSource.boundSource.canNotify=n,t._editing=!1,r.length>0&&(t._dataSourceUpdatingTimer&&clearTimeout(t._dataSourceUpdatingTimer),t._dataSourceUpdatingTimer=setTimeout((()=>{const e=t._getExpandedGroups(t.dataSource.boundHierarchy);r.forEach((e=>t.addGroup(e))),t.dataSource.endUpdate(),t._restoreExpandedGroups(e),t._fullRefresh("update")}),50)),t.virtualization&&t.__updating||t._fullRefresh("update")}expandRowDetails(e){const t=this;if(!t.rowDetailTemplate)return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e];if(!a)return;const l=a.data||a;if(!a||!l)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);if(!i)return;const n=i.nextElementSibling;!n&&!t.virtualization||n&&n.classList.contains("smart-table-row-detail")&&!n.classList.contains("collapsed")||t._toggleRowDetail(i,l.$.id)}endEdit(){const e=this,t=e._editing;if(!t)return;const a=t.row,l=a.data,i=[];let n=!0;for(let a=0;a<t.cells.length;a++){const l=t.cells[a],r=e.columnByDataField[l.dataField],o=l.element,s=l.editor;let d;if(r.editor&&r.editor.template?r.editor.getValue&&(d=r.editor.getValue(s)):(d=s.value,s instanceof HTMLInputElement&&("number"===s.type?d=parseFloat(d):"date"===s.type&&(d=new Date(d),isNaN(d.getTime())&&(d=null)))),r.validation){const t=r.validation(d),a=void 0!==t&&!0!==t;if(a){let a;a="object"==typeof t&&t.message?t.message:e.localize("invalidValue"),o.setAttribute("validation-message",a)}else o.removeAttribute("validation-message");o.classList.toggle("invalid",a),n=n&&!a}i.push({column:r,newValue:d})}if(n){if(e.dataSource.virtualDataSource){const a=Object.assign({},l);for(let e=0;e<t.cells.length;e++){const l=t.cells[e],n=i[e],r=n.column;a[l.dataField]=n.newValue,r.transform&&(a[r.dataField]=r.transform(n.newValue))}for(const t of e._columns)a[t.dataField]instanceof Date&&(a[t.dataField]=a[t.dataField].toISOString().slice(0,10));e._editing.row.data=a,e._requestVirtualDataSource("update",(function(t){return t?r(!1,a):(e._editing.row.data=l,e.cancelEdit()),t}))}else r(!0,l);delete e._editing}function r(l,n){for(let r=0;r<t.cells.length;r++){const o=t.cells[r],s=i[r],d=s.column,c=o.editor;c.contains(e.getRootNode().activeElement)&&e._focusCell(o.element),c.remove(),l&&(n[o.dataField]=s.newValue,d.transform&&(n[d.dataField]=d.transform(s.newValue))),e._setCellContent(o.element,e._formatCellValue(a,d,o.element)),o.element.classList.remove("editing"),e.$.fireEvent("cellEndEdit",{id:n.$.id,row:n,value:n[o.dataField],dataField:o.dataField})}e._updateCellsWithFormulas(),"row"===e.editMode&&e.$.fireEvent("rowEndEdit",{id:n.$.id,row:n})}}expandAllRows(){const e=this;if(e._isExpandCollapseForbidden())return;e.beginUpdate();const t=e["smart-table"===e.nodeName.toLowerCase()?"dataSource":"rows"].boundHierarchy;if(t)for(let e=0;e<t.length;e++){const a=t[e],l=e=>{if(!e.leaf&&(e.expanded=!0,e.children))for(let t=0;t<e.children.length;t++){const a=e.children[t];l(a)}};l(a)}e.endUpdate()}isGroupExpanded(e){const t=this,a=t.dataSource;if(!t.grouping||0===a.groupBy.length)return;const l=t._getGroupByIndex(e);return!!l&&l.expanded}expandGroup(e){const t=this,a=t.dataSource;if(!t.grouping||0===a.groupBy.length)return;const l=t._getGroupByIndex(e);if(!l)return;const i=t._doNotFireEvent,n=t.animation,r=t.$.tableContainer.querySelector(`tr[row-id="${l.$.id}"]:not([unused])`);let o=!1;if(i&&(t.animation="none"),r){if(t._isCollapsed(l))if(i)o=!0;else{let e=l.parent;e&&!e.expanded&&t.expandGroup(l.parent.$.id.replace("Item","").replace(/_/g,"."))}l.expanded||(o||i?(l.expanded=!0,r.setAttribute("aria-expanded",!0),r.classList.add("expanded")):t._hierarchyArrowClickHandler(r,i)),i&&(l.expanded=!0,r.setAttribute("aria-expanded",!0),r.classList.add("expanded"),requestAnimationFrame((()=>t.animation=n)))}else if(l.expanded=!0,!l.expanded&&!i){let e=l.$.id;e=e.replace("Item","").replace(/_/gi,"."),t.$.fireEvent("group",{action:"expand",path:e,dataField:l.groupDataField,label:l.label})}}expandAllRootGroups(){const e=this;if(!e.grouping)return;e.beginUpdate();const t=e.dataSource.boundHierarchy;if(t)for(let e=0;e<t.length;e++)t[e].expanded=!0;e.endUpdate()}expandAllGroups(){const e=this;if(!e.grouping)return;e.beginUpdate();const t=e.dataSource.boundHierarchy;if(t)for(let e=0;e<t.length;e++){const a=t[e],l=e=>{if(e.expanded=!0,e.children)for(let t=0;t<e.children.length;t++){const a=e.children[t];l(a)}};l(a)}e.endUpdate()}collapseAllGroups(){const e=this;if(!e.grouping)return;e.beginUpdate();const t=e.dataSource.boundHierarchy;if(t)for(let e=0;e<t.length;e++)t[e].expanded=!1;e.endUpdate()}expandRow(e){const t=this;if(t._isExpandCollapseForbidden())return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e],l=a.data||a;if(!a||l.leaf)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);if(!i)return l.expanded=!0,-1===t._expandedIds.indexOf(l.$.id)&&t._expandedIds.push(l.$.id),t._updateState("expanded"),void t.$.fireEvent("expand",{id:l.$.id,record:l});if(t._isCollapsed(l)){let e=l.parent;e&&!e.expanded&&t.expandRow(e.$.id)}l.expanded||t._hierarchyArrowClickHandler(i)}exportData(e,t,a,l){const i=this,n=i._columns.filter((e=>e.visible)),r=i.columnGroups,o=i.dataSource,s=getComputedStyle(i),d=s.borderRightColor,c=new Smart.Utilities.DataExporter(void 0,o.groupBy.toArray()),u={};let f,m=Array.from(i.$.tableContainer.firstElementChild.querySelectorAll("th"));if(o.virtualDataSource){f=[];for(let e=0;e<i.rows.length;e++)f.push(i.rows[e].data)}else o.boundHierarchy&&!i.grouping?(c.hierarchical=!0,f=function e(t){const l=[];return t.forEach((t=>{a&&!1===t.$.filtered||(l.push(t),t.leaf||(t._expanded=t.expanded,t.children&&(t.children=e(t.children),0===t.children.length&&(t._expanded=void 0,t.children=void 0,t.leaf=!0))))})),l}(JSON.parse(JSON.stringify(o.boundHierarchy,((e,t)=>{if("parent"!==e)return t}))))):(f=Array.from(o.toArray()),a&&(f=f.filter((e=>!1!==e.$.filtered))));c.style={border:"1px solid "+d,borderCollapse:"collapse",backgroundColor:s.backgroundColor,color:s.color,fontFamily:"Helvetica",header:{border:"1px solid "+d,fontWeight:"bold"},columns:{border:"1px solid "+d}},m=m.filter((e=>!1===e.classList.contains("smart-table-select-all")));for(let e=0;e<n.length;e++){const t=n[e],a={},l={};let i=m[e].offsetWidth+"px";u[t.dataField]=t.label,"date"===t.dataType&&(l.format="d"),a.width=i,c.style.header[t.dataField]=a,c.style.columns[t.dataField]=l}return r?c.header={columns:n,columngroups:r}:f.unshift(u),c.exportData(f,e,t,l)}getRowIndexById(e){const t=this.rowById[e];return this.dataSource&&t&&t.data&&t.data.$?t.data.$.index:-1}getSelection(){const e=this;return 0===e._selectableGroupRecords.length?e._selectedIds.filter((e=>!(""+e).startsWith("Item"))):e._selectedIds.filter((t=>-1===e._selectableGroupRecords.indexOf(t)&&!(""+t).startsWith("Item")))}getState(){return JSON.parse(this._stringifyState())}getValue(e,t){const a=this,l=a.columnByDataField[t];if(!l)return;let i=a.rowById[e];return i?i.data[l.dataField]:(i=a.dataSource.dataItemById[e],i?i[l.dataField]:void 0)}loadState(e){const t=this;if(!e&&!(e=window.localStorage.getItem("smartTable"+t.id)))return;const a=t.stateSettings;let l=!1;if(t._loadingState=!0,"string"==typeof e&&(e=JSON.parse(e)),-1!==a.indexOf("columns")){const a=t.loadColumnStateBehavior,i=t._columns,n=[],r=e.columns;for(let e=0;e<r.length;e++){let t=Object.assign({},r[e]);const l=i.find((e=>e.dataField===t.dataField));if(!l){"implementationOnly"!==a&&n.push(t);continue}const o=l.label,s=["editor","formatFunction","templateElement","templateElementSettings","transform","validation"];"stateOnly"!==a&&s.push("label");for(let e in l)-1===s.indexOf(e)&&delete l[e];t=Object.assign(l,t),"stateOnly"!==a&&o&&(t.label=o),n.push(t)}if("stateOnly"!==a)for(let e=0;e<i.length;e++){const t=i[e];n.find((e=>e.dataField===t.dataField))||n.push(t)}t.columns=n,t._initColumns(!0),l=!0,t._formattingPanel&&(t._formattingPanel.columns=t._columns)}if(t.grouping){const a=t.dataSource,i=t.dataSource.groupBy;e.grouped=e.grouped||[],JSON.stringify(i._array)!==JSON.stringify(e.grouped)&&(t.dataSource.groupBy=e.grouped,a.refreshHierarchy(),l=!0)}else t.hasAttribute("hierarchy")&&-1!==a.indexOf("expanded")&&JSON.stringify(t._expandedIds.slice(0).sort())!==JSON.stringify(e.expanded.slice(0).sort())&&(t.collapseAllRows(),t._expandedIds=e.expanded,l=!0);-1!==a.indexOf("selected")&&e.selected.slice&&JSON.stringify(t._selectedIds.slice(0).sort())!==JSON.stringify(e.selected.slice(0).sort())&&(t._selectedIds=e.selected,l=!0),l&&(t._initRows(),t.refresh());e:if(-1!==a.indexOf("filtered")){const a=t.filtering,l=e.filtered;if(t.clearFilters(),!l)break e;if(a&&t.filterRow&&l.rowFilters){const a=t.$.tableContainer.querySelector(".smart-table-filter-row"),l=Number(t.selection),i=e.filtered.filterRowValues;for(let e=0;e<t._columns.length;e++){const n=i[e];if(!n)continue;const r=t._columns[e].dataType,o=a.children[e+l].firstElementChild,s=t._filterInfo["string"===r?"stringConditions":"numberAndDateConditions"].find((e=>e.value===n.condition));if(-1===["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(s.value))if("date"===r){const e=new Date(n.value),t=(e.getMonth()+1).toString(),a=e.getDate().toString();o.children[0].value=`${e.getFullYear()}-${"0".repeat(2-t.length)}${t}-${"0".repeat(2-a.length)}${a}`}else o.children[0].value=n.value;o.children[1].value=s.label,o.children[1].$.input.dataValue=s.value}t._applyRowFilters()}else if(a&&l.inputFilters)t.$.filterInput.value=l.query,t._filterByAll(l.query);else if(l.appliedFilters){t._filterInfo.appliedFilters||(t._filterInfo.appliedFilters={});for(let e in l.appliedFilters){const a=l.appliedFilters[e],i=new window.Smart.Utilities.FilterGroup;a.filters.forEach(((e,t)=>{const l=i.createFilter(e.type.replace("Filter",""),e.value,e.condition);i.addFilter(a.logicalOperators[t],l)})),t._filterInfo.appliedFilters[e]=i}t._refreshFilters("add")}}-1!==a.indexOf("sorted")&&(t.clearSort(),e.sorted.forEach&&e.sorted.forEach((e=>{t.sortBy(e.dataField,e.direction)}))),a.forEach((e=>t._updateState(e,!1))),t.autoSaveState&&window.localStorage.setItem("smartTable"+t.id,t._stringifyState()),delete t._loadingState}navigateTo(e){const t=this;if(isNaN(e)||null===e)return;const a=t.pageIndex;t.pageIndex=Math.max(Math.min(Math.round(e),t.$.pager.pagesCount-1),0),t.paging&&t.pageIndex!==a&&(t._fullRefresh("pageIndexChange"),t.$.fireEvent("page",{action:"pageIndexChange"}))}removeFilter(e){const t=this,a=t.columnByDataField[e];a&&t.filterRow&&t.clearFilters(e),t._filterInfo.appliedFilters&&a&&(e=a.dataField,t._clearSortByRow&&t._clearSortByRow(!0),t._designerFiltersApplied&&t._clearDesignerFilters(e),delete t._filterInfo.appliedFilters[e],t._refreshFilters("remove"),t._originalDynamicColumnsOrder&&(t._originalDynamicColumnsOrder=t._dynamicColumns.map((e=>e.id))))}removeGroup(e){const t=this,a=t.columnByDataField[e];if(!t.grouping||!a)return;e=a.dataField;const l=t.dataSource,i=l.groupBy,n=i.indexOf(e);-1!==n&&(i.splice(n,1),l.refreshHierarchy(),t._getSelectableGroupRecords(),t._fullRefresh(),t._updateState("grouped"),t.$.fireEvent("group",{action:"remove",dataField:e}))}saveState(){const e=this._stringifyState();return window.localStorage.setItem("smartTable"+this.id,e),JSON.parse(e)}enableSelect(e){const t=this;t.selection&&t._disabledSelection.indexOf(e)>=0&&(t._disabledSelection.splice(t._disabledSelection.indexOf(e),1),t._fullRefresh("update"))}disableSelect(e){const t=this;t.selection&&(t._disabledSelection.push(e),t._fullRefresh("update"))}select(e){const t=this;t.selection&&(Array.isArray(e)?t._changeSelectionOfMultiple(e,"select"):t._selectSingle(e)&&(t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:t._interaction?"interaction":"programmatic"})))}setValue(e,t,a){const l=this,i=l.columnByDataField[t];if(!i)return;let n,r=l.rowById[e];if(r)n=r.data;else{if(r=l.dataSource.dataItemById[e],!r)return;n=r}t=i.dataField,l.dataSource._updating=!0,i.transform?(n[i.originalDataField]=a,n[t]=i.transform(a)):n[t]=a;const o=l.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused]) td[data-field="${t}"]`);if(o&&(l._setCellContent(o,l._formatCellValue(r,i,o),o.classList.contains("tree-cell")),i.templateElement&&i.templateElementSettings)){const e=o.classList.contains("tree-cell"),t=o,a=e?t.children[0].children[1]:t,r=n.$.id;l._cachedTemplates&&l._cachedTemplates[i.dataField+"_"+r]&&(0===l._cachedTemplates[i.dataField+"_"+r].innerHTML.length?delete l._cachedTemplates[i.dataField+"_"+r]:(a.innerHTML="",a.appendChild(l._cachedTemplates[i.dataField+"_"+r]))),i.templateElementSettings(n[i.dataField],r,a.firstElementChild),l._cachedTemplates||(l._cachedTemplates=[]),l._cachedTemplates[i.dataField+"_"+r]||(l._cachedTemplates[i.dataField+"_"+r]=a.firstElementChild)}l._updateCellsWithFormulas(),delete l.dataSource._updating}unselect(e){const t=this;t.selection&&(Array.isArray(e)?t._changeSelectionOfMultiple(e,"unselect"):t._unselectSingle(e)&&(t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:t._interaction&&-1===t._disabledSelection.indexOf(e)?"interaction":"programmatic"})))}set scrollTop(e){const t=this;t.isRendered&&(e=parseInt(e),isNaN(e)||((t.virtualization?t.$.virtualizationContainer:t.$.container).scrollTop=e))}get scrollTop(){const e=this;return e.isRendered?(e.virtualization?e.$.virtualizationContainer:e.$.container).scrollTop:0}set scrollLeft(e){const t=this;t.isRendered&&(e=parseInt(e),isNaN(e)||((t.virtualization?t.$.virtualizationContainer:t.$.container).scrollLeft=e))}get scrollLeft(){const e=this;return e.isRendered?(e.virtualization?e.$.virtualizationContainer:e.$.container).scrollLeft:0}clearContent(){const e=this;for(;e.$.tableContainer.firstChild;)e.$.tableContainer.removeChild(e.$.tableContainer.firstChild)}applyContent(){const e=this;if(void 0===e.content)return void(e.content=e.$.tableContainer);if(""===e.content||null===e.content)return void e.clearContent();if(e.content instanceof HTMLElement)return e.clearContent(),void e.$.content.appendChild(e.content);const t=document.createDocumentFragment();let a=document.createElement("div");t.appendChild(a),e.content instanceof HTMLElement?a.appendChild(e.content):a.innerHTML=e.content;let l=Array.from(a.childNodes);a.parentNode.removeChild(a);for(let e=0;e<l.length;e++)t.appendChild(l[e]);e.clearContent(),e.$.tableContainer.appendChild(t)}propertyChangedHandler(e,t,a){const l=this;if(super.propertyChangedHandler(e,t,a),"innerHTML"!==e)switch(e){case"animation":case"theme":if("theme"===e){const e=getComputedStyle(l);l._defaults.text=l._toHex(e.color),l._defaults.highlight=l._toHex(e.backgroundColor)}if(l.filterRow){const t=l.$.tableContainer.querySelector(".smart-table-filter-row");Array.from(t.querySelectorAll("smart-input, smart-button")).forEach((t=>t[e]=a))}i(e,a);break;case"autoSaveState":a&&window.localStorage.setItem("smartTable"+l.id,l._stringifyState());break;case"columnGroups":a&&(l.columnResize&&(l.columnResize=!1),"auto"===l.columnSizeMode&&(l.removeAttribute("resize-max-reached"),l.columnSizeMode="default")),l.refresh();break;case"columnMinWidth":if(isNaN(parseFloat(a)))return void(l.columnMinWidth=t);l._handleAutoSizeMode(),l._handleFrozenColumnPositions(),l._refreshHorizontalScrollbar();break;case"columnResize":a&&l.columnGroups&&(l.columnResize=!1);break;case"columnResizeNormalize":l._columns&&l._columns.length>0&&""===l._columns[l._columns.length-1].dataField&&(l._columns.pop(),l.columns.pop()),l._initColumns(!0),l.refresh();break;case"columns":{l._conditionalFormatting&&delete l._conditionalFormatting;const e=l._sortColumns,t=l._filterInfo;if(l._clearFilterInput(),l._clearRowFilters(),delete l._filterInfo.appliedFilters,l._sortColumns=[],l._initColumns(!0),l.refresh(),l._formattingPanel&&(l._formattingPanel.columns=l._columns),l.dataSource.dataFields){let a=l.dataSource.dataFields||[];const i=l.columns;let n=!1;if(i.forEach((e=>{if(e.dataType){const t=a.find((t=>t.name===e.dataField));t?t.dataType=e.dataType:e.map?a.find((t=>e.map.indexOf(t.name)>=0?t:null))&&(l.dataSource.dataFields.push({name:e.dataField,map:e.map,dataType:e.dataType}),n=!0):(l.dataSource.dataFields.push({name:e.dataField,dataType:e.dataType}),n=!0)}})),n&&l.dataSource.dataBind){let a=[],i=[];if(l.dataSource&&l.dataSource.groupBy&&l.dataSource.groupBy.toArray&&(a=l.dataSource.groupBy.toArray().slice(0)),a.length>0&&(i=l._getExpandedGroups(l.dataSource.boundHierarchy)),l.dataSource.bindingCompleted=!1,l.dataSource.dataBind(),l._doNotFireEvent=!0,a.length>0&&(a.forEach((e=>l.addGroup(e))),l.dataSource.boundHierarchy&&l.dataSource.refreshHierarchy(),l._restoreExpandedGroups(i)),t.inputFilters?l._filterByAll(t.query):t.rowFilters?l._applyRowFilters():t.appliedFilters&&l._refreshFilters(),e&&(l._sortColumns=[],e.forEach((e=>{l.columnByDataField[e.dataField].sortOrder=null,l.sortBy(e.dataField,e.direction)}))),l._selectedIds.length>0){const e=JSON.stringify(l._selectedIds.slice(0).sort()),t=l.dataSource;l._selectedIds=l._selectedIds.filter((e=>void 0!==t.dataItemById[e]||-1!==l._selectableGroupRecords.indexOf(e))),e!==JSON.stringify(l._selectedIds.slice(0).sort())&&(l._updateSelectAllState(),l._updateState("selected"),l.$.fireEvent("change",{type:"remove"}))}l.virtualization&&setTimeout((()=>{const e=l.columns&&l.columns.length>0?l.columns[0].dataField:"";if(e){const t=l.querySelector('td[data-field="'+e+'"]');t&&l._rowHeight<t.offsetHeight&&(l._rowHeight=t.offsetHeight,l.style.setProperty("--smart-table-row-height",l._rowHeight+"px"),l._refreshDataRows())}}),300),delete l._doNotFireEvent}else t.inputFilters?l._filterByAll(t.query):t.rowFilters?l._applyRowFilters():t.appliedFilters&&l._refreshFilters(),e&&(l._sortColumns=[],e.forEach((e=>{l.columnByDataField[e.dataField].sortOrder=null,l.sortBy(e.dataField,e.direction)})))}break}case"columnSizeMode":if("auto"===a){if(l.columnGroups)return void(l.columnSizeMode="default");l._handleAutoSizeMode()}else l.removeAttribute("resize-max-reached"),l._columns.forEach((e=>{e.visible&&(e._isResponsive?e.headerCellElement.style.width=e.width||e._manualPercentageWidth?l._getColumnWidth(e.width||e._manualPercentageWidth,!0,e):null:e.headerCellElement.style.width=e.width||e._manualWidth?l._getColumnWidth(e.width||e._manualWidth,!0,e):null)}));l._handleFrozenColumnPositions(),l._refreshHorizontalScrollbar();break;case"conditionalFormatting":l._applyInitialConditionalFormatting(l.dataSource),l._refreshDataRows();break;case"conditionalFormattingButton":l.$.header.classList.toggle("smart-hidden",(!l.filtering||l.filterRow)&&!a),!a&&l._dialog&&l._dialog.close();break;case"dataSource":case"dataSourceSettings":{const i=l._sortColumns,n=l._filterInfo;if("dataSource"===e&&null===a&&(l.dataSource=[]),"dataSource"===e&&t&&a&&l.virtualization&&t instanceof Smart.DataAdapter&&t.length===a.length&&t.length>0&&a.length>0&&!l.dataSourceSettings.parentDataField&&!t.parentDataField){if(l.dataSource=t,l._cachedDataSource===a)return;l.beginUpdate();for(let e=0;e<a.length;e++){const t=a[e],i=l.dataSource[e].$.id;l.updateRow(i,t,!0)}return l.endUpdate(void 0,!0),void(l._cachedDataSource=a)}const r=l.$.virtualizationContainer?l.$.virtualizationContainer.scrollTop:0,o=void 0!==l.$.virtualizationContainer&&l.$.virtualizationContainer.$?l.$.virtualizationContainer.$.verticalScrollBar:null;o&&o.beginUpdate();let s=[];if(t&&t.groupBy&&t.groupBy.toArray&&(s=t.groupBy.toArray().slice(0)),l._dataBind(!0),l._doNotFireEvent=!0,s.length>0){const e=l._getExpandedGroups(t.boundHierarchy);if(l.__updating=!0,l.dataSource._groupBy&&(l.dataSource._groupBy.canNotify=!1),l._selectedIds.length>0){const e=JSON.stringify(l._selectedIds.slice(0).sort()),t=l.dataSource;l._selectedIds=l._selectedIds.filter((e=>void 0!==t.dataItemById[e]||-1!==l._selectableGroupRecords.indexOf(e))),s.forEach((e=>l.addGroup(e))),e!==JSON.stringify(l._selectedIds.slice(0).sort())&&(l._updateSelectAllState(),l._updateState("selected"),l.$.fireEvent("change",{type:"remove"}))}else s.forEach((e=>l.addGroup(e)));l.dataSource.boundHierarchy&&l.dataSource.refreshHierarchy(),l.dataSource._groupBy&&(l.dataSource._groupBy.canNotify=!0),l.__updating=!1,l._restoreExpandedGroups(e),l._fullRefresh("update")}if(n.inputFilters?l._filterByAll(n.query):n.rowFilters?l._applyRowFilters():n.appliedFilters&&l._refreshFilters(),i&&(l._sortColumns=[],i.forEach((e=>{l.columnByDataField[e.dataField].sortOrder=null,l.sortBy(e.dataField,e.direction)}))),l._selectedIds.length>0){const e=JSON.stringify(l._selectedIds.slice(0).sort()),t=l.dataSource;l._selectedIds=l._selectedIds.filter((e=>void 0!==t.dataItemById[e]||-1!==l._selectableGroupRecords.indexOf(e))),e!==JSON.stringify(l._selectedIds.slice(0).sort())&&(l._updateSelectAllState(),l._updateState("selected"),l.$.fireEvent("change",{type:"remove"}))}l.virtualization&&(setTimeout((()=>{const e=l.columns&&l.columns.length>0?l.columns[0].dataField:"";if(e){const t=l.querySelector('td[data-field="'+e+'"]');t&&l._rowHeight<t.offsetHeight&&(l._rowHeight=t.offsetHeight,l.style.setProperty("--smart-table-row-height",l._rowHeight+"px"),l._refreshDataRows())}}),300),l.$.virtualizationContainer.scrollTop=r,o&&(o.endUpdate(),l._onVerticalChange({detail:{value:o.value}},!0))),delete l._doNotFireEvent;break}case"disabled":case"unfocusable":case"keyboardNavigation":l._setFocusable(),i("unfocusable",l.disabled||l.unfocusable||!l.keyboardNavigation),"disabled"===e&&l._dialog&&l._dialog.close();break;case"hideSelectionColumn":l.refresh();break;case"columnMenu":l.$.header.classList.toggle("smart-hidden",(!l.filtering||l.filterRow||l.columnMenu)&&!l.conditionalFormattingButton),l.columnMenu&&(l._initialState=l.getState()),l.refresh();break;case"editing":a?l.$.tableContainer.removeAttribute("aria-readonly"):l.$.tableContainer.setAttribute("aria-readonly",!0);break;case"filtering":l.columnMenu||l.$.header.classList.toggle("smart-hidden",(!a||l.filterRow)&&!l.conditionalFormattingButton),a&&l.filterRow?l._createFilterRow():!1===a&&(l.filterRow&&l.$.tableContainer.querySelector(".smart-table-filter-row").remove(),(l._filterInfo.query||l._filterInfo.rowFilters||l._filterInfo.appliedFilters)&&l.clearFilters()),l.virtualization&&l.refresh();break;case"filterRow":if(l.$.header.classList.toggle("smart-hidden",(!l.filtering||a)&&!l.conditionalFormattingButton),!l.filtering)return;a?l._createFilterRow():(l.$.tableContainer.querySelector(".smart-table-filter-row").remove(),l._filterInfo.rowFilters&&l.clearFilters());break;case"filterTemplate":l._applyFilterTemplate();break;case"footerRow":{const e=l.$.tableContainer.querySelector("tfoot");e&&e.remove(),a&&l._createFooterRow();break}case"formulas":a?l._formulaParser=new Smart.FormulaParser(l):delete l._formulaParser,l._updateCellsWithFormulas(!0);break;case"freezeHeader":case"freezeFooter":l.virtualization&&(l[e]=!0);break;case"grouping":a||l.clearGrouping();break;case"headerRow":{const e=Array.from(l.$.tableContainer.firstElementChild.children);for(let t=1;t<e.length;t++)e[t].remove();a&&l._createCustomHeaderRow();break}case"locale":case"messages":{const e=l._dialog;if(l._localize(),l.filterRow){const e=l.$.tableContainer.querySelector(".smart-table-filter-row"),t=Array.from(e.querySelectorAll("smart-input.string-filter")),a=Array.from(e.querySelectorAll("smart-input.num-date-filter")),i=Array.from(e.querySelectorAll("smart-button"));t.concat(a).forEach((e=>e.title=l.localize("filterCondition"))),t.forEach((e=>{e.dataSource=l._filterInfo.stringConditions,void 0===e.$.input.dataValue?e.value=l.localize("CONTAINS"):e.value=l._filterInfo.stringConditions.find((t=>t.value===e.$.input.dataValue)).label})),a.forEach((e=>{e.dataSource=l._filterInfo.numberAndDateConditions,void 0===e.$.input.dataValue?e.value=l.localize("EQUAL"):e.value=l._filterInfo.numberAndDateConditions.find((t=>t.value===e.$.input.dataValue)).label})),i.forEach((e=>e.title=l.localize("clearFilter")))}e&&(e.$.footer.firstElementChild.innerHTML=l.localize("ok"),e.$.footer.children[1].innerHTML=l.localize("cancel"),e.classList.contains("conditional-formatting")?e.label=l.localize("conditionalFormatting"):e.classList.contains("drill-down")&&(e.label=l.localize("details"))),l._formattingPanel&&(l._formattingPanel.messages=l.messages,l._formattingPanel.locale=l.locale),Array.from(l.$.tableContainer.querySelectorAll(".group-label-value>.placeholder")).forEach((e=>{e.textContent=l.localize("EMPTY")}));break}case"pageIndex":l.pageIndex=Math.max(Math.min(Math.round(a),l.$.pager.pagesCount-1),0),l.paging&&l.pageIndex!==t&&(l._fullRefresh("pageIndexChange"),l.$.fireEvent("page",{action:"pageIndexChange"}));break;case"pageSize":l.paging&&(l._fullRefresh("pageSizeChange"),l.$.fireEvent("page",{action:"pageSizeChange"}));break;case"paging":if(!1===a){if(l.dataSource.virtualDataSource)return void(l.paging=!0);if(1===l.$.pager.pagesCount)return}l._fullRefresh();break;case"rowDetailTemplate":l._fullRefresh();break;case"rightToLeft":Array.from(l.$.tableContainer.querySelectorAll(".freeze-near, .freeze-far")).forEach((e=>{e.style.left=null,e.style.right=null,e.style.zIndex=null})),l._handleFrozenColumnPositions(),i("rightToLeft",a);break;case"selected":{const e=l._selectedIds.slice(0);l._clearSelection(),l._changeSelectionOfMultiple(a,"select","programmatic",e);break}case"selection":if(l.filterRow){const e=l.$.tableContainer.querySelector(".smart-table-filter-row");a?e.insertBefore(document.createElement("td"),e.firstElementChild):e.firstElementChild.remove()}l.refresh(),a?(l.$.tableContainer.setAttribute("aria-multiselectable",!0),l._updateSelectAllState()):l.$.tableContainer.removeAttribute("aria-multiselectable");break;case"selectionMode":{l.$.tableContainer.classList.remove("smart-unselectable");const e=l.querySelector(".smart-table-select-all");e&&("one"===l.selectionMode?e.classList.add("smart-visibility-hidden"):e.classList.remove("smart-visibility-hidden"));break}case"sortMode":"none"===a&&l.clearSort();break;case"tooltip":if(!a){const e=l.$.tableContainer.querySelector(".tooltip");e&&(e.classList.remove("tooltip"),e.removeAttribute("title"))}break;case"virtualization":l.virtualization=t}else l._initDataSourceFromHTML();function i(e,t){const a=[];l._dialog&&a.push(l._dialog,l._dialog.$.footer.firstElementChild,l._dialog.$.footer.children[1]),l._formattingPanel&&a.push(l._formattingPanel),a.forEach((a=>a[e]=t))}}_createElement(){const e=this;if(e._expandedRowDetailIds=[],e._editors={},isNaN(parseFloat(e.columnMinWidth))&&(e.columnMinWidth="50px"),e.columnGroups&&(e.columnResize=!1,e.columnSizeMode="default"),e.formulas&&(e._formulaParser=new Smart.FormulaParser(e)),e._setupPagingAndFiltering(),e._localize(),e._selectedIds=e.selected.slice(0),"one"===e.selectionMode){e._selectedIds=e._selectedIds.slice(0,1);const t=e.querySelector(".smart-table-select-all");t&&t.classList.add("smart-visibility-hidden")}e._dataBind(),e.editing||e.$.tableContainer.setAttribute("aria-readonly",!0),e.autoLoadState&&e.loadState(),e.autoSaveState&&window.localStorage.setItem("smartTable"+e.id,e._stringifyState())}_initColumns(e){const t=this,a=t.columns;if(!t.isRendered&&t.dataSource.length>0&&(!a||Array.isArray(a)&&0===a.length)&&(t.columns=t.dataSource.dataFields.map((e=>({label:e.name,dataField:e.name,dataType:e.dataType})))),t._filterInfo.stringDataFields=[],t._columns=[],t.columnByDataField={},t.columns.canNotify=!1,t.columns instanceof Smart.ObservableArray){const e=[];for(let a=0;a<t.columns.length;a++){let l=t.columns[a],i={};for(let e in l)i[e]=l[e];e.push(i)}t.columns=e}for(let a=0;a<t.columns.length;a++){let l=t.columns[a];if("string"==typeof l&&t.dataSource.dataFields){const e=t.dataSource.dataFields.find((e=>{if(e.name===l)return e}));l={label:l,dataField:l,dataType:e&&e.dataType||"string"}}void 0===l.label&&void 0===l.dataField||(void 0===l.label&&(l.label=l.dataField),void 0===l.dataField&&(l.dataField=l.label),l.dataType||(l.dataType="string"),"string"!==l.dataType&&"number"!==l.dataType||!1===l.allowFilter||!l.dataField||t._filterInfo.stringDataFields.push(l.dataField),l.visible=void 0===l.visible||!!l.visible,l.allowResize=void 0===l.allowResize||!!l.allowResize,t._transformColumnDataField(l,e),l.thHierarchy=[],t._columns.push(l),t.columnByDataField[l.dataField]=l)}if("default"===t.columnSizeMode&&t.selection){let e=!0;for(let a=0;a<t._columns.length;a++){const l=t._columns[a];if(!l.width){e=!1,l._isResponsive=!0,l._isFillRemainingWidth=!0;break}}!t.columnResizeNormalize&&e&&t._columns.push({dataField:"",label:"",visible:!0,allowResize:!1,allowFilter:!1,allowSort:!1})}t.columns=new Smart.ObservableArray(t._columns),t._updateState("columns"),t.columns.notify((function(e){if(!t.columns.canNotify)return;if("length"===e.action||"update"===e.action&&-1!==["allowGroup","allowSort","sortOrder"].indexOf(e.propertyName))return void t._updateState("columns");const a=e.target;if("update"===e.action){const l=a.dataField;if("allowEdit"===e.propertyName)return Array.from(t.$.tableContainer.querySelectorAll(`td[data-field="${l}"]`)).forEach((t=>{t.classList.toggle("no-edit",!1===e.newValue),!1===e.newValue?t.setAttribute("aria-readonly",!0):t.removeAttribute("aria-readonly")})),void t._updateState("columns");if("allowFilter"===e.propertyName)return"string"!==a.dataType&&"number"!==a.dataType||!l||(!1===e.newValue?t._filterInfo.stringDataFields=t._filterInfo.stringDataFields.filter((e=>e!==l)):!1===e.oldValue&&t._filterInfo.stringDataFields.push(l)),t.filterRow&&t.$.tableContainer.querySelector(`.smart-table-filter-row td[filter-for="${l}"]`).classList.toggle("no-filter",!1===e.newValue),"smart-pivot-table"===t.nodeName.toLowerCase()&&t._columnNotify(e),void t._updateState("columns");if("transform"===e.propertyName)a.sortOrder&&t.sortBy(a.dataField,null),t._transformColumnDataField(a,!0);else{if(-1!==["allowPivot","allowRowGroup","pivot","rowGroup","summary"].indexOf(e.propertyName)&&"smart-pivot-table"===t.nodeName.toLowerCase())return t._columnNotify(e),void t._updateState("columns");if("visible"===e.propertyName){const e=t._expandedRowDetailIds,a=t.$.tableContainer;let l;return t.filterRow&&(l=a.querySelector(".smart-table-filter-row"),l&&l.remove()),e&&e.length&&!t._columns.some((e=>e.visible))&&e.forEach((e=>t._toggleRowDetail(a.querySelector(`[row-id="${e}"]`),e))),t.$.tableContainer.setAttribute("aria-colcount",t._columns.filter((e=>e.visible)).length+ +t.selection),t.refresh(),void t._updateState("columns")}}}"add"===e.action&&(t.columns[t.columns.length-1].visible=!0),t._columns=t.columns._array,t.columnByDataField=[],t._columns.forEach((e=>{t.columnByDataField[e.dataField]=e,e.originalDataField&&(t.columnByDataField[e.originalDataField]=e)})),t.refresh(!0),t._updateState("columns")})),t.$.tableContainer.setAttribute("aria-colcount",t._columns.filter((e=>e.visible)).length+ +t.selection)}_transformColumnDataField(e,t){const a=this;if("function"==typeof e.transform){if(!a.isRendered||t){const l=a.dataSource,i=a.columns.canNotify;i&&(a.columns.canNotify=!1),t&&e.originalDataField&&(delete a.columnByDataField[e.dataField],e.dataField=e.originalDataField);const n=e.dataField,r=n+"Transformed";a.columnByDataField[n]=e,e.originalDataField=n,e.dataField=r,l.canNotify=!1;for(let t=0;t<l.length;t++){const a=l[t];a[r]=e.transform(a[n])}i&&(a.columns.canNotify=!0),l.canNotify=!0}}else e.transform&&(e.transform=void 0)}_initRows(){const e=this,t=e.dataSource,a=e.context;if(e.context=e,e.rows=[],e.rowById=[],t.virtualDataSource)return e._initRowsVirtualDataSource(),void(e.context=a);if(t.boundHierarchy)return e.$.tableContainer.setAttribute("role","treegrid"),e.setAttribute("hierarchy",""),e._initHierarchicalRows(),void(e.context=a);e.$.tableContainer.setAttribute("role","grid");let l=0,i=t.length,n=!1;if(e.removeAttribute("hierarchy"),e.paging){const a=e.pageSize;if(e._filterInfo.query||e._filterInfo.rowFilters||e._filterInfo.appliedFilters){let e=0;for(let a=0;a<i;a++)!1!==t[a].$.filtered&&e++;i=e,n=!0}const r=Math.max(Math.ceil(i/a),1);e.$.pager.pagesCount=r,e.$.pager.totalRecords=i,e.pageIndex=Math.max(Math.min(e.pageIndex,r-1),0),l=e.pageIndex*a,i=l+a}if(n){let a=-1;for(let n=0;n<t.length;n++){const r=t[n];if(r&&!1!==r.$.filtered){if(a++,a<l)continue;if(a>=i)break;e._addNewRow(r,n)}}}else for(let a=l;a<i;a++){const l=t[a];l&&!1!==l.$.filtered&&e._addNewRow(l,a)}e._observeRows(),e.context=a}_initRowsVirtualDataSource(){const e=this,t=e.dataSource;if(t.boundHierarchy)e.$.tableContainer.setAttribute("role","treegrid"),e.setAttribute("hierarchy",""),e._processHierarchy(t.boundHierarchy,0,t.boundHierarchy.length);else for(let a=0;a<t._dataSource.length;a++){const l=t[a];l&&!1!==l.$.filtered&&e._addNewRow(l,a)}if(e.paging){const a=t.length,l=e.pageSize,i=Math.max(Math.ceil(a/l),1),n=e.$.pager.pagesCount;if(e.$.pager.pagesCount=i,e.$.pager.totalRecords=a,e.pageIndex=Math.max(Math.min(e.pageIndex,i-1),0),null!==n&&n!==i)return void e._fullRefresh()}e._observeRows()}_initHierarchicalRows(){const e=this,t=e.dataSource.boundHierarchy;let a=0,l=t.length,i=!1;if(e.paging){const n=e.pageSize;if(e._filterInfo.query||e._filterInfo.rowFilters||e._filterInfo.appliedFilters){let e=0;for(let a=0;a<l;a++)!1!==t[a].$.filtered&&e++;l=e,i=!0}const r=Math.max(Math.ceil(l/n),1);e.$.pager.pagesCount=r,e.$.pager.totalRecords=l,e.pageIndex=Math.max(Math.min(e.pageIndex,r-1),0),a=e.pageIndex*n,l=a+n}if(i){let i=-1;for(let n=0;n<t.length;n++){const r=t[n];if(r&&!1!==r.$.filtered){if(i++,i<a)continue;if(i>=l)break;e._processHierarchy(t,n,n+1)}}}else e._processHierarchy(t,a,l);e._observeRows()}_processHierarchy(e,t,a){const l=this;for(let i=t;i<a;i++){const t=e[i];if(!t)break;t.leaf?t&&!1!==t.$.filtered&&l._addNewRow(t,i):(-1!==l._expandedIds.indexOf(t.$.id)?t.expanded=!0:void 0===t.expanded&&(t.expanded=!1),!1!==t.$.filtered&&l._addNewRow(t,i),t.children.length&&!1!==t.$.filtered&&l._processHierarchy(t.children,0,t.children.length))}}_observeRows(){const e=this;e.rows=new Smart.ObservableArray(e.rows),e.rows.notify((function(t){if(!e.rows.canNotify||t.path||!e.dataSource)return;e.rows.canNotify=!1;const a=t.action,l=e._selectedIds.slice(0);switch(e.dataSource.canNotify=!1,a){case"add":{const a={};e.dataSource.dataFields.forEach((e=>a[e.name]=""));const l=Object.assign(a,e.rows[t.index]);e.dataSource.add(e.rows[t.index]),e._editing={row:{data:l}};break}case"update":e.dataSource.update(t.index,e.rows[t.index]),e._editing={row:{data:e.rows[t.index]}};break;case"remove":{const a=t.removed[0].data,l=a.$.id,i=e._selectedIds.indexOf(l);e.dataSource.removeAt(a.$.index),delete e.rowById[l],-1!==i&&e._selectedIds.splice(i,1),e._editing={row:t.removed[0]},e._updateSelectAllState();break}}e._fullRefresh(a,l,a),delete e._editing,e.dataSource.canNotify=!0,e.rows.canNotify=!0}))}beginUpdate(){const e=this;if("smart-table"!==e.nodeName.toLowerCase())return;e.__updating=!0,e.__updatedRows=!1;const t=window.__karma__||window.karma;document.hidden&&!t||(e._dirtyHierarchy=!1,e.__updatingOldSelectedIds=e._selectedIds.slice(0),e.__updatingSortColumns=e._sortColumns,e.dataSource&&e.dataSource.clearSort&&e.dataSource.clearSort())}endUpdate(e,t){const a=this;if("smart-table"!==a.nodeName.toLowerCase())return;a.__updating=!1;const l=window.__karma__||window.karma;if(document.hidden&&!l)return;if(!1===e)return;l&&(t=!0);const i=()=>{const t=a.__updatingOldSelectedIds?a.__updatingOldSelectedIds:a._selectedIds.slice(0);a.__updatingOldSelectedIds&&delete a.__updatingOldSelectedIds,a._dirtyHierarchy&&a.dataSource.refreshHierarchy();const l=a._sortColumns,i=a._filterInfo,n=a.dataSource.groupBy._array.slice(0),r=void 0!==a.$.virtualizationContainer&&a.$.virtualizationContainer.$?a.$.virtualizationContainer.$.verticalScrollBar:null;if(r&&r.beginUpdate(),a._doNotFireEvent=!0,a._fullRefresh("update",t,"update"),n.length>0){let e=a._getExpandedGroups(a.dataSource.boundHierarchy);a._dirtyHierarchy&&(e=a._dirtyHierarchy),n.forEach((e=>a.addGroup(e))),a._restoreExpandedGroups(e)}i.inputFilters?a._filterByAll(i.query):i.rowFilters?a._applyRowFilters():i.appliedFilters&&a._refreshFilters(),l&&(a.__updatingSortColumns&&JSON.stringify(a.__updatingSortColumns)!==JSON.stringify(l)||0===n.length||!0===e||!1===a.__updatedRows)&&(a._sortColumns=[],l.forEach((e=>{a.columnByDataField[e.dataField].sortOrder=null,a.sortBy(e.dataField,e.direction)}))),r&&(r.endUpdate(),a._onVerticalChange({detail:{value:r.value}},!0),a._dirtyHierarchy&&(a._rowsInDOM.length<a.rows.length&&0===a.$.virtualizationContainer.$.verticalScrollBar.max&&a._refreshDataRows(),a._dirtyHierarchy=!1)),delete a._doNotFireEvent};if(a._verticalScrollTimer)return a._scheduleUpdate&&clearInterval(a._scheduleUpdate),void(a._scheduleUpdate=setInterval((function(){a._verticalScrollTimer||(i(),clearInterval(a._scheduleUpdate),delete a._scheduleUpdate)}),100));t?i():requestAnimationFrame((()=>{i()}))}_addNewRow(e,t){const a=this,l=e.$.id,i=new Smart.Observable({data:e,boundIndex:t});-1!==a._disabledSelection.indexOf(l)&&(i.allowSelect=!1),i.canNotify=!0,i.notify((function(t){if(a._editing||a._hierarchyChange)return;const i=a.selection;if("allowSelect"===t.propertyName){const n=a._disabledSelection.indexOf(l);if(a._hierarchyChange=!0,t.newValue||-1!==n)t.newValue&&-1!==n&&function e(t){const l=t.$.id,n=a.$.tableContainer.querySelector(`[row-id="${l}"]:not([unused])`),r=a.rowById[l];if(t.parent&&-1!==a._disabledSelection.indexOf(t.parent.$.id))r.allowSelect=!1;else if(a._disabledSelection.splice(a._disabledSelection.indexOf(l),1),n&&(n.classList.remove("disable-select"),i&&(n.setAttribute("aria-selected",!1),n.firstElementChild.firstElementChild.removeAttribute("aria-disabled"))),r&&(r.allowSelect=!0),t.children)for(let a=0;a<t.children.length;a++)e(t.children[a])}(e);else{const t=[];!function e(t,l){const n=t.$.id,r=a.$.tableContainer.querySelector(`[row-id="${n}"]:not([unused])`),o=a.rowById[n];if(l.push(n),r&&(r.removeAttribute("aria-selected"),r.classList.add("disable-select"),i&&r.firstElementChild.firstElementChild.setAttribute("aria-disabled",!0)),o&&(o.allowSelect=!1),t.children)for(let a=0;a<t.children.length;a++)e(t.children[a],l)}(e,t),a._disabledSelection=a._disabledSelection.concat(t),a.unselect(t)}delete a._hierarchyChange}})),a.rowById[l]=i,a.rows.push(i)}refresh(){const e=this;if(e.__updating)return;const t=e._columns.filter((e=>e.visible)),a=e.$.tableContainer,l=a.querySelector(".smart-table-filter-row"),i=a.querySelector("tfoot"),n=document.createElement("tbody"),r=e._getFractionOfMax(),o=e.virtualization?e.$.virtualizationContainer:e.$.tableContainer.parentElement,s={top:o.scrollTop,left:o.scrollLeft};for(e.columns.canNotify=!1;a.childNodes.length>0;)a.childNodes[0].remove();e._createTableHeader(),e.isRendered||!e.onInit||e._loadingState||e.onInit(),e._createCustomHeaderRow(),e._createFooterRow(i),e._createDataRows(n),e._createFilterRow(l);const d=a.querySelectorAll("th[data-field]");for(let a=0;a<t.length;a++){const l=t[a];l.headerCellElement=d[a],l.headerCellElement&&(l.headerCellElement.onclick=function(){const t=this.dataField;e.$.fireEvent("columnClick",{dataField:t}),e.closeColumnMenu(),"none"===e.sortMode||!1===l.allowSort||e._preventClickSort||(e._addSortIconContainer(this),e._sortOnClick=!0,this.headerCellElement.sortIconContainerElement.classList.contains("asc")?e.sortBy(t,"desc"):this.headerCellElement.sortIconContainerElement.classList.contains("desc")?e.sortBy(t,null):e.sortBy(t,"asc"),e._sortOnClick=!1)}.bind(l))}if(e._sortColumns&&e._sortColumns.length>0)for(let t=0;t<e._sortColumns.length;t++){const a=e._sortColumns[t],l=e.columnByDataField[a.dataField];e._addSortIconContainer(l,a.direction,t+1)}e._handleAutoSizeMode(),e._handleFrozenColumnPositions(),e._refreshHorizontalScrollbar(),e.isRendered&&(e.selection&&e._updateSelectAllState(),e._setFractionOfMax(r)),[o.scrollTop,o.scrollLeft]=[s.top,s.left],e.columns.canNotify=!0}_createTableHeader(){const e=this,t=e.selection,a=document.createElement("thead"),l=e._columns.filter((e=>e.visible)),i=e._getColumnHeaderStructure(),n=window.innerWidth,r={};for(let o=0;o<i;o++){const s=document.createElement("tr"),d=document.createDocumentFragment();t&&(s.innerHTML=o<i-1?'<th class="empty"></th>':'<th class="smart-table-select-all freeze-near" scope="col" aria-colindex="1"><div role="checkbox" aria-checked="false" aria-label="Toggle selection of all rows"></div></th>',e.virtualization&&Smart.Utilities.Core.Browser.Safari&&s.querySelector("th").classList.add("sticky")),o<i-1&&s.classList.add("column-groups-header");for(let a=0;a<l.length;a++){const s=l[a];if(0===o&&(s.width&&isNaN(parseFloat(s.width))&&delete s.width,s.responsivePriority&&("number"!=typeof s.responsivePriority&&(s.responsivePriority=1),s.responsivePriority=Math.max(Math.min(Math.round(s.responsivePriority),5),1),i>1&&(r[a]=e._isColumnHidden(s.responsivePriority,n)))),o<i-1){if(r[a])continue;const t=l[a],i=t.headerStructure[o];if(a>0){let r=a-1,s=l[r];for(;s&&e._isColumnHidden(s.responsivePriority,n);)r--,s=l[r];if(s&&i===s.headerStructure[o]&&e._areColumnsWithSameFreezeSettings(t,s))continue}const s=document.createElement("th");if(s.includes=[t],a<l.length-1){let r=1,d=a+1,c=l[d];for(;c;){if(!e._isColumnHidden(c.responsivePriority,n)){if(i!==c.headerStructure[o]||!e._areColumnsWithSameFreezeSettings(t,c))break;r++,s.includes.push(c)}d++,c=l[d]}s.colSpan=r}0!==o&&t.headerStructure[o-1]===i||(s.textContent=i),s.includes.forEach((e=>e.thHierarchy[o]=s)),s.classList.add("column-header"),t.freeze&&s.classList.add("freeze-"+("far"===t.freeze?"far":"near")),e.virtualization&&Smart.Utilities.Core.Browser.Safari&&s.classList.add("sticky"),d.appendChild(s)}else e._setupColumnHeaderCell(t,d,a,s)}s.appendChild(d),a.appendChild(s),e._tableHeader=a}if(e.$.tableContainer.appendChild(a),"default"===e.columnSizeMode){for(let t=0;t<e.columns.length;t++){const l=e.columns[t];if(!l.width){const t=a.querySelector('[data-field="'+l.dataField+'"]');t&&t.offsetWidth<5&&(t.style.width=parseInt(l.minWidth||e.columnMinWidth)+"px")}}if(t){const t=e.columns.filter((e=>e.visible));if(1===t.length){const e=t[0],l=a.querySelector('[data-field="'+e.dataField+'"]');l&&(l.style.width="")}}}}_getColumnHeaderStructure(){const e=this._columns,t=this.columnGroups;if(!t)return 1;let a=1;for(const l of e){let e=l.columnGroup;if(l.headerStructure=[],e&&(e=t.find((t=>t.name===e)),e))for(l.headerStructure.push(e.label||e.name);e.parentGroup&&(e=t.find((t=>t.name===e.parentGroup)),e);)l.headerStructure.unshift(e.label||e.name);l.headerStructure.push(l.label),a=Math.max(a,l.headerStructure.length)}for(const t of e){const e=t.headerStructure,l=e[0];for(;e.length<a;)e.unshift(l)}return a}_isColumnHidden(e,t){return!(!e||1===e||t>1280)&&(t<=640&&2===e||t<=800&&3===e||t<=1024&&4===e||t<=1280&&5===e)}_areColumnsWithSameFreezeSettings(e,t){return!e.freeze&&!t.freeze||e.freeze===t.freeze||!0===e.freeze&&"near"===t.freeze||"near"===e.freeze&&!0===t.freeze}getColumnProperty(e,t){const a=this,l=a.columnByDataField[e];if(!l)return null;switch(t){case"width":return l.width?a._getColumnWidth(l.width,!0,l):l._isResponsive&&l._manualPercentageWidth?a._getColumnWidth(l._manualPercentageWidth+"%",!0,l):a._getColumnWidth(l._manualWidth,!0,l);default:return l[t]}}setColumnProperty(e,t,a){const l=this;if(!l.columnByDataField[e])return null;l.columns.forEach(((i,n)=>{i.dataField===e&&(l.columns[n][t]=a)}))}_getTableRemainingWidth(){const e=this;let t=e.offsetWidth;if(e.selection){const a=e.$.tableContainer.querySelector(".smart-table-select-all");a&&(t=e.offsetWidth-a.offsetWidth),""===e.columns[e.columns.length-1].dataField&&(t-=e.columnMinWidth)}e.virtualization&&e.$.virtualizationContainer&&e.$.virtualizationContainer.computedVerticalScrollBarVisibility&&(t-=20);let a=0;for(let t=0;t<e.columns.length;t++){const l=e.columns[t];l.visible&&l.width&&!(""+l.width).endsWith("%")&&(a+=e._getColumnWidth(l.width))}return t-=a,t}_getColumnWidth(e,t,a){const l=this,i=parseFloat(e);if((e=(e+"").trim()).endsWith("%")){let e=l.offsetWidth;if(l.selection){const t=l.$.tableContainer.querySelector(".smart-table-select-all");t&&(e=l.offsetWidth-t.offsetWidth),""===l.columns[l.columns.length-1].dataField&&(e-=l.columnMinWidth)}l.virtualization&&l.$.virtualizationContainer&&l.$.virtualizationContainer.computedVerticalScrollBarVisibility&&(e-=20);let n=0;for(let e=0;e<l.columns.length;e++){const t=l.columns[e];t.visible&&t.width&&!(""+t.width).endsWith("%")&&(n+=l._getColumnWidth(t.width))}e-=n;const r=a&&a.minWidth||l._getNumericMinWidth(),o=t?i+"%":e*(i/100);return r>o?r:o}return isNaN(i)?"auto":t?i+"px":i}_setupColumnHeaderCell(e,t,a,l){const i=this,n=document.createElement("th");if(n.setAttribute("aria-colindex",a+1+ +e),l.width){let e=l.width;"number"==typeof e&&l.minWidth&&(e=Math.max(e,l.minWidth)),n.style.width=i._getColumnWidth(e,!0,l)}else l._manualWidth&&(l._isResponsive?n.style.width=l._manualPercentageWidth+"%":n.style.width=l._manualWidth+"px");if(1!==i._columns.length&&l.allowResize||n.setAttribute("locked",""),l.freeze&&n.classList.add("freeze-"+("far"===l.freeze?"far":"near")),l.responsivePriority&&n.classList.add("priority-"+l.responsivePriority),i.virtualization&&Smart.Utilities.Core.Browser.Safari&&n.classList.add("sticky"),n.setAttribute("data-field",l.dataField),n.innerHTML=`<div class="wrapper" role="presentation"><div class="label">${l.label}</div></div>`,i.columnMenu){const e=document.createElement("div");e.classList.add("column-menu"),e.setAttribute("aria-hidden",!0),n.firstElementChild.appendChild(e),e.onclick=e=>{i.activeColumnMenu&&i.activeColumnMenu.dataField===l.dataField?i.closeColumnMenu():i.openColumnMenu(l.dataField),e.preventDefault(),e.stopPropagation()}}i.onColumnRender&&i.onColumnRender(l.dataField,n),t.appendChild(n)}_refreshDataRows(){const e=this,t=window.scrollY,a=window.scrollX,l=e.$.tableContainer.children[1],i=Array.from(l.querySelectorAll("tr:not(.smart-table-filter-row)"));if(e._clearCachedTemplates(),e.filterRow||e.footerRow||e.headerRow)for(let e=0;e<i.length;e++)i[e].remove();else l.innerHTML="";e._createDataRows(l),e._handleAutoSizeMode(),e._handleFrozenColumnPositions(),e._refreshHorizontalScrollbar(),(a||t)&&window.scroll(a,t)}_createDataRows(e){const t=this;if(t.virtualization)return void t._createVirtualDataRows(e);const a=t.rowDetailTemplate,l=t.selection,i=document.createDocumentFragment(),n=t.hasAttribute("hierarchy");for(let e=0;e<t.rows.length;e++){const r=t.rows[e],o=r.data;o.groupDataField?t._createGroupHeader(o,i):t._createDataRow(r,i,{hierarchical:n,rowDetailTemplate:a,selection:l,virtualization:!1})}if(i.appendChild(t._createLastRow()),e.appendChild(i),t._updateState("expanded"),e.parentElement||t.$.tableContainer.insertBefore(e,t.$.tableContainer.querySelector("tfoot")),t.getRootNode().activeElement===t.$.tableContainer&&t._tableContainerFocusHandler(),t._templateTags.length){const e=t.querySelectorAll("tr");for(let a=0;a<t._templateTags.length;a++){const l=t._templateTags[a],i=l.index,n=l.dataField,r=l.td;if(e[i]){const t=e[i].querySelector('[data-field="'+n+'"]'),a=[...t.querySelectorAll("smart-button"),...t.querySelectorAll("button"),...t.querySelectorAll("a"),...t.querySelectorAll("span")],l=[...r.querySelectorAll("smart-button"),...r.querySelectorAll("button"),...r.querySelectorAll("a"),...r.querySelectorAll("span")];for(let e=0;e<a.length;e++)"button"===a[e].nodeName.toLowerCase()&&a[e].classList.contains("smart-button")||(a[e].onclick=()=>{l[e].click()})}}}}_createDataRow(e,t,a){const l=this,i=l._columns.filter((e=>e.visible)),n=e.data,r=n.$.id,o=document.createElement("tr"),s={row:o,detail:null};let d=0;o.setAttribute("aria-rowindex",n.$.index+1),l._processAndRenderSelection(n,o,a.hierarchical),a.selection&&d++;for(let t=0;t<i.length;t++){const s=document.createElement("td"),c=i[t];s.setAttribute("data-field",c.dataField),s.setAttribute("aria-colindex",t+1+ +a.selection);let u,f=l._formatCellValue(e,c,s);if(c.freeze&&s.classList.add("freeze-"+("far"===c.freeze?"far":"near")),c.responsivePriority&&s.classList.add("priority-"+c.responsivePriority),!1===c.allowEdit&&(s.classList.add("no-edit"),s.setAttribute("aria-readonly",!0)),0===t&&a.hierarchical){const e=l._areChildrenFiltered(n);n.leaf||(s.classList.add("tree-cell"),u=e),n.level&&(s.classList.add("outline-level-"+Math.min(n.level,10)),!n.leaf&&e||s.classList.add("tree-leaf"))}if(a.virtualization&&c.templateElement){const e=c.templateElement+"";u&&l._setCellContent(s,f,u);const t=u?s.children[0].children[1]:s;e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+n[c.dataField]+"</div>"):t.innerHTML=e,c.templateElementSettings&&(l._cachedTemplates&&l._cachedTemplates[c.dataField+"_"+r]&&(0===l._cachedTemplates[c.dataField+"_"+r].innerHTML.length?delete l._cachedTemplates[c.dataField+"_"+r]:(t.innerHTML="",t.appendChild(l._cachedTemplates[c.dataField+"_"+r]))),c.templateElementSettings(n[c.dataField],r,t.firstElementChild),l._cachedTemplates||(l._cachedTemplates=[]),l._cachedTemplates[c.dataField+"_"+r]||(l._cachedTemplates[c.dataField+"_"+r]=t.firstElementChild))}else l._setCellContent(s,f,u);l.onCellRender&&l.onCellRender(n,c.dataField,n[c.dataField],s),l._applyConditionalFormattingToCell(s,c.dataField,n.$.index),o.appendChild(s),d++}if(o.data=n,o.setAttribute("row-id",r),-1!==l._disabledSelection.indexOf(r)&&(o.removeAttribute("aria-selected"),o.classList.add("disable-select"),a.selection&&o.firstElementChild.firstElementChild.setAttribute("aria-disabled",!0)),n.expanded?(-1===l._expandedIds.indexOf(r)&&l._expandedIds.push(r),o.setAttribute("aria-expanded",!0),o.classList.add("expanded")):!1===n.expanded&&o.setAttribute("aria-expanded",!1),n.level&&l._isCollapsed(n)&&(o.setAttribute("aria-hidden",!0),o.classList.add("collapsed","smart-hidden")),t.appendChild(o),a.rowDetailTemplate){const i=document.createElement("tr");if(-1===l._expandedRowDetailIds.indexOf(r)){if(a.virtualization)return s;i.setAttribute("aria-hidden",!0),i.classList.add("collapsed")}else s.detail=i;i.data=Object.assign(n,{detail:!0}),i.classList.add("smart-table-row-detail"),i.innerHTML=`<td colspan="${d}"><div class="smart-table-detail-container">${l._applyRowDetailTemplate(e)}</div></td>`,t.appendChild(i)}return s}_processAndRenderSelection(e,t,a,l){const i=this,n=e.$.id,r=i._getChildCheckState(e).state;if(a&&i.selectionByHierarchy){const e=i._selectedIds.indexOf(n);!0===r&&-1===e?i._selectedIds.push(n):r||-1===e||i._selectedIds.splice(e,1)}if(!i.selection)return;let o,s;l?(o=t.firstElementChild,s=o.firstElementChild):(o=document.createElement("td"),s=document.createElement("div")),s.className="selection-checkbox",s.setAttribute("role","checkbox"),s.setAttribute("aria-checked",!!r||null===r&&"mixed"),s.setAttribute("aria-label","Toggle row selection"),o.className="smart-table-select-row freeze-near"+(r?" selected":null===r?" indeterminate":""),o.setAttribute("aria-colindex",1),l||(o.appendChild(s),t.appendChild(o)),t.setAttribute("aria-selected",!0===r)}_applyConditionalFormattingToCell(e,t,a){const l=this;if(l._conditionalFormatting&&l._conditionalFormatting[t]){const i=l._conditionalFormatting[t][a];i&&(e.style.backgroundColor=i.background,e.style.color=i.color,e.style.fontFamily=i.fontFamily,e.style.fontSize=i.fontSize)}}_createLastRow(){const e=document.createElement("tr");e.setAttribute("aria-hidden",!0),e.classList.add("last-visible");try{new ResizeObserver((t=>{try{e.classList.toggle("sized",t[0].contentRect.height>0&&null!==e.previousSibling)}catch(e){}})).observe(e)}catch(e){}return e}_createGroupHeader(e,t,a){const l=this;l.columnByDataField[e.groupDataField]||console.error(l.localize("grouping"));const i=l.columnByDataField[e.groupDataField]?l.columnByDataField[e.groupDataField].label:`${l.localize("EMPTY")}`,n=a||document.createElement("tr"),r=document.createElement("td"),o=document.createElement("div"),s=document.createElement("div"),d=document.createElement("div");let c=e.label;if(/<.+?>/.test(c)&&c.replace&&("all"===l.dataSourceSettings.sanitizeHTML?c=c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;"):"blackList"===l.dataSourceSettings.sanitizeHTML&&(c=window.Smart.Utilities.Core.sanitizeHTML(c))),""!==c&&c||(c=`<em class="placeholder">${l.localize("EMPTY")}</em>`),n.removeAttribute("aria-rowindex"),n.data=e,s.classList.add("hierarchy-arrow","smart-arrow","smart-arrow-down"),s.setAttribute("role","button"),s.setAttribute("aria-label","Toggle row"),d.classList.add("group-label"),d.innerHTML=`<span class="group-label-name">${i}: </span>\n <span class="group-label-value">${c}</span>\n <span class="group-label-count">(${l._getLeafCount(e)})</span>`,r.colSpan=l._columns.filter((e=>e.visible)).length,r.classList.add("group-header"),e.level&&(r.classList.add("outline-level-"+Math.min(e.level,10)),l._isCollapsed(e)&&(n.setAttribute("aria-hidden",!0),n.classList.add("collapsed","smart-hidden"))),n.setAttribute("row-id",e.$.id),n.setAttribute("role","group"),n.setAttribute("aria-level",e.level),o.appendChild(s),o.appendChild(d),r.appendChild(o),l._processAndRenderSelection(e,n,!0),n.appendChild(r),n.setAttribute("aria-expanded",e.expanded),n.classList.toggle("expanded",e.expanded),e&&e.$&&!1===e.$.filtered&&n.classList.add("smart-hidden"),l.groupFormatFunction){const t={value:c,row:e.$.id,column:e.groupDataField,data:e,template:null};l.groupFormatFunction(t),c!==t.value&&(d.innerHTML=`<span class="group-label-name">${i}: </span>\n <span class="group-label-value">${t.value}</span>\n <span class="group-label-count">(${l._getLeafCount(e)})</span>`),t.template instanceof HTMLElement&&(d.innerHTML="",d.appendChild(t.template));const a=t.template;let n="";if(a&&a.startsWith("#")){const e=document.querySelector(a);let t=c;if(e&&e instanceof HTMLTemplateElement){const a=e.content.cloneNode(!0),l=document.createElement("div");l.appendChild(a),t=t.toString(),t=t.replace(/'/gi,"\\'"),t=t.replace(/"/gi,'\\"'),n=l.innerHTML.replace(/{{value}}/gi,t),n.indexOf("{{value=")>=0&&(t?(n=n.substring(0,n.indexOf("{{value="))+t+n.substring(n.indexOf("}")),n=n.replace(/}/gi,""),n=n.replace(/{/gi,"")):(n=n.replace(/{{value=/gi,""),n=n.replace(/}}/gi,""))),d.innerHTML=n}}else a&&"string"==typeof a&&(n=a.replace(/{{value}}/gi,c),d.innerHTML=n)}const u=l.selection?1:0;for(let e=0;e<l.columns.length;e++){const t=document.createElement("td"),a=l.columns[e];a.visible&&(t.setAttribute("data-field",a.dataField),t.setAttribute("aria-colindex",e+1+u),t.classList.add("smart-hidden"),n.appendChild(t))}return a||t.appendChild(n),n}_getLeafCount(e){let t=0;return function e(a){for(const l of a)l.leaf?t++:l.children&&l.children.length>0&&e(l.children)}(e.children),t}_isCollapsed(e){let t=e.parent;for(;t;){if(!t.expanded)return!0;t=t.parent}return!1}_areChildrenFiltered(e){if(!e.leaf){if(0===e.children.length&&this.dataSource.virtualDataSource)return!0;for(let t=0;t<e.children.length;t++)if(!1!==e.children[t].$.filtered)return!0;return!1}}_applyRowDetailTemplate(e){const t=this,a=t.dataSource.dataFields;let l=t.rowDetailTemplate;for(let i=0;i<a.length;i++){const n=a[i].name,r=new RegExp(`{{${n}}}`,"g");let o=t.columnByDataField[n]||{dataField:n};if(r.test(l)){let a=t._formatCellValue(e,o,document.createElement("td"));"string"!=typeof a&&(a=e.data[o.dataField]),l=l.replace(r,a)}}return l}_handleFrozenColumnPositions(){const e=this,t=e.rightToLeft,a=e._columns.filter((e=>e.visible));let l=[],i=[],n=0;function r(t,l,i,r,o){const s=a[l-n],d=[s.headerCellElement];for(const e of s.thHierarchy)e.includes[0].dataField===s.dataField&&d.push(e);Array.from(e.$.tableContainer.querySelectorAll(`td:nth-child(${l+1})`)).concat(d).forEach((e=>{e.style[t]=i+"px",o&&(e.style.zIndex=2+r)}))}e.selection&&(t?i.push(0):l.push(0),n=1);for(let e=0+n;e<a.length+n;e++){const r=a[e-n];r.freeze&&(!t&&"far"===r.freeze||t&&"far"!==r.freeze?i.push(e):l.push(e))}if(l.length<2&&i.length<2)return;const o=[];for(const e of a){let t=e.width;t||(t=e.headerCellElement.offsetWidth),e.minWidth&&(t=Math.max(e.minWidth,t)),o.push(t)}if(t){for(let e=0;e<l.length-1;e++){const t=l[e];let a=0;for(let e=t+1;e<o.length;e++)-1!==l.indexOf(e)&&(a+=o[e]);r("left",t,a,e,!0)}for(let e=1;e<i.length;e++){const t=i[e];let a=0;for(let e=0;e<t;e++)-1!==i.indexOf(e)&&(a+=o[e]);r("right",t,a,e,!1)}}else{for(let e=1;e<l.length;e++){const t=l[e];let a=0;for(let e=0;e<t;e++)-1!==l.indexOf(e)&&(a+=o[e]);r("left",t,a,e,!1)}for(let e=0;e<i.length-1;e++){const t=i[e];let a=0;for(let e=t+1;e<o.length;e++)-1!==i.indexOf(e)&&(a+=o[e]);r("right",t,a,e,!0)}}}_formatCellValue(e,t,a,l){const i=this;let n=e&&e.data?e.data.$.id:e;if(void 0===l&&(l=e.data[t.dataField]),"string"==typeof l&&l.indexOf(">")>=0&&/<.+?>/.test(l)&&l.replace&&("all"===i.dataSourceSettings.sanitizeHTML?l=l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;"):"blackList"===i.dataSourceSettings.sanitizeHTML&&(l=window.Smart.Utilities.Core.sanitizeHTML(l))),i._cellsWithFormulas){const e=t.dataField+":"+n;if("string"==typeof l&&/=.+/.test(l)){const t=i._formulaParser;i._cellsWithFormulas[e]=!0,t&&(l=t.parse(l.slice(1)))}else delete i._cellsWithFormulas[e]}if(t.formatFunction){const i={value:l,row:n,column:t.dataField,data:e.data,cell:a,template:null};if(t.formatFunction(i),l=i.value,i.template instanceof HTMLElement)return i.template;if(null===i.template||"string"!=typeof i.template)return l;const r=i.template;let o="";if(r.startsWith("#")){const e=document.querySelector(r);if(e&&e instanceof HTMLTemplateElement){const t=e.content.cloneNode(!0),a=document.createElement("div");return a.appendChild(t),l=(l=(l=l.toString()).replace(/'/gi,"\\'")).replace(/"/gi,'\\"'),o=a.innerHTML.replace(/{{value}}/gi,l),o.indexOf("{{value=")>=0&&(l?(o=o.substring(0,o.indexOf("{{value="))+l+o.substring(o.indexOf("}")),o=o.replace(/}/gi,""),o=o.replace(/{/gi,"")):(o=o.replace(/{{value=/gi,""),o=o.replace(/}}/gi,""))),o}}return o='<div class="smart-table-cell-template">'+r.replace(/{{value}}/gi,l)+"</div>",o}return"date"===t.dataType&&l instanceof Date?l.toLocaleDateString():l}_setCellContent(e,t,a){if(t instanceof HTMLElement==1){for(;e.childNodes.length>0;)e.childNodes[0].remove();if(a){const a=document.createElement("div");a.innerHTML='<div class="hierarchy-arrow smart-arrow smart-arrow-down" role="button" aria-label="Toggle row"></div><div></div>',a.children[1].appendChild(t),e.appendChild(a)}else e.appendChild(t)}else if(a)e.innerHTML=t=`<div>\n <div class="hierarchy-arrow smart-arrow smart-arrow-down" role="button" aria-label="Toggle row"></div>\n <div>${t}</div>\n </div>`;else if("string"==typeof t&&t.indexOf(">")>=0)if(/<.+?>/.test(t)||/&\S+;/.test(t)){if(e._content===t)return;e.innerHTML=t,e._content=t}else e.textContent!==t&&(e.textContent=t);else"html"===this.dataSourceSettings.sanitizeHTMLRender?e.innerHTML!==t&&(e.innerHTML=t):e.textContent!==t&&(e.textContent=t)}_dataBind(e){const t=this;if(t._cellsWithFormulas={},t._templateTags=[],t.dataSource){if(t.dataSource instanceof Smart.DataAdapter==0){const e=t.dataSource;if(Array.isArray(e)){const a=t.columns;let l;if(e.length>0){const t=e[0];l=[];for(let e in t){const a=t[e];"number"==typeof a?l.push({name:e,dataType:"number"}):"boolean"==typeof a?l.push({name:e,dataType:"boolean"}):a instanceof Date?l.push({name:e,dataType:"date"}):a instanceof Object?l.push({name:e,dataType:"any"}):l.push({name:e,dataType:"string"})}}a&&a.length>0&&(l=l||[],a.forEach((e=>{if(e.dataType){const t=l.find((t=>t.name===e.dataField));t?t.dataType=e.dataType:e.map?l.find((t=>e.map.indexOf(t.name)>=0?t:null))&&l.push({name:e.dataField,map:e.map,dataType:e.dataType}):l.push({name:e.dataField,dataType:e.dataType})}}))),t.dataSourceSettings.dataFields&&t.dataSourceSettings.dataFields.length>0?t.dataSource=new Smart.DataAdapter({dataSource:t.dataSource,dataSourceType:t.dataSourceSettings.dataSourceType,dataFields:t.dataSourceSettings.dataFields,keyDataField:t.dataSourceSettings.keyDataField,parentDataField:t.dataSourceSettings.parentDataField,childrenDataField:t.dataSourceSettings.childrenDataField,groupBy:t.dataSourceSettings.groupBy,mapChar:t.dataSourceSettings.mapChar,root:t.dataSourceSettings.root,record:t.dataSourceSettings.record,autoGenerateColumns:t.autoGenerateColumns,id:t.dataSourceSettings.id||t.dataRowId,expandHierarchy:t.expandHierarchy,virtualDataSource:t.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:t.dataSourceSettings.virtualDataSourceOnExpand}):t.dataSource=new Smart.DataAdapter({dataSource:t.dataSource,dataFields:l,id:t.dataRowId||t.dataSourceSettings.id,dataSourceType:t.dataSourceSettings.dataSourceType,keyDataField:t.dataSourceSettings.keyDataField,parentDataField:t.dataSourceSettings.parentDataField,childrenDataField:t.dataSourceSettings.childrenDataField,groupBy:t.dataSourceSettings.groupBy,mapChar:t.dataSourceSettings.mapChar,root:t.dataSourceSettings.root,record:t.dataSourceSettings.record,autoGenerateColumns:t.autoGenerateColumns,expandHierarchy:t.expandHierarchy,virtualDataSource:t.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:t.dataSourceSettings.virtualDataSourceOnExpand})}else t.dataSource=new Smart.DataAdapter({dataSource:[],id:t.dataRowId,expandHierarchy:t.expandHierarchy})}}else{if(t.dataFields=[],!t.columns||Array.isArray(t.columns)&&0===t.columns.length){t.columns=[];const e=t.querySelectorAll("th");for(let a=0;a<e.length;a++){const l=e[a].innerHTML.trim();let i={label:l,dataField:l,dataType:"string"};t.columns.push(i),t.dataFields.push(l)}}else for(let e=0;e<t.columns.length;e++){const a=t.columns[e];"string"==typeof a?t.dataFields.push(a):"object"==typeof a&&t.dataFields.push(a.dataField+(a.dataType?": "+a.dataType:""))}let e=[];if(!t.rows){const a=t.querySelectorAll("tr");for(let l=0;l<a.length;l++){const i={},n=a[l].querySelectorAll("td");if(n.length>0){for(let e=0;e<t.columns.length;e++){const a=t.columns[e];i[a.dataField]=n[e].innerHTML.trim(),i[a.dataField].indexOf("<")>=0&&t._templateTags.push({index:l,dataField:a.dataField,td:n[e]})}e.push(i)}}t.dataSource=new Smart.DataAdapter({dataSource:e,expandHierarchy:t.expandHierarchy,dataFields:t.dataFields,id:t.dataRowId})}const a=t.$.container.querySelectorAll("table");a.length>1&&a[a.length-1].parentNode.removeChild(a[a.length-1])}t.dataSource.expandHierarchy=t.expandHierarchy,t._transformDataSource(),t._applyInitialConditionalFormatting(t.dataSource),t._initColumns(e),t._initRows(),t.dataSource.notify((function(e){if(t.dataSource._updating)return void delete t.dataSource._updating;if(t._editing)return;const a=e.data,l=t._selectedIds.slice(0);let i=e.action;switch(t.rows.canNotify=!1,e.action){case"add":if(a.length)for(let e=0;e<a.length;e++)t._addNewRow(a[e],t.dataSource.length-a.length+e);else t._addNewRow(a,t.dataSource.length-1);break;case"update":if(a.length)for(let l=0;l<a.length;l++){const i=e.index[l];t.rows[i].data=a[l]}break;case"insert":t._addNewRow(a,e.index);for(let e=0;e<t.rows.length;e++)t.rows[e].dataIndex=e;break;case"remove":case"removeLast":i="remove",function(e){const a=e.$.id,l=t._selectedIds.indexOf(a);delete t.rowById[a],t.rows.splice(e.$.index,1),-1!==l&&t._selectedIds.splice(l,1)}(a);break;case"bindingComplete":if(t.filtering&&t.filterRow){const e=t._filterInfo;e.inputFilters?t._filterByAll(e.query):e.rowFilters?t._applyRowFilters():e.appliedFilters&&t._refreshFilters()}}t.rows.canNotify=!0,this.refreshHierarchy(),t._fullRefresh(void 0,l,i)})),t.refresh(),t.dataSource.virtualDataSource&&(t.paging=!0,t._requestVirtualDataSource("dataBind")),t.$.tableContainer.setAttribute("aria-rowcount",t.dataSource.length)}_requestVirtualDataSource(e,t,a=null){const l=this,i=l.pageSize,n=Math.max(l.pageIndex*i,0),r=n+i,o=[],s=[],d={};let c=null;if(l.dataSource._updating=!0,l._sortColumns&&(l._sortColumns.forEach(((e,t)=>o[e.dataField]={sortOrder:e.direction,sortIndex:t})),o.length=l._sortColumns.length),l._filterInfo.appliedFilters){for(let e in l._filterInfo.appliedFilters)s[e]=l._filterInfo.appliedFilters[e];s.length=Object.keys(l._filterInfo.appliedFilters).length,c="and"}else{const e=l._filterInfo.inputFilters||l._filterInfo.rowFilters;e&&(e.forEach((e=>s[e[0]]=e[1])),s.length=e.length),c=l._filterInfo.inputFilters?"or":"and"}l._editing&&(d.row=l._editing.row.data),l.$.loadingIndicatorContainer.classList.remove("smart-hidden"),l.setAttribute("loading",""),l.dataSource.onVirtualDataSourceRequested((function(i){let n=!0;-1!==["add","update","remove"].indexOf(e)&&t&&(n=t(i.result)),l.$.loadingIndicatorContainer.classList.add("smart-hidden"),l.removeAttribute("loading"),n&&(a&&(a.expanded=!0),l._initRows(),l._refreshDataRows())}),{first:n,last:r,sorting:o,filtering:s,filterOperator:c,grouping:[],edit:d,row:a,action:e})}sortBy(e,t){const a=this,l=a.columnByDataField[e];if(l){if(!1===l.allowSort)return;e=l.dataField}if(a._sortBy({column:l,columnDataField:e,sortOrder:t,dataFields:a.dataSource.dataFields,columnByDataField:"columnByDataField"}),null===e){const e=!0===a._sortOnClick?"interaction":"programmatic";a.$.fireEvent("sort",{columns:[],sortDataFields:[],sortOrders:[],sortDataTypes:[],type:e})}}_sortBy(e){const t=this,a=e.column,l=e.columnDataField,i=e.sortOrder,n=e.dataFields,r=e.columnByDataField,o=[],s=[],d=[],c=function(e){t._addSortIconContainer(e),e.headerCellElement&&(e.headerCellElement.removeAttribute("aria-sort"),e.headerCellElement.sortIconContainerElement.classList.remove("desc"),e.headerCellElement.sortIconContainerElement.classList.remove("asc")),e.sortOrder=null},u=function(){if(t._sortColumns&&t._sortColumns.length>0)for(let e=0;e<t._sortColumns.length;e++){const a=t._sortColumns[e],l=t[r][a.dataField];c(l)}t._sortColumns=[]};if(null==a)return void(t._sortColumns&&t._sortColumns.length>0&&(u(),t._sortCallback(o,s,d),t._updateState("sorted")));if("none"===t.sortMode||!t.dataSource)return;if(i&&a.sortOrder===i)return;let f=i||"asc";null===i&&(f=null),c(a),t._sortColumns||(t._sortColumns=[]);let m="string";for(let e=0;e<n.length;e++){const t=n[e];if(t.name===l){m=t.dataType,"any"===m&&(m="number");break}}let h=!0;for(let e=0;e<t._sortColumns.length;e++){const n=t._sortColumns[e];if(n.dataField===l)if(h=!1,null===f&&(n.direction="desc"),"asc"===n.direction)n.direction="desc",f="desc";else if("desc"===n.direction){t._sortColumns.splice(e,1),c(a),f=i;break}}h&&("one"===t.sortMode&&u(),t._sortColumns.push({dataField:l,direction:f,dataType:m})),t._addSortIconContainer(a),null!==f?(a.headerCellElement&&(a.headerCellElement.sortIconContainerElement.classList.remove("asc"),a.headerCellElement.sortIconContainerElement.classList.remove("desc")),a.sortOrder=f,a.headerCellElement&&("desc"===f?(a.headerCellElement.sortIconContainerElement.classList.add("desc"),a.headerCellElement.setAttribute("aria-sort","descending")):(a.headerCellElement.sortIconContainerElement.classList.add("asc"),a.headerCellElement.setAttribute("aria-sort","ascending")))):a.headerCellElement&&(a.headerCellElement.sortIconContainerElement.classList.remove("asc"),a.headerCellElement.sortIconContainerElement.classList.remove("desc"),a.headerCellElement.removeAttribute("aria-sort"));for(let e=0;e<t._sortColumns.length;e++){const a=t._sortColumns[e],l=t[r][a.dataField];o.push(a.dataField),s.push(a.direction),d.push(a.dataType),l.headerCellElement&&l.headerCellElement.sortIconContainerElement.setAttribute("order",e+1)}if(t._sortCallback(o,s,d),t._updateState("sorted"),!t._doNotFireEvent){const e=!0===t._sortOnClick?"interaction":"programmatic";t.$.fireEvent("sort",{columns:t._sortColumns,sortDataFields:o,sortOrders:s,sortDataTypes:d,type:e})}}_addSortIconContainer(e,t,a){const l=e.headerCellElement;if(l&&!l.sortIconContainerElement){const e=document.createElement("div");e.classList.add("sort-by"),e.setAttribute("aria-hidden",!0),t&&e.classList.add(t),l.firstElementChild.appendChild(e),l.sortIconContainerElement=e,"asc"===t?l.setAttribute("aria-sort","ascending"):"desc"===t?l.setAttribute("aria-sort","descending"):l.removeAttribute("aria-sort"),void 0!==a&&e.setAttribute("order",a)}}_sortCallback(e,t,a){const l=this,i=l.dataSource;if(!i.virtualDataSource){let n=null;for(let e=0;e<l.columns.length;e++){const t=l.columns[e];t.sort&&(n||(n={}),n[t.dataField]=t.sort)}i._sort(l.dataSource.boundSource,e,t,a,l.sort,n);let r=[],o=[];if(i.groupBy&&i.groupBy.toArray&&(r=i.groupBy.toArray().slice(0)),r.length>0&&(o=l._getExpandedGroups(i.boundHierarchy)),i.refreshHierarchy(),r.length>0){const e=l._doNotFireEvent;l._doNotFireEvent=!0,l._restoreExpandedGroups(o),l._doNotFireEvent=e}}l._fullRefresh("sort")}clearSort(){this.sortBy(null)}_fullRefresh(e,t,a,l){const i=this;if(i.__updating)return;if(i.dataSource.virtualDataSource)return void i._requestVirtualDataSource(e,l);const n=i._getFractionOfMax();t||(t=i._selectedIds.slice(0)),t=JSON.stringify(t.sort()),i._initRows(),i._refreshDataRows(),i._setFractionOfMax(n),"filter"===e&&(i._updateSelectAllState(),a||(a="filter")),t!==JSON.stringify(i._selectedIds.slice(0).sort())&&("filter"!==e&&i._updateSelectAllState(),i._updateState("selected"),i.$.fireEvent("change",{type:a})),"string"==typeof e&&-1!==e.indexOf("page")&&i._fixFrozenHeaderFirefox()}_pagerChangeHandler(e){const t=this;(t.isInShadowDOM?e.composedPath()[0]:e.target)===t.$.pager&&(t.pageIndex=e.detail.index,t._fullRefresh("pageIndexChange"),t.$.fireEvent("page",{action:"pageIndexChange"}))}_pagerPageSizeChanged(e){const t=this;t.pageSize=e.detail.value,t._fullRefresh("pageSizeChange"),t.$.fireEvent("page",{action:"pageSizeChange"})}_filterInputKeyupHandler(){const e=this;clearTimeout(e._filterInputTimeout),e._filterInputTimeout=setTimeout((function(){if(e._filterInfo&&e.$.filterInput.value!==e._filterInfo.query){const t=e.context;e.context=e,e._filterByAll(e.$.filterInput.value),e.context=t}}),500)}_filterByAll(e){const t=this;if(t._filterInfo.query=e,""===e)return void t.clearFilters();const a=[];t._clearRowFilters(),delete t._filterInfo.appliedFilters,t._filterInfo.stringDataFields.forEach((t=>{const l=new Smart.Utilities.FilterGroup,i=l.createFilter("string",e,"CONTAINS");l.addFilter("or",i),a.push([t,l])})),t.dataSource.virtualDataSource||t.dataSource._filter(a,t.filterOperator),t._filterInfo.inputFilters=a,t._fullRefresh("filter"),t._updateState("filtered"),t._doNotFireEvent||t.$.fireEvent("filter",{action:"add",filters:a})}_setupPagingAndFiltering(){const e=this;e.$.pager.$.pageSizeSelector.classList.add("underlined"),e.$.pager.$.pageSizeSelector.dropDownAppendTo="body",e._filterInfo={query:""},e._applyFilterTemplate(),e.$.header.classList.toggle("smart-hidden",(!e.filtering||e.filterRow||e.columnMenu)&&!e.conditionalFormattingButton)}_applyFilterTemplate(){const e=this,t=e.filterTemplate;if(e.$.filterTemplateContainer.innerHTML="",!t)return e.$.filterInput.classList.remove("smart-hidden"),e.$.filterTemplateContainer.classList.add("smart-hidden"),void(e.filterTemplate=null);const a=document.getElementById(t);if(a&&a instanceof HTMLTemplateElement){const t=document.importNode(a.content,!0);e.$.filterInput.classList.add("smart-hidden"),e.$.filterTemplateContainer.classList.remove("smart-hidden"),e.$.filterTemplateContainer.appendChild(t)}else e.filterTemplate=null,e.$.filterInput.classList.remove("smart-hidden"),e.$.filterTemplateContainer.classList.add("smart-hidden")}_refreshFilters(e){const t=this,a=[];for(let e in t._filterInfo.appliedFilters){let l=t._filterInfo.appliedFilters[e];a.push([e,l])}0!==a.length?(t._clearFilterInput(),t._clearRowFilters(),t.dataSource.virtualDataSource||t.dataSource._filter(a,t.filterOperator),t._fullRefresh("filter"),t._updateState("filtered"),e&&!t._doNotFireEvent&&t.$.fireEvent("filter",{action:e,filters:a})):t.clearFilters()}_localize(){const e=this,t=e.$.pager;t.messages[e.locale]||(t.messages[e.locale]={}),t.messages[e.locale].pageSizeLabel=e.localize("itemsPerPage"),t.messages[e.locale].summaryPrefix=e.localize("summaryPrefix"),t.messages[e.locale].summarySuffix="",t.$.firstButton.setAttribute("tooltip",e.localize("firstButton")),t.$.previousButton.setAttribute("tooltip",e.localize("previousButton")),t.$.nextButton.setAttribute("tooltip",e.localize("nextButton")),t.$.lastButton.setAttribute("tooltip",e.localize("lastButton")),e.$.filterInput.placeholder=e.localize("filterPlaceholder"),e.$.conditionalFormattingButton.setAttribute("tooltip",e.localize("conditionalFormatting")),e._filterInfo.stringConditions=[{value:"EMPTY",label:e.localize("EMPTY")},{value:"NOT_EMPTY",label:e.localize("NOT_EMPTY")},{value:"CONTAINS",label:e.localize("CONTAINS")},{value:"CONTAINS_CASE_SENSITIVE",label:e.localize("CONTAINS_CASE_SENSITIVE")},{value:"DOES_NOT_CONTAIN",label:e.localize("DOES_NOT_CONTAIN")},{value:"DOES_NOT_CONTAIN_CASE_SENSITIVE",label:e.localize("DOES_NOT_CONTAIN_CASE_SENSITIVE")},{value:"STARTS_WITH",label:e.localize("STARTS_WITH")},{value:"STARTS_WITH_CASE_SENSITIVE",label:e.localize("STARTS_WITH_CASE_SENSITIVE")},{value:"ENDS_WITH",label:e.localize("ENDS_WITH")},{value:"ENDS_WITH_CASE_SENSITIVE",label:e.localize("ENDS_WITH_CASE_SENSITIVE")},{value:"EQUAL",label:e.localize("EQUAL")},{value:"EQUAL_CASE_SENSITIVE",label:e.localize("EQUAL_CASE_SENSITIVE")},{value:"NULL",label:e.localize("NULL")},{value:"NOT_NULL",label:e.localize("NOT_NULL")}],e._filterInfo.numberAndDateConditions=[{value:"EQUAL",label:e.localize("EQUAL")},{value:"NOT_EQUAL",label:e.localize("NOT_EQUAL")},{value:"LESS_THAN",label:e.localize("LESS_THAN")},{value:"LESS_THAN_OR_EQUAL",label:e.localize("LESS_THAN_OR_EQUAL")},{value:"GREATER_THAN",label:e.localize("GREATER_THAN")},{value:"GREATER_THAN_OR_EQUAL",label:e.localize("GREATER_THAN_OR_EQUAL")},{value:"NULL",label:e.localize("NULL")},{value:"NOT_NULL",label:e.localize("NOT_NULL")}]}_createFilterRow(e){const t=this;if(!t.filtering||!t.filterRow)return;if(e)return void t.$.tableContainer.children[1].insertBefore(e,t.$.tableContainer.children[1].firstElementChild);const a=document.createElement("tr"),l=t._columns.filter((e=>e.visible));let i="";a.className="smart-table-filter-row",t.selection&&(i+="<td></td>");for(let e=0;e<l.length;e++){const a=l[e];i+=t._createFilterRowInput(a)}a.innerHTML=i,t.$.tableContainer.children[1].insertBefore(a,t.$.tableContainer.children[1].firstElementChild)}_createFilterRowInput(e){const t=this,a=` animation="${t.animation}" `,l=t.rightToLeft?" right-to-left":"",i=[];let n,r,o,s;return"string"===e.dataType?(n=t._filterInfo.stringConditions,r="string",o="string-filter",s=t.localize("CONTAINS")):(n=t._filterInfo.numberAndDateConditions,r=e.dataType,o="num-date-filter",s=t.localize("EQUAL")),e.freeze&&i.push("freeze-"+("far"===e.freeze?"far":"near")),e.responsivePriority&&i.push("priority-"+e.responsivePriority),!1===e.allowFilter&&i.push("no-filter"),`<td${i.length?' class="'+i.join(" ")+'"':""} filter-for="${e.dataField}">\n <div>\n <input type="${r}" class="filter-value" aria-label="Filter value" />\n <smart-input class="${o}${a}data-source='${JSON.stringify(n)}' drop-down-button-position="right" drop-down-width="auto" readonly${l} value="${s}" title="${t.localize("filterCondition")}" aria-label="Filter condition"></smart-input>\n <smart-button class="smart-hidden" title="${t.localize("clearFilter")}"${a}${l} aria-label="Clear filter"></smart-button>\n </div>\n </td>`}_tableContainerChangeHandler(e){const t=this,a=t.isInShadowDOM?e.composedPath()[0]:e.target;a.classList.contains("filter-value")&&("date"===a.type||a instanceof Smart.Input&&(""!==a.previousElementSibling.value||-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(e.detail.value)))&&t._applyRowFilters()}_tableContainerClickHandler(e){const t=this;if(t._editing)return;const a=t.isInShadowDOM?e.composedPath()[0]:e.target;if(!t.$.tableContainer.contains(a))return;const l=a.closest("tbody tr[row-id], tfoot tr.grand-total");if(l){t.closeColumnMenu();const i=a.closest("td");if(a.classList.contains("hierarchy-arrow")){const e=t.animation;return t.virtualization&&(t._animation="none"),t._hierarchyArrowClickHandler(l,i),void(t.virtualization&&(t._animation=e))}const n=l.getAttribute("row-id");let r;n&&(r=t.rowById?t.rowById[n].data:t.rows.dataItemById[n]);const o=r?r.$.id:void 0,s=i?i.getAttribute("data-field"):void 0;if(!r&&l.classList.contains("grand-total")&&(r=l.data),void 0!==s){const a={};for(let e=0;e<t.columns.length;e++){const l=t.columns[e];a[l.dataField]=r[l.dataField]}t.$.fireEvent("cellClick",{id:n,row:a,dataField:s,value:r[s],originalEvent:e})}if(t._toggleSelection(l,r,e,a),t.editing||t.drillDown){if(!s||i.classList.contains("no-edit"))return;clearTimeout(t._dblclickObject.timeout),t._dblclickObject.numberOfClicks++,2===t._dblclickObject.numberOfClicks?(t._dblclickObject.numberOfClicks=0,t._beginEdit({rowElement:l,cell:i,dataField:s})):t._dblclickObject.timeout=setTimeout((function(){t._dblclickObject.numberOfClicks=0}),300)}return void(t.rowDetailTemplate&&t._toggleRowDetail(l,o))}const i=a.closest(".smart-table-select-all");if(i){if("one"===t.selectionMode)return;return void t._selectAllCheckboxClickHandler(i)}const n=a.closest(".smart-table-filter-row smart-button")||a.closest(".smart-table-column-menu smart-button");if(n){const e=n.parentElement.firstElementChild,a=n.parentElement.children[1];return e.value="",-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(a.$.input.dataValue)&&(a.value=t.localize("text"===e.type?"CONTAINS":"EQUAL"),delete a.$.input.dataValue),void t._applyRowFilters()}}_toggleSelection(e,t,a,l){const i=this;if(!i.selection||"cell"===i.selectionMode||e.classList.contains("disable-select")||e.classList.contains("grand-total"))return;function n(){i._selectedIds=[],Array.from(i.$.tableContainer.querySelectorAll(".smart-table-select-row.selected")).forEach((e=>{e.parentElement.classList.contains("disable-select")||e.parentElement.setAttribute("aria-selected",!1),e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1)}))}const r=t.$.id;let o=-1!==i._selectedIds.indexOf(r);if(i._interaction=!0,"one"===i.selectionMode){if(o)return;n(),i.select(r)}if("many"===i.selectionMode)if(o)i.unselect(r);else{if(i._disabledSelection.length>0&&t.children&&t.children.length>0){let e=0,a=0,l=[];if(t.children.forEach((t=>{const n=t.$.id;-1===i._selectedIds.indexOf(n)?e++:l.push(n),-1!==i._disabledSelection.indexOf(n)&&a++})),e===a)return i.unselect(l),void delete i._interaction}i.select(r),i._selectionStart={data:t,element:e}}else{if(i._selectionStart&&a.shiftKey){let t,a,l;if(i.virtualization?(t=i.rows,a=t.findIndex((e=>e.data.$.id===r)),l=t.findIndex((e=>e.data.$.id===i._selectionStart.data.$.id))):(t=Array.from(i.$.tableContainer.querySelectorAll("tr[row-id]:not([unused])")),a=t.indexOf(e),l=t.indexOf(i._selectionStart.element)),a!==l){const e=JSON.stringify(i._selectedIds.slice(0).sort()),r=Math.min(a,l),o=Math.max(a,l);n();const s=[];for(let e=r;e<=o;e++){const a=t[e];s.push(a.data.$.id)}return i._changeSelectionOfMultiple(s,"select","interaction",e),getSelection().removeAllRanges(),void delete i._interaction}if(1===i._selectedIds.length)return void delete i._interaction}const s=!!l&&(l.classList.contains("selection-checkbox")||l.classList.contains("smart-table-select-row"));let d=!1;if(1===i._selectedIds.length)d=!0;else if(i.hasAttribute("hierarchy")&&i.selectionByHierarchy){const e=[];!function e(t,a){const l=t.$.id;-1!==i._selectedIds.indexOf(l)&&a.push(l),t.children&&t.children.forEach((t=>e(t,a)))}(t,e),i._selectedIds.length===e.length&&(d=!0),t&&t.leaf&&(d=!0),o=i._getChildCheckState(t).maxSelected}else i.hasAttribute("hierarchy")&&!i.selectionByHierarchy&&(d=!0);if(o&&(s||d||a.ctrlKey||a.metaKey))return delete i._selectionStart,i.unselect(r),void delete i._interaction;s||a.ctrlKey||a.metaKey||n(),i.select(r),i._selectionStart={data:t,element:e}}delete i._interaction}_selectAllCheckboxClickHandler(e,t){const a=this;if(void 0===t){const l=a._filterInfo;if(l.inputFilters||l.rowFilters||l.appliedFilters)return void a._selectAllCheckboxClickHandlerFiltering(e);if(t=a.dataSource,a.hasAttribute("hierarchy")&&a._disabledSelection.length>0){const e=t.boundHierarchy,l=a._getChildCheckState({children:e}).maxSelected;return void a._changeSelectionOfMultiple(e.map((e=>e.$.id)),l?"unselect":"select","interaction")}}const l=t.length,i=a._selectedIds.length===l-a._disabledSelection.length+a._selectableGroupRecords.length,n=a._selectedIds.slice(0);if(a._selectedIds=[],i)a._updateCSSOnUnselectAll(e);else{let i,n=0;for(let e=0;e<l;e++){const l=t[e].$.id;-1===a._disabledSelection.indexOf(l)&&(a._selectedIds.push(l),n++)}n===l?i=!0:0===n&&(i=!1),a._updateCSSOnSelectAll(e,i),a._selectableGroupRecords.length>0&&(a._selectedIds=a._selectedIds.concat(a._selectableGroupRecords))}n.length!==a._selectedIds.length&&(a._updateState("selected"),a.$.fireEvent("change",{type:"interaction"}))}_selectAllCheckboxClickHandlerFiltering(e){const t=this,a=t.dataSource,l=t._selectedIds.slice(0),i=[],n=[];let r=0;for(let e=0;e<a.length;e++){const o=a[e];if(!1===o.$.filtered)continue;const s=o.$.id;r++,-1!==l.indexOf(s)&&i.push(s),-1===t._disabledSelection.indexOf(s)&&n.push(s)}const o=i.length===n.length;if(t._selectedIds=t._selectedIds.filter((e=>-1===n.indexOf(e))),o)t._updateCSSOnUnselectAll(e);else{let a;t._selectedIds=t._selectedIds.concat(n),n.length===r?a=!0:0===n.length&&(a=!1),t._updateCSSOnSelectAll(e,a)}l.length!==t._selectedIds.length&&(t._updateState("selected"),t.$.fireEvent("change",{type:"interaction"}))}_updateCSSOnUnselectAll(e){e.classList.remove("indeterminate","selected"),e.firstElementChild.setAttribute("aria-checked",!1),Array.from(this.$.tableContainer.querySelectorAll(".smart-table-select-row")).forEach((e=>{e.parentElement.classList.contains("disable-select")||e.parentElement.setAttribute("aria-selected",!1),e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1)}))}_updateCSSOnSelectAll(e,t){t?(e.classList.remove("indeterminate"),e.classList.add("selected"),e.firstElementChild.setAttribute("aria-checked",!0)):!1===t?(e.classList.remove("indeterminate","selected"),e.firstElementChild.setAttribute("aria-checked",!1)):(e.classList.remove("selected"),e.classList.add("indeterminate"),e.firstElementChild.setAttribute("aria-checked","mixed")),Array.from(this.$.tableContainer.querySelectorAll(".smart-table-select-row")).forEach((e=>{e.parentElement.classList.contains("disable-select")||(e.parentElement.setAttribute("aria-selected",!0),e.classList.remove("indeterminate"),e.classList.add("selected"),e.firstElementChild.setAttribute("aria-checked",!0))}))}_beginEdit(e){const t=this,a=t.editMode,l=e.dataField;let i=e.rowId,n=e.rowElement,r=e.rowObject,o=e.cell,s=[],d=[];if(t.editing){n||(n=t.$.tableContainer.querySelector(`tr[row-id="${i}"]:not([unused])`)),r||(i=n.getAttribute("row-id"),r=t.rowById[i],i=r.data.$.id),"row"===a?(s=n.querySelectorAll("td[data-field]"),d=t._columns.filter((e=>e.visible)).map((e=>e.dataField)),o||(o=l?n.querySelector(`td[data-field="${l}"`):s[0])):(o||(o=n.querySelector(`td[data-field="${l}"`)),s=[o],d=[l]),t._editing={row:r,cells:[]};for(let e=0;e<d.length;e++){const a=s[e];let l=d[e];const n=t.columnByDataField[l];if(!1===n.allowEdit)continue;n.transform&&(l=n.originalDataField);const c=r.data[l],u=t._initEditor(n,i,l,c);let f=u instanceof HTMLInputElement&&"date"===u.type;if(n.editor&&n.editor.template)n.editor.onRender&&n.editor.onRender(i,l,u,c);else if(f)if(c instanceof Date&&!isNaN(c.getTime())){const e=(c.getMonth()+1).toString(),t=c.getDate().toString();u.value=`${c.getFullYear()}-${"0".repeat(2-e.length)}${e}-${"0".repeat(2-t.length)}${t}`}else u.value="";else u.value=void 0===c?"":c;a.classList.add("editing"),a.innerHTML="",a.appendChild(u),a===o&&u.focus&&(u.focus(),n.editor&&n.editor.template||f||!u.select||u.select()),t._editing.cells.push({dataField:l,editor:u,element:a}),t.$.fireEvent("cellBeginEdit",{id:r.data.$.id,row:r.data,value:r.data[l],dataField:l})}"row"===a&&t.$.fireEvent("rowBeginEdit",{id:r.data.$.id,row:r.data})}}_initEditor(e,t,a,l){let i=this._editors[a];if(i)return i;if(e.editor&&e.editor.template){const n=document.createElement("div");return n.innerHTML=e.editor.template,i=n.firstElementChild,i.className="smart-table-editor",e.editor.onInit&&e.editor.onInit(t,a,i,l),i}return i=document.createElement("input"),i.className="smart-table-editor standard","number"===e.dataType?i.type="number":"date"===e.dataType?i.type="date":i.type="text",this._editors[a]=i,i}_toggleRowDetail(e,t){const a=this;if(a.virtualization)return void a._toggleRowDetailVirtualization(e,t);const l=e.nextElementSibling;l.classList.toggle("collapsed"),l.classList.contains("collapsed")?(l.setAttribute("aria-hidden",!0),a._expandedRowDetailIds=a._expandedRowDetailIds.filter((e=>e!==t))):(l.removeAttribute("aria-hidden"),a._expandedRowDetailIds.push(t))}_toggleRowDetailVirtualization(e,t){const a=this;let l=e.nextElementSibling;function i(){let e=a.$.virtualizationContainer.$.verticalScrollBar,t=a.$.virtualizationContainer.$.verticalScrollBar.value;a._ignoreVerticalChange=!0,a._refreshDataRows(),t=Math.min(e.max,t),e.value=t,delete a._ignoreVerticalChange,a._onVerticalChange({detail:{value:t}},!0)}if(l&&l.classList.contains("smart-table-row-detail")&&!l.classList.contains("collapsed"))return l.setAttribute("aria-hidden",!0),a._expandedRowDetailIds=a._expandedRowDetailIds.filter((e=>e!==t)),l.classList.add("collapsed"),l.remove(),void i();const n=e.data;l=document.createElement("tr"),l.classList.add("collapsed"),a._createRowDetailOnDemand(l,{data:n},n),e.parentElement.insertBefore(l,e.nextElementSibling),a._expandedRowDetailIds.push(t),l.classList.remove("collapsed"),i()}_setFocusable(){const e=this,t="smart-table"===e.nodeName.toLowerCase();if(!e.keyboardNavigation||e.disabled||e.unfocusable||e.hasAttribute("modal"))return e.$.tableContainer.removeAttribute("tabindex"),t&&(e.$.filterInput.unfocusable=!0,e.$.pager.unfocusable=!0),void(e.$.conditionalFormattingButton.unfocusable=!0);const a=e.$.tableContainer.getAttribute("tabindex");(null===a||a<0)&&e.$.tableContainer.setAttribute("tabindex",0),t&&(e.$.filterInput.unfocusable=!1,e.$.pager.unfocusable=!1),e.$.conditionalFormattingButton.unfocusable=!1}_tableContainerFocusHandler(){const e=this;e._focusedCell&&e.$.tableContainer.contains(e._focusedCell)||e._focusCell(e.$.tableContainer.children[1].querySelector("tr:not([unused]) td[data-field], tr:not([unused]) td.group-header"))}_tableContainerDownHandler(e){const t=this.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;this._focusCell(t.closest("td[data-field], td.group-header")),e.stopPropagation()}_focusCell(e,t){const a=this;if(!e||!e.hasAttribute("data-field")&&!e.classList.contains("group-header")||e.parentElement.classList.contains("grand-total"))return!1;if(a._focusedCell){if(a._focusedCell===e)return!1;a._focusedCell.removeAttribute("focus")}if(a._focusedCell=e,e.setAttribute("focus",""),!t)return;const l=a.$.tableContainer.parentElement,i=a.$.header.offsetHeight,n=a.freezeHeader?a.$.tableContainer.firstElementChild.offsetHeight:0,r=l.scrollTop;let o=e.offsetTop-i-n;if(o<r)l.scrollTop=o;else{const t=a.footerRow&&a.freezeFooter?a.$.tableContainer.lastElementChild.offsetHeight:0,s=a.$.pager.offsetHeight,d=l.clientHeight-(i+n+t+s);o+=e.offsetHeight,o>r+d&&(l.scrollTop=o-d)}if(e.classList.contains("freeze-near")||e.classList.contains("freeze-far"))return;const s=l.scrollLeft,d=a.$.tableContainer.querySelector("tr[row-id]:not([unused])");let c,u=0;if(Array.from(d.children).forEach((e=>{e.classList.contains("freeze-near")&&(u+=e.offsetWidth)})),a.rightToLeft){let t=e.previousElementSibling;for(c=0;t;)t.classList.contains("freeze-near")||(c-=t.offsetWidth),t=t.previousElementSibling;if(c>s)l.scrollLeft=c;else{const t=l.clientWidth;c-=e.offsetWidth,c<s-t&&(l.scrollLeft=c+t-u)}}else if(c=e.offsetLeft-u,c<s)l.scrollLeft=c;else{const t=l.clientWidth;c+=e.offsetWidth+u,c>s+t&&(l.scrollLeft=c-t)}}focus(){const e=this;!e.keyboardNavigation||e.disabled||e.unfocusable||e.hasAttribute("modal")||e.$.tableContainer.focus()}blur(){this.$.tableContainer.blur()}_tableContainerKeydownHandler(e){const t=this,a=t.isInShadowDOM?e.composedPath()[0]:e.target,l=e.key;if("Shift"===l)return void("extended"===t.selectionMode&&t.$.tableContainer.classList.add("smart-unselectable"));if(!t.contains(a))return;if(a&&"INPUT"===a.nodeName&&!t._editing)return;const i=t._focusedCell;if(!i)return;const n=t.virtualization,r=i.classList.contains("group-header");if(r&&-1!==["ArrowRight","ArrowLeft","Home","End","Escape","F2"].indexOf(l))return void e.preventDefault();if(t._editing){switch(l){case"Enter":t.endEdit();break;case"Escape":t.cancelEdit();break;default:return}return t.$.tableContainer.focus(),void e.preventDefault()}const o=i.parentElement;if(n&&o){const e=t.$.virtualizationContainer.$.verticalScrollBar,a=e.value,i=o.data.$.id;if("ArrowUp"===l&&0===a&&i===t._rowsVirtual[0].data.$.id||"ArrowDown"===l&&a===e.max&&i===t._rowsVirtual[t._rowsVirtual.length-1].data.$.id)return}let s="ArrowRight",d="ArrowLeft";switch(t.rightToLeft&&(s="ArrowLeft",d="ArrowRight"),l){case s:case d:{const a=l===s?"nextElementSibling":"previousElementSibling";let r=i[a];for(;r&&r.classList.contains("smart-hidden");)r=r[a];t._focusCell(r,!n,e),t._scrollToVirtualization(l===s?"nextArrow":"prevArrow",r);break}case"ArrowUp":case"ArrowDown":{const a="ArrowUp"===l?"previousElementSibling":"nextElementSibling";let s=o[a];for(;s&&(s.classList.contains("smart-table-row-detail")||s.classList.contains("collapsed"));)s=s[a];s&&(r?t._focusCell(s.querySelector("td[data-field], .group-header"),!n,e):t._focusCell(s.querySelector(`td[data-field="${i.getAttribute("data-field")}"], .group-header`),!n,e),t._scrollToVirtualization(l,s));break}case"Home":t._focusCell(o.querySelector("td[data-field]"),!n,e),t._scrollToVirtualization(l);break;case"End":{const a=o.querySelectorAll("td[data-field]");let i=a.length-1,r=a[i];for(;r.classList.contains("smart-hidden");)i--,r=a[i];t._focusCell(r,!n,e),t._scrollToVirtualization(l);break}case"PageDown":t._pageDownHandler(i,e);break;case"PageUp":t._pageUpHandler(i,e);break;case"Enter":{const a=o.data;t.dataSource.boundHierarchy&&t._areChildrenFiltered(a)?t._hierarchyArrowClickHandler(o,i,e):t.rowDetailTemplate&&t._toggleRowDetail(o,a.$.id);break}case" ":t._toggleSelection(o,o.data,e);break;case"F2":t.beginEdit(o.data.$.id,i.getAttribute("data-field"));break;default:return}if(e.preventDefault(),t.onKeyboardScroll){const e=n?t.$.virtualizationContainer:t.$.container;t.onKeyboardScroll(l,e.scrollTop,e.scrollLeft)}}_pageDownHandler(e,t){const a=this,l=a.paging;if(!l&&e.parentElement===e.parentElement.parentElement.lastElementChild)return;const i=a.virtualization,n=a.$.tableContainer,r=n.parentElement,o=i?a.$.virtualizationContainer:r;let s=e.getAttribute("data-field");function d(){const e=n.querySelectorAll("tr[row-id]:not([unused])");let t=i?0:a.$.header.offsetHeight+a.$.pager.offsetHeight;a.footerRow&&a.freezeFooter&&(t+=n.lastElementChild.offsetHeight);for(let a=e.length-1;a>=0;a--){const l=e[a];if(!l.classList.contains("collapsed")&&l.offsetTop+l.offsetHeight<=(i?-r.offsetTop:r.scrollTop)+o.clientHeight-t)return l.querySelector(`td[data-field${s}], .group-header`)}}s=s?`="${s}"`:"";let c=d();if(c)if(e===c){const u=(a.freezeHeader?n.firstElementChild.offsetHeight:0)+a._rowHeight;let f;if(i?(f=o.$.verticalScrollBar.value,o.$.verticalScrollBar.value+=o.clientHeight-u):r.scrollTop+=r.clientHeight-u,c=d(),l&&(i&&f===o.$.verticalScrollBar.value||!i&&e===c)){const e=a.pageIndex;a.navigateTo(a.pageIndex+1),a.pageIndex!==e&&(i&&(o.$.verticalScrollBar.value=0),a._focusCell(n.querySelector(`tr[row-id]:not([unused]) td[data-field${s}], tr[row-id]:not([unused]) .group-header`),!i,t))}else a._focusCell(c,void 0,t)}else a._focusCell(c,void 0,t)}_pageUpHandler(e,t){const a=this,l=a.virtualization,i=a.$.tableContainer,n=i.parentElement,r=l?a.$.virtualizationContainer:n;let o=e.getAttribute("data-field");function s(){const e=i.querySelectorAll("tr[row-id]:not([unused])");let t=0;a.freezeHeader&&(t=i.firstElementChild.offsetHeight);for(let a=0;a<e.length;a++){const i=e[a];if(!i.classList.contains("collapsed")&&i.offsetTop>=(l?-n.offsetTop:n.scrollTop)+t)return i.querySelector(`td[data-field${o}], .group-header`)}}o=o?`="${o}"`:"";let d=s();if(d)if(e===d){const c=(a.freezeHeader?i.firstElementChild.offsetHeight:0)+a._rowHeight;let u;if(l?(u=r.$.verticalScrollBar.value,r.$.verticalScrollBar.value-=r.clientHeight-c):n.scrollTop-=n.clientHeight-c,d=s(),a.paging&&(l&&u===r.$.verticalScrollBar.value||!l&&e===d)){const e=a.pageIndex;if(a.navigateTo(a.pageIndex-1),a.pageIndex!==e){l&&(r.$.verticalScrollBar.value=r.$.verticalScrollBar.max);const e=i.querySelectorAll(`tr[row-id]:not([aria-hidden="true"]) td[data-field${o}], tr[row-id]:not([aria-hidden="true"]) .group-header`);a._focusCell(e[e.length-1],!l,t)}}else a._focusCell(d,void 0,t)}else a._focusCell(d,void 0,t)}_tableContainerKeyupHandler(e){const t=this,a=t.isInShadowDOM?e.composedPath()[0]:e.target;if("Shift"===e.key&&"extended"===t.selectionMode&&t.$.tableContainer.classList.remove("smart-unselectable"),t.contains(a))return a.classList.contains("filter-value")&&"date"!==a.type?(clearTimeout(t._filterRowTimeout),void(t._filterRowTimeout=setTimeout((function(){const e=t.context;t.context=t,t._applyRowFilters(),t.context=e}),500))):void 0}_tableContainerPointeroverHandler(e){const t=this;if(!t.tooltip)return;const a=(t.isInShadowDOM?e.composedPath()[0]:e.target).closest("tbody td[data-field], thead th[data-field]");if(!a)return;const l=t.$.tableContainer.querySelector(".tooltip"),i=t.columnByDataField[a.getAttribute("data-field")],n=t.virtualization;if(l&&(l.classList.remove("tooltip"),l.removeAttribute("title")),"th"!==a.tagName.toLowerCase())(a.classList.contains("tree-cell")&&a.firstElementChild&&a.firstElementChild.children[1].scrollWidth>a.firstElementChild.children[1].offsetWidth||a.scrollWidth>a.offsetWidth)&&(a.classList.add("tooltip"),a.title=n&&i&&i.templateElement?"":a.innerText);else{const e=a.querySelector(".label");e&&e.scrollWidth>e.offsetWidth&&(a.classList.add("tooltip"),a.title=n&&i&&i.templateElement?"":e.innerText)}}_documentDownHandler(e){const t=this,a=t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;function l(){"default"!==t.columnSizeMode&&(t._preventClickSort=!0,clearTimeout(t._dblclickObject.timeout),t._dblclickObject.numberOfClicks++,2===t._dblclickObject.numberOfClicks?(t._dblclickObject.numberOfClicks=0,t._autoResizeColumnOnDblclick()):t._dblclickObject.timeout=setTimeout((function(){t._dblclickObject.numberOfClicks=0}),300))}if(delete t._preventClickSort,t._editing&&!a.closest(".smart-table-editor")){const e=a.closest(".smart-drop-down")||a.closest(".smart-input-drop-down-menu");if(!e)return void t.endEdit();const l=e.ownerElement;if(!l)return void t.endEdit();if(t.$.container.contains(l)&&l.classList.contains("smart-table-editor"))return;return void t.endEdit()}const i=t.columnReorder,n=t.columnResize;if(i&&!t.columnTotals||n){const r=a.closest("th[data-field]:not(.smart-pivot-table-total-header)");if(r&&t.$.tableContainer.contains(r)){if(t.$.tableContainer.classList.add("smart-unselectable"),n&&t._columns.length>1&&!t.hasAttribute("resize-max-reached")){const a=t.rightToLeft,i=r.getBoundingClientRect();let n=null;if(!a&&e.clientX<=i.left+5||a&&e.clientX>=i.right-5){const i=r.previousElementSibling;if(i&&i.hasAttribute("data-field")){if(i.hasAttribute("locked"))return;for(let e=0;e<t.columns.length;e++){const a=t.columns[e];if(a.headerCellElement===i){n=a;break}}const r=i.getBoundingClientRect(),o=n&&n.minWidth||t._getNumericMinWidth();return t._resizeDetails={FeedbackShown:!1,Item:i,ItemStart:r[a?"right":"left"]+window.scrollX,Min:o,StartPosition:{left:e.pageX,top:e.pageY},StartTime:new Date},t._resizeDetails.Max=t._getCurrentResizeMax(),void l()}}if(!a&&e.clientX>=i.right-5||a&&e.clientX<=i.left+5){if(r.hasAttribute("locked"))return;for(let e=0;e<t.columns.length;e++){const a=t.columns[e];if(a.headerCellElement===r){n=a;break}}const o=n&&n.minWidth||t._getNumericMinWidth();return t._resizeDetails={FeedbackShown:!1,Item:r,ItemStart:i[a?"right":"left"]+window.scrollX,Min:o,StartPosition:{left:e.pageX,top:e.pageY},StartTime:new Date},t._resizeDetails.Max=t._getCurrentResizeMax(),void l()}}i&&(t._dragDetails={FeedbackShown:!1,Item:r,StartPosition:{left:e.pageX,top:e.pageY},StartTime:new Date})}}}_documentMoveHandler(e){const t=this,a=t._dragDetails;if(!a)return void(t._resizeDetails&&t._handleResizeOnMove(e));if(!a.FeedbackShown){const l=(new Date).getTime()-a.StartTime.getTime()>500,i=Math.abs(a.StartPosition.left-e.pageX)>5||Math.abs(a.StartPosition.top-e.pageY)>5;if(!i||!(!t._isMobile||t._isMobile&&l))return void(t._isMobile&&i&&!l&&(delete t._dragDetails,t.$.tableContainer.classList.remove("smart-unselectable")));t._hideBodyOverflow(),a.Feedback=t._addDragFeedback(),a.FeedbackShown=!0,a.Item.classList.add("dragged"),t.classList.add("smart-unselectable")}const l=t.$.tableContainer.parentElement;a.Feedback.style.left=e.pageX+10+"px",a.Feedback.style.top=e.pageY+10+"px",a.HoveredItem&&(a.HoveredItem.classList.remove("drop-column","left","right"),delete a.HoveredItem),l.offsetWidth<l.scrollWidth&&(clearInterval(t._dragInterval),t._dragInterval=setInterval((function(){const a=l.getBoundingClientRect();a.left<=e.clientX&&a.left+a.width>=e.clientX?e.clientX>=a.left&&e.clientX<=a.left+25?l.scrollLeft-=t._autoScrollCoefficient:e.clientX>=a.left+a.width-25&&e.clientX<=a.left+a.width?l.scrollLeft+=t._autoScrollCoefficient:clearInterval(t._dragInterval):clearInterval(t._dragInterval)}),10));const i=t._getClosestThToHover(e);i&&(i.classList.add("drop-column"),a.HoveredItem=i)}_hideBodyOverflow(){const e=(document.scrollingElement||document.documentElement).scrollHeight>document.documentElement.clientHeight,t=(document.scrollingElement||document.documentElement).scrollWidth>document.documentElement.clientWidth;this._originalBodyOverflow={overflowX:document.body.style.overflowX,overflowY:document.body.style.overflowY,overflow:document.body.style.overflow},document.body.classList.add("smart-dragging"),document.body.style.overflow=document.body.style.overflowX=document.body.style.overflowY="",e&&!t?document.body.style.overflowX="hidden":t&&!e?document.body.style.overflowY="hidden":t||e||(document.body.style.overflow="hidden")}_addDragFeedback(){const e=this,t=e._dragDetails.Item,a=document.createElement("div");return a.className="smart-table-feedback",a.setAttribute("parent-table-id",e.id),a.innerHTML=e.columnByDataField[t.getAttribute("data-field")].label,e.theme&&a.setAttribute("theme",e.theme),document.body.appendChild(a),a}_getClosestThToHover(e){const t=e.clientX,a=Array.from(this.$.tableContainer.querySelectorAll("th[data-field]:not(.smart-pivot-table-total-header)"));let l,i,n;for(let e=0;e<a.length;e++){const r=a[e];if(!r||this._dragDetails.Item===r)continue;const o=r.getBoundingClientRect(),s=Math.abs(t-o.left),d=Math.abs(t-o.right),c=Math.min(s,d);if(!(void 0===i||c<i))break;l=r,i=c,n=s<d?"left":"right"}return l&&l.classList.add(n),l}_handleResizeOnMove(e){const t=this,a=t._resizeDetails;if(!a.FeedbackShown){const l=(new Date).getTime()-a.StartTime.getTime()>500,i=Math.abs(a.StartPosition.left-e.pageX)>=1||Math.abs(a.StartPosition.top-e.pageY)>=1;if(!i||!(!t._isMobile||t._isMobile&&l))return void(t._isMobile&&i&&!l&&(delete t._resizeDetails,t.$.tableContainer.classList.remove("smart-unselectable","resizing"),document.body.style.cursor=null));a.Feedback=t._addResizeFeedbacks(),a.FeedbackShown=!0,t.classList.add("smart-unselectable","resizing"),document.body.style.cursor="col-resize"}const l=a.Feedback,i=a.ItemStart;let n;t.rightToLeft?(n=Math.min(a.Max,Math.max(a.Min,Math.round(i-e.pageX))),l.style.left=i-n+"px"):(n=Math.min(a.Max,Math.max(a.Min,Math.round(e.pageX-i))),l.style.left=i+n+"px"),l.classList.toggle("min",n===a.Min),l.classList.toggle("max",n===a.Max),t.columnResizeFeedback&&(l.innerHTML=n+"px"),a.Width=n}_addResizeFeedbacks(){const e=this,t=e._resizeDetails,a=e.$.container.getBoundingClientRect(),l=a.top+window.scrollY+"px",i=a.height+"px",n=document.createElement("div"),r=document.createElement("div");return r.className="smart-table-resize-feedback static",r.setAttribute("parent-table-id",e.id),r.style.top=l,r.style.left=t.ItemStart+"px",r.style.height=i,e._resizeDetails.StaticFeedback=r,n.className="smart-table-resize-feedback",n.setAttribute("parent-table-id",e.id),n.style.top=l,n.style.height=i,e.theme&&(r.setAttribute("theme",e.theme),n.setAttribute("theme",e.theme)),document.body.appendChild(n),document.body.appendChild(r),n}_resolveResize(e){const t=this,a=t._resizeDetails;if(delete t._resizeDetails,t.$.tableContainer.classList.remove("smart-unselectable","resizing"),e){if(!a.FeedbackShown)return;a.StaticFeedback.remove(),a.Feedback.remove()}const l=t._columns.find((e=>e.headerCellElement===a.Item));t.classList.remove("smart-unselectable","resizing"),document.body.style.cursor=null;let i=a.Width;i<t.columnMinWidth&&(i=t.columnMinWidth);const n=t._getTableRemainingWidth();if(l){const e=l._isResponsive||!!(l.width&&l.width.toString().indexOf("%")>=0);if(delete l.width,l.minWidth&&i<l.minWidth&&(i=l.minWidth),l._manualWidth=i,l._manualPercentageWidth=parseFloat(i/n*100),l._isResponsive=e,a.Item.style.width=l._isResponsive?parseFloat(i/n*100)+"%":i+"px",l._isFillRemainingWidth){let e=!0;for(let a=0;a<t._columns.length;a++){const l=t._columns[a];if(!l.width&&!l._manualWidth){e=!1;break}}!t.columnResizeNormalize&&e&&(t.columns.push({dataField:"",label:"",visible:!0,allowResize:!1,allowFilter:!1,allowSort:!1}),t._initColumns(!0),t.refresh())}}else a.Item.style.width=i+"px";t._handleAutoSizeMode(l),t._handleFrozenColumnPositions(),t._refreshHorizontalScrollbar();const r=parseFloat(i/n*100);t.$.fireEvent("columnResize",{dataField:l.dataField,headerCellElement:a.Item,widthInPercentages:r,width:i})}openColumnMenu(e){const t=this,a=t.columnByDataField[e];if(!a)return;const l=a.headerCellElement;if(!l)return;if(a&&!1===a.allowMenu)return;const i=l.querySelector(".column-menu");if(!i)return;const n=()=>{const e=c.getBoundingClientRect(),a=t.activeColumnMenu;t._columnsSettingsMenu.style.top=e.top+window.scrollY+"px",t._columnsSettingsMenu.style.left=e.right+window.scrollX+"px",e.right-i.offsetWidth+window.scrollX+a.offsetWidth>t.getBoundingClientRect().right&&(t._columnsSettingsMenu.style.left=10+e.right-a.offsetWidth-t._columnsSettingsMenu.offsetWidth+window.scrollX+"px")},r=()=>{const e=a.headerCellElement;e.hasAttribute("column-menu-button")||e.setAttribute("column-menu-button","");const l=e.querySelector(".column-menu"),i=l.getBoundingClientRect();o.style.top=i.bottom+10+window.scrollY+"px",o.style.left=i.right-l.offsetWidth+window.scrollX+"px",i.right-l.offsetWidth+window.scrollX+o.offsetWidth>t.getBoundingClientRect().right&&(o.style.left=i.right-o.offsetWidth+window.scrollX+"px");const n=o.querySelector("input");n&&n.focus()};a.columnMenu&&a.columnMenu.remove(),t.closeColumnMenu();const o=document.createElement("div");o.classList.add("smart-table-column-menu","wrapper"),o.owner=l,o.dataField=e;const s=document.createElement("div");s.innerHTML=`<span class='menu-icon sort-asc'></span><span class="label">${t.localize("columnMenuItemSortAsc")}</span>`,s.classList.add("smart-table-menu-item");const d=document.createElement("div");d.innerHTML=`<span class='menu-icon sort-desc'></span><span class="label">${t.localize("columnMenuItemSortDesc")}</span>`,d.classList.add("smart-table-menu-item");const c=document.createElement("div");c.innerHTML=`<span class='menu-icon columns'></span><span class="label">${t.localize("columnMenuItemColumns")}</span>`,c.classList.add("smart-table-menu-item","columns-item");const u=document.createElement("div");u.innerHTML=`<span class='menu-icon filter-by'></span><span class="label">${t.localize("columnMenuItemFilter")}</span>`,u.classList.add("smart-table-menu-item","filter-item");const f=document.createElement("div");f.innerHTML=`<span class='menu-icon filter-by-remove'></span><span class="label">${t.localize("columnMenuItemRemoveFilter")}</span>`,f.classList.add("smart-table-menu-item","remove-filter-item","smart-hidden");const m=document.createElement("div");m.innerHTML=`<span class='menu-icon sort-remove'></span><span class="label">${t.localize("columnMenuItemRemoveSort")}</span>`,m.classList.add("smart-table-menu-item","remove-sort-item","smart-hidden");const h=document.createElement("div");h.innerHTML=`<span class='menu-icon reset'></span><span class="label">${t.localize("columnMenuItemReset")}</span>`,h.classList.add("smart-table-menu-item","reset-item"),c.onmouseleave=e=>{const a=t._columnsSettingsMenu.getBoundingClientRect();e.pageX>=a.left-20&&e.pageX<=a.right+20&&e.pageY>=a.top-20&&e.pageY<=a.bottom+20||t._columnsSettingsMenu&&t._columnsSettingsMenu.remove()},c.onmouseenter=()=>{t._columnsSettingsMenu=(()=>{t._columnsSettingsMenu&&t._columnsSettingsMenu.remove();const a=document.createElement("div");a.classList.add("smart-table-column-menu","wrapper","smart-table-columns-menu");let l=0,i=null;for(let o=0;o<t.columns.length;o++){const s=document.createElement("div");s.innerHTML=`<span class='column-item menu-icon'></span><span class="label">${t.columns[o].label}</span>`,s.classList.add("smart-table-menu-item"),s.column=t.columns[o],e!==s.column.dataField&&!1!==s.column.allowHide&&(s.column.visible?(l++,i=s):s.firstElementChild.classList.add("off"),s.onpointerdown=e=>{s.column.visible=!s.column.visible,s.column.visible?s.firstElementChild.classList.remove("off"):s.firstElementChild.classList.add("off"),r(),n(),e.stopPropagation(),e.preventDefault()},a.appendChild(s))}return 1===l&&i&&i.classList.add("smart-disabled"),document.body.appendChild(a),a})(),n()};const p=t._createFilterRowInput(a);t.filtering&&!1!==a.allowFilter&&(t.filterRow?o.insertBefore(f,o.firstElementChild):(o.innerHTML=p,o.insertBefore(u,o.firstElementChild))),o.insertBefore(h,o.firstElementChild),o.insertBefore(c,o.firstElementChild),o.insertBefore(m,o.firstElementChild),!1!==a.allowSort&&"none"!==t.sortMode&&(o.insertBefore(d,o.firstElementChild),o.insertBefore(s,o.firstElementChild),a.headerCellElement.hasAttribute("aria-sort")&&(m.classList.remove("smart-hidden"),"ascending"===a.headerCellElement.getAttribute("aria-sort")?s.classList.add("smart-disabled"):d.classList.add("smart-disabled")),m.onclick=()=>{t.sortBy(a.dataField,null),t.closeColumnMenu()},s.onclick=()=>{t.sortBy(a.dataField,"asc"),t.closeColumnMenu()},d.onclick=()=>{t.sortBy(a.dataField,"desc"),t.closeColumnMenu()}),h.onclick=()=>{if(t._initialState){if(t.loadState(t._initialState),t._filterInfo.filterRowValues&&delete t._filterInfo.filterRowValues,t.clearFilters(),t.filterRow){const e=t.$.tableContainer.querySelector(".smart-table-filter-row");e&&e.remove()}t._initRows(),t.refresh()}t.closeColumnMenu()};const g=t.columns.findIndex((e=>e.dataField===a.dataField));t.appendChild(o);const _=o.lastElementChild.children[2];_&&(_.onclick=()=>{const e=_.parentElement.firstElementChild,a=_.parentElement.children[1];e.value="",-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(a.$.input.dataValue)&&(a.value=t.localize("text"===e.type?"CONTAINS":"EQUAL"),delete a.$.input.dataValue),t._applyRowFilters()});const b=t._filterInfo&&t._filterInfo.filterRowValues?t._filterInfo.filterRowValues[g]:null;if(b&&!t.filterRow){const e=o.lastElementChild,l=a.dataType,i=t._filterInfo["string"===l?"stringConditions":"numberAndDateConditions"].find((e=>e.value===b.condition));if(-1===["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(i.value))if("date"===l){const t=new Date(b.value),a=(t.getMonth()+1).toString(),l=t.getDate().toString();e.children[0].value=`${t.getFullYear()}-${"0".repeat(2-a.length)}${a}-${"0".repeat(2-l.length)}${l}`}else e.children[0].value=b.value;e.children[1].value=i.label,e.children[1].$.input.dataValue=i.value,e.children[2].classList.remove("smart-hidden")}a.headerCellElement.hasAttribute("filter")&&f.classList.remove("smart-hidden"),f.onclick=()=>{t.removeFilter(a.dataField),t.closeColumnMenu()},r(),a.columnMenu=t.activeColumnMenu=o,t.$.fireEvent("openColumnMenu",{dataField:e})}closeColumnMenu(){const e=this;e.activeColumnMenu&&(e.activeColumnMenu.owner.hasAttribute("column-menu-button")&&e.activeColumnMenu.owner.removeAttribute("column-menu-button"),e._columnsSettingsMenu&&e._columnsSettingsMenu.remove(),e.$.fireEvent("closeColumnMenu",{dataField:e.activeColumnMenu.dataField}),e.activeColumnMenu.remove(),delete e.activeColumnMenu)}_documentUpHandler(e){const t=this,a=t._dragDetails;if(t.activeColumnMenu){const a=e.originalEvent?e.originalEvent:e;if(a){let e=!1,l=a.target;for(;l;)if(l=l.parentNode,l===t){e=!0;break}(t.activeColumnMenu.contains(a.target)||t._columnsSettingsMenu&&t._columnsSettingsMenu.contains(a.target))&&(e=!0);const i=t.activeColumnMenu.querySelector("smart-input");i&&i.$.scrollView.contains(a.target)&&(e=!0),e||t.closeColumnMenu()}}if(t._selectDrag)return t.$.main.classList.remove("prevent-scroll"),void delete t._selectDrag;if(!a)return void(t._resizeDetails&&t._resolveResize(!0));if(delete t._dragDetails,t.$.tableContainer.classList.remove("smart-unselectable"),!a.FeedbackShown)return;const l=a.HoveredItem;document.body.classList.remove("smart-dragging"),document.body.style.overflow=t._originalBodyOverflow.overflow,document.body.style.eoverflowX=t._originalBodyOverflow.overflowX,document.body.style.overflowY=t._originalBodyOverflow.overflowY,delete t._originalBodyOverflow,t.classList.remove("smart-unselectable"),a.Item.classList.remove("dragged"),document.body.removeChild(a.Feedback),clearInterval(t._dragInterval),delete t._dragInterval,l&&t._applyColumnReorder(a,l),t._preventClickSort=!0,requestAnimationFrame((()=>delete t._preventClickSort))}_applyColumnReorder(e,t){const a=this,l=a.rightToLeft,i=a._columns,n=e.Item.getAttribute("data-field"),r=i.find((e=>e.dataField===n)),o=t.getAttribute("data-field"),s=t.classList.contains("right"),d=a._columns.filter((e=>e.dataField!==n)),c=d.findIndex((e=>e.dataField===o));t.classList.remove("drop-column","left","right"),s&&!l||!s&&l?d.splice(c+1,0,r):d.splice(c,0,r),i.map((e=>e.dataField)).join(",")!==d.map((e=>e.dataField)).join(",")&&(a.columns=d,a._initColumns(),a.refresh())}_applyRowFilters(){const e=this;if(!e.filtering||!e.filterRow&&!e.columnMenu)return;const t=e.filterRow?e.$.tableContainer.querySelector(".smart-table-filter-row"):null,a=Number(e.selection),l=e._columns.filter((e=>e.visible)),i=[],n=[];for(let r=0;r<l.length;r++){const o=l[r].dataField,s=l[r].dataType;if(l[r].headerCellElement&&l[r].headerCellElement.hasAttribute("filter")&&l[r].headerCellElement.removeAttribute("filter"),!e.filterRow&&!l[r].columnMenu){n.push(null);continue}const d=e.filterRow?t.children[r+a].firstElementChild:l[r].columnMenu.lastElementChild,c=d.children[2];let u=d.firstElementChild.value,f=d.children[1].value;"string"===s?f=e._filterInfo.stringConditions.find((e=>e.label===f)).value:(f=e._filterInfo.numberAndDateConditions.find((e=>e.label===f)).value,""!==u&&("number"===s?(u=parseFloat(u),isNaN(u)&&(d.firstElementChild.value="",u="")):"date"===s&&(u=new Date(u),u.setHours(0,0,0))));const m=-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(f);if(""!==u||m){const e=new Smart.Utilities.FilterGroup,t=e.createFilter(s,u,f);e.addFilter("or",t),i.push([o,e]),c.classList.remove("smart-hidden"),n.push({condition:f,value:u}),l[r].headerCellElement&&l[r].headerCellElement.setAttribute("filter","")}else c.classList.add("smart-hidden"),n.push(null),l[r].headerCellElement&&l[r].headerCellElement.hasAttribute("filter")&&l[r].headerCellElement.removeAttribute("filter");m?d.firstElementChild.setAttribute("disabled",!0):d.firstElementChild.removeAttribute("disabled")}i.length>0?(e.dataSource.virtualDataSource||e.dataSource._filter(i,e.filterOperator),e._filterInfo.rowFilters=i,e._filterInfo.filterRowValues=n,delete e._filterInfo.appliedFilters,e._fullRefresh("filter"),e._updateState("filtered"),e._doNotFireEvent||e.$.fireEvent("filter",{action:"add",filters:i})):e._filterInfo.rowFilters?(e._filterInfo.filterRowValues&&delete e._filterInfo.filterRowValues,e.clearFilters()):e._filterInfo.filterRowValues&&delete e._filterInfo.filterRowValues}_clearFilterInput(){const e=this;e._filterInfo.query="",delete e._filterInfo.inputFilters,e.$.filterInput.value=""}_clearRowFilters(e){const t=this;if(!t._filterInfo.rowFilters)return;const a=t.$.tableContainer.querySelector(".smart-table-filter-row"),l=t.selection?1:0;let i=t._columns.filter((e=>e.visible));if(e&&(i=t._columns.filter((t=>t.dataField===e))),a)for(let e=0;e<i.length;e++){const t=a.children[e+l]?a.children[e+l].firstElementChild:null;t&&(t.firstElementChild.value="",t.children[2].classList.add("smart-hidden")),i[e].headerCellElement&&i[e].headerCellElement.hasAttribute("filter")&&i[e].headerCellElement.removeAttribute("filter")}delete t._filterInfo.rowFilters}_createFooterRow(e){const t=this,a=t.footerRow;if(!a)return;if(e)return void t.$.tableContainer.appendChild(e);const l=document.getElementById(a);if(l&&l instanceof HTMLTemplateElement){const e=document.createElement("tfoot"),a=document.importNode(l.content,!0);e.appendChild(a),t.$.tableContainer.appendChild(e)}else t.footerRow=null}_createCustomHeaderRow(){const e=this,t=e.$.tableContainer.firstElementChild;let a=e.headerRow;if(a){if("function"==typeof a)a.call(e,t);else if("string"==typeof a){const e=document.getElementById(a);if(!e)return void(t.innerHTML=`<tr><th>${a}</th></tr>`);a=e}a instanceof HTMLTemplateElement?t.appendChild(document.importNode(a.content,!0)):a.nodeName?t.appendChild(a):e.headerRow=null}}_updateSelectAllState(e){const t=this;if(!t.selection||"cell"===t.selectionMode)return;const a=t.$.tableContainer.querySelector(".smart-table-select-all");let l;if(void 0===e){const a=t.dataSource,i=t._filterInfo;if(i.inputFilters||i.rowFilters||i.appliedFilters){const i=t._selectedIds;e=0,l=0;for(let t=0;t<a.length;t++){const n=a[t];if(!1===n.$.filtered)continue;const r=n.$.id;e++,-1!==i.indexOf(r)&&l++}}else e=t.dataSource.length}void 0===l&&(l=t._selectedIds.length),0===l||0===e?(a.classList.remove("selected","indeterminate"),a.firstElementChild.setAttribute("aria-checked",!1)):l===e+t._selectableGroupRecords.length?(a.classList.remove("indeterminate"),a.classList.add("selected"),a.firstElementChild.setAttribute("aria-checked",!0)):(a.classList.remove("selected"),a.classList.add("indeterminate"),a.firstElementChild.setAttribute("aria-checked","mixed"))}_resizeHandler(){const e=this;clearTimeout(e._resizeTimeout);const t=()=>{if(Smart.Utilities.Core.Browser.Firefox&&e.virtualization){const t=e.$.virtualizationContainer.$.verticalScrollBar.value;e._onVerticalChange({detail:{value:t}},!0)}};t(),"default"===e.columnSizeMode&&e._handleAutoSizeMode(),e._resizeTimeout=setTimeout((function(){if(e.columnGroups&&e._columns.some((e=>e.responsivePriority&&e.responsivePriority>1)))return void e.refresh();const a=e.offsetWidth,l=e.offsetHeight;if(e.virtualization&&e._cachedHeight!==l){const i=e._getFractionOfMax();return e._refreshDataRows(),e._setFractionOfMax(i),e._cachedWidth=a,e._cachedHeight=l,void t()}e._handleAutoSizeMode(),e._handleFrozenColumnPositions(),e._refreshHorizontalScrollbar(),e._cachedWidth=a,e._cachedHeight=l,t()}),75)}_hierarchyArrowClickHandler(e,t){const a=this,l=!a.grouping,i=e.data;if(a.animation=a._animation,l&&a.dataSource.virtualDataSource&&!i.expanded&&i.children&&0===i.children.length)return a._requestVirtualDataSource("expand",void 0,i),void a.$.fireEvent("expand",{id:i.$.id,record:i});if(a.virtualization)return void a._hierarchyArrowClickHandlerVirtualization(e,t);const n=a.$.tableContainer,r=i.$.id;function o(e){e.forEach((e=>{a._expandSingleChildRow(n.querySelector(`tr[row-id="${e.$.id}"]:not([unused])`)),e.children&&e.expanded&&requestAnimationFrame((()=>o(e.children)))}))}if(i.expanded?function e(t){t.forEach((t=>{a._collapseSingleChildRow(n.querySelector(`tr[row-id="${t.$.id}"]:not([unused])`)),t.children&&e(t.children)}))}(i.children):requestAnimationFrame((()=>o(i.children))),i.expanded=!i.expanded,e.setAttribute("aria-expanded",i.expanded),e.classList.toggle("expanded",i.expanded),l)i.expanded?(-1===a._expandedIds.indexOf(r)&&a._expandedIds.push(r),a.$.fireEvent("expand",{id:i.$.id,record:i})):(a._expandedIds=a._expandedIds.filter((e=>e!==r)),a.$.fireEvent("collapse",{id:i.$.id,record:i})),a._updateState("expanded");else if(!0!==t){let e=""+i.$.id;e=e.replace("Item","").replace(/_/gi,"."),i.expanded?a.$.fireEvent("group",{action:"expand",path:e,dataField:i.groupDataField,label:i.label}):a.$.fireEvent("group",{action:"collapse",path:e,dataField:i.groupDataField,label:i.label})}}_expandSingleChildRow(e,t=[]){e&&(t.push(!1),"none"!==this.animation?(e.classList.remove("smart-hidden"),requestAnimationFrame((()=>{e.classList.add("no-height"),e.ontransitionend=function(){e.classList.remove("no-height"),e.ontransitionend=null,t.pop()},e.removeAttribute("aria-hidden"),e.classList.remove("collapsed")}))):(e.removeAttribute("aria-hidden"),e.classList.remove("collapsed","smart-hidden"),t.pop()))}_collapseSingleChildRow(e,t=[]){e&&(t.push(!1),"none"!==this.animation?e.ontransitionend=function(){e.classList.add("smart-hidden"),e.ontransitionend=null,t.pop()}:(e.classList.add("smart-hidden"),t.pop()),e.setAttribute("aria-hidden",!0),e.classList.add("collapsed"))}_getGroupByIndex(e){"number"==typeof e&&(e=e.toString());const t=this.dataSource.boundHierarchy,a=e.split(".");let l=t[a[0]];if(l){for(let e=1;e<a.length;e++)if(l=l.children[a[e]],!l||l.leaf)return;return l}}getGroupChildren(e){"number"==typeof e&&(e=e.toString());const t=this.dataSource.boundHierarchy,a=e.split(".");let l=t[a[0]];if(!l)return[];for(let e=1;e<a.length;e++)if(l=l.children[a[e]],!l||l.leaf)return[];return l.children}_createDialog(){const e=this,t=document.createElement("smart-window"),a=document.createElement("template"),l=` animation=${e.animation} theme="${e.theme}"${e.rightToLeft?" right-to-left":""}${!e.keyboardNavigation||e.unfocusable?" unfocusable":""}`;a.innerHTML=`<smart-button class="ok primary"${l}>${e.localize("ok")}</smart-button>\n<smart-button class="cancel"${l}>${e.localize("cancel")}</smart-button>`,t.animation=e.animation,t.footerTemplate=a,t.headerButtons=["close"],t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.unfocusable=!e.keyboardNavigation||e.unfocusable,t.className="smart-table-window",t.ownerElement=e,e._dialog=t,e._addDialogHandlers(),e.getShadowRootOrBody().appendChild(t),e.setAttribute("aria-owns",t.id)}_addDialogHandlers(){const e=this,t=e._dialog;t.addEventListener("close",e._dialogEventHandler),t.addEventListener("click",e._dialogEventHandler)}_dialogEventHandler(e){const t=this,a=t.ownerElement,l=t.isInShadowDOM?e.composedPath()[0]:e.target,i=e.type,n=a.context;if(a.context=a,"close"===i){if(l!==t)return void(a.context=n);const e=t.classList.contains("conditional-formatting"),i=t.classList.contains("fields");t.ok?(e&&a._applyConditionalFormatting(),delete t.ok):e&&JSON.stringify(a._formattingPanel.items)!==JSON.stringify(a._formattingPanel.getItems())&&(a._formattingPanel.$.itemsContainer.innerHTML="",a._formattingPanel._addDefaultItems()),t.content.innerHTML="",t.classList.remove("conditional-formatting","drill-down","fields"),!a.keyboardNavigation||a.disabled||a.unfocusable||(a.$.tableContainer.setAttribute("tabindex",0),"smart-table"===a.nodeName.toLowerCase()&&(a.$.filterInput.unfocusable=!1,a.$.pager.unfocusable=!1),a.$.conditionalFormattingButton.unfocusable=!1),a.removeAttribute("modal"),e?a.$.conditionalFormattingButton.focus():i&&a.$.fieldsButton?a.$.fieldsButton.focus():a.$.tableContainer.focus()}else"click"===i&&t.$.footer.contains(l)&&(l.closest(".ok")?(t.ok=!0,t.close()):l.closest(".cancel")&&t.close());a.context=n}_openDialog(e,t,a){const l=this;l._dialog||l._createDialog();const i=l._dialog;i.label=e,i.classList.add(a),i.appendChild(t),l.$.tableContainer.removeAttribute("tabindex"),"smart-table"===l.nodeName.toLowerCase()&&(l.$.filterInput.unfocusable=!0,l.$.pager.unfocusable=!0),"drill-down"!==a?i.setAttribute("aria-controls",l.$.tableContainer.id):i.removeAttribute("aria-controls"),l.$.conditionalFormattingButton.unfocusable=!0,l.setAttribute("modal",""),i.open()}_conditionalFormattingButtonClickHandler(e,t,a){const l=this;let i;l._formattingPanel?i=l._formattingPanel:(i=document.createElement("smart-formatting-panel"),i.animation=l.animation,i.columns=t||l._columns,i.dataSource=a||l.dataSource,i.locale=l.locale,i.messages=l.messages,i.rightToLeft=l.rightToLeft,i.theme=l.theme,i.unfocusable=!l.keyboardNavigation||l.unfocusable,i.ownerElement=l,l._formattingPanel=i),l.conditionalFormatting&&(i.items=l.conditionalFormatting.slice(0)),l._openDialog(l.localize("conditionalFormatting"),i,"conditional-formatting")}_transformDataSource(){const e=this;if(!e.isRendered&&e.dataTransform){const t=e.dataSource;for(let a=0;a<t.length;a++)e.dataTransform(t[a])}}_applyInitialConditionalFormatting(e){const t=this,a=t.conditionalFormatting;if(!a||0===a.length)return void(t._conditionalFormatting=null);const l=t._defaults,i=new Smart.Utilities.ConditionalFormatter(e),n=[];let r;if("smart-pivot-table"===t.nodeName.toLowerCase()){const e=t._dynamicColumns;r=function(t){return"all"===t?e.map((e=>e.id)):e.filter((e=>e.dataFields[e.dataFields.length-1].dataField===t)).map((e=>e.id))}}else r=function(e){return"all"===e?t._columns.map((e=>e.value)):[e]};for(let e=0;e<a.length;e++){a[e]=Object.assign({column:"all",condition:"lessThan",firstValue:0,secondValue:1,fontFamily:l.fontFamily,fontSize:l.fontSize,text:l.text,highlight:l.highlight},a[e]);const t=a[e],o=r(t.column),s=t.condition;i.color=t.highlight,i.comparator=t.firstValue,i.min=t.firstValue,i.max=t.secondValue;const d=i.format(s,o);for(let e in d){const a=d[e];for(let e in a){const l=a[e];l.color=t.text,l.fontFamily=t.fontFamily,l.fontSize=t.fontSize}}n.push(d)}if(t._formattingPanel&&(t._formattingPanel.items=a.slice(0)),0===n.length)return n[0];const o={};for(let e=0;e<n.length;e++){const t=n[e];for(let e in t){const a=t[e];o[e]||(o[e]={});for(let t in a)o[e][t]=Object.assign({},o[e][t],a[t])}}t._conditionalFormatting=o}_toHex(e){if(-1!==e.indexOf("#"))return e;const t=/rgb\((\d+), (\d+), (\d+)\)/g.exec(e);return t?"#"+(parseFloat(t[1]).toString(16).padStart(2,"0")+parseFloat(t[2]).toString(16).padStart(2,"0")+parseFloat(t[3]).toString(16).padStart(2,"0")).toUpperCase():"#FFFFFF"}_applyConditionalFormatting(){const e=this,t=e._conditionalFormatting;e._conditionalFormatting=e._formattingPanel.apply(),e.conditionalFormatting=e._formattingPanel.getItems(),e._conditionalFormatting!==t&&e._refreshDataRows()}_updateState(e,t){const a=this;let l;if("selected"===e&&(l=a.getSelection(),a.selected=l),-1===a.stateSettings.indexOf(e))return;const i=a._state;switch(e){case"columns":i.columns=a._columns;break;case"expanded":i.expanded=a._expandedIds;break;case"filtered":i.filtered=a._filterInfo;break;case"grouped":i.grouped=a.dataSource.groupBy._array.slice(0);break;case"selected":i.selected=l;break;case"sorted":i.sorted=a._sortColumns||[]}a.autoSaveState&&a.isRendered&&!1!==t&&window.localStorage.setItem("smartTable"+a.id,a._stringifyState())}_stringifyState(){const e=this,t=JSON.parse(JSON.stringify(e._state));return["columns","expanded","filtered","grouped","selected","sorted"].forEach((a=>{-1===e.stateSettings.indexOf(a)&&delete t[a]})),JSON.stringify(t,(function(e,t){if(!("function"==typeof t||t instanceof HTMLElement||"sortOrder"===e||"thHierarchy"===e))return t}))}_handleAutoSizeMode(){const e=this;if("default"===e.columnSizeMode){const t=e._columns.filter((e=>e.visible)),a=[],l=t=>{const a=t.headerCellElement;if(!a)return;const l=parseInt(t.minWidth||e.columnMinWidth);a.offsetWidth<l?a.style.width=l+"px":(a.style.width="",a.offsetWidth<l&&(a.style.width=l+"px"))};t.forEach((t=>{if(t.width||t._manualWidth||(l(t),a.push(t)),t.width&&"string"==typeof t.width&&t.width.endsWith("%")){const a=e._getColumnWidth(t.width,!1,t);!1===t.autoWidth?t.headerCellElement.style.width=t.width:(t.headerCellElement.setAttribute("responsive-width",t.width),t.headerCellElement.style.width=a+"px")}else if(t._manualPercentageWidth)if(t._isResponsive){const a=e._getColumnWidth(t._manualPercentageWidth+"%",!1,t);!1===t.autoWidth?t.headerCellElement.style.width=t.width:(t.headerCellElement.setAttribute("responsive-width",t._manualPercentageWidth+"%"),t.headerCellElement.style.width=a+"px")}else t.headerCellElement.style.width=t._manualWidth+"px"}));for(let e=0;e<a.length;e++)l(a[e]);return}const t=e._columns.filter((e=>e.visible)),a=e._getNumericMinWidth();let l,i;t.forEach((e=>{e.width||e._manualWidth||(l||(l=e),i=e,e.headerCellElement.style.width=null)}));const n=e.$.tableContainer.offsetWidth-(e.selection?e.$.tableContainer.querySelector(".smart-table-select-all").offsetWidth:0);let r=new Map,o=0,s=0,d=0;e.removeAttribute("resize-max-reached"),e.setAttribute("auto-size",""),l&&(l.headerCellElement.style.width="100%");for(let i=0;i<t.length;i++){const n=t[i];if(n===l){d++;continue}const c=n.headerCellElement;let u,f;n.width?(u=f=e._getColumnWidth(n.width,!1,n),n.minWidth&&u<f&&(u=n.minWidth,f=n.minWidth)):n._manualWidth?(u=n._manualWidth,f=n.minWidth||a,u<f&&(u=f)):(u=Math.max(c.offsetWidth,a),f=n.minWidth||a,d++),o+=u,s+=f,n._isResponsive&&(u=e._getColumnWidth(n._manualPercentageWidth+"%",!1,n),u<f&&(u=f)),r.set(n,{width:u,minWidth:f})}function c(){l.headerCellElement.style.width=null;const e=Math.max(l.headerCellElement.offsetWidth,a),t=l.minWidth||a;r.set(l,{width:e,minWidth:t}),o+=Math.max(e,t),s+=t}if(l)if(l!==i)i.headerCellElement.style.width="100%",c(),i.headerCellElement.style.width=null;else if(t.length>1){const e=t.find((e=>e!==l));e.headerCellElement.style.width="100%",c(),e._isResponsive?e.headerCellElement.style.width=r.get(e).width+"%":e.headerCellElement.style.width=r.get(e).width+"px"}else c();if(n<=s||0===d)t.forEach((t=>{if(t._isResponsive){if(t.headerCellElement.style.width=(t._manualPercentageWidth?t._manualPercentageWidth+"%":r.get(t).minWidth)+"px",t._manualPercentageWidth){const a=e._getColumnWidth(t._manualPercentageWidth+"%",!1,t),l=t.minWidth||e.columnMinWidth;a===l&&(t.headerCellElement.style.width=l+"px")}}else t.headerCellElement.style.width=(t._manualWidth?t._manualWidth:r.get(t).minWidth)+"px"})),n<=s&&e.setAttribute("resize-max-reached","");else if(n>s)if(n<o){const a=[];let l,i=o-n,s=d;for(;i>0&&s>0;)l=Math.ceil(i/s),t.forEach((e=>{if(e.width||e._manualWidth||-1!==a.indexOf(e))return;const t=r.get(e);let n=Math.max(t.width-l,t.minWidth);const o=t.width-n;i-=o,n===t.minWidth&&(s--,a.push(e)),t.width=n}));t.forEach((t=>{if(t._isResponsive){if(t.headerCellElement.style.width=r.get(t).width+"%",t._manualPercentageWidth){const a=e._getColumnWidth(t._manualPercentageWidth+"%",!1,t),l=t.minWidth||e.columnMinWidth;a===l&&(t.headerCellElement.style.width=l+"px")}}else t.headerCellElement.style.width=r.get(t).width+"px"}))}else n===o?t.forEach((e=>{e._isResponsive?e.headerCellElement.style.width=r.get(e).width+"%":e.headerCellElement.style.width=r.get(e).width+"px"})):t.forEach((e=>{const t=r.get(e).width;e.headerCellElement.style.width=e===l?n-o+t+"px":t+"px"}));e.removeAttribute("auto-size")}_getNumericMinWidth(){const e=this,t=e.columnMinWidth;return"string"==typeof t&&-1!==t.indexOf("%")?e.offsetWidth*(parseFloat(t)/100):parseFloat(t)}_getCurrentResizeMax(){const e=this;if("default"===e.columnSizeMode)return 1/0;const t=e._resizeDetails,a=e._columns,l=a.find((e=>e.headerCellElement===t.Item)),i=a.indexOf(l);let n,r=a.length-1;for(let e=a.length-1;e>=0;e--)if(a[e].visible){r=e;break}if(i===r)return t.Item.offsetWidth;for(let t=i+1;t<a.length;t++){const l=a[t];t===r&&l.headerCellElement&&(n=l.headerCellElement.getBoundingClientRect()[e.rightToLeft?"left":"right"]+window.scrollX)}return n}_autoResizeColumnOnDblclick(){const e=this,t=e._resizeDetails,a=t.Item,l=e._columns.find((e=>e.headerCellElement!==a)).headerCellElement,i=l.style.width;e.setAttribute("auto-size",""),a.style.width=null,l.style.width="100%";let n=a.offsetWidth;l.style.width=i,e.removeAttribute("auto-size",""),n=Math.min(t.Max,Math.max(t.Min,n)),t.Width=n,e._resolveResize()}_isExpandCollapseForbidden(){const e=this;return(!e.hasAttribute("hierarchy")||e.grouping)&&"smart-pivot-table"!==e.nodeName.toLowerCase()}_selectSingle(e){const t=this,a=t.rowById?t.rowById[e]||t.dataSource.dataItemById[e]:t.rows.dataItemById[e];if(!a)return;const l=a.data?a.data.$.id:a.$.id;if(-1!==t._selectedIds.indexOf(l)||-1!==t._disabledSelection.indexOf(l))return;const i=t.$.tableContainer.querySelector(`tr[row-id="${l}"]:not([unused])`);if("one"===t.selectionMode&&(t._clearSelection(),t._selectedIds=[]),t._selectedIds.push(l),i){const e=i.firstElementChild;e.classList.remove("indeterminate"),e.classList.add("selected"),e.firstElementChild.setAttribute("aria-checked",!0),i.setAttribute("aria-selected",!0)}return t._handleHierarchicalSelection(a,!0),!0}_unselectSingle(e){const t=this,a=t.rowById?t.rowById[e]||t.dataSource.dataItemById[e]:t.rows.dataItemById[e];if(!a)return;const l=a.data?a.data.$.id:a.$.id,i=t._selectedIds.indexOf(l),n=t.$.tableContainer.querySelector(`tr[row-id="${l}"]:not([unused])`);if(-1!==i&&t._selectedIds.splice(i,1),n){const e=n.firstElementChild;e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1),n.setAttribute("aria-selected",!1)}return t._handleHierarchicalSelection(a,!1),!0}_changeSelectionOfMultiple(e,t,a="programmatic",l){const i=this;l||(l=JSON.stringify(i._selectedIds.slice(0).sort()));for(let a=0;a<e.length;a++)i[`_${t}Single`](e[a]);l!==JSON.stringify(i._selectedIds.slice(0).sort())&&(i._updateSelectAllState(),i._updateState("selected"),i.$.fireEvent("change",{type:a}))}_handleHierarchicalSelection(e,t){const a=this;if(!a.hasAttribute("hierarchy"))return;if(!1===a.selectionByHierarchy)return;const l=e.data;let i=l;for(l&&l.children&&function e(t,l){const i=t.children;let n=0;for(let t=0;t<i.length;t++){const r=i[t];if(!1===r.$.filtered)continue;let o=a._setThreeStateCheckbox(r,l);r.children&&r.children.length>0&&(o=e(r,l)),l&&!1===o&&n++}if(l&&n>0)return a._setThreeStateCheckbox(t,n!==i.length&&null)}(l,t);i&&i.parent;){const e=i.parent,t=a._getChildCheckState(e).state;a._setThreeStateCheckbox(e,t),i=e}}_getChildCheckState(e){const t=this,a=t._selectedIds,l=t._disabledSelection,i=e.children;if(!i||0===i.length||!t.selectionByHierarchy){const t=e.$.id,i=-1!==a.indexOf(t);return{state:i,maxSelected:!!i||-1!==l.indexOf(t)}}let n=!0,r=0,o=0,s=0;for(let e=0;e<i.length;e++){const a=i[e];if(!1===a.$.filtered)continue;const l=t._getChildCheckState(a);r++,l.state?o++:null===l.state?s++:!1===l.maxSelected&&(n=!1)}return 0!==o&&o===r?{state:!0,maxSelected:!0}:0===o&&0===s?{state:!1,maxSelected:n}:{state:null,maxSelected:n}}_setThreeStateCheckbox(e,t){const a=this,l=e.$.id,i=a._selectedIds,n=i.indexOf(l);t&&(-1!==a._disabledSelection.indexOf(l)?t=!1:-1===n&&i.push(l)),t||-1===n||i.splice(n,1);const r=a.$.tableContainer.querySelector(`tr[row-id="${l}"]:not([unused])`);if(!r)return t;const o=r.firstElementChild,s=o.firstElementChild;return t?(o.classList.remove("indeterminate"),o.classList.add("selected"),s.setAttribute("aria-checked",!0),r.setAttribute("aria-selected",!0)):!1===t?(o.classList.remove("selected","indeterminate"),s.setAttribute("aria-checked",!1),r.setAttribute("aria-selected",!1)):(o.classList.remove("selected"),o.classList.add("indeterminate"),s.setAttribute("aria-checked","mixed"),r.setAttribute("aria-selected",!1)),t}_getSelectableGroupRecords(){const e=this,t=e.dataSource,a=t.boundHierarchy;e._selectableGroupRecords=[],a?(function t(a){a.forEach((a=>{a.groupDataField&&(e._selectableGroupRecords.push(a.$.id),t(a.children))}))}(a),e._selectedIds=e._selectedIds.filter((a=>void 0!==t.dataItemById[a]||-1!==e._selectableGroupRecords.indexOf(a)))):e._selectedIds=e._selectedIds.filter((e=>void 0!==t.dataItemById[e]))}_clearSelection(e){const t=this;if(0===t._selectedIds.length)return;const a=t.$.tableContainer.querySelector(".smart-table-select-all");Array.from(t.$.tableContainer.querySelectorAll(".smart-table-select-row")).forEach((e=>{e.parentElement.classList.contains("disable-select")||e.parentElement.setAttribute("aria-selected",!1),e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1)})),a&&(a.classList.remove("indeterminate","selected"),a.firstElementChild.setAttribute("aria-checked",!1)),t._selectedIds=[],e&&(t._updateState("selected"),t.$.fireEvent("change",{type:"programmatic"}))}_updateCellsWithFormulas(e){const t=this,a=t.formulas,l=t._cellsWithFormulas;if(a||e)for(let e in l){const a=/(.+):(.+)/.exec(e),l=t.columnByDataField[a[1]],i=t.rowById[a[2]];if(!l||!i)continue;const n=t.$.tableContainer.querySelector(`tr[row-id="${i.data.$.id}"]:not([unused]) td[data-field="${l.dataField}"]`);n&&t._setCellContent(n,t._formatCellValue(i,l,n),n.classList.contains("tree-cell"))}}_createVirtualDataRows(e){const t=this,a=t.rowDetailTemplate,l=t.selection,i=t.hasAttribute("hierarchy"),n=document.createDocumentFragment(),r=t.$.virtualizationContainer,o=t.$.tableContainer,s=t._rowHeight;t.isRendered&&(r.scrollWidth=0,r.scrollHeight=0,r.$.scrollViewerContainer.classList.remove("hscroll","vscroll"));const d=r.$.scrollViewerContainer.offsetHeight-o.firstElementChild.offsetHeight-(t.filtering&&t.filterRow?s:0)-(t.footerRow?o.lastElementChild.offsetHeight:0),c=d<5,u=t._getVirtualRecords(i,c),f=u.length;let m=i?2*d:d+3*s,h=s*f,p=0;t._rowsVirtual=u,t._rowsInDOM=[];for(let e=0;e<f;e++){const r=u[e],o=r.data;if(!r.detail){if(o.groupDataField)t._rowsInDOM.push(t._createGroupHeader(o,n));else{const e=t._createDataRow(r,n,{hierarchical:i,rowDetailTemplate:a,selection:l,virtualization:!0});t._rowsInDOM.push(e.row),e.detail&&(t._rowsInDOM.push(e.detail),p+=t._rowDetailHeight,m+=t._rowDetailHeight)}if(p+=s,!c&&p>m)break}}e.appendChild(n),t._updateState("expanded"),e.parentElement||t.$.tableContainer.insertBefore(e,t.$.tableContainer.querySelector("tfoot")),r.refresh(),a&&(h+=t._expandedRowDetailIds.length*(t._rowDetailHeight-s));let g=Math.max(0,h-d);g>0&&r.computedHorizontalScrollBarVisibility&&(g+=r.$.horizontalScrollBar.offsetHeight),r.$.scrollViewerContentContainer.style.top=0,r.$.verticalScrollBar.max=g,t._scrollHeight=h,t._start={view:0,data:0},!c&&t._rowsInDOM.length>0&&r.$.scrollViewerContentContainer.offsetHeight<r.$.scrollViewerContainer.offsetHeight&&t._rowsInDOM[t._rowsInDOM.length-1].classList.add("last-row"),t._fixFrozenHeaderFirefox(),t._focusEquivalentCell()}_getVirtualRecords(e,t){const a=this,l=e&&!t?a.rows.filter((e=>0===e.data.level||!a._isCollapsed(e.data))):a.rows;if(e||!a.rowDetailTemplate)return l;const i=[];return l.forEach((e=>{i.push(e),-1!==a._expandedRowDetailIds.indexOf(e.data.$.id)&&i.push({detail:!0,data:e.data})})),i}_onVerticalChange(e,t){const a=this;if(a._ignoreVerticalChange)return;const l=a.rows,i=a._rowHeight,n=a.$.virtualizationContainer;let r,o,s=e.detail.value;if(Smart.Utilities.Core.Browser.Firefox&&a.virtualization&&(n.$.scrollViewerContentContainer.style.top=null),a.setAttribute("ignore-detail-animation",""),a._rowsInDOM.length===l.length||0===n.$.verticalScrollBar.max){const e=Math.floor(s/i);return a._start={view:e,data:e},n.$.scrollViewerContentContainer.style.top=-s+"px",requestAnimationFrame((()=>a.removeAttribute("ignore-detail-animation"))),void a._fixFrozenHeaderFirefox()}if(a._expandedRowDetailIds.length>0){let e,t=0;r=1;for(let l=0;l<a._rowsVirtual.length;l++){const i=t;if(a._rowsVirtual[l].detail?t+=a._rowDetailHeight:t+=a._rowHeight,void 0===o&&s<=t){o=l,e=s-i;break}}n.computedVerticalScrollBarVisibility?s=e+a._rowHeight:r=0}else{for(s=s%(2*i)+i,s<i&&(s+=i);s+n.$.scrollViewerContainer.offsetHeight>a.$.tableContainer.offsetHeight;)s-=i;r=Math.floor(s/i),o=Math.floor(e.detail.value/i),r<0&&(o-=r,r=0)}n.$.scrollViewerContentContainer.style.top=-s+"px",a._updateVisibleRows(r,o,t||a._expandedRowDetailIds.length>0),a._fixFrozenHeaderFirefox(),requestAnimationFrame((()=>a.removeAttribute("ignore-detail-animation")))}_fixFrozenHeaderFirefox(){const e=this;e.virtualization&&e.$.virtualizationContainer&&e.$.virtualizationContainer.$.scrollViewerContentContainer&&(e._tableHeader.style.top=-parseFloat(e.$.virtualizationContainer.$.scrollViewerContentContainer.style.top)+"px"),Smart.Utilities.Core.Browser.Firefox&&e.virtualization}_focusEquivalentCell(e){const t=this,a=t._focusedCell;if(!e&&!a)return;let l;if(!e){if(!a.parentElement)return;e={rowId:a.parentElement.data.$.id,dataField:a.getAttribute("data-field")}}l=e.dataField?t.$.tableContainer.querySelector(`tr[row-id="${e.rowId}"]:not([unused]) td[data-field="${e.dataField}"]`):t.$.tableContainer.querySelector(`tr[row-id="${e.rowId}"]:not([unused]) td.group-header`),t._focusCell(l)}_detachCachedTemplates(){const e=this;e._cachedTemplates&&(delete e._cachedTemplates,e._tableCachedTemplates&&(e._tableCachedTemplates.remove(),delete e._tableCachedTemplates))}_clearCachedTemplates(){const e=this;if(e._cachedTemplates&&Object.keys(e._cachedTemplates).length>0){e._tableCachedTemplates||(e._tableCachedTemplates=document.createElement("div"),e._tableCachedTemplates.style.display="none",document.body.appendChild(e._tableCachedTemplates));const t=document.createDocumentFragment();for(let a in e._cachedTemplates)t.appendChild(e._cachedTemplates[a]);e._tableCachedTemplates.appendChild(t)}}_updateVisibleRows(e,t,a){const l=this,i=t-e,n=l._rowsVirtual.length,r={hierarchical:l.hasAttribute("hierarchy"),selection:l.selection};let o;if(a=a&&(r.hierarchical||!!l.rowDetailTemplate),r.hierarchical&&!l.grouping&&(a=!0),l._sortColumns&&l._sortColumns.length>0&&(a=!0),l._focusedCell){const e=l._focusedCell.parentElement;e&&(o={rowId:e.data.$.id,dataField:l._focusedCell.getAttribute("data-field")})}for(let t=0;t<e;t++){const e=l._rowsInDOM[t];let n=i+t;n>=0&&(a||e.data.$.index!==n||e.data.detail)&&l._updateVisibleRow(e,n,r),e.setAttribute("unused",""),e.setAttribute("aria-hidden",!0),e.classList.remove("smart-table-row-detail")}for(let t=e;t<l._rowsInDOM.length;t++){const e=l._rowsInDOM[t],o=i+t;o<n?(e.removeAttribute("unused"),e.removeAttribute("aria-hidden"),(a||e.data.$.index!==o||e.data.parent)&&l._updateVisibleRow(e,o,r)):e.setAttribute("aria-hidden",!0)}l._start={view:e,data:t},l._focusEquivalentCell(o)}_updateVisibleRow(e,t,a){const l=this,i=l._columns.filter((e=>e.visible));if(!i.length)return;const n=l._rowsVirtual[t],r=n.data,o=r.$.id,s=Number(a.selection),d=!r.groupDataField&&!e.firstElementChild.classList.contains("group-header")&&!n.detail&&!e.classList.contains("smart-table-row-detail")&&e.childElementCount>1;if(e.className="",d){const t=e.attributes;for(;t.length>0;)e.removeAttribute(t[0].name)}else e.innerHTML="";if(r.groupDataField)l._createGroupHeader(r,void 0,e);else if(n.detail)l._createRowDetailOnDemand(e,n,r);else{e.setAttribute("aria-rowindex",r.$.index+1),l._processAndRenderSelection(r,e,a.hierarchical,d);for(let t=0;t<i.length;t++){const c=i[t];let u=d?e.children[t+s]:document.createElement("td"),f=!1;if(u&&(l.grouping&&!r.groupDataField||l.dataSource&&l.dataSource.groupBy&&l.dataSource.groupBy.length>0)&&u.removeAttribute("colspan"),!u){if(!d)continue;u=document.createElement("td"),f=!0,e.appendChild(u)}d&&(u.className=""),u.setAttribute("data-field",c.dataField),u.setAttribute("aria-colindex",t+1+s);let m,h=l._formatCellValue(n,c,u);if(f&&l._setCellContent(u,h,m),c.freeze&&u.classList.add("freeze-"+("far"===c.freeze?"far":"near")),c.responsivePriority&&u.classList.add("priority-"+c.responsivePriority),!1===c.allowEdit?(u.classList.add("no-edit"),u.setAttribute("aria-readonly",!0)):u.removeAttribute("aria-readonly"),0===t&&a.hierarchical){const e=l._areChildrenFiltered(r);r.leaf||(u.classList.add("tree-cell"),m=e),r.level&&(u.classList.add("outline-level-"+Math.min(r.level,10)),!r.leaf&&e||u.classList.add("tree-leaf"))}if(c.templateElement){if(f&&l.grouping){const e=c.templateElement+"",t=u;e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=e}else if(a.hierarchical&&l.grouping&&r.leaf){const e=c.templateElement+"",t=u;if((!t.firstElementChild||!(t.firstElementChild.hasAttribute("ng-version")||t.innerHTML.indexOf("ng-version")>=0))&&t.firstElementChild&&!t.firstElementChild.classList.contains(".smart-table-cell-template")){const a=t.innerHTML;e.substring(e.lastIndexOf("</"))!==a.substring(a.lastIndexOf("</"))&&(e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=e)}}if(m&&!u.querySelector(".hierarchy-arrow")){l._setCellContent(u,h,m);const e=u.children[0].children[1],t=c.templateElement+"";t.indexOf("{{value}}")>=0?e.innerHTML=t.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):e.innerHTML=t}else if(a.hierarchical&&!l.grouping&&r.leaf){const e=u;if(!e.firstElementChild||!(e.firstElementChild.hasAttribute("ng-version")||e.innerHTML.indexOf("ng-version")>=0)){l._setCellContent(u,h,!1);const t=c.templateElement+"";t.indexOf("{{value}}")>=0?e.innerHTML=t.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):e.innerHTML=t}}if(!d){const e=c.templateElement+"",t=m?u.children[0].children[1]:u;e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=e}let e=m?u.children[0].children[1].firstElementChild:u.firstElementChild;if(!e&&a.hierarchical){l._setCellContent(u,h,!1);const t=u,a=c.templateElement+"";a.indexOf("{{value}}")>=0?t.innerHTML=a.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=a,e=m?u.children[0].children[1].firstElementChild:u.firstElementChild}c.templateElementSettings?c.templateElementSettings(r[c.dataField],o,e):c.templateElement.indexOf("{{value}}")>=0&&(u.querySelector(".smart-table-cell-template").textContent=r[c.dataField])}else c.formatFunction,l._setCellContent(u,h,m);l.onCellRender&&l.onCellRender(r,c.dataField,r[c.dataField],u),l._applyConditionalFormattingToCell(u,c.dataField,r.$.index),d||e.appendChild(u)}e.data=r,e.setAttribute("row-id",o),-1!==l._disabledSelection.indexOf(o)&&(e.removeAttribute("aria-selected"),e.classList.add("disable-select"),a.selection&&e.firstElementChild.firstElementChild.setAttribute("aria-disabled",!0)),r.expanded?(-1===l._expandedIds.indexOf(o)&&l._expandedIds.push(o),e.setAttribute("aria-expanded",!0),e.classList.add("expanded")):!1===r.expanded&&e.setAttribute("aria-expanded",!1),r.level&&l._isCollapsed(r)&&(e.setAttribute("aria-hidden",!0),e.classList.add("collapsed","smart-hidden"))}}_createRowDetailOnDemand(e,t,a){const l=this,i=Number(l.selection)+l._columns.filter((e=>e.visible)).length;e.data=Object.assign(a,{detail:!0}),e.classList.add("smart-table-row-detail"),e.removeAttribute("aria-rowindex"),e.removeAttribute("row-id"),e.innerHTML=`<td colspan="${i}"><div class="smart-table-detail-container">${l._applyRowDetailTemplate(t)}</div></td>`}_hierarchyArrowClickHandlerVirtualization(e,t){const a=this,l=!a.grouping,i=a.$.tableContainer,n={nextRow:e.nextElementSibling,tbody:i.children[1]},r=e.data,o=[],s=[],d=Math.ceil((a.$.virtualizationContainer.$.scrollViewerContainer.offsetHeight-i.firstElementChild.offsetHeight)/a._rowHeight);function c(){0===o.length?function(){if(a._ignoreVerticalChange=!0,r.expanded=!r.expanded,l)r.expanded?(-1===a._expandedIds.indexOf(r.$.id)&&a._expandedIds.push(r.$.id),a.$.fireEvent("expand",{id:r.$.id,record:r})):(a._expandedIds=a._expandedIds.filter((e=>e!==r.$.id)),a.$.fireEvent("collapse",{id:r.$.id,record:r})),a._updateState("expanded");else if(!0!==t){const e=t=>{for(let a=0;a<t.length;a++){const l=t[a];if(l.$.id===r.$.id)return l;if(l.children){let t=e(l.children);if(t)return t}}return null},t=e(a.dataSource.boundHierarchy);t&&(t.expanded=r.expanded);let l=""+r.$.id;l=l.replace("Item","").replace(/_/gi,"."),r.expanded?a.$.fireEvent("group",{action:"expand",path:l,dataField:r.groupDataField,label:r.label}):a.$.fireEvent("group",{action:"collapse",path:l,dataField:r.groupDataField,label:r.label})}for(const e of s)e.remove();let e=a.$.virtualizationContainer.$.verticalScrollBar,i=a.$.virtualizationContainer.$.verticalScrollBar.value;a._refreshDataRows(),i=Math.min(e.max,i),e.value=i,delete a._ignoreVerticalChange,a._onVerticalChange({detail:{value:i}},!0)}():requestAnimationFrame((()=>c()))}function u(e){for(const t of e){if(s.length>=d)break;!1!==t.$.filtered&&(s.push(a._expandSingleChildRowVirtualization(t,n,o)),t.children&&t.expanded&&u(t.children))}}r.expanded?function e(t){t.forEach((t=>{a._collapseSingleChildRow(i.querySelector(`tr[row-id="${t.$.id}"]:not([unused])`),o),t.children&&e(t.children)}))}(r.children):requestAnimationFrame((()=>u(r.children))),e.setAttribute("aria-expanded",!r.expanded),e.classList.toggle("expanded",!r.expanded),requestAnimationFrame((()=>c()))}_expandSingleChildRowVirtualization(e,t,a){const l=this,i=l.rowById[e.$.id],n=document.createDocumentFragment();let r;if(i){if(r=i.data.groupDataField?l._createGroupHeader(i.data,n):l._createDataRow(i,n,{virtualization:!0,hierarchical:!0,selection:l.selection}).row,-1===[...t.tbody.children].indexOf(t.nextRow)){let a=!1;e.children&&0===e.children.length&&(a=!0),e.children||(a=!0),l._rowsInDOM&&l._rowsInDOM.length===l.rows.length&&(a=!0),a||t.tbody.appendChild(n)}else t.tbody.insertBefore(n,t.nextRow);return l._expandSingleChildRow(r,a),r}}_getFractionOfMax(){const e=this;return e.isRendered&&e.virtualization?{vertical:function(){const t=e.$.virtualizationContainer.$.verticalScrollBar,a=t.max;return 0===a?0:t.value/a}(),horizontal:function(){const t=e.$.virtualizationContainer.$.horizontalScrollBar,a=t.max;return 0===a?0:t.value/a}()}:null}_setFractionOfMax(e){if(!this.virtualization||null===e)return;const t=this.$.virtualizationContainer,a=t.$.verticalScrollBar,l=t.$.horizontalScrollBar;a.value=a.max*e.vertical,l.value=l.max*e.horizontal}_refreshHorizontalScrollbar(){const e=this.$.virtualizationContainer;if(!e)return;const t=e.$.scrollViewerContainer,a=e.$.horizontalScrollBar,l=e.$.verticalScrollBar,i=e.$.scrollViewerContentContainer.offsetWidth-t.offsetWidth;let n,r;i>0&&!t.classList.contains("hscroll")?(t.classList.add("hscroll"),n="add"):i<=0&&t.classList.contains("hscroll")&&(r=a.offsetHeight,t.classList.remove("hscroll"),n="subtract"),e.scrollWidth!==i&&(e.scrollWidth=i),e.computedVerticalScrollBarVisibility&&("add"===n?(r=a.offsetHeight,l.max+=r):"subtract"===n&&(l.max-=r))}_scrollToVirtualization(e,t){const a=this;if(!a.virtualization)return;const l=a.$.virtualizationContainer,i=l.$.scrollViewerContentContainer,n=l.$.verticalScrollBar,r=l.$.horizontalScrollBar,o=a.$.tableContainer,s=i.offsetLeft,d=i.offsetTop,c=n.value;let u,f;switch(t&&(u=t.offsetLeft,f=t.offsetTop),e){case"nextArrow":{if(!t||!l.computedHorizontalScrollBarVisibility)return;const e=s+u+t.offsetWidth-l.offsetWidth;e>0&&(r.value+=e+n.offsetWidth);break}case"prevArrow":if(!t||!l.computedHorizontalScrollBarVisibility||u>=-s)return;r.value=u-s-r.value;break;case"ArrowUp":{const e=o.firstElementChild.offsetHeight-d-f;if(e<=0)return;let t;if(a._focusedCell){const e=a._focusedCell.parentElement;e&&(t={rowId:e.data.$.id,dataField:a._focusedCell.getAttribute("data-field")})}const l=Math.max(0,c-e);l!==c&&(n.value=l,a._focusEquivalentCell(t));break}case"ArrowDown":{const e=d+f+t.offsetHeight-l.offsetHeight;if(e<=0)return;const a=Math.min(n.max,c+e);a!==c&&(n.value=a);break}case"Home":case"End":if(!l.computedHorizontalScrollBarVisibility)return;r.value="Home"===e?0:r.max}}_getExpandedGroups(e){const t=this,a=[];return e?(function e(l){l.forEach((l=>{l.expanded&&a.push({groupDataField:l.groupDataField,label:l.label,ancestorSignature:t._getGroupAncestorSignature(l)}),l.children&&l.children.length>0&&!1===l.children[0].leaf&&e(l.children)}))}(e),a):[]}_getGroupAncestorSignature(e){const t=[];let a=e.parent;for(;a;)t.push({groupDataField:a.groupDataField,label:a.label}),a=a.parent;return JSON.stringify(t)}_restoreExpandedGroups(e){if(0===e.length)return;const t=this,a=t.dataSource,l=[];!function a(i){i&&i.forEach((i=>{if(e.some((e=>e.groupDataField===i.groupDataField&&e.label===i.label&&e.ancestorSignature===t._getGroupAncestorSignature(i)))){let e=i.$.id;"string"==typeof e&&(e=e.replace("Item","").replace(/_/g,".")),l.push(e)}i.children&&i.children.length>0&&!1===i.children[0].leaf&&a(i.children)}))}(a.boundHierarchy);const i=t._doNotFireEvent;t._doNotFireEvent=!0,l.forEach((e=>t.expandGroup(e))),t._doNotFireEvent=i}});
153
+ Smart("smart-table",class extends Smart.ContentElement{static get properties(){return{autoLoadState:{value:!1,type:"boolean"},autoSaveState:{value:!1,type:"boolean"},columnGroups:{value:null,type:"array?"},columnMinWidth:{value:"50px",type:"any"},columnReorder:{value:!1,type:"boolean"},columnResize:{value:!1,type:"boolean"},columnResizeFeedback:{value:!1,type:"boolean"},columnResizeNormalize:{value:!1,type:"boolean"},columns:{value:[],type:"any?",reflectToAttribute:!1},columnSizeMode:{value:"default",allowedValues:["auto","default"],type:"string"},conditionalFormatting:{value:null,type:"array?",reflectToAttribute:!1},conditionalFormattingButton:{value:!1,type:"boolean"},deferredScrollDelay:{value:1,type:"number"},dataRowId:{value:null,type:"string?"},dataSource:{value:null,type:"any?",reflectToAttribute:!1},dataSourceSettings:{value:{autoGenerateColumns:{value:!1,type:"boolean"},sanitizeHTML:{value:"blackList",allowedValues:["all","blackList","none"],type:"string"},sanitizeHTMLRender:{value:"text",allowedValues:["text","html"],type:"string"},root:{value:"",type:"string"},record:{value:"",type:"string"},keyDataField:{value:"",type:"string"},parentDataField:{value:"",type:"string"},childrenDataField:{value:"",type:"string"},groupBy:{value:[],type:"array"},dataFields:{value:[],type:"array"},mapChar:{value:".",type:"string"},id:{value:"",type:"string"},virtualDataSource:{value:null,type:"any"},virtualDataSourceOnExpand:{value:null,type:"any"}},type:"object"},dataTransform:{value:null,type:"function?",reflectToAttribute:!1},editing:{value:!1,type:"boolean"},editMode:{value:"cell",allowedValues:["cell","row"],type:"string"},expandHierarchy:{value:!1,type:"boolean"},filtering:{value:!1,type:"boolean"},columnMenu:{value:!1,type:"boolean"},filterRow:{value:!1,type:"boolean"},filterTemplate:{value:null,type:"string?"},filterOperator:{value:"and",type:"string?"},footerRow:{value:null,type:"string?"},formulas:{value:!1,type:"boolean"},freezeFooter:{value:!1,type:"boolean"},freezeHeader:{value:!1,type:"boolean"},grouping:{value:!1,type:"boolean"},groupFormatFunction:{value:null,type:"any"},headerRow:{value:null,type:"any"},hideSelectionColumn:{value:!1,type:"boolean"},keyboardNavigation:{value:!1,type:"boolean"},loadColumnStateBehavior:{value:"implementationOnly",allowedValues:["stateOnly","implementationOnly","intersection"],type:"string"},messages:{value:{en:{add:"Add condition",all:"All columns",apply:"Apply",between:"Between",cancel:"Cancel",clearFilter:"Clear filter",close:"Close",column:"Column:",condition:"Condition:",conditionalFormatting:"Conditional Formatting",CONTAINS:"contains",CONTAINS_CASE_SENSITIVE:"contains (case sensitive)",DOES_NOT_CONTAIN:"does not contain",DOES_NOT_CONTAIN_CASE_SENSITIVE:"does not contain (case sensitive)",EMPTY:"empty",ENDS_WITH:"ends with",ENDS_WITH_CASE_SENSITIVE:"ends with (case sensitive)",EQUAL:"equal",equal:"Equal To",EQUAL_CASE_SENSITIVE:"equal (case sensitive)",filterCondition:"Filter condition",filterPlaceholder:"Filter",firstButton:"First",fontFamily:"Font family:",fontSize:"Font size:",format:"Format:",formatColumn:"Format Column",GREATER_THAN:"greater than",GREATER_THAN_OR_EQUAL:"greater than or equal",greaterThan:"Greater Than",highlight:"Highlight",invalidValue:"Invalid value",itemsPerPage:"Items per page:",lastButton:"Last",LESS_THAN:"less than",LESS_THAN_OR_EQUAL:"less than or equal",lessThan:"Less Than",nextButton:"Next",NOT_EMPTY:"not empty",NOT_EQUAL:"not equal",NOT_NULL:"not null",notEqual:"Not Equal To",NULL:"null",ok:"OK",previousButton:"Previous",remove:"Remove condition",secondValue:"Second value:",STARTS_WITH:"starts with",STARTS_WITH_CASE_SENSITIVE:"starts with (case sensitive)",summaryPrefix:"of",text:"Text",value:"Value:",with:"with",columnMenuItemSortAsc:"Sort Ascending",columnMenuItemSortDesc:"Sort Descending",columnMenuItemReset:"Reset",columnMenuItemRemoveSort:"Remove Sort",columnMenuItemFilter:"Show rows where:",columnMenuItemRemoveFilter:"Remove Filter",columnMenuItemColumns:"Columns",grouping:"Group field name is not found in the dataFields collection!"}},type:"object",extend:!0},onCellRender:{value:null,type:"function?",reflectToAttribute:!1},onColumnRender:{value:null,type:"function?",reflectToAttribute:!1},onInit:{value:null,type:"function?",reflectToAttribute:!1},pageSize:{value:10,allowedValues:[10,25,50],type:"int"},pageIndex:{value:0,type:"int"},paging:{value:!1,type:"boolean"},rowDetailTemplate:{value:null,type:"string?"},selected:{value:[],type:"array",reflectToAttribute:!1},selection:{value:!1,type:"boolean"},selectionMode:{value:"many",type:"string",allowedValues:["one","many","extended"]},selectionByHierarchy:{value:!0,type:"boolean"},sort:{value:null,type:"function?",reflectToAttribute:!1},sortMode:{value:"none",type:"string",allowedValues:["none","one","many"]},stateSettings:{value:["columns","expanded","filtered","grouped","selected","sorted"],type:"array"},tooltip:{value:!1,type:"boolean"},virtualization:{value:!1,type:"boolean"}}}static get listeners(){return{resize:"_resizeHandler","conditionalFormattingButton.click":"_conditionalFormattingButtonClickHandler","filterInput.keyup":"_filterInputKeyupHandler","pager.change":"_pagerChangeHandler","pager.pageSizeChanged":"_pagerPageSizeChanged","tableContainer.change":"_tableContainerChangeHandler","tableContainer.click":"_tableContainerClickHandler","tableContainer.down":"_tableContainerDownHandler","tableContainer.focus":"_tableContainerFocusHandler","tableContainer.pointerover":"_tableContainerPointeroverHandler","document.down":"_documentDownHandler","document.keydown":"_tableContainerKeydownHandler","document.keyup":"_tableContainerKeyupHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler"}}template(){return Smart.Templates[this.nodeName]&&delete Smart.Templates[this.nodeName],this.virtualization?'<div id="container" class="smart-container" role="presentation">\n <div id="header" class="smart-table-header" role="toolbar">\n <smart-input id="filterInput" class="underlined" animation="[[animation]]" locale="[[locale]]" right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-input>\n <div id="filterTemplateContainer" class="smart-table-filter-template-container smart-hidden"></div>\n <smart-button id="conditionalFormattingButton" class="smart-table-toolbar-button conditional-formatting" animation="[[animation]]" right-to-left="[[rightToLeft]]" theme="[[theme]]" aria-label="Conditional Formatting"></smart-button>\n </div>\n <smart-scroll-viewer style="opacity: 0.99" id="virtualizationContainer" class="smart-table-virtualization-container" right-to-left="[[rightToLeft]]" theme="[[theme]]">\n <table id="tableContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-table-container">\n <content></content>\n </table>\n </smart-scroll-viewer>\n <smart-pager id="pager" animation="[[animation]]" locale="[[locale]]" page-index="[[pageIndex]]" page-size="[[pageSize]]" pages-count="null" show-first-last-navigation-buttons show-page-size-selector show-prev-next-navigation-buttons show-summary right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-pager>\n <div id="loadingIndicatorContainer" class="smart-loader-container smart-hidden" aria-label="Loading">\n <span id="loadingIndicator" class="smart-loader" role="presentation"></span>\n </div>\n </div>':'<div id="container" class="smart-container" role="presentation">\n <div id="header" class="smart-table-header" role="toolbar">\n <smart-input id="filterInput" class="underlined" animation="[[animation]]" locale="[[locale]]" right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-input>\n <div id="filterTemplateContainer" class="smart-table-filter-template-container smart-hidden"></div>\n <smart-button id="conditionalFormattingButton" class="smart-table-toolbar-button conditional-formatting" animation="[[animation]]" right-to-left="[[rightToLeft]]" theme="[[theme]]" aria-label="Conditional Formatting"></smart-button>\n </div>\n <table id="tableContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-table-container">\n <content></content>\n </table>\n <smart-pager id="pager" animation="[[animation]]" locale="[[locale]]" page-index="[[pageIndex]]" page-size="[[pageSize]]" pages-count="null" show-first-last-navigation-buttons show-page-size-selector show-prev-next-navigation-buttons show-summary right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-pager>\n <div id="loadingIndicatorContainer" class="smart-loader-container smart-hidden" aria-label="Loading">\n <span id="loadingIndicator" class="smart-loader" role="presentation"></span>\n </div>\n </div>'}resetState(e){const t=this;switch(e){case"expanded":t._expandedIds=[],t._state.expanded=[];break;case"selected":t._selectedIds=[],t._disabledSelection=[],t._selectableGroupRecords=[],t.set("selected",[]),t._state.selected=[];break;default:t._dblclickObject={numberOfClicks:0},t._expandedIds=[],t._selectedIds=[],t._disabledSelection=[],t._selectableGroupRecords=[],t._state={expanded:[],selected:[],sorted:[]},t.set("selected",[])}}render(){this._render(),super.render()}_render(){const e=this,t=getComputedStyle(e);if(e.setAttribute("role","presentation"),e.$.tableContainer.id=e.id+"TableContainer",e._cachedWidth=e.offsetWidth,e._cachedHeight=e.offsetHeight,e._defaults={fontFamily:t.fontFamily,fontSize:t.fontSize,text:e._toHex(t.color),highlight:e._toHex(t.backgroundColor)},e._isMobile=Smart.Utilities.Core.isMobile,e._autoScrollCoefficient=Smart.Utilities.Core.Browser.Firefox?8:Smart.Utilities.Core.Browser.Edge?16:4,e._dblclickObject={numberOfClicks:0},e._expandedIds=[],e._selectedIds=[],e._disabledSelection=[],e._selectableGroupRecords=[],e._state={expanded:[],selected:[],sorted:[]},e._rowHeight=parseFloat(t.getPropertyValue("--smart-table-row-height")),e._rowDetailHeight=parseFloat(t.getPropertyValue("--smart-table-row-detail-height")),e._animation=e.animation,e._setFocusable(),e.selection&&e.$.tableContainer.setAttribute("aria-multiselectable",!0),e.virtualization){const t=e.$.virtualizationContainer,a=e;t&&(t._mouseWheelHandler=function(e){const l=t;if(!l.disabled&&(l.computedHorizontalScrollBarVisibility||l.computedVerticalScrollBarVisibility)){if(e.shiftKey&&l.computedHorizontalScrollBarVisibility){const t=l.scrollLeft;if(0===t&&e.deltaX<0||t===l.scrollHeight&&e.deltaX>0)return;return e.stopPropagation(),e.preventDefault(),void(l.scrollWidth>0&&l.scrollTo(void 0,l.scrollLeft+l._getScrollCoefficient(e,l.offsetWidth)))}if(l.computedVerticalScrollBarVisibility){const t=l.scrollTop;if(0===t&&e.deltaY<0||t===l.scrollHeight&&e.deltaY>0)return;if(e.stopPropagation(),e.preventDefault(),l.scrollHeight>0){let t=3*a._rowHeight;e.deltaY<=0&&(t=-3*a._rowHeight),Math.abs(e.deltaY)>=100?l.scrollTop+=t:l.scrollTop+=e.deltaY}}}},t._verticalScrollbarHandler=function(t){0===e.deferredScrollDelay?e._onVerticalChange(t):(e._verticalScrollTimer&&(clearTimeout(e._verticalScrollTimer),delete e._verticalScrollTimer),e._verticalScrollTimer=setTimeout((()=>{e._onVerticalChange(t),delete e._verticalScrollTimer}),e.deferredScrollDelay))}),t.hasStyleObserver=!1,t.$.verticalScrollBar.hasStyleObserver=!1,t.$.horizontalScrollBar.hasStyleObserver=!1,e.freezeHeader=!0,e.freezeFooter=!0}e.isRendered?e.innerHTML&&e.innerHTML.trim().length>1?e._initDataSourceFromHTML():e._fullRefresh():(e._createElement(),setTimeout((()=>{const t=e.querySelectorAll("tr[row-id]");if(t.length>0){let a=!1;for(let l=0;l<t.length;l++){const i=t[l];e._rowHeight<i.offsetHeight&&(e._rowHeight=i.offsetHeight,a=!0)}a&&(e.style.setProperty("--smart-table-row-height",e._rowHeight+"px"),e._refreshDataRows())}}),500),e.columnMenu&&(e._initialState=e.getState()),super.render())}_initDataSourceFromHTML(){const e=this,t=e.context;e.context=e,e.hasAttribute("smart-blazor")&&(e.$.tableContainer.innerHTML="");const a=e.columns;e.dataSource=null,e.rows=null,e.columns=null;const l=e.querySelectorAll("th");let i=[],n=[],r=[];for(let e=0;e<l.length;e++){const t=l[e].innerHTML.trim();let a={label:t,dataField:t,dataType:"string"};i.push(a),n.push(t)}if(0===l.length&&a&&a.length>0)for(let e=0;e<a.length;e++){const t=a[e];let l={label:t.label,dataField:t.dataField,dataType:t.dataType};t.width&&(l.width=t.width),t.allowResize&&(l.allowResize=t.allowResize),t.allowFilter&&(l.allowFilter=t.allowFilter),t.allowSort&&(l.allowSort=t.allowSort),t.allowHide&&(l.allowHide=t.allowHide),t.allowMenu&&(l.allowMenu=t.allowMenu),t.freeze&&(l.freeze=t.freeze),t.responsivePriority&&(l.responsivePriority=t.responsivePriority),t.columnGroup&&(l.columnGroup=t.columnGroup),i.push(l),n.push({name:t.dataField,dataType:t.dataType})}const o=e.querySelectorAll("tr");for(let e=0;e<o.length;e++){const t={},a=o[e].querySelectorAll("td");if(a.length>0){for(let e=0;e<i.length;e++)t[i[e].dataField]=a[e].innerHTML.trim();r.push(t)}}const s=new Smart.DataAdapter({dataSource:r,expandHierarchy:e.expandHierarchy,dataFields:n,id:e.dataRowId});e.$.tableContainer.innerHTML="",e.columns=i,e.context=t,e.dataSource=s}attached(){const e=this;super.attached(),e.isCompleted&&e._dialog&&(e._addDialogHandlers(),e.getShadowRootOrBody().appendChild(e._dialog)),e.isRendered&&e.isCompleted&&e.endUpdate()}detached(){const e=this;if(super.detached(),e._focusedCell&&!e.$.tableContainer.contains(e._focusedCell)&&delete e._focusedCell,!e._dialog)return;e._detachCachedTemplates();const t=e._dialog;t.removeEventListener("change",e._dialogEventHandler),t.removeEventListener("clear",e._dialogEventHandler),t.removeEventListener("click",e._dialogEventHandler),t.removeEventListener("close",e._dialogEventHandler),t.removeEventListener("filter",e._dialogEventHandler),t.remove()}addFilter(e,t){const a=this,l=a.columnByDataField[e];"string"==typeof t?t=a.dataSource._createFilter(l.dataType,[t]):Array.isArray(t)&&(t=a.dataSource._createFilter(l.dataType,t)),l&&!1!==l.allowFilter&&t instanceof Smart.Utilities.FilterGroup!=0&&(e=l.dataField,a._clearSortByRow&&a._clearSortByRow(!0),a._designerFiltersApplied&&a._clearDesignerFilters(),a._filterInfo.appliedFilters||(a._filterInfo.appliedFilters={}),a._filterInfo.appliedFilters[e]=t,a._refreshFilters("add"),l.headerCellElement&&l.headerCellElement.setAttribute("filter",""),a.$.filterInput&&t&&!a.filterRow&&!a.columnMenu&&(a.$.filterInput.value=t.filters[t.filters.length-1].value,a._filterInfo.query=a.$.filterInput.value),a._originalDynamicColumnsOrder&&(a._originalDynamicColumnsOrder=a._dynamicColumns.map((e=>e.id))))}addGroup(e){const t=this;if(!t.grouping)return;const a=t.columnByDataField[e];if(!a||!1===a.allowGroup)return;const l=t.dataSource,i=l.groupBy;e=a.dataField,-1===i.indexOf(e)&&(i.push(e),l.refreshHierarchy(),t._getSelectableGroupRecords(),t._fullRefresh(),t._updateState("grouped"),t._doNotFireEvent||t.$.fireEvent("group",{action:"add",dataField:e}))}beginEdit(e,t){const a=this;if(!a.editing)return;const l=a.columnByDataField[t];if(t=l?l.dataField:void 0,"cell"===a.editMode&&!t||l&&!1===l.allowEdit)return;const i=a.rowById[e];if(!i)return;const n=i.data.$.id;a._editing&&a.endEdit(),a._beginEdit({rowId:n,rowObject:i,dataField:t})}cancelEdit(){const e=this,t=e._editing;if(t){for(let a=0;a<t.cells.length;a++){const l=t.cells[a];l.editor.contains(e.getRootNode().activeElement)&&e._focusCell(l.element),l.editor.remove(),e._setCellContent(l.element,e._formatCellValue(t.row,e.columnByDataField[l.dataField],l.element)),l.element.classList.remove("editing")}delete e._editing}}clearFilters(e=null){const t=this,a=t._filterInfo;(a.inputFilters||a.rowFilters||a.appliedFilters)&&(t._clearFilterInput(),t._clearRowFilters(e),delete t._filterInfo.appliedFilters,t.dataSource.virtualDataSource||t.dataSource.clearFilter(),t._fullRefresh("filter"),t._updateState("filtered"),t._doNotFireEvent||t.$.fireEvent("filter",{action:"remove"}))}clearGrouping(){const e=this,t=e.dataSource;0!==t.groupBy.length&&(t.groupBy=[],t.refreshHierarchy(),e._getSelectableGroupRecords(),e._fullRefresh(),e._updateState("grouped"),e.$.fireEvent("group",{action:"remove"}))}clearSelection(){this._clearSelection(!0)}collapseAllRows(){const e=this;e._isExpandCollapseForbidden()||function t(a){for(let l=0;l<a.length;l++){const i=a[l];i.leaf||(i.children&&t(i.children),i.expanded&&e.collapseRow(i.$.id))}}(e["smart-table"===e.nodeName.toLowerCase()?"dataSource":"rows"].boundHierarchy)}collapseGroup(e){const t=this;if(!t.grouping||0===t.dataSource.groupBy.length)return;const a=t._getGroupByIndex(e);if(!a||!a.expanded)return;const l=t.$.tableContainer.querySelector(`tr[row-id="${a.$.id}"]:not([unused])`);if(!l){a.expanded=!1;let e=a.$.id;return e=e.replace("Item","").replace(/_/gi,"."),void t.$.fireEvent("group",{action:"collapse",path:e,dataField:a.groupDataField,label:a.label})}if(t._isCollapsed(a))return l.setAttribute("aria-expanded",!1),l.classList.remove("expanded"),void(a.expanded=!1);t._hierarchyArrowClickHandler(l)}collapseRow(e){const t=this;if(t._isExpandCollapseForbidden())return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e],l=a.data||a;if(!a||l.leaf||!l.expanded)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);return i?t._isCollapsed(l)?(i.setAttribute("aria-expanded",!1),i.classList.remove("expanded"),l.expanded=!1,t._expandedIds=t._expandedIds.filter((e=>e!==l.$.id)),t._updateState("expanded"),void t.$.fireEvent("collapse",{record:l})):void t._hierarchyArrowClickHandler(i):(l.expanded=!1,t._expandedIds=t._expandedIds.filter((e=>e!==l.$.id)),void t._updateState("expanded"))}collapseRowDetails(e){const t=this;if(!t.rowDetailTemplate)return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e],l=a.data||a;if(!a||!l)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);if(!i)return;const n=i.nextElementSibling;n&&n.classList.contains("smart-table-row-detail")&&!n.classList.contains("collapsed")&&t._toggleRowDetail(i,l.$.id)}collapseAllRowDetails(){const e=this;if(!e.rowDetailTemplate||!e.dataSource)return;let t=e.dataSource.boundSource;t||(t=e.$.tableContainer.querySelectorAll("tr[row-id]:not([unused])"));for(let a=0;a<t.length;a++)e.collapseRowDetails(t[a].$.id)}expandAllRowDetails(){const e=this;if(!e.rowDetailTemplate||!e.dataSource)return;let t=e.dataSource.boundSource;t||(t=e.$.tableContainer.querySelectorAll("tr[row-id]:not([unused])"));for(let a=0;a<t.length;a++)e.expandRowDetails(t[a].$.id)}updateRow(e,t,a){const l=this,i=l.rowById?l.rowById[e]:l.rows.dataItemById[e];if(!i)return;const n=l._selectedIds.slice(0);l._editing=!0,l.__updatedRows=!0;let r=[];l.dataSource&&l.dataSource.groupBy&&l.dataSource.groupBy.toArray&&(r=l.dataSource.groupBy.toArray().slice(0));const o=l.dataSource.boundSource.canNotify;l.dataSource.boundSource.canNotify=!1;const s=e=>{if(i.data[e]=t[e],l.dataSource.id&&i&&i.data&&i.data.$&&(i.data.$.id=t[l.dataSource.id]),i&&i.data.$&&void 0!==i.data.$.index){const a=i.data.$.index,n=l.dataSource.dataSource,o=()=>{const a=t[e];if(null==a){const t=l.columnByDataField[e];return t?"number"===t.dataType?0:"boolean"!==t.dataType&&("date"===t.dataType?new Date:""):""}return a};if(n&&n[a]&&(n[a][e]=o()),l.dataSource[a]){if(r.length>0&&!l._dirtyHierarchy&&l.dataSource[a][e]!==o()&&r.indexOf(e)>=0){const e=l._getExpandedGroups(l.dataSource.boundHierarchy);l._dirtyHierarchy=e}l.dataSource[a][e]=o()}}};for(let e=0;e<l.columns.length;e++){const a=l.columns[e];void 0!==t[a.dataField]&&s(a.dataField)}if(a){const e=l.dataSource.dataFields;if(e)for(let t=0;t<e.length;t++)e[t].map?s(e[t].map):s(e[t].name)}l._editing=!1,l.dataSource.boundSource.canNotify=o,l.__updating||(l.dataSource.refreshHierarchy(),l._fullRefresh(void 0,n,"update"))}addRow(e){const t=this;let a=[];const l=t.dataSource.boundSource.canNotify;if(t.dataSource.boundSource.canNotify=!1,t._editing=!0,t.__updatedRows=!0,t.dataSource&&t.dataSource.groupBy&&t.dataSource.groupBy.toArray&&(a=t.dataSource.groupBy.toArray().slice(0),a.length>0&&t.dataSource.beginUpdate()),a.length>0)t.dataSource?t.dataSource.add(e,!0):t._addNewRow(e,0);else if(t.dataSource)if(t.dataSource.boundHierarchy&&t.$.tableContainer&&"treegrid"===t.$.tableContainer.getAttribute("role")){const a=e[t.dataSource.parentDataField];t.dataSource.add(e,a)}else t.dataSource.add(e,!0);else t._addNewRow(e,0);t.dataSource.boundSource.canNotify=l,t._editing=!1,a.length>0||t.dataSource.boundHierarchy&&t.$.tableContainer&&"treegrid"===t.$.tableContainer.getAttribute("role")?(t._dataSourceUpdatingTimer&&clearTimeout(t._dataSourceUpdatingTimer),t._dataSourceUpdatingTimer=setTimeout((()=>{t._doNotFireEvent=!0;const e=t._getExpandedGroups(t.dataSource.boundHierarchy);a.forEach((e=>t.addGroup(e))),t.dataSource.endUpdate(),t._restoreExpandedGroups(e),t._fullRefresh("update"),t._doNotFireEvent=!1}),50)):(t._dataSourceUpdatingTimer&&clearTimeout(t._dataSourceUpdatingTimer),t._dataSourceUpdatingTimer=setTimeout((()=>{t._doNotFireEvent=!0,t._fullRefresh("update"),t._doNotFireEvent=!1})))}removeRow(e){const t=this,a=t.rowById?t.rowById[e]:t.rows.dataItemById[e];if(!a){if(t.dataSource&&t.dataSource.dataItemById){const a=t.dataSource.dataItemById[e];if(a){const l=void 0!==a.$?a.$.index:0;t.dataSource.removeAt(l),t._selectedIds.indexOf(e)>=0&&(t._selectedIds.splice(t._selectedIds.indexOf(e),1),t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:"remove"})),t.virtualization&&t.__updating||t._fullRefresh("update")}}return}const l=a.data||a,i=void 0!==l.$?l.$.index:0,n=t.dataSource.boundSource.canNotify;t.dataSource.boundSource.canNotify=!1,t._editing=!0,t.__updatedRows=!0;let r=[];t.dataSource&&t.dataSource.groupBy&&t.dataSource.groupBy.toArray&&(r=t.dataSource.groupBy.toArray().slice(0),r.length>0&&t.dataSource.beginUpdate()),t._doNotFireEvent=!0,t._sortColumns&&t._sortColumns.length?t.dataSource.remove(l):t.dataSource.removeAt(i),t._selectedIds.indexOf(e)>=0&&(t._selectedIds.splice(t._selectedIds.indexOf(e),1),t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:"remove"})),t._doNotFireEvent=!1,t.dataSource.boundSource.canNotify=n,t._editing=!1,r.length>0&&(t._dataSourceUpdatingTimer&&clearTimeout(t._dataSourceUpdatingTimer),t._dataSourceUpdatingTimer=setTimeout((()=>{const e=t._getExpandedGroups(t.dataSource.boundHierarchy);r.forEach((e=>t.addGroup(e))),t.dataSource.endUpdate(),t._restoreExpandedGroups(e),t._fullRefresh("update")}),50)),t.virtualization&&t.__updating||t._fullRefresh("update")}expandRowDetails(e){const t=this;if(!t.rowDetailTemplate)return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e];if(!a)return;const l=a.data||a;if(!a||!l)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);if(!i)return;const n=i.nextElementSibling;!n&&!t.virtualization||n&&n.classList.contains("smart-table-row-detail")&&!n.classList.contains("collapsed")||t._toggleRowDetail(i,l.$.id)}endEdit(){const e=this,t=e._editing;if(!t)return;const a=t.row,l=a.data,i=[];let n=!0;for(let a=0;a<t.cells.length;a++){const l=t.cells[a],r=e.columnByDataField[l.dataField],o=l.element,s=l.editor;let d;if(r.editor&&r.editor.template?r.editor.getValue&&(d=r.editor.getValue(s)):(d=s.value,s instanceof HTMLInputElement&&("number"===s.type?d=parseFloat(d):"date"===s.type&&(d=new Date(d),isNaN(d.getTime())&&(d=null)))),r.validation){const t=r.validation(d),a=void 0!==t&&!0!==t;if(a){let a;a="object"==typeof t&&t.message?t.message:e.localize("invalidValue"),o.setAttribute("validation-message",a)}else o.removeAttribute("validation-message");o.classList.toggle("invalid",a),n=n&&!a}i.push({column:r,newValue:d})}if(n){if(e.dataSource.virtualDataSource){const a=Object.assign({},l);for(let e=0;e<t.cells.length;e++){const l=t.cells[e],n=i[e],r=n.column;a[l.dataField]=n.newValue,r.transform&&(a[r.dataField]=r.transform(n.newValue))}for(const t of e._columns)a[t.dataField]instanceof Date&&(a[t.dataField]=a[t.dataField].toISOString().slice(0,10));e._editing.row.data=a,e._requestVirtualDataSource("update",(function(t){return t?r(!1,a):(e._editing.row.data=l,e.cancelEdit()),t}))}else r(!0,l);delete e._editing}function r(l,n){for(let r=0;r<t.cells.length;r++){const o=t.cells[r],s=i[r],d=s.column,c=o.editor;c.contains(e.getRootNode().activeElement)&&e._focusCell(o.element),c.remove(),l&&(n[o.dataField]=s.newValue,d.transform&&(n[d.dataField]=d.transform(s.newValue))),e._setCellContent(o.element,e._formatCellValue(a,d,o.element)),o.element.classList.remove("editing"),e.$.fireEvent("cellEndEdit",{id:n.$.id,row:n,value:n[o.dataField],dataField:o.dataField})}e._updateCellsWithFormulas(),"row"===e.editMode&&e.$.fireEvent("rowEndEdit",{id:n.$.id,row:n})}}expandAllRows(){const e=this;if(e._isExpandCollapseForbidden())return;e.beginUpdate();const t=e["smart-table"===e.nodeName.toLowerCase()?"dataSource":"rows"].boundHierarchy;if(t)for(let e=0;e<t.length;e++){const a=t[e],l=e=>{if(!e.leaf&&(e.expanded=!0,e.children))for(let t=0;t<e.children.length;t++){const a=e.children[t];l(a)}};l(a)}e.endUpdate()}isGroupExpanded(e){const t=this,a=t.dataSource;if(!t.grouping||0===a.groupBy.length)return;const l=t._getGroupByIndex(e);return!!l&&l.expanded}expandGroup(e){const t=this,a=t.dataSource;if(!t.grouping||0===a.groupBy.length)return;const l=t._getGroupByIndex(e);if(!l)return;const i=t._doNotFireEvent,n=t.animation,r=t.$.tableContainer.querySelector(`tr[row-id="${l.$.id}"]:not([unused])`);let o=!1;if(i&&(t.animation="none"),r){if(t._isCollapsed(l))if(i)o=!0;else{let e=l.parent;e&&!e.expanded&&t.expandGroup(l.parent.$.id.replace("Item","").replace(/_/g,"."))}l.expanded||(o||i?(l.expanded=!0,r.setAttribute("aria-expanded",!0),r.classList.add("expanded")):t._hierarchyArrowClickHandler(r,i)),i&&(l.expanded=!0,r.setAttribute("aria-expanded",!0),r.classList.add("expanded"),requestAnimationFrame((()=>t.animation=n)))}else if(l.expanded=!0,!l.expanded&&!i){let e=l.$.id;e=e.replace("Item","").replace(/_/gi,"."),t.$.fireEvent("group",{action:"expand",path:e,dataField:l.groupDataField,label:l.label})}}expandAllRootGroups(){const e=this;if(!e.grouping)return;e.beginUpdate();const t=e.dataSource.boundHierarchy;if(t)for(let e=0;e<t.length;e++)t[e].expanded=!0;e.endUpdate()}expandAllGroups(){const e=this;if(!e.grouping)return;e.beginUpdate();const t=e.dataSource.boundHierarchy;if(t)for(let e=0;e<t.length;e++){const a=t[e],l=e=>{if(e.expanded=!0,e.children)for(let t=0;t<e.children.length;t++){const a=e.children[t];l(a)}};l(a)}e.endUpdate()}collapseAllGroups(){const e=this;if(!e.grouping)return;e.beginUpdate();const t=e.dataSource.boundHierarchy;if(t)for(let e=0;e<t.length;e++)t[e].expanded=!1;e.endUpdate()}expandRow(e){const t=this;if(t._isExpandCollapseForbidden())return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e],l=a.data||a;if(!a||l.leaf)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);if(!i)return l.expanded=!0,-1===t._expandedIds.indexOf(l.$.id)&&t._expandedIds.push(l.$.id),t._updateState("expanded"),void t.$.fireEvent("expand",{id:l.$.id,record:l});if(t._isCollapsed(l)){let e=l.parent;e&&!e.expanded&&t.expandRow(e.$.id)}l.expanded||t._hierarchyArrowClickHandler(i)}exportData(e,t,a,l){const i=this,n=i._columns.filter((e=>e.visible)),r=i.columnGroups,o=i.dataSource,s=getComputedStyle(i),d=s.borderRightColor,c=new Smart.Utilities.DataExporter(void 0,o.groupBy.toArray()),u={};let f,m=Array.from(i.$.tableContainer.firstElementChild.querySelectorAll("th"));if(o.virtualDataSource){f=[];for(let e=0;e<i.rows.length;e++)f.push(i.rows[e].data)}else o.boundHierarchy&&!i.grouping?(c.hierarchical=!0,f=function e(t){const l=[];return t.forEach((t=>{a&&!1===t.$.filtered||(l.push(t),t.leaf||(t._expanded=t.expanded,t.children&&(t.children=e(t.children),0===t.children.length&&(t._expanded=void 0,t.children=void 0,t.leaf=!0))))})),l}(JSON.parse(JSON.stringify(o.boundHierarchy,((e,t)=>{if("parent"!==e)return t}))))):(f=Array.from(o.toArray()),a&&(f=f.filter((e=>!1!==e.$.filtered))));c.style={border:"1px solid "+d,borderCollapse:"collapse",backgroundColor:s.backgroundColor,color:s.color,fontFamily:"Helvetica",header:{border:"1px solid "+d,fontWeight:"bold"},columns:{border:"1px solid "+d}},m=m.filter((e=>!1===e.classList.contains("smart-table-select-all")));for(let e=0;e<n.length;e++){const t=n[e],a={},l={};let i=m[e].offsetWidth+"px";u[t.dataField]=t.label,"date"===t.dataType&&(l.format="d"),a.width=i,c.style.header[t.dataField]=a,c.style.columns[t.dataField]=l}return r?c.header={columns:n,columngroups:r}:f.unshift(u),c.exportData(f,e,t,l)}getRowIndexById(e){const t=this.rowById[e];return this.dataSource&&t&&t.data&&t.data.$?t.data.$.index:-1}getSelection(){const e=this;return 0===e._selectableGroupRecords.length?e._selectedIds.filter((e=>!(""+e).startsWith("Item"))):e._selectedIds.filter((t=>-1===e._selectableGroupRecords.indexOf(t)&&!(""+t).startsWith("Item")))}getState(){return JSON.parse(this._stringifyState())}getValue(e,t){const a=this,l=a.columnByDataField[t];if(!l)return;let i=a.rowById[e];return i?i.data[l.dataField]:(i=a.dataSource.dataItemById[e],i?i[l.dataField]:void 0)}loadState(e){const t=this;if(!e&&!(e=window.localStorage.getItem("smartTable"+t.id)))return;const a=t.stateSettings;let l=!1;if(t._loadingState=!0,"string"==typeof e&&(e=JSON.parse(e)),-1!==a.indexOf("columns")){const a=t.loadColumnStateBehavior,i=t._columns,n=[],r=e.columns;for(let e=0;e<r.length;e++){let t=Object.assign({},r[e]);const l=i.find((e=>e.dataField===t.dataField));if(!l){"implementationOnly"!==a&&n.push(t);continue}const o=l.label,s=["editor","formatFunction","templateElement","templateElementSettings","transform","validation"];"stateOnly"!==a&&s.push("label");for(let e in l)-1===s.indexOf(e)&&delete l[e];t=Object.assign(l,t),"stateOnly"!==a&&o&&(t.label=o),n.push(t)}if("stateOnly"!==a)for(let e=0;e<i.length;e++){const t=i[e];n.find((e=>e.dataField===t.dataField))||n.push(t)}t.columns=n,t._initColumns(!0),l=!0,t._formattingPanel&&(t._formattingPanel.columns=t._columns)}if(t.grouping){const a=t.dataSource,i=t.dataSource.groupBy;e.grouped=e.grouped||[],JSON.stringify(i._array)!==JSON.stringify(e.grouped)&&(t.dataSource.groupBy=e.grouped,a.refreshHierarchy(),l=!0)}else t.hasAttribute("hierarchy")&&-1!==a.indexOf("expanded")&&JSON.stringify(t._expandedIds.slice(0).sort())!==JSON.stringify(e.expanded.slice(0).sort())&&(t.collapseAllRows(),t._expandedIds=e.expanded,l=!0);-1!==a.indexOf("selected")&&e.selected.slice&&JSON.stringify(t._selectedIds.slice(0).sort())!==JSON.stringify(e.selected.slice(0).sort())&&(t._selectedIds=e.selected,l=!0),l&&(t._initRows(),t.refresh());e:if(-1!==a.indexOf("filtered")){const a=t.filtering,l=e.filtered;if(t.clearFilters(),!l)break e;if(a&&t.filterRow&&l.rowFilters){const a=t.$.tableContainer.querySelector(".smart-table-filter-row"),l=Number(t.selection),i=e.filtered.filterRowValues;for(let e=0;e<t._columns.length;e++){const n=i[e];if(!n)continue;const r=t._columns[e].dataType,o=a.children[e+l].firstElementChild,s=t._filterInfo["string"===r?"stringConditions":"numberAndDateConditions"].find((e=>e.value===n.condition));if(-1===["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(s.value))if("date"===r){const e=new Date(n.value),t=(e.getMonth()+1).toString(),a=e.getDate().toString();o.children[0].value=`${e.getFullYear()}-${"0".repeat(2-t.length)}${t}-${"0".repeat(2-a.length)}${a}`}else o.children[0].value=n.value;o.children[1].value=s.label,o.children[1].$.input.dataValue=s.value}t._applyRowFilters()}else if(a&&l.inputFilters)t.$.filterInput.value=l.query,t._filterByAll(l.query);else if(l.appliedFilters){t._filterInfo.appliedFilters||(t._filterInfo.appliedFilters={});for(let e in l.appliedFilters){const a=l.appliedFilters[e],i=new window.Smart.Utilities.FilterGroup;a.filters.forEach(((e,t)=>{const l=i.createFilter(e.type.replace("Filter",""),e.value,e.condition);i.addFilter(a.logicalOperators[t],l)})),t._filterInfo.appliedFilters[e]=i}t._refreshFilters("add")}}-1!==a.indexOf("sorted")&&(t.clearSort(),e.sorted.forEach&&e.sorted.forEach((e=>{t.sortBy(e.dataField,e.direction)}))),a.forEach((e=>t._updateState(e,!1))),t.autoSaveState&&window.localStorage.setItem("smartTable"+t.id,t._stringifyState()),delete t._loadingState}navigateTo(e){const t=this;if(isNaN(e)||null===e)return;const a=t.pageIndex;t.pageIndex=Math.max(Math.min(Math.round(e),t.$.pager.pagesCount-1),0),t.paging&&t.pageIndex!==a&&(t._fullRefresh("pageIndexChange"),t.$.fireEvent("page",{action:"pageIndexChange"}))}removeFilter(e){const t=this,a=t.columnByDataField[e];a&&t.filterRow&&t.clearFilters(e),t._filterInfo.appliedFilters&&a&&(e=a.dataField,t._clearSortByRow&&t._clearSortByRow(!0),t._designerFiltersApplied&&t._clearDesignerFilters(e),delete t._filterInfo.appliedFilters[e],t._refreshFilters("remove"),t._originalDynamicColumnsOrder&&(t._originalDynamicColumnsOrder=t._dynamicColumns.map((e=>e.id))))}removeGroup(e){const t=this,a=t.columnByDataField[e];if(!t.grouping||!a)return;e=a.dataField;const l=t.dataSource,i=l.groupBy,n=i.indexOf(e);-1!==n&&(i.splice(n,1),l.refreshHierarchy(),t._getSelectableGroupRecords(),t._fullRefresh(),t._updateState("grouped"),t.$.fireEvent("group",{action:"remove",dataField:e}))}saveState(){const e=this._stringifyState();return window.localStorage.setItem("smartTable"+this.id,e),JSON.parse(e)}enableSelect(e){const t=this;t.selection&&t._disabledSelection.indexOf(e)>=0&&(t._disabledSelection.splice(t._disabledSelection.indexOf(e),1),t._fullRefresh("update"))}disableSelect(e){const t=this;t.selection&&(t._disabledSelection.push(e),t._fullRefresh("update"))}select(e){const t=this;t.selection&&(Array.isArray(e)?t._changeSelectionOfMultiple(e,"select"):t._selectSingle(e)&&(t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:t._interaction?"interaction":"programmatic"})))}setValue(e,t,a){const l=this,i=l.columnByDataField[t];if(!i)return;let n,r=l.rowById[e];if(r)n=r.data;else{if(r=l.dataSource.dataItemById[e],!r)return;n=r}t=i.dataField,l.dataSource._updating=!0,i.transform?(n[i.originalDataField]=a,n[t]=i.transform(a)):n[t]=a;const o=l.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused]) td[data-field="${t}"]`);if(o&&(l._setCellContent(o,l._formatCellValue(r,i,o),o.classList.contains("tree-cell")),i.templateElement&&i.templateElementSettings)){const e=o.classList.contains("tree-cell"),t=o,a=e?t.children[0].children[1]:t,r=n.$.id;l._cachedTemplates&&l._cachedTemplates[i.dataField+"_"+r]&&(0===l._cachedTemplates[i.dataField+"_"+r].innerHTML.length?delete l._cachedTemplates[i.dataField+"_"+r]:(a.innerHTML="",a.appendChild(l._cachedTemplates[i.dataField+"_"+r]))),i.templateElementSettings(n[i.dataField],r,a.firstElementChild),l._cachedTemplates||(l._cachedTemplates=[]),l._cachedTemplates[i.dataField+"_"+r]||(l._cachedTemplates[i.dataField+"_"+r]=a.firstElementChild)}l._updateCellsWithFormulas(),delete l.dataSource._updating}unselect(e){const t=this;t.selection&&(Array.isArray(e)?t._changeSelectionOfMultiple(e,"unselect"):t._unselectSingle(e)&&(t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:t._interaction&&-1===t._disabledSelection.indexOf(e)?"interaction":"programmatic"})))}set scrollTop(e){const t=this;t.isRendered&&(e=parseInt(e),isNaN(e)||((t.virtualization?t.$.virtualizationContainer:t.$.container).scrollTop=e))}get scrollTop(){const e=this;return e.isRendered?(e.virtualization?e.$.virtualizationContainer:e.$.container).scrollTop:0}set scrollLeft(e){const t=this;t.isRendered&&(e=parseInt(e),isNaN(e)||((t.virtualization?t.$.virtualizationContainer:t.$.container).scrollLeft=e))}get scrollLeft(){const e=this;return e.isRendered?(e.virtualization?e.$.virtualizationContainer:e.$.container).scrollLeft:0}clearContent(){const e=this;for(;e.$.tableContainer.firstChild;)e.$.tableContainer.removeChild(e.$.tableContainer.firstChild)}applyContent(){const e=this;if(void 0===e.content)return void(e.content=e.$.tableContainer);if(""===e.content||null===e.content)return void e.clearContent();if(e.content instanceof HTMLElement)return e.clearContent(),void e.$.content.appendChild(e.content);const t=document.createDocumentFragment();let a=document.createElement("div");t.appendChild(a),e.content instanceof HTMLElement?a.appendChild(e.content):a.innerHTML=e.content;let l=Array.from(a.childNodes);a.parentNode.removeChild(a);for(let e=0;e<l.length;e++)t.appendChild(l[e]);e.clearContent(),e.$.tableContainer.appendChild(t)}propertyChangedHandler(e,t,a){const l=this;if(super.propertyChangedHandler(e,t,a),"innerHTML"!==e)switch(e){case"animation":case"theme":if("theme"===e){const e=getComputedStyle(l);l._defaults.text=l._toHex(e.color),l._defaults.highlight=l._toHex(e.backgroundColor)}if(l.filterRow){const t=l.$.tableContainer.querySelector(".smart-table-filter-row");Array.from(t.querySelectorAll("smart-input, smart-button")).forEach((t=>t[e]=a))}i(e,a);break;case"autoSaveState":a&&window.localStorage.setItem("smartTable"+l.id,l._stringifyState());break;case"columnGroups":a&&(l.columnResize&&(l.columnResize=!1),"auto"===l.columnSizeMode&&(l.removeAttribute("resize-max-reached"),l.columnSizeMode="default")),l.refresh();break;case"columnMinWidth":if(isNaN(parseFloat(a)))return void(l.columnMinWidth=t);l._handleAutoSizeMode(),l._handleFrozenColumnPositions(),l._refreshHorizontalScrollbar();break;case"columnResize":a&&l.columnGroups&&(l.columnResize=!1);break;case"columnResizeNormalize":l._columns&&l._columns.length>0&&""===l._columns[l._columns.length-1].dataField&&(l._columns.pop(),l.columns.pop()),l._initColumns(!0),l.refresh();break;case"columns":{l._conditionalFormatting&&delete l._conditionalFormatting;const e=l._sortColumns,t=l._filterInfo;if(l._clearFilterInput(),l._clearRowFilters(),delete l._filterInfo.appliedFilters,l._sortColumns=[],l._initColumns(!0),l.refresh(),l._formattingPanel&&(l._formattingPanel.columns=l._columns),l.dataSource.dataFields){let a=l.dataSource.dataFields||[];const i=l.columns;let n=!1;if(i.forEach((e=>{if(e.dataType){const t=a.find((t=>t.name===e.dataField));t?t.dataType=e.dataType:e.map?a.find((t=>e.map.indexOf(t.name)>=0?t:null))&&(l.dataSource.dataFields.push({name:e.dataField,map:e.map,dataType:e.dataType}),n=!0):(l.dataSource.dataFields.push({name:e.dataField,dataType:e.dataType}),n=!0)}})),n&&l.dataSource.dataBind){let a=[],i=[];if(l.dataSource&&l.dataSource.groupBy&&l.dataSource.groupBy.toArray&&(a=l.dataSource.groupBy.toArray().slice(0)),a.length>0&&(i=l._getExpandedGroups(l.dataSource.boundHierarchy)),l.dataSource.bindingCompleted=!1,l.dataSource.dataBind(),l._doNotFireEvent=!0,a.length>0&&(a.forEach((e=>l.addGroup(e))),l.dataSource.boundHierarchy&&l.dataSource.refreshHierarchy(),l._restoreExpandedGroups(i)),t.inputFilters?l._filterByAll(t.query):t.rowFilters?l._applyRowFilters():t.appliedFilters&&l._refreshFilters(),e&&(l._sortColumns=[],e.forEach((e=>{l.columnByDataField[e.dataField].sortOrder=null,l.sortBy(e.dataField,e.direction)}))),l._selectedIds.length>0){const e=JSON.stringify(l._selectedIds.slice(0).sort()),t=l.dataSource;l._selectedIds=l._selectedIds.filter((e=>void 0!==t.dataItemById[e]||-1!==l._selectableGroupRecords.indexOf(e))),e!==JSON.stringify(l._selectedIds.slice(0).sort())&&(l._updateSelectAllState(),l._updateState("selected"),l.$.fireEvent("change",{type:"remove"}))}l.virtualization&&setTimeout((()=>{const e=l.columns&&l.columns.length>0?l.columns[0].dataField:"";if(e){const t=l.querySelector('td[data-field="'+e+'"]');t&&l._rowHeight<t.offsetHeight&&(l._rowHeight=t.offsetHeight,l.style.setProperty("--smart-table-row-height",l._rowHeight+"px"),l._refreshDataRows())}}),300),delete l._doNotFireEvent}else t.inputFilters?l._filterByAll(t.query):t.rowFilters?l._applyRowFilters():t.appliedFilters&&l._refreshFilters(),e&&(l._sortColumns=[],e.forEach((e=>{l.columnByDataField[e.dataField].sortOrder=null,l.sortBy(e.dataField,e.direction)})))}break}case"columnSizeMode":if("auto"===a){if(l.columnGroups)return void(l.columnSizeMode="default");l._handleAutoSizeMode()}else l.removeAttribute("resize-max-reached"),l._columns.forEach((e=>{e.visible&&(e._isResponsive?e.headerCellElement.style.width=e.width||e._manualPercentageWidth?l._getColumnWidth(e.width||e._manualPercentageWidth,!0,e):null:e.headerCellElement.style.width=e.width||e._manualWidth?l._getColumnWidth(e.width||e._manualWidth,!0,e):null)}));l._handleFrozenColumnPositions(),l._refreshHorizontalScrollbar();break;case"conditionalFormatting":l._applyInitialConditionalFormatting(l.dataSource),l._refreshDataRows();break;case"conditionalFormattingButton":l.$.header.classList.toggle("smart-hidden",(!l.filtering||l.filterRow)&&!a),!a&&l._dialog&&l._dialog.close();break;case"dataSource":case"dataSourceSettings":{const i=l._sortColumns,n=l._filterInfo;if("dataSource"===e&&null===a&&(l.dataSource=[]),"dataSource"===e&&t&&a&&l.virtualization&&t instanceof Smart.DataAdapter&&t.length===a.length&&t.length>0&&a.length>0&&!l.dataSourceSettings.parentDataField&&!t.parentDataField){if(l.dataSource=t,l._cachedDataSource===a)return;l.beginUpdate();for(let e=0;e<a.length;e++){const t=a[e],i=l.dataSource[e].$.id;l.updateRow(i,t,!0)}return l.endUpdate(void 0,!0),void(l._cachedDataSource=a)}const r=l.$.virtualizationContainer?l.$.virtualizationContainer.scrollTop:0,o=void 0!==l.$.virtualizationContainer&&l.$.virtualizationContainer.$?l.$.virtualizationContainer.$.verticalScrollBar:null;o&&o.beginUpdate();let s=[];if(t&&t.groupBy&&t.groupBy.toArray&&(s=t.groupBy.toArray().slice(0)),l._dataBind(!0),l._doNotFireEvent=!0,s.length>0){const e=l._getExpandedGroups(t.boundHierarchy);if(l.__updating=!0,l.dataSource._groupBy&&(l.dataSource._groupBy.canNotify=!1),l._selectedIds.length>0){const e=JSON.stringify(l._selectedIds.slice(0).sort()),t=l.dataSource;l._selectedIds=l._selectedIds.filter((e=>void 0!==t.dataItemById[e]||-1!==l._selectableGroupRecords.indexOf(e))),s.forEach((e=>l.addGroup(e))),e!==JSON.stringify(l._selectedIds.slice(0).sort())&&(l._updateSelectAllState(),l._updateState("selected"),l.$.fireEvent("change",{type:"remove"}))}else s.forEach((e=>l.addGroup(e)));l.dataSource.boundHierarchy&&l.dataSource.refreshHierarchy(),l.dataSource._groupBy&&(l.dataSource._groupBy.canNotify=!0),l.__updating=!1,l._restoreExpandedGroups(e),l._fullRefresh("update")}if(n.inputFilters?l._filterByAll(n.query):n.rowFilters?l._applyRowFilters():n.appliedFilters&&l._refreshFilters(),i&&(l._sortColumns=[],i.forEach((e=>{l.columnByDataField[e.dataField].sortOrder=null,l.sortBy(e.dataField,e.direction)}))),l._selectedIds.length>0){const e=JSON.stringify(l._selectedIds.slice(0).sort()),t=l.dataSource;l._selectedIds=l._selectedIds.filter((e=>void 0!==t.dataItemById[e]||-1!==l._selectableGroupRecords.indexOf(e))),e!==JSON.stringify(l._selectedIds.slice(0).sort())&&(l._updateSelectAllState(),l._updateState("selected"),l.$.fireEvent("change",{type:"remove"}))}l.virtualization&&(setTimeout((()=>{const e=l.columns&&l.columns.length>0?l.columns[0].dataField:"";if(e){const t=l.querySelector('td[data-field="'+e+'"]');t&&l._rowHeight<t.offsetHeight&&(l._rowHeight=t.offsetHeight,l.style.setProperty("--smart-table-row-height",l._rowHeight+"px"),l._refreshDataRows())}}),300),l.$.virtualizationContainer.scrollTop=r,o&&(o.endUpdate(),l._onVerticalChange({detail:{value:o.value}},!0))),delete l._doNotFireEvent;break}case"disabled":case"unfocusable":case"keyboardNavigation":l._setFocusable(),i("unfocusable",l.disabled||l.unfocusable||!l.keyboardNavigation),"disabled"===e&&l._dialog&&l._dialog.close();break;case"hideSelectionColumn":l.refresh();break;case"columnMenu":l.$.header.classList.toggle("smart-hidden",(!l.filtering||l.filterRow||l.columnMenu)&&!l.conditionalFormattingButton),l.columnMenu&&(l._initialState=l.getState()),l.refresh();break;case"editing":a?l.$.tableContainer.removeAttribute("aria-readonly"):l.$.tableContainer.setAttribute("aria-readonly",!0);break;case"filtering":l.columnMenu||l.$.header.classList.toggle("smart-hidden",(!a||l.filterRow)&&!l.conditionalFormattingButton),a&&l.filterRow?l._createFilterRow():!1===a&&(l.filterRow&&l.$.tableContainer.querySelector(".smart-table-filter-row").remove(),(l._filterInfo.query||l._filterInfo.rowFilters||l._filterInfo.appliedFilters)&&l.clearFilters()),l.virtualization&&l.refresh();break;case"filterRow":if(l.$.header.classList.toggle("smart-hidden",(!l.filtering||a)&&!l.conditionalFormattingButton),!l.filtering)return;a?l._createFilterRow():(l.$.tableContainer.querySelector(".smart-table-filter-row").remove(),l._filterInfo.rowFilters&&l.clearFilters());break;case"filterTemplate":l._applyFilterTemplate();break;case"footerRow":{const e=l.$.tableContainer.querySelector("tfoot");e&&e.remove(),a&&l._createFooterRow();break}case"formulas":a?l._formulaParser=new Smart.FormulaParser(l):delete l._formulaParser,l._updateCellsWithFormulas(!0);break;case"freezeHeader":case"freezeFooter":l.virtualization&&(l[e]=!0);break;case"grouping":a||l.clearGrouping();break;case"headerRow":{const e=Array.from(l.$.tableContainer.firstElementChild.children);for(let t=1;t<e.length;t++)e[t].remove();a&&l._createCustomHeaderRow();break}case"locale":case"messages":{const e=l._dialog;if(l._localize(),l.filterRow){const e=l.$.tableContainer.querySelector(".smart-table-filter-row"),t=Array.from(e.querySelectorAll("smart-input.string-filter")),a=Array.from(e.querySelectorAll("smart-input.num-date-filter")),i=Array.from(e.querySelectorAll("smart-button"));t.concat(a).forEach((e=>e.title=l.localize("filterCondition"))),t.forEach((e=>{e.dataSource=l._filterInfo.stringConditions,void 0===e.$.input.dataValue?e.value=l.localize("CONTAINS"):e.value=l._filterInfo.stringConditions.find((t=>t.value===e.$.input.dataValue)).label})),a.forEach((e=>{e.dataSource=l._filterInfo.numberAndDateConditions,void 0===e.$.input.dataValue?e.value=l.localize("EQUAL"):e.value=l._filterInfo.numberAndDateConditions.find((t=>t.value===e.$.input.dataValue)).label})),i.forEach((e=>e.title=l.localize("clearFilter")))}e&&(e.$.footer.firstElementChild.innerHTML=l.localize("ok"),e.$.footer.children[1].innerHTML=l.localize("cancel"),e.classList.contains("conditional-formatting")?e.label=l.localize("conditionalFormatting"):e.classList.contains("drill-down")&&(e.label=l.localize("details"))),l._formattingPanel&&(l._formattingPanel.messages=l.messages,l._formattingPanel.locale=l.locale),Array.from(l.$.tableContainer.querySelectorAll(".group-label-value>.placeholder")).forEach((e=>{e.textContent=l.localize("EMPTY")}));break}case"pageIndex":l.pageIndex=Math.max(Math.min(Math.round(a),l.$.pager.pagesCount-1),0),l.paging&&l.pageIndex!==t&&(l._fullRefresh("pageIndexChange"),l.$.fireEvent("page",{action:"pageIndexChange"}));break;case"pageSize":l.paging&&(l._fullRefresh("pageSizeChange"),l.$.fireEvent("page",{action:"pageSizeChange"}));break;case"paging":if(!1===a){if(l.dataSource.virtualDataSource)return void(l.paging=!0);if(1===l.$.pager.pagesCount)return}l._fullRefresh();break;case"rowDetailTemplate":l._fullRefresh();break;case"rightToLeft":Array.from(l.$.tableContainer.querySelectorAll(".freeze-near, .freeze-far")).forEach((e=>{e.style.left=null,e.style.right=null,e.style.zIndex=null})),l._handleFrozenColumnPositions(),i("rightToLeft",a);break;case"selected":{const e=l._selectedIds.slice(0);l._clearSelection(),l._changeSelectionOfMultiple(a,"select","programmatic",e);break}case"selection":if(l.filterRow){const e=l.$.tableContainer.querySelector(".smart-table-filter-row");a?e.insertBefore(document.createElement("td"),e.firstElementChild):e.firstElementChild.remove()}l.refresh(),a?(l.$.tableContainer.setAttribute("aria-multiselectable",!0),l._updateSelectAllState()):l.$.tableContainer.removeAttribute("aria-multiselectable");break;case"selectionMode":{l.$.tableContainer.classList.remove("smart-unselectable");const e=l.querySelector(".smart-table-select-all");e&&("one"===l.selectionMode?e.classList.add("smart-visibility-hidden"):e.classList.remove("smart-visibility-hidden"));break}case"sortMode":"none"===a&&l.clearSort();break;case"tooltip":if(!a){const e=l.$.tableContainer.querySelector(".tooltip");e&&(e.classList.remove("tooltip"),e.removeAttribute("title"))}break;case"virtualization":l.virtualization=t}else l._initDataSourceFromHTML();function i(e,t){const a=[];l._dialog&&a.push(l._dialog,l._dialog.$.footer.firstElementChild,l._dialog.$.footer.children[1]),l._formattingPanel&&a.push(l._formattingPanel),a.forEach((a=>a[e]=t))}}_createElement(){const e=this;if(e._expandedRowDetailIds=[],e._editors={},isNaN(parseFloat(e.columnMinWidth))&&(e.columnMinWidth="50px"),e.columnGroups&&(e.columnResize=!1,e.columnSizeMode="default"),e.formulas&&(e._formulaParser=new Smart.FormulaParser(e)),e._setupPagingAndFiltering(),e._localize(),e._selectedIds=e.selected.slice(0),"one"===e.selectionMode){e._selectedIds=e._selectedIds.slice(0,1);const t=e.querySelector(".smart-table-select-all");t&&t.classList.add("smart-visibility-hidden")}e._dataBind(),e.editing||e.$.tableContainer.setAttribute("aria-readonly",!0),e.autoLoadState&&e.loadState(),e.autoSaveState&&window.localStorage.setItem("smartTable"+e.id,e._stringifyState())}_initColumns(e){const t=this,a=t.columns;if(!t.isRendered&&t.dataSource.length>0&&(!a||Array.isArray(a)&&0===a.length)&&(t.columns=t.dataSource.dataFields.map((e=>({label:e.name,dataField:e.name,dataType:e.dataType})))),t._filterInfo.stringDataFields=[],t._columns=[],t.columnByDataField={},t.columns.canNotify=!1,t.columns instanceof Smart.ObservableArray){const e=[];for(let a=0;a<t.columns.length;a++){let l=t.columns[a],i={};for(let e in l)i[e]=l[e];e.push(i)}t.columns=e}for(let a=0;a<t.columns.length;a++){let l=t.columns[a];if("string"==typeof l&&t.dataSource.dataFields){const e=t.dataSource.dataFields.find((e=>{if(e.name===l)return e}));l={label:l,dataField:l,dataType:e&&e.dataType||"string"}}void 0===l.label&&void 0===l.dataField||(void 0===l.label&&(l.label=l.dataField),void 0===l.dataField&&(l.dataField=l.label),l.dataType||(l.dataType="string"),"string"!==l.dataType&&"number"!==l.dataType||!1===l.allowFilter||!l.dataField||t._filterInfo.stringDataFields.push(l.dataField),l.visible=void 0===l.visible||!!l.visible,l.allowResize=void 0===l.allowResize||!!l.allowResize,t._transformColumnDataField(l,e),l.thHierarchy=[],t._columns.push(l),t.columnByDataField[l.dataField]=l)}if("default"===t.columnSizeMode&&t.selection){let e=!0;for(let a=0;a<t._columns.length;a++){const l=t._columns[a];if(!l.width){e=!1,l._isResponsive=!0,l._isFillRemainingWidth=!0;break}}!t.columnResizeNormalize&&e&&t._columns.push({dataField:"",label:"",visible:!0,allowResize:!1,allowFilter:!1,allowSort:!1})}t.columns=new Smart.ObservableArray(t._columns),t._updateState("columns"),t.columns.notify((function(e){if(!t.columns.canNotify)return;if("length"===e.action||"update"===e.action&&-1!==["allowGroup","allowSort","sortOrder"].indexOf(e.propertyName))return void t._updateState("columns");const a=e.target;if("update"===e.action){const l=a.dataField;if("allowEdit"===e.propertyName)return Array.from(t.$.tableContainer.querySelectorAll(`td[data-field="${l}"]`)).forEach((t=>{t.classList.toggle("no-edit",!1===e.newValue),!1===e.newValue?t.setAttribute("aria-readonly",!0):t.removeAttribute("aria-readonly")})),void t._updateState("columns");if("allowFilter"===e.propertyName)return"string"!==a.dataType&&"number"!==a.dataType||!l||(!1===e.newValue?t._filterInfo.stringDataFields=t._filterInfo.stringDataFields.filter((e=>e!==l)):!1===e.oldValue&&t._filterInfo.stringDataFields.push(l)),t.filterRow&&t.$.tableContainer.querySelector(`.smart-table-filter-row td[filter-for="${l}"]`).classList.toggle("no-filter",!1===e.newValue),"smart-pivot-table"===t.nodeName.toLowerCase()&&t._columnNotify(e),void t._updateState("columns");if("transform"===e.propertyName)a.sortOrder&&t.sortBy(a.dataField,null),t._transformColumnDataField(a,!0);else{if(-1!==["allowPivot","allowRowGroup","pivot","rowGroup","summary"].indexOf(e.propertyName)&&"smart-pivot-table"===t.nodeName.toLowerCase())return t._columnNotify(e),void t._updateState("columns");if("visible"===e.propertyName){const e=t._expandedRowDetailIds,a=t.$.tableContainer;let l;return t.filterRow&&(l=a.querySelector(".smart-table-filter-row"),l&&l.remove()),e&&e.length&&!t._columns.some((e=>e.visible))&&e.forEach((e=>t._toggleRowDetail(a.querySelector(`[row-id="${e}"]`),e))),t.$.tableContainer.setAttribute("aria-colcount",t._columns.filter((e=>e.visible)).length+ +t.selection),t.refresh(),void t._updateState("columns")}}}"add"===e.action&&(t.columns[t.columns.length-1].visible=!0),t._columns=t.columns._array,t.columnByDataField=[],t._columns.forEach((e=>{t.columnByDataField[e.dataField]=e,e.originalDataField&&(t.columnByDataField[e.originalDataField]=e)})),t.refresh(!0),t._updateState("columns")})),t.$.tableContainer.setAttribute("aria-colcount",t._columns.filter((e=>e.visible)).length+ +t.selection)}_transformColumnDataField(e,t){const a=this;if("function"==typeof e.transform){if(!a.isRendered||t){const l=a.dataSource,i=a.columns.canNotify;i&&(a.columns.canNotify=!1),t&&e.originalDataField&&(delete a.columnByDataField[e.dataField],e.dataField=e.originalDataField);const n=e.dataField,r=n+"Transformed";a.columnByDataField[n]=e,e.originalDataField=n,e.dataField=r,l.canNotify=!1;for(let t=0;t<l.length;t++){const a=l[t];a[r]=e.transform(a[n])}i&&(a.columns.canNotify=!0),l.canNotify=!0}}else e.transform&&(e.transform=void 0)}_initRows(){const e=this,t=e.dataSource,a=e.context;if(e.context=e,e.rows=[],e.rowById=[],t.virtualDataSource)return e._initRowsVirtualDataSource(),void(e.context=a);if(t.boundHierarchy)return e.$.tableContainer.setAttribute("role","treegrid"),e.setAttribute("hierarchy",""),e._initHierarchicalRows(),void(e.context=a);e.$.tableContainer.setAttribute("role","grid");let l=0,i=t.length,n=!1;if(e.removeAttribute("hierarchy"),e.paging){const a=e.pageSize;if(e._filterInfo.query||e._filterInfo.rowFilters||e._filterInfo.appliedFilters){let e=0;for(let a=0;a<i;a++)!1!==t[a].$.filtered&&e++;i=e,n=!0}const r=Math.max(Math.ceil(i/a),1);e.$.pager.pagesCount=r,e.$.pager.totalRecords=i,e.pageIndex=Math.max(Math.min(e.pageIndex,r-1),0),l=e.pageIndex*a,i=l+a}if(n){let a=-1;for(let n=0;n<t.length;n++){const r=t[n];if(r&&!1!==r.$.filtered){if(a++,a<l)continue;if(a>=i)break;e._addNewRow(r,n)}}}else for(let a=l;a<i;a++){const l=t[a];l&&!1!==l.$.filtered&&e._addNewRow(l,a)}e._observeRows(),e.context=a}_initRowsVirtualDataSource(){const e=this,t=e.dataSource;if(t.boundHierarchy)e.$.tableContainer.setAttribute("role","treegrid"),e.setAttribute("hierarchy",""),e._processHierarchy(t.boundHierarchy,0,t.boundHierarchy.length);else for(let a=0;a<t._dataSource.length;a++){const l=t[a];l&&!1!==l.$.filtered&&e._addNewRow(l,a)}if(e.paging){const a=t.length,l=e.pageSize,i=Math.max(Math.ceil(a/l),1),n=e.$.pager.pagesCount;if(e.$.pager.pagesCount=i,e.$.pager.totalRecords=a,e.pageIndex=Math.max(Math.min(e.pageIndex,i-1),0),null!==n&&n!==i)return void e._fullRefresh()}e._observeRows()}_initHierarchicalRows(){const e=this,t=e.dataSource.boundHierarchy;let a=0,l=t.length,i=!1;if(e.paging){const n=e.pageSize;if(e._filterInfo.query||e._filterInfo.rowFilters||e._filterInfo.appliedFilters){let e=0;for(let a=0;a<l;a++)!1!==t[a].$.filtered&&e++;l=e,i=!0}const r=Math.max(Math.ceil(l/n),1);e.$.pager.pagesCount=r,e.$.pager.totalRecords=l,e.pageIndex=Math.max(Math.min(e.pageIndex,r-1),0),a=e.pageIndex*n,l=a+n}if(i){let i=-1;for(let n=0;n<t.length;n++){const r=t[n];if(r&&!1!==r.$.filtered){if(i++,i<a)continue;if(i>=l)break;e._processHierarchy(t,n,n+1)}}}else e._processHierarchy(t,a,l);e._observeRows()}_processHierarchy(e,t,a){const l=this;for(let i=t;i<a;i++){const t=e[i];if(!t)break;t.leaf?t&&!1!==t.$.filtered&&l._addNewRow(t,i):(-1!==l._expandedIds.indexOf(t.$.id)?t.expanded=!0:void 0===t.expanded&&(t.expanded=!1),!1!==t.$.filtered&&l._addNewRow(t,i),t.children.length&&!1!==t.$.filtered&&l._processHierarchy(t.children,0,t.children.length))}}_observeRows(){const e=this;e.rows=new Smart.ObservableArray(e.rows),e.rows.notify((function(t){if(!e.rows.canNotify||t.path||!e.dataSource)return;e.rows.canNotify=!1;const a=t.action,l=e._selectedIds.slice(0);switch(e.dataSource.canNotify=!1,a){case"add":{const a={};e.dataSource.dataFields.forEach((e=>a[e.name]=""));const l=Object.assign(a,e.rows[t.index]);e.dataSource.add(e.rows[t.index]),e._editing={row:{data:l}};break}case"update":e.dataSource.update(t.index,e.rows[t.index]),e._editing={row:{data:e.rows[t.index]}};break;case"remove":{const a=t.removed[0].data,l=a.$.id,i=e._selectedIds.indexOf(l);e.dataSource.removeAt(a.$.index),delete e.rowById[l],-1!==i&&e._selectedIds.splice(i,1),e._editing={row:t.removed[0]},e._updateSelectAllState();break}}e._fullRefresh(a,l,a),delete e._editing,e.dataSource.canNotify=!0,e.rows.canNotify=!0}))}beginUpdate(){const e=this;if("smart-table"!==e.nodeName.toLowerCase())return;e.__updating=!0,e.__updatedRows=!1;const t=window.__karma__||window.karma;document.hidden&&!t||(e._dirtyHierarchy=!1,e.__updatingOldSelectedIds=e._selectedIds.slice(0),e.__updatingSortColumns=e._sortColumns,e.dataSource&&e.dataSource.clearSort&&e.dataSource.clearSort())}endUpdate(e,t){const a=this;if("smart-table"!==a.nodeName.toLowerCase())return;a.__updating=!1;const l=window.__karma__||window.karma;if(document.hidden&&!l)return;if(!1===e)return;l&&(t=!0);const i=()=>{const t=a.__updatingOldSelectedIds?a.__updatingOldSelectedIds:a._selectedIds.slice(0);a.__updatingOldSelectedIds&&delete a.__updatingOldSelectedIds,a._dirtyHierarchy&&a.dataSource.refreshHierarchy();const l=a._sortColumns,i=a._filterInfo,n=a.dataSource.groupBy._array.slice(0),r=void 0!==a.$.virtualizationContainer&&a.$.virtualizationContainer.$?a.$.virtualizationContainer.$.verticalScrollBar:null;if(r&&r.beginUpdate(),a._doNotFireEvent=!0,a._fullRefresh("update",t,"update"),n.length>0){let e=a._getExpandedGroups(a.dataSource.boundHierarchy);a._dirtyHierarchy&&(e=a._dirtyHierarchy),n.forEach((e=>a.addGroup(e))),a._restoreExpandedGroups(e)}i.inputFilters?a._filterByAll(i.query):i.rowFilters?a._applyRowFilters():i.appliedFilters&&a._refreshFilters(),l&&(a.__updatingSortColumns&&JSON.stringify(a.__updatingSortColumns)!==JSON.stringify(l)||0===n.length||!0===e||!1===a.__updatedRows)&&(a._sortColumns=[],l.forEach((e=>{a.columnByDataField[e.dataField].sortOrder=null,a.sortBy(e.dataField,e.direction)}))),r&&(r.endUpdate(),a._onVerticalChange({detail:{value:r.value}},!0),a._dirtyHierarchy&&(a._rowsInDOM.length<a.rows.length&&0===a.$.virtualizationContainer.$.verticalScrollBar.max&&a._refreshDataRows(),a._dirtyHierarchy=!1)),delete a._doNotFireEvent};if(a._verticalScrollTimer)return a._scheduleUpdate&&clearInterval(a._scheduleUpdate),void(a._scheduleUpdate=setInterval((function(){a._verticalScrollTimer||(i(),clearInterval(a._scheduleUpdate),delete a._scheduleUpdate)}),100));t?i():requestAnimationFrame((()=>{i()}))}_addNewRow(e,t){const a=this,l=e.$.id,i=new Smart.Observable({data:e,boundIndex:t});-1!==a._disabledSelection.indexOf(l)&&(i.allowSelect=!1),i.canNotify=!0,i.notify((function(t){if(a._editing||a._hierarchyChange)return;const i=a.selection;if("allowSelect"===t.propertyName){const n=a._disabledSelection.indexOf(l);if(a._hierarchyChange=!0,t.newValue||-1!==n)t.newValue&&-1!==n&&function e(t){const l=t.$.id,n=a.$.tableContainer.querySelector(`[row-id="${l}"]:not([unused])`),r=a.rowById[l];if(t.parent&&-1!==a._disabledSelection.indexOf(t.parent.$.id))r.allowSelect=!1;else if(a._disabledSelection.splice(a._disabledSelection.indexOf(l),1),n&&(n.classList.remove("disable-select"),i&&(n.setAttribute("aria-selected",!1),n.firstElementChild.firstElementChild.removeAttribute("aria-disabled"))),r&&(r.allowSelect=!0),t.children)for(let a=0;a<t.children.length;a++)e(t.children[a])}(e);else{const t=[];!function e(t,l){const n=t.$.id,r=a.$.tableContainer.querySelector(`[row-id="${n}"]:not([unused])`),o=a.rowById[n];if(l.push(n),r&&(r.removeAttribute("aria-selected"),r.classList.add("disable-select"),i&&r.firstElementChild.firstElementChild.setAttribute("aria-disabled",!0)),o&&(o.allowSelect=!1),t.children)for(let a=0;a<t.children.length;a++)e(t.children[a],l)}(e,t),a._disabledSelection=a._disabledSelection.concat(t),a.unselect(t)}delete a._hierarchyChange}})),a.rowById[l]=i,a.rows.push(i)}refresh(){const e=this;if(e.__updating)return;const t=e._columns.filter((e=>e.visible)),a=e.$.tableContainer,l=a.querySelector(".smart-table-filter-row"),i=a.querySelector("tfoot"),n=document.createElement("tbody"),r=e._getFractionOfMax(),o=e.virtualization?e.$.virtualizationContainer:e.$.tableContainer.parentElement,s={top:o.scrollTop,left:o.scrollLeft};for(e.columns.canNotify=!1;a.childNodes.length>0;)a.childNodes[0].remove();e._createTableHeader(),e.isRendered||!e.onInit||e._loadingState||e.onInit(),e._createCustomHeaderRow(),e._createFooterRow(i),e._createDataRows(n),e._createFilterRow(l);const d=a.querySelectorAll("th[data-field]");for(let a=0;a<t.length;a++){const l=t[a];l.headerCellElement=d[a],l.headerCellElement&&(l.headerCellElement.onclick=function(){const t=this.dataField;e.$.fireEvent("columnClick",{dataField:t}),e.closeColumnMenu(),"none"===e.sortMode||!1===l.allowSort||e._preventClickSort||(e._addSortIconContainer(this),e._sortOnClick=!0,this.headerCellElement.sortIconContainerElement.classList.contains("asc")?e.sortBy(t,"desc"):this.headerCellElement.sortIconContainerElement.classList.contains("desc")?e.sortBy(t,null):e.sortBy(t,"asc"),e._sortOnClick=!1)}.bind(l))}if(e._sortColumns&&e._sortColumns.length>0)for(let t=0;t<e._sortColumns.length;t++){const a=e._sortColumns[t],l=e.columnByDataField[a.dataField];e._addSortIconContainer(l,a.direction,t+1)}e._handleAutoSizeMode(),e._handleFrozenColumnPositions(),e._refreshHorizontalScrollbar(),e.isRendered&&(e.selection&&e._updateSelectAllState(),e._setFractionOfMax(r)),[o.scrollTop,o.scrollLeft]=[s.top,s.left],e.columns.canNotify=!0}_createTableHeader(){const e=this,t=e.selection,a=document.createElement("thead"),l=e._columns.filter((e=>e.visible)),i=e._getColumnHeaderStructure(),n=window.innerWidth,r={};for(let o=0;o<i;o++){const s=document.createElement("tr"),d=document.createDocumentFragment();t&&(s.innerHTML=o<i-1?'<th class="empty"></th>':'<th class="smart-table-select-all freeze-near" scope="col" aria-colindex="1"><div role="checkbox" aria-checked="false" aria-label="Toggle selection of all rows"></div></th>',e.virtualization&&Smart.Utilities.Core.Browser.Safari&&s.querySelector("th").classList.add("sticky")),o<i-1&&s.classList.add("column-groups-header");for(let a=0;a<l.length;a++){const s=l[a];if(0===o&&(s.width&&isNaN(parseFloat(s.width))&&delete s.width,s.responsivePriority&&("number"!=typeof s.responsivePriority&&(s.responsivePriority=1),s.responsivePriority=Math.max(Math.min(Math.round(s.responsivePriority),5),1),i>1&&(r[a]=e._isColumnHidden(s.responsivePriority,n)))),o<i-1){if(r[a])continue;const t=l[a],i=t.headerStructure[o];if(a>0){let r=a-1,s=l[r];for(;s&&e._isColumnHidden(s.responsivePriority,n);)r--,s=l[r];if(s&&i===s.headerStructure[o]&&e._areColumnsWithSameFreezeSettings(t,s))continue}const s=document.createElement("th");if(s.includes=[t],a<l.length-1){let r=1,d=a+1,c=l[d];for(;c;){if(!e._isColumnHidden(c.responsivePriority,n)){if(i!==c.headerStructure[o]||!e._areColumnsWithSameFreezeSettings(t,c))break;r++,s.includes.push(c)}d++,c=l[d]}s.colSpan=r}0!==o&&t.headerStructure[o-1]===i||(s.textContent=i),s.includes.forEach((e=>e.thHierarchy[o]=s)),s.classList.add("column-header"),t.freeze&&s.classList.add("freeze-"+("far"===t.freeze?"far":"near")),e.virtualization&&Smart.Utilities.Core.Browser.Safari&&s.classList.add("sticky"),d.appendChild(s)}else e._setupColumnHeaderCell(t,d,a,s)}s.appendChild(d),a.appendChild(s),e._tableHeader=a}if(e.$.tableContainer.appendChild(a),"default"===e.columnSizeMode){for(let t=0;t<e.columns.length;t++){const l=e.columns[t];if(!l.width){const t=a.querySelector('[data-field="'+l.dataField+'"]');t&&t.offsetWidth<5&&(t.style.width=parseInt(l.minWidth||e.columnMinWidth)+"px")}}if(t){const t=e.columns.filter((e=>e.visible));if(1===t.length){const e=t[0],l=a.querySelector('[data-field="'+e.dataField+'"]');l&&(l.style.width="")}}}}_getColumnHeaderStructure(){const e=this._columns,t=this.columnGroups;if(!t)return 1;let a=1;for(const l of e){let e=l.columnGroup;if(l.headerStructure=[],e&&(e=t.find((t=>t.name===e)),e))for(l.headerStructure.push(e.label||e.name);e.parentGroup&&(e=t.find((t=>t.name===e.parentGroup)),e);)l.headerStructure.unshift(e.label||e.name);l.headerStructure.push(l.label),a=Math.max(a,l.headerStructure.length)}for(const t of e){const e=t.headerStructure,l=e[0];for(;e.length<a;)e.unshift(l)}return a}_isColumnHidden(e,t){return!(!e||1===e||t>1280)&&(t<=640&&2===e||t<=800&&3===e||t<=1024&&4===e||t<=1280&&5===e)}_areColumnsWithSameFreezeSettings(e,t){return!e.freeze&&!t.freeze||e.freeze===t.freeze||!0===e.freeze&&"near"===t.freeze||"near"===e.freeze&&!0===t.freeze}getColumnProperty(e,t){const a=this,l=a.columnByDataField[e];if(!l)return null;switch(t){case"width":return l.width?a._getColumnWidth(l.width,!0,l):l._isResponsive&&l._manualPercentageWidth?a._getColumnWidth(l._manualPercentageWidth+"%",!0,l):a._getColumnWidth(l._manualWidth,!0,l);default:return l[t]}}setColumnProperty(e,t,a){const l=this;if(!l.columnByDataField[e])return null;l.columns.forEach(((i,n)=>{i.dataField===e&&(l.columns[n][t]=a)}))}_getTableRemainingWidth(){const e=this;let t=e.offsetWidth;if(e.selection){const a=e.$.tableContainer.querySelector(".smart-table-select-all");a&&(t=e.offsetWidth-a.offsetWidth),""===e.columns[e.columns.length-1].dataField&&(t-=e.columnMinWidth)}e.virtualization&&e.$.virtualizationContainer&&e.$.virtualizationContainer.computedVerticalScrollBarVisibility&&(t-=20);let a=0;for(let t=0;t<e.columns.length;t++){const l=e.columns[t];l.visible&&l.width&&!(""+l.width).endsWith("%")&&(a+=e._getColumnWidth(l.width))}return t-=a,t}_getColumnWidth(e,t,a){const l=this,i=parseFloat(e);if((e=(e+"").trim()).endsWith("%")){let e=l.offsetWidth;if(l.selection){const t=l.$.tableContainer.querySelector(".smart-table-select-all");t&&(e=l.offsetWidth-t.offsetWidth),""===l.columns[l.columns.length-1].dataField&&(e-=l.columnMinWidth)}l.virtualization&&l.$.virtualizationContainer&&l.$.virtualizationContainer.computedVerticalScrollBarVisibility&&(e-=20);let n=0;for(let e=0;e<l.columns.length;e++){const t=l.columns[e];t.visible&&t.width&&!(""+t.width).endsWith("%")&&(n+=l._getColumnWidth(t.width))}e-=n;const r=a&&a.minWidth||l._getNumericMinWidth(),o=t?i+"%":e*(i/100);return r>o?r:o}return isNaN(i)?"auto":t?i+"px":i}_setupColumnHeaderCell(e,t,a,l){const i=this,n=document.createElement("th");if(n.setAttribute("aria-colindex",a+1+ +e),l.width){let e=l.width;"number"==typeof e&&l.minWidth&&(e=Math.max(e,l.minWidth)),n.style.width=i._getColumnWidth(e,!0,l)}else l._manualWidth&&(l._isResponsive?n.style.width=l._manualPercentageWidth+"%":n.style.width=l._manualWidth+"px");if(1!==i._columns.length&&l.allowResize||n.setAttribute("locked",""),l.freeze&&n.classList.add("freeze-"+("far"===l.freeze?"far":"near")),l.responsivePriority&&n.classList.add("priority-"+l.responsivePriority),i.virtualization&&Smart.Utilities.Core.Browser.Safari&&n.classList.add("sticky"),n.setAttribute("data-field",l.dataField),n.innerHTML=`<div class="wrapper" role="presentation"><div class="label">${l.label}</div></div>`,i.columnMenu){const e=document.createElement("div");e.classList.add("column-menu"),e.setAttribute("aria-hidden",!0),n.firstElementChild.appendChild(e),e.onclick=e=>{i.activeColumnMenu&&i.activeColumnMenu.dataField===l.dataField?i.closeColumnMenu():i.openColumnMenu(l.dataField),e.preventDefault(),e.stopPropagation()}}i.onColumnRender&&i.onColumnRender(l.dataField,n),t.appendChild(n)}_refreshDataRows(){const e=this,t=window.scrollY,a=window.scrollX,l=e.$.tableContainer.children[1],i=Array.from(l.querySelectorAll("tr:not(.smart-table-filter-row)"));if(e._clearCachedTemplates(),e.filterRow||e.footerRow||e.headerRow)for(let e=0;e<i.length;e++)i[e].remove();else l.innerHTML="";e._createDataRows(l),e._handleAutoSizeMode(),e._handleFrozenColumnPositions(),e._refreshHorizontalScrollbar(),(a||t)&&window.scroll(a,t)}_createDataRows(e){const t=this;if(t.virtualization)return void t._createVirtualDataRows(e);const a=t.rowDetailTemplate,l=t.selection,i=document.createDocumentFragment(),n=t.hasAttribute("hierarchy");for(let e=0;e<t.rows.length;e++){const r=t.rows[e],o=r.data;o.groupDataField?t._createGroupHeader(o,i):t._createDataRow(r,i,{hierarchical:n,rowDetailTemplate:a,selection:l,virtualization:!1})}if(i.appendChild(t._createLastRow()),e.appendChild(i),t._updateState("expanded"),e.parentElement||t.$.tableContainer.insertBefore(e,t.$.tableContainer.querySelector("tfoot")),t.getRootNode().activeElement===t.$.tableContainer&&t._tableContainerFocusHandler(),t._templateTags.length){const e=t.querySelectorAll("tr");for(let a=0;a<t._templateTags.length;a++){const l=t._templateTags[a],i=l.index,n=l.dataField,r=l.td;if(e[i]){const t=e[i].querySelector('[data-field="'+n+'"]'),a=[...t.querySelectorAll("smart-button"),...t.querySelectorAll("button"),...t.querySelectorAll("a"),...t.querySelectorAll("span")],l=[...r.querySelectorAll("smart-button"),...r.querySelectorAll("button"),...r.querySelectorAll("a"),...r.querySelectorAll("span")];for(let e=0;e<a.length;e++)"button"===a[e].nodeName.toLowerCase()&&a[e].classList.contains("smart-button")||(a[e].onclick=()=>{l[e].click()})}}}}_createDataRow(e,t,a){const l=this,i=l._columns.filter((e=>e.visible)),n=e.data,r=n.$.id,o=document.createElement("tr"),s={row:o,detail:null};let d=0;o.setAttribute("aria-rowindex",n.$.index+1),l._processAndRenderSelection(n,o,a.hierarchical),a.selection&&d++;for(let t=0;t<i.length;t++){const s=document.createElement("td"),c=i[t];s.setAttribute("data-field",c.dataField),s.setAttribute("aria-colindex",t+1+ +a.selection);let u,f=l._formatCellValue(e,c,s);if(c.freeze&&s.classList.add("freeze-"+("far"===c.freeze?"far":"near")),c.responsivePriority&&s.classList.add("priority-"+c.responsivePriority),!1===c.allowEdit&&(s.classList.add("no-edit"),s.setAttribute("aria-readonly",!0)),0===t&&a.hierarchical){const e=l._areChildrenFiltered(n);n.leaf||(s.classList.add("tree-cell"),u=e),n.level&&(s.classList.add("outline-level-"+Math.min(n.level,10)),!n.leaf&&e||s.classList.add("tree-leaf"))}if(a.virtualization&&c.templateElement){const e=c.templateElement+"";u&&l._setCellContent(s,f,u);const t=u?s.children[0].children[1]:s;e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+n[c.dataField]+"</div>"):t.innerHTML=e,c.templateElementSettings&&(l._cachedTemplates&&l._cachedTemplates[c.dataField+"_"+r]&&(0===l._cachedTemplates[c.dataField+"_"+r].innerHTML.length?delete l._cachedTemplates[c.dataField+"_"+r]:(t.innerHTML="",t.appendChild(l._cachedTemplates[c.dataField+"_"+r]))),c.templateElementSettings(n[c.dataField],r,t.firstElementChild),l._cachedTemplates||(l._cachedTemplates=[]),l._cachedTemplates[c.dataField+"_"+r]||(l._cachedTemplates[c.dataField+"_"+r]=t.firstElementChild))}else l._setCellContent(s,f,u);l.onCellRender&&l.onCellRender(n,c.dataField,n[c.dataField],s),l._applyConditionalFormattingToCell(s,c.dataField,n.$.index),o.appendChild(s),d++}if(o.data=n,o.setAttribute("row-id",r),-1!==l._disabledSelection.indexOf(r)&&(o.removeAttribute("aria-selected"),o.classList.add("disable-select"),a.selection&&o.firstElementChild.firstElementChild.setAttribute("aria-disabled",!0)),n.expanded?(-1===l._expandedIds.indexOf(r)&&l._expandedIds.push(r),o.setAttribute("aria-expanded",!0),o.classList.add("expanded")):!1===n.expanded&&o.setAttribute("aria-expanded",!1),n.level&&l._isCollapsed(n)&&(o.setAttribute("aria-hidden",!0),o.classList.add("collapsed","smart-hidden")),t.appendChild(o),a.rowDetailTemplate){const i=document.createElement("tr");if(-1===l._expandedRowDetailIds.indexOf(r)){if(a.virtualization)return s;i.setAttribute("aria-hidden",!0),i.classList.add("collapsed")}else s.detail=i;i.data=Object.assign(n,{detail:!0}),i.classList.add("smart-table-row-detail"),i.innerHTML=`<td colspan="${d}"><div class="smart-table-detail-container">${l._applyRowDetailTemplate(e)}</div></td>`,t.appendChild(i)}return s}_processAndRenderSelection(e,t,a,l){const i=this,n=e.$.id,r=i._getChildCheckState(e).state;if(a&&i.selectionByHierarchy){const e=i._selectedIds.indexOf(n);!0===r&&-1===e?i._selectedIds.push(n):r||-1===e||i._selectedIds.splice(e,1)}if(!i.selection)return;let o,s;l?(o=t.firstElementChild,s=o.firstElementChild):(o=document.createElement("td"),s=document.createElement("div")),s.className="selection-checkbox",s.setAttribute("role","checkbox"),s.setAttribute("aria-checked",!!r||null===r&&"mixed"),s.setAttribute("aria-label","Toggle row selection"),o.className="smart-table-select-row freeze-near"+(r?" selected":null===r?" indeterminate":""),o.setAttribute("aria-colindex",1),l||(o.appendChild(s),t.appendChild(o)),t.setAttribute("aria-selected",!0===r)}_applyConditionalFormattingToCell(e,t,a){const l=this;if(l._conditionalFormatting&&l._conditionalFormatting[t]){const i=l._conditionalFormatting[t][a];i&&(e.style.backgroundColor=i.background,e.style.color=i.color,e.style.fontFamily=i.fontFamily,e.style.fontSize=i.fontSize)}}_createLastRow(){const e=document.createElement("tr");e.setAttribute("aria-hidden",!0),e.classList.add("last-visible");try{new ResizeObserver((t=>{try{e.classList.toggle("sized",t[0].contentRect.height>0&&null!==e.previousSibling)}catch(e){}})).observe(e)}catch(e){}return e}_createGroupHeader(e,t,a){const l=this;l.columnByDataField[e.groupDataField]||console.error(l.localize("grouping"));const i=l.columnByDataField[e.groupDataField]?l.columnByDataField[e.groupDataField].label:`${l.localize("EMPTY")}`,n=a||document.createElement("tr"),r=document.createElement("td"),o=document.createElement("div"),s=document.createElement("div"),d=document.createElement("div");let c=e.label;if(/<.+?>/.test(c)&&c.replace&&("all"===l.dataSourceSettings.sanitizeHTML?c=c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;"):"blackList"===l.dataSourceSettings.sanitizeHTML&&(c=window.Smart.Utilities.Core.sanitizeHTML(c))),""!==c&&c||(c=`<em class="placeholder">${l.localize("EMPTY")}</em>`),n.removeAttribute("aria-rowindex"),n.data=e,s.classList.add("hierarchy-arrow","smart-arrow","smart-arrow-down"),s.setAttribute("role","button"),s.setAttribute("aria-label","Toggle row"),d.classList.add("group-label"),d.innerHTML=`<span class="group-label-name">${i}: </span>\n <span class="group-label-value">${c}</span>\n <span class="group-label-count">(${l._getLeafCount(e)})</span>`,r.colSpan=l._columns.filter((e=>e.visible)).length,r.classList.add("group-header"),e.level&&(r.classList.add("outline-level-"+Math.min(e.level,10)),l._isCollapsed(e)&&(n.setAttribute("aria-hidden",!0),n.classList.add("collapsed","smart-hidden"))),n.setAttribute("row-id",e.$.id),n.setAttribute("role","group"),n.setAttribute("aria-level",e.level),o.appendChild(s),o.appendChild(d),r.appendChild(o),l._processAndRenderSelection(e,n,!0),n.appendChild(r),n.setAttribute("aria-expanded",e.expanded),n.classList.toggle("expanded",e.expanded),e&&e.$&&!1===e.$.filtered&&n.classList.add("smart-hidden"),l.groupFormatFunction){const t={value:c,row:e.$.id,column:e.groupDataField,data:e,template:null};l.groupFormatFunction(t),c!==t.value&&(d.innerHTML=`<span class="group-label-name">${i}: </span>\n <span class="group-label-value">${t.value}</span>\n <span class="group-label-count">(${l._getLeafCount(e)})</span>`),t.template instanceof HTMLElement&&(d.innerHTML="",d.appendChild(t.template));const a=t.template;let n="";if(a&&a.startsWith("#")){const e=document.querySelector(a);let t=c;if(e&&e instanceof HTMLTemplateElement){const a=e.content.cloneNode(!0),l=document.createElement("div");l.appendChild(a),t=t.toString(),t=t.replace(/'/gi,"\\'"),t=t.replace(/"/gi,'\\"'),n=l.innerHTML.replace(/{{value}}/gi,t),n.indexOf("{{value=")>=0&&(t?(n=n.substring(0,n.indexOf("{{value="))+t+n.substring(n.indexOf("}")),n=n.replace(/}/gi,""),n=n.replace(/{/gi,"")):(n=n.replace(/{{value=/gi,""),n=n.replace(/}}/gi,""))),d.innerHTML=n}}else a&&"string"==typeof a&&(n=a.replace(/{{value}}/gi,c),d.innerHTML=n)}const u=l.selection?1:0;for(let e=0;e<l.columns.length;e++){const t=document.createElement("td"),a=l.columns[e];a.visible&&(t.setAttribute("data-field",a.dataField),t.setAttribute("aria-colindex",e+1+u),t.classList.add("smart-hidden"),n.appendChild(t))}return a||t.appendChild(n),n}_getLeafCount(e){let t=0;return function e(a){for(const l of a)l.leaf?t++:l.children&&l.children.length>0&&e(l.children)}(e.children),t}_isCollapsed(e){let t=e.parent;for(;t;){if(!t.expanded)return!0;t=t.parent}return!1}_areChildrenFiltered(e){if(!e.leaf){if(0===e.children.length&&this.dataSource.virtualDataSource)return!0;for(let t=0;t<e.children.length;t++)if(!1!==e.children[t].$.filtered)return!0;return!1}}_applyRowDetailTemplate(e){const t=this,a=t.dataSource.dataFields;let l=t.rowDetailTemplate;for(let i=0;i<a.length;i++){const n=a[i].name,r=new RegExp(`{{${n}}}`,"g");let o=t.columnByDataField[n]||{dataField:n};if(r.test(l)){let a=t._formatCellValue(e,o,document.createElement("td"));"string"!=typeof a&&(a=e.data[o.dataField]),l=l.replace(r,a)}}return l}_handleFrozenColumnPositions(){const e=this,t=e.rightToLeft,a=e._columns.filter((e=>e.visible));let l=[],i=[],n=0;function r(t,l,i,r,o){const s=a[l-n],d=[s.headerCellElement];for(const e of s.thHierarchy)e.includes[0].dataField===s.dataField&&d.push(e);Array.from(e.$.tableContainer.querySelectorAll(`td:nth-child(${l+1})`)).concat(d).forEach((e=>{e.style[t]=i+"px",o&&(e.style.zIndex=2+r)}))}e.selection&&(t?i.push(0):l.push(0),n=1);for(let e=0+n;e<a.length+n;e++){const r=a[e-n];r.freeze&&(!t&&"far"===r.freeze||t&&"far"!==r.freeze?i.push(e):l.push(e))}if(l.length<2&&i.length<2)return;const o=[];for(const e of a){let t=e.width;t||(t=e.headerCellElement.offsetWidth),e.minWidth&&(t=Math.max(e.minWidth,t)),o.push(t)}if(t){for(let e=0;e<l.length-1;e++){const t=l[e];let a=0;for(let e=t+1;e<o.length;e++)-1!==l.indexOf(e)&&(a+=o[e]);r("left",t,a,e,!0)}for(let e=1;e<i.length;e++){const t=i[e];let a=0;for(let e=0;e<t;e++)-1!==i.indexOf(e)&&(a+=o[e]);r("right",t,a,e,!1)}}else{for(let e=1;e<l.length;e++){const t=l[e];let a=0;for(let e=0;e<t;e++)-1!==l.indexOf(e)&&(a+=o[e]);r("left",t,a,e,!1)}for(let e=0;e<i.length-1;e++){const t=i[e];let a=0;for(let e=t+1;e<o.length;e++)-1!==i.indexOf(e)&&(a+=o[e]);r("right",t,a,e,!0)}}}_formatCellValue(e,t,a,l){const i=this;let n=e&&e.data?e.data.$.id:e;if(void 0===l&&(l=e.data[t.dataField]),"string"==typeof l&&l.indexOf(">")>=0&&/<.+?>/.test(l)&&l.replace&&("all"===i.dataSourceSettings.sanitizeHTML?l=l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&quot;"):"blackList"===i.dataSourceSettings.sanitizeHTML&&(l=window.Smart.Utilities.Core.sanitizeHTML(l))),i._cellsWithFormulas){const e=t.dataField+":"+n;if("string"==typeof l&&/=.+/.test(l)){const t=i._formulaParser;i._cellsWithFormulas[e]=!0,t&&(l=t.parse(l.slice(1)))}else delete i._cellsWithFormulas[e]}if(t.formatFunction){const i={value:l,row:n,column:t.dataField,data:e.data,cell:a,template:null};if(t.formatFunction(i),l=i.value,i.template instanceof HTMLElement)return i.template;if(null===i.template||"string"!=typeof i.template)return l;const r=i.template;let o="";if(r.startsWith("#")){const e=document.querySelector(r);if(e&&e instanceof HTMLTemplateElement){const t=e.content.cloneNode(!0),a=document.createElement("div");return a.appendChild(t),l=(l=(l=l.toString()).replace(/'/gi,"\\'")).replace(/"/gi,'\\"'),o=a.innerHTML.replace(/{{value}}/gi,l),o.indexOf("{{value=")>=0&&(l?(o=o.substring(0,o.indexOf("{{value="))+l+o.substring(o.indexOf("}")),o=o.replace(/}/gi,""),o=o.replace(/{/gi,"")):(o=o.replace(/{{value=/gi,""),o=o.replace(/}}/gi,""))),o}}return o='<div class="smart-table-cell-template">'+r.replace(/{{value}}/gi,l)+"</div>",o}return"date"===t.dataType&&l instanceof Date?l.toLocaleDateString():l}_setCellContent(e,t,a){if(t instanceof HTMLElement==1){for(;e.childNodes.length>0;)e.childNodes[0].remove();if(a){const a=document.createElement("div");a.innerHTML='<div class="hierarchy-arrow smart-arrow smart-arrow-down" role="button" aria-label="Toggle row"></div><div></div>',a.children[1].appendChild(t),e.appendChild(a)}else e.appendChild(t)}else if(a)e.innerHTML=t=`<div>\n <div class="hierarchy-arrow smart-arrow smart-arrow-down" role="button" aria-label="Toggle row"></div>\n <div>${t}</div>\n </div>`;else if("string"==typeof t&&t.indexOf(">")>=0)if(/<.+?>/.test(t)||/&\S+;/.test(t)){if(e._content===t)return;e.innerHTML=t,e._content=t}else e.textContent!==t&&(e.textContent=t);else"html"===this.dataSourceSettings.sanitizeHTMLRender?e.innerHTML!==t&&(e.innerHTML=t):e.textContent!==t&&(e.textContent=t)}_dataBind(e){const t=this;if(t._cellsWithFormulas={},t._templateTags=[],t.dataSource){if(t.dataSource instanceof Smart.DataAdapter==0){const e=t.dataSource;if(Array.isArray(e)){const a=t.columns;let l;if(e.length>0){const t=e[0];l=[];for(let e in t){const a=t[e];"number"==typeof a?l.push({name:e,dataType:"number"}):"boolean"==typeof a?l.push({name:e,dataType:"boolean"}):a instanceof Date?l.push({name:e,dataType:"date"}):a instanceof Object?l.push({name:e,dataType:"any"}):l.push({name:e,dataType:"string"})}}a&&a.length>0&&(l=l||[],a.forEach((e=>{if(e.dataType){const t=l.find((t=>t.name===e.dataField));t?t.dataType=e.dataType:e.map?l.find((t=>e.map.indexOf(t.name)>=0?t:null))&&l.push({name:e.dataField,map:e.map,dataType:e.dataType}):l.push({name:e.dataField,dataType:e.dataType})}}))),t.dataSourceSettings.dataFields&&t.dataSourceSettings.dataFields.length>0?t.dataSource=new Smart.DataAdapter({dataSource:t.dataSource,dataSourceType:t.dataSourceSettings.dataSourceType,dataFields:t.dataSourceSettings.dataFields,keyDataField:t.dataSourceSettings.keyDataField,parentDataField:t.dataSourceSettings.parentDataField,childrenDataField:t.dataSourceSettings.childrenDataField,groupBy:t.dataSourceSettings.groupBy,mapChar:t.dataSourceSettings.mapChar,root:t.dataSourceSettings.root,record:t.dataSourceSettings.record,autoGenerateColumns:t.autoGenerateColumns,id:t.dataSourceSettings.id||t.dataRowId,expandHierarchy:t.expandHierarchy,virtualDataSource:t.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:t.dataSourceSettings.virtualDataSourceOnExpand}):t.dataSource=new Smart.DataAdapter({dataSource:t.dataSource,dataFields:l,id:t.dataRowId||t.dataSourceSettings.id,dataSourceType:t.dataSourceSettings.dataSourceType,keyDataField:t.dataSourceSettings.keyDataField,parentDataField:t.dataSourceSettings.parentDataField,childrenDataField:t.dataSourceSettings.childrenDataField,groupBy:t.dataSourceSettings.groupBy,mapChar:t.dataSourceSettings.mapChar,root:t.dataSourceSettings.root,record:t.dataSourceSettings.record,autoGenerateColumns:t.autoGenerateColumns,expandHierarchy:t.expandHierarchy,virtualDataSource:t.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:t.dataSourceSettings.virtualDataSourceOnExpand})}else t.dataSource=new Smart.DataAdapter({dataSource:[],id:t.dataRowId,expandHierarchy:t.expandHierarchy})}}else{if(t.dataFields=[],!t.columns||Array.isArray(t.columns)&&0===t.columns.length){t.columns=[];const e=t.querySelectorAll("th");for(let a=0;a<e.length;a++){const l=e[a].innerHTML.trim();let i={label:l,dataField:l,dataType:"string"};t.columns.push(i),t.dataFields.push(l)}}else for(let e=0;e<t.columns.length;e++){const a=t.columns[e];"string"==typeof a?t.dataFields.push(a):"object"==typeof a&&t.dataFields.push(a.dataField+(a.dataType?": "+a.dataType:""))}let e=[];if(!t.rows){const a=t.querySelectorAll("tr");for(let l=0;l<a.length;l++){const i={},n=a[l].querySelectorAll("td");if(n.length>0){for(let e=0;e<t.columns.length;e++){const a=t.columns[e];i[a.dataField]=n[e].innerHTML.trim(),i[a.dataField].indexOf("<")>=0&&t._templateTags.push({index:l,dataField:a.dataField,td:n[e]})}e.push(i)}}t.dataSource=new Smart.DataAdapter({dataSource:e,expandHierarchy:t.expandHierarchy,dataFields:t.dataFields,id:t.dataRowId})}const a=t.$.container.querySelectorAll("table");a.length>1&&a[a.length-1].parentNode.removeChild(a[a.length-1])}t.dataSource.expandHierarchy=t.expandHierarchy,t._transformDataSource(),t._applyInitialConditionalFormatting(t.dataSource),t._initColumns(e),t._initRows(),t.dataSource.notify((function(e){if(t.dataSource._updating)return void delete t.dataSource._updating;if(t._editing)return;const a=e.data,l=t._selectedIds.slice(0);let i=e.action;switch(t.rows.canNotify=!1,e.action){case"add":if(a.length)for(let e=0;e<a.length;e++)t._addNewRow(a[e],t.dataSource.length-a.length+e);else t._addNewRow(a,t.dataSource.length-1);break;case"update":if(a.length)for(let l=0;l<a.length;l++){const i=e.index[l];t.rows[i].data=a[l]}break;case"insert":t._addNewRow(a,e.index);for(let e=0;e<t.rows.length;e++)t.rows[e].dataIndex=e;break;case"remove":case"removeLast":i="remove",function(e){const a=e.$.id,l=t._selectedIds.indexOf(a);delete t.rowById[a],t.rows.splice(e.$.index,1),-1!==l&&t._selectedIds.splice(l,1)}(a);break;case"bindingComplete":if(t.filtering&&t.filterRow){const e=t._filterInfo;e.inputFilters?t._filterByAll(e.query):e.rowFilters?t._applyRowFilters():e.appliedFilters&&t._refreshFilters()}}t.rows.canNotify=!0,this.refreshHierarchy(),t._fullRefresh(void 0,l,i)})),t.refresh(),t.dataSource.virtualDataSource&&(t.paging=!0,t._requestVirtualDataSource("dataBind")),t.$.tableContainer.setAttribute("aria-rowcount",t.dataSource.length)}_requestVirtualDataSource(e,t,a=null){const l=this,i=l.pageSize,n=Math.max(l.pageIndex*i,0),r=n+i,o=[],s=[],d={};let c=null;if(l.dataSource._updating=!0,l._sortColumns&&(l._sortColumns.forEach(((e,t)=>o[e.dataField]={sortOrder:e.direction,sortIndex:t})),o.length=l._sortColumns.length),l._filterInfo.appliedFilters){for(let e in l._filterInfo.appliedFilters)s[e]=l._filterInfo.appliedFilters[e];s.length=Object.keys(l._filterInfo.appliedFilters).length,c="and"}else{const e=l._filterInfo.inputFilters||l._filterInfo.rowFilters;e&&(e.forEach((e=>s[e[0]]=e[1])),s.length=e.length),c=l._filterInfo.inputFilters?"or":"and"}l._editing&&(d.row=l._editing.row.data),l.$.loadingIndicatorContainer.classList.remove("smart-hidden"),l.setAttribute("loading",""),l.dataSource.onVirtualDataSourceRequested((function(i){let n=!0;-1!==["add","update","remove"].indexOf(e)&&t&&(n=t(i.result)),l.$.loadingIndicatorContainer.classList.add("smart-hidden"),l.removeAttribute("loading"),n&&(a&&(a.expanded=!0),l._initRows(),l._refreshDataRows())}),{first:n,last:r,sorting:o,filtering:s,filterOperator:c,grouping:[],edit:d,row:a,action:e})}sortBy(e,t){const a=this,l=a.columnByDataField[e];if(l){if(!1===l.allowSort)return;e=l.dataField}if(a._sortBy({column:l,columnDataField:e,sortOrder:t,dataFields:a.dataSource.dataFields,columnByDataField:"columnByDataField"}),null===e){const e=!0===a._sortOnClick?"interaction":"programmatic";a.$.fireEvent("sort",{columns:[],sortDataFields:[],sortOrders:[],sortDataTypes:[],type:e})}}_sortBy(e){const t=this,a=e.column,l=e.columnDataField,i=e.sortOrder,n=e.dataFields,r=e.columnByDataField,o=[],s=[],d=[],c=function(e){t._addSortIconContainer(e),e.headerCellElement&&(e.headerCellElement.removeAttribute("aria-sort"),e.headerCellElement.sortIconContainerElement.classList.remove("desc"),e.headerCellElement.sortIconContainerElement.classList.remove("asc")),e.sortOrder=null},u=function(){if(t._sortColumns&&t._sortColumns.length>0)for(let e=0;e<t._sortColumns.length;e++){const a=t._sortColumns[e],l=t[r][a.dataField];c(l)}t._sortColumns=[]};if(null==a)return void(t._sortColumns&&t._sortColumns.length>0&&(u(),t._sortCallback(o,s,d),t._updateState("sorted")));if("none"===t.sortMode||!t.dataSource)return;if(i&&a.sortOrder===i)return;let f=i||"asc";null===i&&(f=null),c(a),t._sortColumns||(t._sortColumns=[]);let m="string";for(let e=0;e<n.length;e++){const t=n[e];if(t.name===l){m=t.dataType,"any"===m&&(m="number");break}}let h=!0;for(let e=0;e<t._sortColumns.length;e++){const n=t._sortColumns[e];if(n.dataField===l)if(h=!1,null===f&&(n.direction="desc"),"asc"===n.direction)n.direction="desc",f="desc";else if("desc"===n.direction){t._sortColumns.splice(e,1),c(a),f=i;break}}h&&("one"===t.sortMode&&u(),t._sortColumns.push({dataField:l,direction:f,dataType:m})),t._addSortIconContainer(a),null!==f?(a.headerCellElement&&(a.headerCellElement.sortIconContainerElement.classList.remove("asc"),a.headerCellElement.sortIconContainerElement.classList.remove("desc")),a.sortOrder=f,a.headerCellElement&&("desc"===f?(a.headerCellElement.sortIconContainerElement.classList.add("desc"),a.headerCellElement.setAttribute("aria-sort","descending")):(a.headerCellElement.sortIconContainerElement.classList.add("asc"),a.headerCellElement.setAttribute("aria-sort","ascending")))):a.headerCellElement&&(a.headerCellElement.sortIconContainerElement.classList.remove("asc"),a.headerCellElement.sortIconContainerElement.classList.remove("desc"),a.headerCellElement.removeAttribute("aria-sort"));for(let e=0;e<t._sortColumns.length;e++){const a=t._sortColumns[e],l=t[r][a.dataField];o.push(a.dataField),s.push(a.direction),d.push(a.dataType),l.headerCellElement&&l.headerCellElement.sortIconContainerElement.setAttribute("order",e+1)}if(t._sortCallback(o,s,d),t._updateState("sorted"),!t._doNotFireEvent){const e=!0===t._sortOnClick?"interaction":"programmatic";t.$.fireEvent("sort",{columns:t._sortColumns,sortDataFields:o,sortOrders:s,sortDataTypes:d,type:e})}}_addSortIconContainer(e,t,a){const l=e.headerCellElement;if(l&&!l.sortIconContainerElement){const e=document.createElement("div");e.classList.add("sort-by"),e.setAttribute("aria-hidden",!0),t&&e.classList.add(t),l.firstElementChild.appendChild(e),l.sortIconContainerElement=e,"asc"===t?l.setAttribute("aria-sort","ascending"):"desc"===t?l.setAttribute("aria-sort","descending"):l.removeAttribute("aria-sort"),void 0!==a&&e.setAttribute("order",a)}}_sortCallback(e,t,a){const l=this,i=l.dataSource;if(!i.virtualDataSource){let n=null;for(let e=0;e<l.columns.length;e++){const t=l.columns[e];t.sort&&(n||(n={}),n[t.dataField]=t.sort)}i._sort(l.dataSource.boundSource,e,t,a,l.sort,n);let r=[],o=[];if(i.groupBy&&i.groupBy.toArray&&(r=i.groupBy.toArray().slice(0)),r.length>0&&(o=l._getExpandedGroups(i.boundHierarchy)),i.refreshHierarchy(),r.length>0){const e=l._doNotFireEvent;l._doNotFireEvent=!0,l._restoreExpandedGroups(o),l._doNotFireEvent=e}}l._fullRefresh("sort")}clearSort(){this.sortBy(null)}_fullRefresh(e,t,a,l){const i=this;if(i.__updating)return;if(i.dataSource.virtualDataSource)return void i._requestVirtualDataSource(e,l);const n=i._getFractionOfMax();t||(t=i._selectedIds.slice(0)),t=JSON.stringify(t.sort()),i._initRows(),i._refreshDataRows(),i._setFractionOfMax(n),"filter"===e&&(i._updateSelectAllState(),a||(a="filter")),t!==JSON.stringify(i._selectedIds.slice(0).sort())&&("filter"!==e&&i._updateSelectAllState(),i._updateState("selected"),i.$.fireEvent("change",{type:a})),"string"==typeof e&&-1!==e.indexOf("page")&&i._fixFrozenHeaderFirefox()}_pagerChangeHandler(e){const t=this;(t.isInShadowDOM?e.composedPath()[0]:e.target)===t.$.pager&&(t.pageIndex=e.detail.index,t._fullRefresh("pageIndexChange"),t.$.fireEvent("page",{action:"pageIndexChange"}))}_pagerPageSizeChanged(e){const t=this;t.pageSize=e.detail.value,t._fullRefresh("pageSizeChange"),t.$.fireEvent("page",{action:"pageSizeChange"})}_filterInputKeyupHandler(){const e=this;clearTimeout(e._filterInputTimeout),e._filterInputTimeout=setTimeout((function(){if(e._filterInfo&&e.$.filterInput.value!==e._filterInfo.query){const t=e.context;e.context=e,e._filterByAll(e.$.filterInput.value),e.context=t}}),500)}_filterByAll(e){const t=this;if(t._filterInfo.query=e,""===e)return void t.clearFilters();const a=[];t._clearRowFilters(),delete t._filterInfo.appliedFilters,t._filterInfo.stringDataFields.forEach((t=>{const l=new Smart.Utilities.FilterGroup,i=l.createFilter("string",e,"CONTAINS");l.addFilter("or",i),a.push([t,l])})),t.dataSource.virtualDataSource||t.dataSource._filter(a,t.filterOperator),t._filterInfo.inputFilters=a,t._fullRefresh("filter"),t._updateState("filtered"),t._doNotFireEvent||t.$.fireEvent("filter",{action:"add",filters:a})}_setupPagingAndFiltering(){const e=this;e.$.pager.$.pageSizeSelector.classList.add("underlined"),e.$.pager.$.pageSizeSelector.dropDownAppendTo="body",e._filterInfo={query:""},e._applyFilterTemplate(),e.$.header.classList.toggle("smart-hidden",(!e.filtering||e.filterRow||e.columnMenu)&&!e.conditionalFormattingButton)}_applyFilterTemplate(){const e=this,t=e.filterTemplate;if(e.$.filterTemplateContainer.innerHTML="",!t)return e.$.filterInput.classList.remove("smart-hidden"),e.$.filterTemplateContainer.classList.add("smart-hidden"),void(e.filterTemplate=null);const a=document.getElementById(t);if(a&&a instanceof HTMLTemplateElement){const t=document.importNode(a.content,!0);e.$.filterInput.classList.add("smart-hidden"),e.$.filterTemplateContainer.classList.remove("smart-hidden"),e.$.filterTemplateContainer.appendChild(t)}else e.filterTemplate=null,e.$.filterInput.classList.remove("smart-hidden"),e.$.filterTemplateContainer.classList.add("smart-hidden")}_refreshFilters(e){const t=this,a=[];for(let e in t._filterInfo.appliedFilters){let l=t._filterInfo.appliedFilters[e];a.push([e,l])}0!==a.length?(t._clearFilterInput(),t._clearRowFilters(),t.dataSource.virtualDataSource||t.dataSource._filter(a,t.filterOperator),t._fullRefresh("filter"),t._updateState("filtered"),e&&!t._doNotFireEvent&&t.$.fireEvent("filter",{action:e,filters:a})):t.clearFilters()}_localize(){const e=this,t=e.$.pager;t.messages[e.locale]||(t.messages[e.locale]={}),t.messages[e.locale].pageSizeLabel=e.localize("itemsPerPage"),t.messages[e.locale].summaryPrefix=e.localize("summaryPrefix"),t.messages[e.locale].summarySuffix="",t.$.firstButton.setAttribute("tooltip",e.localize("firstButton")),t.$.previousButton.setAttribute("tooltip",e.localize("previousButton")),t.$.nextButton.setAttribute("tooltip",e.localize("nextButton")),t.$.lastButton.setAttribute("tooltip",e.localize("lastButton")),e.$.filterInput.placeholder=e.localize("filterPlaceholder"),e.$.conditionalFormattingButton.setAttribute("tooltip",e.localize("conditionalFormatting")),e._filterInfo.stringConditions=[{value:"EMPTY",label:e.localize("EMPTY")},{value:"NOT_EMPTY",label:e.localize("NOT_EMPTY")},{value:"CONTAINS",label:e.localize("CONTAINS")},{value:"CONTAINS_CASE_SENSITIVE",label:e.localize("CONTAINS_CASE_SENSITIVE")},{value:"DOES_NOT_CONTAIN",label:e.localize("DOES_NOT_CONTAIN")},{value:"DOES_NOT_CONTAIN_CASE_SENSITIVE",label:e.localize("DOES_NOT_CONTAIN_CASE_SENSITIVE")},{value:"STARTS_WITH",label:e.localize("STARTS_WITH")},{value:"STARTS_WITH_CASE_SENSITIVE",label:e.localize("STARTS_WITH_CASE_SENSITIVE")},{value:"ENDS_WITH",label:e.localize("ENDS_WITH")},{value:"ENDS_WITH_CASE_SENSITIVE",label:e.localize("ENDS_WITH_CASE_SENSITIVE")},{value:"EQUAL",label:e.localize("EQUAL")},{value:"EQUAL_CASE_SENSITIVE",label:e.localize("EQUAL_CASE_SENSITIVE")},{value:"NULL",label:e.localize("NULL")},{value:"NOT_NULL",label:e.localize("NOT_NULL")}],e._filterInfo.numberAndDateConditions=[{value:"EQUAL",label:e.localize("EQUAL")},{value:"NOT_EQUAL",label:e.localize("NOT_EQUAL")},{value:"LESS_THAN",label:e.localize("LESS_THAN")},{value:"LESS_THAN_OR_EQUAL",label:e.localize("LESS_THAN_OR_EQUAL")},{value:"GREATER_THAN",label:e.localize("GREATER_THAN")},{value:"GREATER_THAN_OR_EQUAL",label:e.localize("GREATER_THAN_OR_EQUAL")},{value:"NULL",label:e.localize("NULL")},{value:"NOT_NULL",label:e.localize("NOT_NULL")}]}_createFilterRow(e){const t=this;if(!t.filtering||!t.filterRow)return;if(e)return void t.$.tableContainer.children[1].insertBefore(e,t.$.tableContainer.children[1].firstElementChild);const a=document.createElement("tr"),l=t._columns.filter((e=>e.visible));let i="";a.className="smart-table-filter-row",t.selection&&(i+="<td></td>");for(let e=0;e<l.length;e++){const a=l[e];i+=t._createFilterRowInput(a)}a.innerHTML=i,t.$.tableContainer.children[1].insertBefore(a,t.$.tableContainer.children[1].firstElementChild)}_createFilterRowInput(e){const t=this,a=` animation="${t.animation}" `,l=t.rightToLeft?" right-to-left":"",i=[];let n,r,o,s;return"string"===e.dataType?(n=t._filterInfo.stringConditions,r="string",o="string-filter",s=t.localize("CONTAINS")):(n=t._filterInfo.numberAndDateConditions,r=e.dataType,o="num-date-filter",s=t.localize("EQUAL")),e.freeze&&i.push("freeze-"+("far"===e.freeze?"far":"near")),e.responsivePriority&&i.push("priority-"+e.responsivePriority),!1===e.allowFilter&&i.push("no-filter"),`<td${i.length?' class="'+i.join(" ")+'"':""} filter-for="${e.dataField}">\n <div>\n <input type="${r}" class="filter-value" aria-label="Filter value" />\n <smart-input class="${o}${a}data-source='${JSON.stringify(n)}' drop-down-button-position="right" drop-down-width="auto" readonly${l} value="${s}" title="${t.localize("filterCondition")}" aria-label="Filter condition"></smart-input>\n <smart-button class="smart-hidden" title="${t.localize("clearFilter")}"${a}${l} aria-label="Clear filter"></smart-button>\n </div>\n </td>`}_tableContainerChangeHandler(e){const t=this,a=t.isInShadowDOM?e.composedPath()[0]:e.target;a.classList.contains("filter-value")&&("date"===a.type||a instanceof Smart.Input&&(""!==a.previousElementSibling.value||-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(e.detail.value)))&&t._applyRowFilters()}_tableContainerClickHandler(e){const t=this;if(t._editing)return;const a=t.isInShadowDOM?e.composedPath()[0]:e.target;if(!t.$.tableContainer.contains(a))return;const l=a.closest("tbody tr[row-id], tfoot tr.grand-total");if(l){t.closeColumnMenu();const i=a.closest("td");if(a.classList.contains("hierarchy-arrow")){const e=t.animation;return t.virtualization&&(t._animation="none"),t._hierarchyArrowClickHandler(l,i),void(t.virtualization&&(t._animation=e))}const n=l.getAttribute("row-id");let r;n&&(r=t.rowById?t.rowById[n].data:t.rows.dataItemById[n]);const o=r?r.$.id:void 0,s=i?i.getAttribute("data-field"):void 0;if(!r&&l.classList.contains("grand-total")&&(r=l.data),void 0!==s){const a={};for(let e=0;e<t.columns.length;e++){const l=t.columns[e];a[l.dataField]=r[l.dataField]}t.$.fireEvent("cellClick",{id:n,row:a,dataField:s,value:r[s],originalEvent:e})}if(t._toggleSelection(l,r,e,a),t.editing||t.drillDown){if(!s||i.classList.contains("no-edit"))return;clearTimeout(t._dblclickObject.timeout),t._dblclickObject.numberOfClicks++,2===t._dblclickObject.numberOfClicks?(t._dblclickObject.numberOfClicks=0,t._beginEdit({rowElement:l,cell:i,dataField:s})):t._dblclickObject.timeout=setTimeout((function(){t._dblclickObject.numberOfClicks=0}),300)}return void(t.rowDetailTemplate&&t._toggleRowDetail(l,o))}const i=a.closest(".smart-table-select-all");if(i){if("one"===t.selectionMode)return;return void t._selectAllCheckboxClickHandler(i)}const n=a.closest(".smart-table-filter-row smart-button")||a.closest(".smart-table-column-menu smart-button");if(n){const e=n.parentElement.firstElementChild,a=n.parentElement.children[1];return e.value="",-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(a.$.input.dataValue)&&(a.value=t.localize("text"===e.type?"CONTAINS":"EQUAL"),delete a.$.input.dataValue),void t._applyRowFilters()}}_toggleSelection(e,t,a,l){const i=this;if(!i.selection||"cell"===i.selectionMode||e.classList.contains("disable-select")||e.classList.contains("grand-total"))return;function n(){i._selectedIds=[],Array.from(i.$.tableContainer.querySelectorAll(".smart-table-select-row.selected")).forEach((e=>{e.parentElement.classList.contains("disable-select")||e.parentElement.setAttribute("aria-selected",!1),e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1)}))}const r=t.$.id;let o=-1!==i._selectedIds.indexOf(r);if(i._interaction=!0,"one"===i.selectionMode){if(o)return;n(),i.select(r)}if("many"===i.selectionMode)if(o)i.unselect(r);else{if(i._disabledSelection.length>0&&t.children&&t.children.length>0){let e=0,a=0,l=[];if(t.children.forEach((t=>{const n=t.$.id;-1===i._selectedIds.indexOf(n)?e++:l.push(n),-1!==i._disabledSelection.indexOf(n)&&a++})),e===a)return i.unselect(l),void delete i._interaction}i.select(r),i._selectionStart={data:t,element:e}}else{if(i._selectionStart&&a.shiftKey){let t,a,l;if(i.virtualization?(t=i.rows,a=t.findIndex((e=>e.data.$.id===r)),l=t.findIndex((e=>e.data.$.id===i._selectionStart.data.$.id))):(t=Array.from(i.$.tableContainer.querySelectorAll("tr[row-id]:not([unused])")),a=t.indexOf(e),l=t.indexOf(i._selectionStart.element)),a!==l){const e=JSON.stringify(i._selectedIds.slice(0).sort()),r=Math.min(a,l),o=Math.max(a,l);n();const s=[];for(let e=r;e<=o;e++){const a=t[e];s.push(a.data.$.id)}return i._changeSelectionOfMultiple(s,"select","interaction",e),getSelection().removeAllRanges(),void delete i._interaction}if(1===i._selectedIds.length)return void delete i._interaction}const s=!!l&&(l.classList.contains("selection-checkbox")||l.classList.contains("smart-table-select-row"));let d=!1;if(1===i._selectedIds.length)d=!0;else if(i.hasAttribute("hierarchy")&&i.selectionByHierarchy){const e=[];!function e(t,a){const l=t.$.id;-1!==i._selectedIds.indexOf(l)&&a.push(l),t.children&&t.children.forEach((t=>e(t,a)))}(t,e),i._selectedIds.length===e.length&&(d=!0),t&&t.leaf&&(d=!0),o=i._getChildCheckState(t).maxSelected}else i.hasAttribute("hierarchy")&&!i.selectionByHierarchy&&(d=!0);if(o&&(s||d||a.ctrlKey||a.metaKey))return delete i._selectionStart,i.unselect(r),void delete i._interaction;s||a.ctrlKey||a.metaKey||n(),i.select(r),i._selectionStart={data:t,element:e}}delete i._interaction}_selectAllCheckboxClickHandler(e,t){const a=this;if(void 0===t){const l=a._filterInfo;if(l.inputFilters||l.rowFilters||l.appliedFilters)return void a._selectAllCheckboxClickHandlerFiltering(e);if(t=a.dataSource,a.hasAttribute("hierarchy")&&a._disabledSelection.length>0){const e=t.boundHierarchy,l=a._getChildCheckState({children:e}).maxSelected;return void a._changeSelectionOfMultiple(e.map((e=>e.$.id)),l?"unselect":"select","interaction")}}const l=t.length,i=a._selectedIds.length===l-a._disabledSelection.length+a._selectableGroupRecords.length,n=a._selectedIds.slice(0);if(a._selectedIds=[],i)a._updateCSSOnUnselectAll(e);else{let i,n=0;for(let e=0;e<l;e++){const l=t[e].$.id;-1===a._disabledSelection.indexOf(l)&&(a._selectedIds.push(l),n++)}n===l?i=!0:0===n&&(i=!1),a._updateCSSOnSelectAll(e,i),a._selectableGroupRecords.length>0&&(a._selectedIds=a._selectedIds.concat(a._selectableGroupRecords))}n.length!==a._selectedIds.length&&(a._updateState("selected"),a.$.fireEvent("change",{type:"interaction"}))}_selectAllCheckboxClickHandlerFiltering(e){const t=this,a=t.dataSource,l=t._selectedIds.slice(0),i=[],n=[];let r=0;for(let e=0;e<a.length;e++){const o=a[e];if(!1===o.$.filtered)continue;const s=o.$.id;r++,-1!==l.indexOf(s)&&i.push(s),-1===t._disabledSelection.indexOf(s)&&n.push(s)}const o=i.length===n.length;if(t._selectedIds=t._selectedIds.filter((e=>-1===n.indexOf(e))),o)t._updateCSSOnUnselectAll(e);else{let a;t._selectedIds=t._selectedIds.concat(n),n.length===r?a=!0:0===n.length&&(a=!1),t._updateCSSOnSelectAll(e,a)}l.length!==t._selectedIds.length&&(t._updateState("selected"),t.$.fireEvent("change",{type:"interaction"}))}_updateCSSOnUnselectAll(e){e.classList.remove("indeterminate","selected"),e.firstElementChild.setAttribute("aria-checked",!1),Array.from(this.$.tableContainer.querySelectorAll(".smart-table-select-row")).forEach((e=>{e.parentElement.classList.contains("disable-select")||e.parentElement.setAttribute("aria-selected",!1),e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1)}))}_updateCSSOnSelectAll(e,t){t?(e.classList.remove("indeterminate"),e.classList.add("selected"),e.firstElementChild.setAttribute("aria-checked",!0)):!1===t?(e.classList.remove("indeterminate","selected"),e.firstElementChild.setAttribute("aria-checked",!1)):(e.classList.remove("selected"),e.classList.add("indeterminate"),e.firstElementChild.setAttribute("aria-checked","mixed")),Array.from(this.$.tableContainer.querySelectorAll(".smart-table-select-row")).forEach((e=>{e.parentElement.classList.contains("disable-select")||(e.parentElement.setAttribute("aria-selected",!0),e.classList.remove("indeterminate"),e.classList.add("selected"),e.firstElementChild.setAttribute("aria-checked",!0))}))}_beginEdit(e){const t=this,a=t.editMode,l=e.dataField;let i=e.rowId,n=e.rowElement,r=e.rowObject,o=e.cell,s=[],d=[];if(t.editing){n||(n=t.$.tableContainer.querySelector(`tr[row-id="${i}"]:not([unused])`)),r||(i=n.getAttribute("row-id"),r=t.rowById[i],i=r.data.$.id),"row"===a?(s=n.querySelectorAll("td[data-field]"),d=t._columns.filter((e=>e.visible)).map((e=>e.dataField)),o||(o=l?n.querySelector(`td[data-field="${l}"`):s[0])):(o||(o=n.querySelector(`td[data-field="${l}"`)),s=[o],d=[l]),t._editing={row:r,cells:[]};for(let e=0;e<d.length;e++){const a=s[e];let l=d[e];const n=t.columnByDataField[l];if(!1===n.allowEdit)continue;n.transform&&(l=n.originalDataField);const c=r.data[l],u=t._initEditor(n,i,l,c);let f=u instanceof HTMLInputElement&&"date"===u.type;if(n.editor&&n.editor.template)n.editor.onRender&&n.editor.onRender(i,l,u,c);else if(f)if(c instanceof Date&&!isNaN(c.getTime())){const e=(c.getMonth()+1).toString(),t=c.getDate().toString();u.value=`${c.getFullYear()}-${"0".repeat(2-e.length)}${e}-${"0".repeat(2-t.length)}${t}`}else u.value="";else u.value=void 0===c?"":c;a.classList.add("editing"),a.innerHTML="",a.appendChild(u),a===o&&u.focus&&(u.focus(),n.editor&&n.editor.template||f||!u.select||u.select()),t._editing.cells.push({dataField:l,editor:u,element:a}),t.$.fireEvent("cellBeginEdit",{id:r.data.$.id,row:r.data,value:r.data[l],dataField:l})}"row"===a&&t.$.fireEvent("rowBeginEdit",{id:r.data.$.id,row:r.data})}}_initEditor(e,t,a,l){let i=this._editors[a];if(i)return i;if(e.editor&&e.editor.template){const n=document.createElement("div");return n.innerHTML=e.editor.template,i=n.firstElementChild,i.className="smart-table-editor",e.editor.onInit&&e.editor.onInit(t,a,i,l),i}return i=document.createElement("input"),i.className="smart-table-editor standard","number"===e.dataType?i.type="number":"date"===e.dataType?i.type="date":i.type="text",this._editors[a]=i,i}_toggleRowDetail(e,t){const a=this;if(a.virtualization)return void a._toggleRowDetailVirtualization(e,t);const l=e.nextElementSibling;l.classList.toggle("collapsed"),l.classList.contains("collapsed")?(l.setAttribute("aria-hidden",!0),a._expandedRowDetailIds=a._expandedRowDetailIds.filter((e=>e!==t))):(l.removeAttribute("aria-hidden"),a._expandedRowDetailIds.push(t))}_toggleRowDetailVirtualization(e,t){const a=this;let l=e.nextElementSibling;function i(){let e=a.$.virtualizationContainer.$.verticalScrollBar,t=a.$.virtualizationContainer.$.verticalScrollBar.value;a._ignoreVerticalChange=!0,a._refreshDataRows(),t=Math.min(e.max,t),e.value=t,delete a._ignoreVerticalChange,a._onVerticalChange({detail:{value:t}},!0)}if(l&&l.classList.contains("smart-table-row-detail")&&!l.classList.contains("collapsed"))return l.setAttribute("aria-hidden",!0),a._expandedRowDetailIds=a._expandedRowDetailIds.filter((e=>e!==t)),l.classList.add("collapsed"),l.remove(),void i();const n=e.data;l=document.createElement("tr"),l.classList.add("collapsed"),a._createRowDetailOnDemand(l,{data:n},n),e.parentElement.insertBefore(l,e.nextElementSibling),a._expandedRowDetailIds.push(t),l.classList.remove("collapsed"),i()}_setFocusable(){const e=this,t="smart-table"===e.nodeName.toLowerCase();if(!e.keyboardNavigation||e.disabled||e.unfocusable||e.hasAttribute("modal"))return e.$.tableContainer.removeAttribute("tabindex"),t&&(e.$.filterInput.unfocusable=!0,e.$.pager.unfocusable=!0),void(e.$.conditionalFormattingButton.unfocusable=!0);const a=e.$.tableContainer.getAttribute("tabindex");(null===a||a<0)&&e.$.tableContainer.setAttribute("tabindex",0),t&&(e.$.filterInput.unfocusable=!1,e.$.pager.unfocusable=!1),e.$.conditionalFormattingButton.unfocusable=!1}_tableContainerFocusHandler(){const e=this;e._focusedCell&&e.$.tableContainer.contains(e._focusedCell)||e._focusCell(e.$.tableContainer.children[1].querySelector("tr:not([unused]) td[data-field], tr:not([unused]) td.group-header"))}_tableContainerDownHandler(e){const t=this.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;this._focusCell(t.closest("td[data-field], td.group-header")),e.stopPropagation()}_focusCell(e,t){const a=this;if(!e||!e.hasAttribute("data-field")&&!e.classList.contains("group-header")||e.parentElement.classList.contains("grand-total"))return!1;if(a._focusedCell){if(a._focusedCell===e)return!1;a._focusedCell.removeAttribute("focus")}if(a._focusedCell=e,e.setAttribute("focus",""),!t)return;const l=a.$.tableContainer.parentElement,i=a.$.header.offsetHeight,n=a.freezeHeader?a.$.tableContainer.firstElementChild.offsetHeight:0,r=l.scrollTop;let o=e.offsetTop-i-n;if(o<r)l.scrollTop=o;else{const t=a.footerRow&&a.freezeFooter?a.$.tableContainer.lastElementChild.offsetHeight:0,s=a.$.pager.offsetHeight,d=l.clientHeight-(i+n+t+s);o+=e.offsetHeight,o>r+d&&(l.scrollTop=o-d)}if(e.classList.contains("freeze-near")||e.classList.contains("freeze-far"))return;const s=l.scrollLeft,d=a.$.tableContainer.querySelector("tr[row-id]:not([unused])");let c,u=0;if(Array.from(d.children).forEach((e=>{e.classList.contains("freeze-near")&&(u+=e.offsetWidth)})),a.rightToLeft){let t=e.previousElementSibling;for(c=0;t;)t.classList.contains("freeze-near")||(c-=t.offsetWidth),t=t.previousElementSibling;if(c>s)l.scrollLeft=c;else{const t=l.clientWidth;c-=e.offsetWidth,c<s-t&&(l.scrollLeft=c+t-u)}}else if(c=e.offsetLeft-u,c<s)l.scrollLeft=c;else{const t=l.clientWidth;c+=e.offsetWidth+u,c>s+t&&(l.scrollLeft=c-t)}}focus(){const e=this;!e.keyboardNavigation||e.disabled||e.unfocusable||e.hasAttribute("modal")||e.$.tableContainer.focus()}blur(){this.$.tableContainer.blur()}_tableContainerKeydownHandler(e){const t=this,a=t.isInShadowDOM?e.composedPath()[0]:e.target,l=e.key;if("Shift"===l)return void("extended"===t.selectionMode&&t.$.tableContainer.classList.add("smart-unselectable"));if(!t.contains(a))return;if(a&&"INPUT"===a.nodeName&&!t._editing)return;const i=t._focusedCell;if(!i)return;const n=t.virtualization,r=i.classList.contains("group-header");if(r&&-1!==["ArrowRight","ArrowLeft","Home","End","Escape","F2"].indexOf(l))return void e.preventDefault();if(t._editing){switch(l){case"Enter":t.endEdit();break;case"Escape":t.cancelEdit();break;default:return}return t.$.tableContainer.focus(),void e.preventDefault()}const o=i.parentElement;if(n&&o){const e=t.$.virtualizationContainer.$.verticalScrollBar,a=e.value,i=o.data.$.id;if("ArrowUp"===l&&0===a&&i===t._rowsVirtual[0].data.$.id||"ArrowDown"===l&&a===e.max&&i===t._rowsVirtual[t._rowsVirtual.length-1].data.$.id)return}let s="ArrowRight",d="ArrowLeft";switch(t.rightToLeft&&(s="ArrowLeft",d="ArrowRight"),l){case s:case d:{const a=l===s?"nextElementSibling":"previousElementSibling";let r=i[a];for(;r&&r.classList.contains("smart-hidden");)r=r[a];t._focusCell(r,!n,e),t._scrollToVirtualization(l===s?"nextArrow":"prevArrow",r);break}case"ArrowUp":case"ArrowDown":{const a="ArrowUp"===l?"previousElementSibling":"nextElementSibling";let s=o[a];for(;s&&(s.classList.contains("smart-table-row-detail")||s.classList.contains("collapsed"));)s=s[a];s&&(r?t._focusCell(s.querySelector("td[data-field], .group-header"),!n,e):t._focusCell(s.querySelector(`td[data-field="${i.getAttribute("data-field")}"], .group-header`),!n,e),t._scrollToVirtualization(l,s));break}case"Home":t._focusCell(o.querySelector("td[data-field]"),!n,e),t._scrollToVirtualization(l);break;case"End":{const a=o.querySelectorAll("td[data-field]");let i=a.length-1,r=a[i];for(;r.classList.contains("smart-hidden");)i--,r=a[i];t._focusCell(r,!n,e),t._scrollToVirtualization(l);break}case"PageDown":t._pageDownHandler(i,e);break;case"PageUp":t._pageUpHandler(i,e);break;case"Enter":{const a=o.data;t.dataSource.boundHierarchy&&t._areChildrenFiltered(a)?t._hierarchyArrowClickHandler(o,i,e):t.rowDetailTemplate&&t._toggleRowDetail(o,a.$.id);break}case" ":t._toggleSelection(o,o.data,e);break;case"F2":t.beginEdit(o.data.$.id,i.getAttribute("data-field"));break;default:return}if(e.preventDefault(),t.onKeyboardScroll){const e=n?t.$.virtualizationContainer:t.$.container;t.onKeyboardScroll(l,e.scrollTop,e.scrollLeft)}}_pageDownHandler(e,t){const a=this,l=a.paging;if(!l&&e.parentElement===e.parentElement.parentElement.lastElementChild)return;const i=a.virtualization,n=a.$.tableContainer,r=n.parentElement,o=i?a.$.virtualizationContainer:r;let s=e.getAttribute("data-field");function d(){const e=n.querySelectorAll("tr[row-id]:not([unused])");let t=i?0:a.$.header.offsetHeight+a.$.pager.offsetHeight;a.footerRow&&a.freezeFooter&&(t+=n.lastElementChild.offsetHeight);for(let a=e.length-1;a>=0;a--){const l=e[a];if(!l.classList.contains("collapsed")&&l.offsetTop+l.offsetHeight<=(i?-r.offsetTop:r.scrollTop)+o.clientHeight-t)return l.querySelector(`td[data-field${s}], .group-header`)}}s=s?`="${s}"`:"";let c=d();if(c)if(e===c){const u=(a.freezeHeader?n.firstElementChild.offsetHeight:0)+a._rowHeight;let f;if(i?(f=o.$.verticalScrollBar.value,o.$.verticalScrollBar.value+=o.clientHeight-u):r.scrollTop+=r.clientHeight-u,c=d(),l&&(i&&f===o.$.verticalScrollBar.value||!i&&e===c)){const e=a.pageIndex;a.navigateTo(a.pageIndex+1),a.pageIndex!==e&&(i&&(o.$.verticalScrollBar.value=0),a._focusCell(n.querySelector(`tr[row-id]:not([unused]) td[data-field${s}], tr[row-id]:not([unused]) .group-header`),!i,t))}else a._focusCell(c,void 0,t)}else a._focusCell(c,void 0,t)}_pageUpHandler(e,t){const a=this,l=a.virtualization,i=a.$.tableContainer,n=i.parentElement,r=l?a.$.virtualizationContainer:n;let o=e.getAttribute("data-field");function s(){const e=i.querySelectorAll("tr[row-id]:not([unused])");let t=0;a.freezeHeader&&(t=i.firstElementChild.offsetHeight);for(let a=0;a<e.length;a++){const i=e[a];if(!i.classList.contains("collapsed")&&i.offsetTop>=(l?-n.offsetTop:n.scrollTop)+t)return i.querySelector(`td[data-field${o}], .group-header`)}}o=o?`="${o}"`:"";let d=s();if(d)if(e===d){const c=(a.freezeHeader?i.firstElementChild.offsetHeight:0)+a._rowHeight;let u;if(l?(u=r.$.verticalScrollBar.value,r.$.verticalScrollBar.value-=r.clientHeight-c):n.scrollTop-=n.clientHeight-c,d=s(),a.paging&&(l&&u===r.$.verticalScrollBar.value||!l&&e===d)){const e=a.pageIndex;if(a.navigateTo(a.pageIndex-1),a.pageIndex!==e){l&&(r.$.verticalScrollBar.value=r.$.verticalScrollBar.max);const e=i.querySelectorAll(`tr[row-id]:not([aria-hidden="true"]) td[data-field${o}], tr[row-id]:not([aria-hidden="true"]) .group-header`);a._focusCell(e[e.length-1],!l,t)}}else a._focusCell(d,void 0,t)}else a._focusCell(d,void 0,t)}_tableContainerKeyupHandler(e){const t=this,a=t.isInShadowDOM?e.composedPath()[0]:e.target;if("Shift"===e.key&&"extended"===t.selectionMode&&t.$.tableContainer.classList.remove("smart-unselectable"),t.contains(a))return a.classList.contains("filter-value")&&"date"!==a.type?(clearTimeout(t._filterRowTimeout),void(t._filterRowTimeout=setTimeout((function(){const e=t.context;t.context=t,t._applyRowFilters(),t.context=e}),500))):void 0}_tableContainerPointeroverHandler(e){const t=this;if(!t.tooltip)return;const a=(t.isInShadowDOM?e.composedPath()[0]:e.target).closest("tbody td[data-field], thead th[data-field]");if(!a)return;const l=t.$.tableContainer.querySelector(".tooltip"),i=t.columnByDataField[a.getAttribute("data-field")],n=t.virtualization;if(l&&(l.classList.remove("tooltip"),l.removeAttribute("title")),"th"!==a.tagName.toLowerCase())(a.classList.contains("tree-cell")&&a.firstElementChild&&a.firstElementChild.children[1].scrollWidth>a.firstElementChild.children[1].offsetWidth||a.scrollWidth>a.offsetWidth)&&(a.classList.add("tooltip"),a.title=n&&i&&i.templateElement?"":a.innerText);else{const e=a.querySelector(".label");e&&e.scrollWidth>e.offsetWidth&&(a.classList.add("tooltip"),a.title=n&&i&&i.templateElement?"":e.innerText)}}_documentDownHandler(e){const t=this,a=t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;function l(){"default"!==t.columnSizeMode&&(t._preventClickSort=!0,clearTimeout(t._dblclickObject.timeout),t._dblclickObject.numberOfClicks++,2===t._dblclickObject.numberOfClicks?(t._dblclickObject.numberOfClicks=0,t._autoResizeColumnOnDblclick()):t._dblclickObject.timeout=setTimeout((function(){t._dblclickObject.numberOfClicks=0}),300))}if(delete t._preventClickSort,t._editing&&!a.closest(".smart-table-editor")){const e=a.closest(".smart-drop-down")||a.closest(".smart-input-drop-down-menu");if(!e)return void t.endEdit();const l=e.ownerElement;if(!l)return void t.endEdit();if(t.$.container.contains(l)&&l.classList.contains("smart-table-editor"))return;return void t.endEdit()}const i=t.columnReorder,n=t.columnResize;if(i&&!t.columnTotals||n){const r=a.closest("th[data-field]:not(.smart-pivot-table-total-header)");if(r&&t.$.tableContainer.contains(r)){if(t.$.tableContainer.classList.add("smart-unselectable"),n&&t._columns.length>1&&!t.hasAttribute("resize-max-reached")){const a=t.rightToLeft,i=r.getBoundingClientRect();let n=null;if(!a&&e.clientX<=i.left+5||a&&e.clientX>=i.right-5){const i=r.previousElementSibling;if(i&&i.hasAttribute("data-field")){if(i.hasAttribute("locked"))return;for(let e=0;e<t.columns.length;e++){const a=t.columns[e];if(a.headerCellElement===i){n=a;break}}const r=i.getBoundingClientRect(),o=n&&n.minWidth||t._getNumericMinWidth();return t._resizeDetails={FeedbackShown:!1,Item:i,ItemStart:r[a?"right":"left"]+window.scrollX,Min:o,StartPosition:{left:e.pageX,top:e.pageY},StartTime:new Date},t._resizeDetails.Max=t._getCurrentResizeMax(),void l()}}if(!a&&e.clientX>=i.right-5||a&&e.clientX<=i.left+5){if(r.hasAttribute("locked"))return;for(let e=0;e<t.columns.length;e++){const a=t.columns[e];if(a.headerCellElement===r){n=a;break}}const o=n&&n.minWidth||t._getNumericMinWidth();return t._resizeDetails={FeedbackShown:!1,Item:r,ItemStart:i[a?"right":"left"]+window.scrollX,Min:o,StartPosition:{left:e.pageX,top:e.pageY},StartTime:new Date},t._resizeDetails.Max=t._getCurrentResizeMax(),void l()}}i&&(t._dragDetails={FeedbackShown:!1,Item:r,StartPosition:{left:e.pageX,top:e.pageY},StartTime:new Date})}}}_documentMoveHandler(e){const t=this,a=t._dragDetails;if(!a)return void(t._resizeDetails&&t._handleResizeOnMove(e));if(!a.FeedbackShown){const l=(new Date).getTime()-a.StartTime.getTime()>500,i=Math.abs(a.StartPosition.left-e.pageX)>5||Math.abs(a.StartPosition.top-e.pageY)>5;if(!i||!(!t._isMobile||t._isMobile&&l))return void(t._isMobile&&i&&!l&&(delete t._dragDetails,t.$.tableContainer.classList.remove("smart-unselectable")));t._hideBodyOverflow(),a.Feedback=t._addDragFeedback(),a.FeedbackShown=!0,a.Item.classList.add("dragged"),t.classList.add("smart-unselectable")}const l=t.$.tableContainer.parentElement;a.Feedback.style.left=e.pageX+10+"px",a.Feedback.style.top=e.pageY+10+"px",a.HoveredItem&&(a.HoveredItem.classList.remove("drop-column","left","right"),delete a.HoveredItem),l.offsetWidth<l.scrollWidth&&(clearInterval(t._dragInterval),t._dragInterval=setInterval((function(){const a=l.getBoundingClientRect();a.left<=e.clientX&&a.left+a.width>=e.clientX?e.clientX>=a.left&&e.clientX<=a.left+25?l.scrollLeft-=t._autoScrollCoefficient:e.clientX>=a.left+a.width-25&&e.clientX<=a.left+a.width?l.scrollLeft+=t._autoScrollCoefficient:clearInterval(t._dragInterval):clearInterval(t._dragInterval)}),10));const i=t._getClosestThToHover(e);i&&(i.classList.add("drop-column"),a.HoveredItem=i)}_hideBodyOverflow(){const e=(document.scrollingElement||document.documentElement).scrollHeight>document.documentElement.clientHeight,t=(document.scrollingElement||document.documentElement).scrollWidth>document.documentElement.clientWidth;this._originalBodyOverflow={overflowX:document.body.style.overflowX,overflowY:document.body.style.overflowY,overflow:document.body.style.overflow},document.body.classList.add("smart-dragging"),document.body.style.overflow=document.body.style.overflowX=document.body.style.overflowY="",e&&!t?document.body.style.overflowX="hidden":t&&!e?document.body.style.overflowY="hidden":t||e||(document.body.style.overflow="hidden")}_addDragFeedback(){const e=this,t=e._dragDetails.Item,a=document.createElement("div");return a.className="smart-table-feedback",a.setAttribute("parent-table-id",e.id),a.innerHTML=e.columnByDataField[t.getAttribute("data-field")].label,e.theme&&a.setAttribute("theme",e.theme),document.body.appendChild(a),a}_getClosestThToHover(e){const t=e.clientX,a=Array.from(this.$.tableContainer.querySelectorAll("th[data-field]:not(.smart-pivot-table-total-header)"));let l,i,n;for(let e=0;e<a.length;e++){const r=a[e];if(!r||this._dragDetails.Item===r)continue;const o=r.getBoundingClientRect(),s=Math.abs(t-o.left),d=Math.abs(t-o.right),c=Math.min(s,d);if(!(void 0===i||c<i))break;l=r,i=c,n=s<d?"left":"right"}return l&&l.classList.add(n),l}_handleResizeOnMove(e){const t=this,a=t._resizeDetails;if(!a.FeedbackShown){const l=(new Date).getTime()-a.StartTime.getTime()>500,i=Math.abs(a.StartPosition.left-e.pageX)>=1||Math.abs(a.StartPosition.top-e.pageY)>=1;if(!i||!(!t._isMobile||t._isMobile&&l))return void(t._isMobile&&i&&!l&&(delete t._resizeDetails,t.$.tableContainer.classList.remove("smart-unselectable","resizing"),document.body.style.cursor=null));a.Feedback=t._addResizeFeedbacks(),a.FeedbackShown=!0,t.classList.add("smart-unselectable","resizing"),document.body.style.cursor="col-resize"}const l=a.Feedback,i=a.ItemStart;let n;t.rightToLeft?(n=Math.min(a.Max,Math.max(a.Min,Math.round(i-e.pageX))),l.style.left=i-n+"px"):(n=Math.min(a.Max,Math.max(a.Min,Math.round(e.pageX-i))),l.style.left=i+n+"px"),l.classList.toggle("min",n===a.Min),l.classList.toggle("max",n===a.Max),t.columnResizeFeedback&&(l.innerHTML=n+"px"),a.Width=n}_addResizeFeedbacks(){const e=this,t=e._resizeDetails,a=e.$.container.getBoundingClientRect(),l=a.top+window.scrollY+"px",i=a.height+"px",n=document.createElement("div"),r=document.createElement("div");return r.className="smart-table-resize-feedback static",r.setAttribute("parent-table-id",e.id),r.style.top=l,r.style.left=t.ItemStart+"px",r.style.height=i,e._resizeDetails.StaticFeedback=r,n.className="smart-table-resize-feedback",n.setAttribute("parent-table-id",e.id),n.style.top=l,n.style.height=i,e.theme&&(r.setAttribute("theme",e.theme),n.setAttribute("theme",e.theme)),document.body.appendChild(n),document.body.appendChild(r),n}_resolveResize(e){const t=this,a=t._resizeDetails;if(delete t._resizeDetails,t.$.tableContainer.classList.remove("smart-unselectable","resizing"),e){if(!a.FeedbackShown)return;a.StaticFeedback.remove(),a.Feedback.remove()}const l=t._columns.find((e=>e.headerCellElement===a.Item));t.classList.remove("smart-unselectable","resizing"),document.body.style.cursor=null;let i=a.Width;i<t.columnMinWidth&&(i=t.columnMinWidth);const n=t._getTableRemainingWidth();if(l){const e=l._isResponsive||!!(l.width&&l.width.toString().indexOf("%")>=0);if(delete l.width,l.minWidth&&i<l.minWidth&&(i=l.minWidth),l._manualWidth=i,l._manualPercentageWidth=parseFloat(i/n*100),l._isResponsive=e,a.Item.style.width=l._isResponsive?parseFloat(i/n*100)+"%":i+"px",l._isFillRemainingWidth){let e=!0;for(let a=0;a<t._columns.length;a++){const l=t._columns[a];if(!l.width&&!l._manualWidth){e=!1;break}}!t.columnResizeNormalize&&e&&(t.columns.push({dataField:"",label:"",visible:!0,allowResize:!1,allowFilter:!1,allowSort:!1}),t._initColumns(!0),t.refresh())}}else a.Item.style.width=i+"px";t._handleAutoSizeMode(l),t._handleFrozenColumnPositions(),t._refreshHorizontalScrollbar();const r=parseFloat(i/n*100);t.$.fireEvent("columnResize",{dataField:l.dataField,headerCellElement:a.Item,widthInPercentages:r,width:i})}openColumnMenu(e){const t=this,a=t.columnByDataField[e];if(!a)return;const l=a.headerCellElement;if(!l)return;if(a&&!1===a.allowMenu)return;const i=l.querySelector(".column-menu");if(!i)return;const n=()=>{const e=c.getBoundingClientRect(),a=t.activeColumnMenu;t._columnsSettingsMenu.style.top=e.top+window.scrollY+"px",t._columnsSettingsMenu.style.left=e.right+window.scrollX+"px",e.right-i.offsetWidth+window.scrollX+a.offsetWidth>t.getBoundingClientRect().right&&(t._columnsSettingsMenu.style.left=10+e.right-a.offsetWidth-t._columnsSettingsMenu.offsetWidth+window.scrollX+"px")},r=()=>{const e=a.headerCellElement;e.hasAttribute("column-menu-button")||e.setAttribute("column-menu-button","");const l=e.querySelector(".column-menu"),i=l.getBoundingClientRect();o.style.top=i.bottom+10+window.scrollY+"px",o.style.left=i.right-l.offsetWidth+window.scrollX+"px",i.right-l.offsetWidth+window.scrollX+o.offsetWidth>t.getBoundingClientRect().right&&(o.style.left=i.right-o.offsetWidth+window.scrollX+"px");const n=o.querySelector("input");n&&n.focus()};a.columnMenu&&a.columnMenu.remove(),t.closeColumnMenu();const o=document.createElement("div");o.classList.add("smart-table-column-menu","wrapper"),o.owner=l,o.dataField=e;const s=document.createElement("div");s.innerHTML=`<span class='menu-icon sort-asc'></span><span class="label">${t.localize("columnMenuItemSortAsc")}</span>`,s.classList.add("smart-table-menu-item");const d=document.createElement("div");d.innerHTML=`<span class='menu-icon sort-desc'></span><span class="label">${t.localize("columnMenuItemSortDesc")}</span>`,d.classList.add("smart-table-menu-item");const c=document.createElement("div");c.innerHTML=`<span class='menu-icon columns'></span><span class="label">${t.localize("columnMenuItemColumns")}</span>`,c.classList.add("smart-table-menu-item","columns-item");const u=document.createElement("div");u.innerHTML=`<span class='menu-icon filter-by'></span><span class="label">${t.localize("columnMenuItemFilter")}</span>`,u.classList.add("smart-table-menu-item","filter-item");const f=document.createElement("div");f.innerHTML=`<span class='menu-icon filter-by-remove'></span><span class="label">${t.localize("columnMenuItemRemoveFilter")}</span>`,f.classList.add("smart-table-menu-item","remove-filter-item","smart-hidden");const m=document.createElement("div");m.innerHTML=`<span class='menu-icon sort-remove'></span><span class="label">${t.localize("columnMenuItemRemoveSort")}</span>`,m.classList.add("smart-table-menu-item","remove-sort-item","smart-hidden");const h=document.createElement("div");h.innerHTML=`<span class='menu-icon reset'></span><span class="label">${t.localize("columnMenuItemReset")}</span>`,h.classList.add("smart-table-menu-item","reset-item"),c.onmouseleave=e=>{const a=t._columnsSettingsMenu.getBoundingClientRect();e.pageX>=a.left-20&&e.pageX<=a.right+20&&e.pageY>=a.top-20&&e.pageY<=a.bottom+20||t._columnsSettingsMenu&&t._columnsSettingsMenu.remove()},c.onmouseenter=()=>{t._columnsSettingsMenu=(()=>{t._columnsSettingsMenu&&t._columnsSettingsMenu.remove();const a=document.createElement("div");a.classList.add("smart-table-column-menu","wrapper","smart-table-columns-menu");let l=0,i=null;for(let o=0;o<t.columns.length;o++){const s=document.createElement("div");s.innerHTML=`<span class='column-item menu-icon'></span><span class="label">${t.columns[o].label}</span>`,s.classList.add("smart-table-menu-item"),s.column=t.columns[o],e!==s.column.dataField&&!1!==s.column.allowHide&&(s.column.visible?(l++,i=s):s.firstElementChild.classList.add("off"),s.onpointerdown=e=>{s.column.visible=!s.column.visible,s.column.visible?s.firstElementChild.classList.remove("off"):s.firstElementChild.classList.add("off"),r(),n(),e.stopPropagation(),e.preventDefault()},a.appendChild(s))}return 1===l&&i&&i.classList.add("smart-disabled"),document.body.appendChild(a),a})(),n()};const p=t._createFilterRowInput(a);if(t.filtering&&!1!==a.allowFilter)if(t.filterRow)o.insertBefore(f,o.firstElementChild);else{o.innerHTML=p,o.insertBefore(u,o.firstElementChild);const e=o.querySelector(".filter-value");e.onkeyup=a=>{"Enter"===a.key&&t.closeColumnMenu(),"Escape"===a.key&&(e.value="")},e.nextElementSibling.onchange=()=>{t._applyRowFilters()}}o.insertBefore(h,o.firstElementChild),o.insertBefore(c,o.firstElementChild),o.insertBefore(m,o.firstElementChild),!1!==a.allowSort&&"none"!==t.sortMode&&(o.insertBefore(d,o.firstElementChild),o.insertBefore(s,o.firstElementChild),a.headerCellElement.hasAttribute("aria-sort")&&(m.classList.remove("smart-hidden"),"ascending"===a.headerCellElement.getAttribute("aria-sort")?s.classList.add("smart-disabled"):d.classList.add("smart-disabled")),m.onclick=()=>{t.sortBy(a.dataField,null),t.closeColumnMenu()},s.onclick=()=>{t.sortBy(a.dataField,"asc"),t.closeColumnMenu()},d.onclick=()=>{t.sortBy(a.dataField,"desc"),t.closeColumnMenu()}),h.onclick=()=>{if(t._initialState){if(t.loadState(t._initialState),t._filterInfo.filterRowValues&&delete t._filterInfo.filterRowValues,t.clearFilters(),t.filterRow){const e=t.$.tableContainer.querySelector(".smart-table-filter-row");e&&e.remove()}t._initRows(),t.refresh()}t.closeColumnMenu()};const g=t.columns.findIndex((e=>e.dataField===a.dataField));t.appendChild(o);const _=o.lastElementChild.children[2];_&&(_.onclick=()=>{const e=_.parentElement.firstElementChild,a=_.parentElement.children[1];e.value="",-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(a.$.input.dataValue)&&(a.value=t.localize("text"===e.type?"CONTAINS":"EQUAL"),delete a.$.input.dataValue),t._applyRowFilters()});const b=t._filterInfo&&t._filterInfo.filterRowValues?t._filterInfo.filterRowValues[g]:null;if(b&&!t.filterRow){const e=o.lastElementChild,l=a.dataType,i=t._filterInfo["string"===l?"stringConditions":"numberAndDateConditions"].find((e=>e.value===b.condition));if(-1===["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(i.value))if("date"===l){const t=new Date(b.value),a=(t.getMonth()+1).toString(),l=t.getDate().toString();e.children[0].value=`${t.getFullYear()}-${"0".repeat(2-a.length)}${a}-${"0".repeat(2-l.length)}${l}`}else e.children[0].value=b.value;e.children[1].value=i.label,e.children[1].$.input.dataValue=i.value,e.children[2].classList.remove("smart-hidden")}a.headerCellElement.hasAttribute("filter")&&f.classList.remove("smart-hidden"),f.onclick=()=>{t.removeFilter(a.dataField),t.closeColumnMenu()},r(),a.columnMenu=t.activeColumnMenu=o,t.$.fireEvent("openColumnMenu",{dataField:e})}closeColumnMenu(){const e=this;e.activeColumnMenu&&(e.activeColumnMenu.owner.hasAttribute("column-menu-button")&&e.activeColumnMenu.owner.removeAttribute("column-menu-button"),e._columnsSettingsMenu&&e._columnsSettingsMenu.remove(),e.$.fireEvent("closeColumnMenu",{dataField:e.activeColumnMenu.dataField}),e.activeColumnMenu.remove(),delete e.activeColumnMenu)}_documentUpHandler(e){const t=this,a=t._dragDetails;if(t.activeColumnMenu){const a=e.originalEvent?e.originalEvent:e;if(a){let e=!1,l=a.target;for(;l;)if(l=l.parentNode,l===t){e=!0;break}(t.activeColumnMenu.contains(a.target)||t._columnsSettingsMenu&&t._columnsSettingsMenu.contains(a.target))&&(e=!0);const i=t.activeColumnMenu.querySelector("smart-input");i&&i.$.scrollView.contains(a.target)&&(e=!0),e||t.closeColumnMenu()}}if(t._selectDrag)return t.$.main.classList.remove("prevent-scroll"),void delete t._selectDrag;if(!a)return void(t._resizeDetails&&t._resolveResize(!0));if(delete t._dragDetails,t.$.tableContainer.classList.remove("smart-unselectable"),!a.FeedbackShown)return;const l=a.HoveredItem;document.body.classList.remove("smart-dragging"),document.body.style.overflow=t._originalBodyOverflow.overflow,document.body.style.eoverflowX=t._originalBodyOverflow.overflowX,document.body.style.overflowY=t._originalBodyOverflow.overflowY,delete t._originalBodyOverflow,t.classList.remove("smart-unselectable"),a.Item.classList.remove("dragged"),document.body.removeChild(a.Feedback),clearInterval(t._dragInterval),delete t._dragInterval,l&&t._applyColumnReorder(a,l),t._preventClickSort=!0,requestAnimationFrame((()=>delete t._preventClickSort))}_applyColumnReorder(e,t){const a=this,l=a.rightToLeft,i=a._columns,n=e.Item.getAttribute("data-field"),r=i.find((e=>e.dataField===n)),o=t.getAttribute("data-field"),s=t.classList.contains("right"),d=a._columns.filter((e=>e.dataField!==n)),c=d.findIndex((e=>e.dataField===o));t.classList.remove("drop-column","left","right"),s&&!l||!s&&l?d.splice(c+1,0,r):d.splice(c,0,r),i.map((e=>e.dataField)).join(",")!==d.map((e=>e.dataField)).join(",")&&(a.columns=d,a._initColumns(),a.refresh())}_applyRowFilters(){const e=this;if(!e.filtering||!e.filterRow&&!e.columnMenu)return;const t=e.filterRow?e.$.tableContainer.querySelector(".smart-table-filter-row"):null,a=Number(e.selection),l=e._columns.filter((e=>e.visible)),i=[],n=[];for(let r=0;r<l.length;r++){const o=l[r].dataField,s=l[r].dataType;if(l[r].headerCellElement&&l[r].headerCellElement.hasAttribute("filter")&&l[r].headerCellElement.removeAttribute("filter"),!e.filterRow&&!l[r].columnMenu){n.push(null);continue}const d=e.filterRow?t.children[r+a].firstElementChild:l[r].columnMenu.lastElementChild,c=d.children[2];let u=d.firstElementChild.value,f=d.children[1].value;"string"===s?f=e._filterInfo.stringConditions.find((e=>e.label===f)).value:(f=e._filterInfo.numberAndDateConditions.find((e=>e.label===f)).value,""!==u&&("number"===s?(u=parseFloat(u),isNaN(u)&&(d.firstElementChild.value="",u="")):"date"===s&&(u=new Date(u),u.setHours(0,0,0))));const m=-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(f);if(""!==u||m){const e=new Smart.Utilities.FilterGroup,t=e.createFilter(s,u,f);e.addFilter("or",t),i.push([o,e]),c.classList.remove("smart-hidden"),n.push({condition:f,value:u}),l[r].headerCellElement&&l[r].headerCellElement.setAttribute("filter","")}else c.classList.add("smart-hidden"),n.push(null),l[r].headerCellElement&&l[r].headerCellElement.hasAttribute("filter")&&l[r].headerCellElement.removeAttribute("filter");m?d.firstElementChild.setAttribute("disabled",!0):d.firstElementChild.removeAttribute("disabled")}i.length>0?(e.dataSource.virtualDataSource||e.dataSource._filter(i,e.filterOperator),e._filterInfo.rowFilters=i,e._filterInfo.filterRowValues=n,delete e._filterInfo.appliedFilters,e._fullRefresh("filter"),e._updateState("filtered"),e._doNotFireEvent||e.$.fireEvent("filter",{action:"add",filters:i})):e._filterInfo.rowFilters?(e._filterInfo.filterRowValues&&delete e._filterInfo.filterRowValues,e.clearFilters()):e._filterInfo.filterRowValues&&delete e._filterInfo.filterRowValues}_clearFilterInput(){const e=this;e._filterInfo.query="",delete e._filterInfo.inputFilters,e.$.filterInput.value=""}_clearRowFilters(e){const t=this;if(!t._filterInfo.rowFilters)return;const a=t.$.tableContainer.querySelector(".smart-table-filter-row"),l=t.selection?1:0;let i=t._columns.filter((e=>e.visible));if(e&&(i=t._columns.filter((t=>t.dataField===e))),a)for(let e=0;e<i.length;e++){const t=a.children[e+l]?a.children[e+l].firstElementChild:null;t&&(t.firstElementChild.value="",t.children[2].classList.add("smart-hidden")),i[e].headerCellElement&&i[e].headerCellElement.hasAttribute("filter")&&i[e].headerCellElement.removeAttribute("filter")}delete t._filterInfo.rowFilters}_createFooterRow(e){const t=this,a=t.footerRow;if(!a)return;if(e)return void t.$.tableContainer.appendChild(e);const l=document.getElementById(a);if(l&&l instanceof HTMLTemplateElement){const e=document.createElement("tfoot"),a=document.importNode(l.content,!0);e.appendChild(a),t.$.tableContainer.appendChild(e)}else t.footerRow=null}_createCustomHeaderRow(){const e=this,t=e.$.tableContainer.firstElementChild;let a=e.headerRow;if(a){if("function"==typeof a)a.call(e,t);else if("string"==typeof a){const e=document.getElementById(a);if(!e)return void(t.innerHTML=`<tr><th>${a}</th></tr>`);a=e}a instanceof HTMLTemplateElement?t.appendChild(document.importNode(a.content,!0)):a.nodeName?t.appendChild(a):e.headerRow=null}}_updateSelectAllState(e){const t=this;if(!t.selection||"cell"===t.selectionMode)return;const a=t.$.tableContainer.querySelector(".smart-table-select-all");let l;if(void 0===e){const a=t.dataSource,i=t._filterInfo;if(i.inputFilters||i.rowFilters||i.appliedFilters){const i=t._selectedIds;e=0,l=0;for(let t=0;t<a.length;t++){const n=a[t];if(!1===n.$.filtered)continue;const r=n.$.id;e++,-1!==i.indexOf(r)&&l++}}else e=t.dataSource.length}void 0===l&&(l=t._selectedIds.length),0===l||0===e?(a.classList.remove("selected","indeterminate"),a.firstElementChild.setAttribute("aria-checked",!1)):l===e+t._selectableGroupRecords.length?(a.classList.remove("indeterminate"),a.classList.add("selected"),a.firstElementChild.setAttribute("aria-checked",!0)):(a.classList.remove("selected"),a.classList.add("indeterminate"),a.firstElementChild.setAttribute("aria-checked","mixed"))}_resizeHandler(){const e=this;clearTimeout(e._resizeTimeout);const t=()=>{if(Smart.Utilities.Core.Browser.Firefox&&e.virtualization){const t=e.$.virtualizationContainer.$.verticalScrollBar.value;e._onVerticalChange({detail:{value:t}},!0)}};t(),"default"===e.columnSizeMode&&e._handleAutoSizeMode(),e._resizeTimeout=setTimeout((function(){if(e.columnGroups&&e._columns.some((e=>e.responsivePriority&&e.responsivePriority>1)))return void e.refresh();const a=e.offsetWidth,l=e.offsetHeight;if(e.virtualization&&e._cachedHeight!==l){const i=e._getFractionOfMax();return e._refreshDataRows(),e._setFractionOfMax(i),e._cachedWidth=a,e._cachedHeight=l,void t()}e._handleAutoSizeMode(),e._handleFrozenColumnPositions(),e._refreshHorizontalScrollbar(),e._cachedWidth=a,e._cachedHeight=l,t()}),75)}_hierarchyArrowClickHandler(e,t){const a=this,l=!a.grouping,i=e.data;if(a.animation=a._animation,l&&a.dataSource.virtualDataSource&&!i.expanded&&i.children&&0===i.children.length)return a._requestVirtualDataSource("expand",void 0,i),void a.$.fireEvent("expand",{id:i.$.id,record:i});if(a.virtualization)return void a._hierarchyArrowClickHandlerVirtualization(e,t);const n=a.$.tableContainer,r=i.$.id;function o(e){e.forEach((e=>{a._expandSingleChildRow(n.querySelector(`tr[row-id="${e.$.id}"]:not([unused])`)),e.children&&e.expanded&&requestAnimationFrame((()=>o(e.children)))}))}if(i.expanded?function e(t){t.forEach((t=>{a._collapseSingleChildRow(n.querySelector(`tr[row-id="${t.$.id}"]:not([unused])`)),t.children&&e(t.children)}))}(i.children):requestAnimationFrame((()=>o(i.children))),i.expanded=!i.expanded,e.setAttribute("aria-expanded",i.expanded),e.classList.toggle("expanded",i.expanded),l)i.expanded?(-1===a._expandedIds.indexOf(r)&&a._expandedIds.push(r),a.$.fireEvent("expand",{id:i.$.id,record:i})):(a._expandedIds=a._expandedIds.filter((e=>e!==r)),a.$.fireEvent("collapse",{id:i.$.id,record:i})),a._updateState("expanded");else if(!0!==t){let e=""+i.$.id;e=e.replace("Item","").replace(/_/gi,"."),i.expanded?a.$.fireEvent("group",{action:"expand",path:e,dataField:i.groupDataField,label:i.label}):a.$.fireEvent("group",{action:"collapse",path:e,dataField:i.groupDataField,label:i.label})}}_expandSingleChildRow(e,t=[]){e&&(t.push(!1),"none"!==this.animation?(e.classList.remove("smart-hidden"),requestAnimationFrame((()=>{e.classList.add("no-height"),e.ontransitionend=function(){e.classList.remove("no-height"),e.ontransitionend=null,t.pop()},e.removeAttribute("aria-hidden"),e.classList.remove("collapsed")}))):(e.removeAttribute("aria-hidden"),e.classList.remove("collapsed","smart-hidden"),t.pop()))}_collapseSingleChildRow(e,t=[]){e&&(t.push(!1),"none"!==this.animation?e.ontransitionend=function(){e.classList.add("smart-hidden"),e.ontransitionend=null,t.pop()}:(e.classList.add("smart-hidden"),t.pop()),e.setAttribute("aria-hidden",!0),e.classList.add("collapsed"))}_getGroupByIndex(e){"number"==typeof e&&(e=e.toString());const t=this.dataSource.boundHierarchy,a=e.split(".");let l=t[a[0]];if(l){for(let e=1;e<a.length;e++)if(l=l.children[a[e]],!l||l.leaf)return;return l}}getGroupChildren(e){"number"==typeof e&&(e=e.toString());const t=this.dataSource.boundHierarchy,a=e.split(".");let l=t[a[0]];if(!l)return[];for(let e=1;e<a.length;e++)if(l=l.children[a[e]],!l||l.leaf)return[];return l.children}_createDialog(){const e=this,t=document.createElement("smart-window"),a=document.createElement("template"),l=` animation=${e.animation} theme="${e.theme}"${e.rightToLeft?" right-to-left":""}${!e.keyboardNavigation||e.unfocusable?" unfocusable":""}`;a.innerHTML=`<smart-button class="ok primary"${l}>${e.localize("ok")}</smart-button>\n<smart-button class="cancel"${l}>${e.localize("cancel")}</smart-button>`,t.animation=e.animation,t.footerTemplate=a,t.headerButtons=["close"],t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.unfocusable=!e.keyboardNavigation||e.unfocusable,t.className="smart-table-window",t.ownerElement=e,e._dialog=t,e._addDialogHandlers(),e.getShadowRootOrBody().appendChild(t),e.setAttribute("aria-owns",t.id)}_addDialogHandlers(){const e=this,t=e._dialog;t.addEventListener("close",e._dialogEventHandler),t.addEventListener("click",e._dialogEventHandler)}_dialogEventHandler(e){const t=this,a=t.ownerElement,l=t.isInShadowDOM?e.composedPath()[0]:e.target,i=e.type,n=a.context;if(a.context=a,"close"===i){if(l!==t)return void(a.context=n);const e=t.classList.contains("conditional-formatting"),i=t.classList.contains("fields");t.ok?(e&&a._applyConditionalFormatting(),delete t.ok):e&&JSON.stringify(a._formattingPanel.items)!==JSON.stringify(a._formattingPanel.getItems())&&(a._formattingPanel.$.itemsContainer.innerHTML="",a._formattingPanel._addDefaultItems()),t.content.innerHTML="",t.classList.remove("conditional-formatting","drill-down","fields"),!a.keyboardNavigation||a.disabled||a.unfocusable||(a.$.tableContainer.setAttribute("tabindex",0),"smart-table"===a.nodeName.toLowerCase()&&(a.$.filterInput.unfocusable=!1,a.$.pager.unfocusable=!1),a.$.conditionalFormattingButton.unfocusable=!1),a.removeAttribute("modal"),e?a.$.conditionalFormattingButton.focus():i&&a.$.fieldsButton?a.$.fieldsButton.focus():a.$.tableContainer.focus()}else"click"===i&&t.$.footer.contains(l)&&(l.closest(".ok")?(t.ok=!0,t.close()):l.closest(".cancel")&&t.close());a.context=n}_openDialog(e,t,a){const l=this;l._dialog||l._createDialog();const i=l._dialog;i.label=e,i.classList.add(a),i.appendChild(t),l.$.tableContainer.removeAttribute("tabindex"),"smart-table"===l.nodeName.toLowerCase()&&(l.$.filterInput.unfocusable=!0,l.$.pager.unfocusable=!0),"drill-down"!==a?i.setAttribute("aria-controls",l.$.tableContainer.id):i.removeAttribute("aria-controls"),l.$.conditionalFormattingButton.unfocusable=!0,l.setAttribute("modal",""),i.open()}_conditionalFormattingButtonClickHandler(e,t,a){const l=this;let i;l._formattingPanel?i=l._formattingPanel:(i=document.createElement("smart-formatting-panel"),i.animation=l.animation,i.columns=t||l._columns,i.dataSource=a||l.dataSource,i.locale=l.locale,i.messages=l.messages,i.rightToLeft=l.rightToLeft,i.theme=l.theme,i.unfocusable=!l.keyboardNavigation||l.unfocusable,i.ownerElement=l,l._formattingPanel=i),l.conditionalFormatting&&(i.items=l.conditionalFormatting.slice(0)),l._openDialog(l.localize("conditionalFormatting"),i,"conditional-formatting")}_transformDataSource(){const e=this;if(!e.isRendered&&e.dataTransform){const t=e.dataSource;for(let a=0;a<t.length;a++)e.dataTransform(t[a])}}_applyInitialConditionalFormatting(e){const t=this,a=t.conditionalFormatting;if(!a||0===a.length)return void(t._conditionalFormatting=null);const l=t._defaults,i=new Smart.Utilities.ConditionalFormatter(e),n=[];let r;if("smart-pivot-table"===t.nodeName.toLowerCase()){const e=t._dynamicColumns;r=function(t){return"all"===t?e.map((e=>e.id)):e.filter((e=>e.dataFields[e.dataFields.length-1].dataField===t)).map((e=>e.id))}}else r=function(e){return"all"===e?t._columns.map((e=>e.value)):[e]};for(let e=0;e<a.length;e++){a[e]=Object.assign({column:"all",condition:"lessThan",firstValue:0,secondValue:1,fontFamily:l.fontFamily,fontSize:l.fontSize,text:l.text,highlight:l.highlight},a[e]);const t=a[e],o=r(t.column),s=t.condition;i.color=t.highlight,i.comparator=t.firstValue,i.min=t.firstValue,i.max=t.secondValue;const d=i.format(s,o);for(let e in d){const a=d[e];for(let e in a){const l=a[e];l.color=t.text,l.fontFamily=t.fontFamily,l.fontSize=t.fontSize}}n.push(d)}if(t._formattingPanel&&(t._formattingPanel.items=a.slice(0)),0===n.length)return n[0];const o={};for(let e=0;e<n.length;e++){const t=n[e];for(let e in t){const a=t[e];o[e]||(o[e]={});for(let t in a)o[e][t]=Object.assign({},o[e][t],a[t])}}t._conditionalFormatting=o}_toHex(e){if(-1!==e.indexOf("#"))return e;const t=/rgb\((\d+), (\d+), (\d+)\)/g.exec(e);return t?"#"+(parseFloat(t[1]).toString(16).padStart(2,"0")+parseFloat(t[2]).toString(16).padStart(2,"0")+parseFloat(t[3]).toString(16).padStart(2,"0")).toUpperCase():"#FFFFFF"}_applyConditionalFormatting(){const e=this,t=e._conditionalFormatting;e._conditionalFormatting=e._formattingPanel.apply(),e.conditionalFormatting=e._formattingPanel.getItems(),e._conditionalFormatting!==t&&e._refreshDataRows()}_updateState(e,t){const a=this;let l;if("selected"===e&&(l=a.getSelection(),a.selected=l),-1===a.stateSettings.indexOf(e))return;const i=a._state;switch(e){case"columns":i.columns=a._columns;break;case"expanded":i.expanded=a._expandedIds;break;case"filtered":i.filtered=a._filterInfo;break;case"grouped":i.grouped=a.dataSource.groupBy._array.slice(0);break;case"selected":i.selected=l;break;case"sorted":i.sorted=a._sortColumns||[]}a.autoSaveState&&a.isRendered&&!1!==t&&window.localStorage.setItem("smartTable"+a.id,a._stringifyState())}_stringifyState(){const e=this,t=JSON.parse(JSON.stringify(e._state));return["columns","expanded","filtered","grouped","selected","sorted"].forEach((a=>{-1===e.stateSettings.indexOf(a)&&delete t[a]})),JSON.stringify(t,(function(e,t){if(!("function"==typeof t||t instanceof HTMLElement||"sortOrder"===e||"thHierarchy"===e))return t}))}_handleAutoSizeMode(){const e=this;if("default"===e.columnSizeMode){const t=e._columns.filter((e=>e.visible)),a=[],l=t=>{const a=t.headerCellElement;if(!a)return;const l=parseInt(t.minWidth||e.columnMinWidth);a.offsetWidth<l?a.style.width=l+"px":(a.style.width="",a.offsetWidth<l&&(a.style.width=l+"px"))};t.forEach((t=>{if(t.width||t._manualWidth||(l(t),a.push(t)),t.width&&"string"==typeof t.width&&t.width.endsWith("%")){const a=e._getColumnWidth(t.width,!1,t);!1===t.autoWidth?t.headerCellElement.style.width=t.width:(t.headerCellElement.setAttribute("responsive-width",t.width),t.headerCellElement.style.width=a+"px")}else if(t._manualPercentageWidth)if(t._isResponsive){const a=e._getColumnWidth(t._manualPercentageWidth+"%",!1,t);!1===t.autoWidth?t.headerCellElement.style.width=t.width:(t.headerCellElement.setAttribute("responsive-width",t._manualPercentageWidth+"%"),t.headerCellElement.style.width=a+"px")}else t.headerCellElement.style.width=t._manualWidth+"px"}));for(let e=0;e<a.length;e++)l(a[e]);return}const t=e._columns.filter((e=>e.visible)),a=e._getNumericMinWidth();let l,i;t.forEach((e=>{e.width||e._manualWidth||(l||(l=e),i=e,e.headerCellElement.style.width=null)}));const n=e.$.tableContainer.offsetWidth-(e.selection?e.$.tableContainer.querySelector(".smart-table-select-all").offsetWidth:0);let r=new Map,o=0,s=0,d=0;e.removeAttribute("resize-max-reached"),e.setAttribute("auto-size",""),l&&(l.headerCellElement.style.width="100%");for(let i=0;i<t.length;i++){const n=t[i];if(n===l){d++;continue}const c=n.headerCellElement;let u,f;n.width?(u=f=e._getColumnWidth(n.width,!1,n),n.minWidth&&u<f&&(u=n.minWidth,f=n.minWidth)):n._manualWidth?(u=n._manualWidth,f=n.minWidth||a,u<f&&(u=f)):(u=Math.max(c.offsetWidth,a),f=n.minWidth||a,d++),o+=u,s+=f,n._isResponsive&&(u=e._getColumnWidth(n._manualPercentageWidth+"%",!1,n),u<f&&(u=f)),r.set(n,{width:u,minWidth:f})}function c(){l.headerCellElement.style.width=null;const e=Math.max(l.headerCellElement.offsetWidth,a),t=l.minWidth||a;r.set(l,{width:e,minWidth:t}),o+=Math.max(e,t),s+=t}if(l)if(l!==i)i.headerCellElement.style.width="100%",c(),i.headerCellElement.style.width=null;else if(t.length>1){const e=t.find((e=>e!==l));e.headerCellElement.style.width="100%",c(),e._isResponsive?e.headerCellElement.style.width=r.get(e).width+"%":e.headerCellElement.style.width=r.get(e).width+"px"}else c();if(n<=s||0===d)t.forEach((t=>{if(t._isResponsive){if(t.headerCellElement.style.width=(t._manualPercentageWidth?t._manualPercentageWidth+"%":r.get(t).minWidth)+"px",t._manualPercentageWidth){const a=e._getColumnWidth(t._manualPercentageWidth+"%",!1,t),l=t.minWidth||e.columnMinWidth;a===l&&(t.headerCellElement.style.width=l+"px")}}else t.headerCellElement.style.width=(t._manualWidth?t._manualWidth:r.get(t).minWidth)+"px"})),n<=s&&e.setAttribute("resize-max-reached","");else if(n>s)if(n<o){const a=[];let l,i=o-n,s=d;for(;i>0&&s>0;)l=Math.ceil(i/s),t.forEach((e=>{if(e.width||e._manualWidth||-1!==a.indexOf(e))return;const t=r.get(e);let n=Math.max(t.width-l,t.minWidth);const o=t.width-n;i-=o,n===t.minWidth&&(s--,a.push(e)),t.width=n}));t.forEach((t=>{if(t._isResponsive){if(t.headerCellElement.style.width=r.get(t).width+"%",t._manualPercentageWidth){const a=e._getColumnWidth(t._manualPercentageWidth+"%",!1,t),l=t.minWidth||e.columnMinWidth;a===l&&(t.headerCellElement.style.width=l+"px")}}else t.headerCellElement.style.width=r.get(t).width+"px"}))}else n===o?t.forEach((e=>{e._isResponsive?e.headerCellElement.style.width=r.get(e).width+"%":e.headerCellElement.style.width=r.get(e).width+"px"})):t.forEach((e=>{const t=r.get(e).width;e.headerCellElement.style.width=e===l?n-o+t+"px":t+"px"}));e.removeAttribute("auto-size")}_getNumericMinWidth(){const e=this,t=e.columnMinWidth;return"string"==typeof t&&-1!==t.indexOf("%")?e.offsetWidth*(parseFloat(t)/100):parseFloat(t)}_getCurrentResizeMax(){const e=this;if("default"===e.columnSizeMode)return 1/0;const t=e._resizeDetails,a=e._columns,l=a.find((e=>e.headerCellElement===t.Item)),i=a.indexOf(l);let n,r=a.length-1;for(let e=a.length-1;e>=0;e--)if(a[e].visible){r=e;break}if(i===r)return t.Item.offsetWidth;for(let t=i+1;t<a.length;t++){const l=a[t];t===r&&l.headerCellElement&&(n=l.headerCellElement.getBoundingClientRect()[e.rightToLeft?"left":"right"]+window.scrollX)}return n}_autoResizeColumnOnDblclick(){const e=this,t=e._resizeDetails,a=t.Item,l=e._columns.find((e=>e.headerCellElement!==a)).headerCellElement,i=l.style.width;e.setAttribute("auto-size",""),a.style.width=null,l.style.width="100%";let n=a.offsetWidth;l.style.width=i,e.removeAttribute("auto-size",""),n=Math.min(t.Max,Math.max(t.Min,n)),t.Width=n,e._resolveResize()}_isExpandCollapseForbidden(){const e=this;return(!e.hasAttribute("hierarchy")||e.grouping)&&"smart-pivot-table"!==e.nodeName.toLowerCase()}_selectSingle(e){const t=this,a=t.rowById?t.rowById[e]||t.dataSource.dataItemById[e]:t.rows.dataItemById[e];if(!a)return;const l=a.data?a.data.$.id:a.$.id;if(-1!==t._selectedIds.indexOf(l)||-1!==t._disabledSelection.indexOf(l))return;const i=t.$.tableContainer.querySelector(`tr[row-id="${l}"]:not([unused])`);if("one"===t.selectionMode&&(t._clearSelection(),t._selectedIds=[]),t._selectedIds.push(l),i){const e=i.firstElementChild;e.classList.remove("indeterminate"),e.classList.add("selected"),e.firstElementChild.setAttribute("aria-checked",!0),i.setAttribute("aria-selected",!0)}return t._handleHierarchicalSelection(a,!0),!0}_unselectSingle(e){const t=this,a=t.rowById?t.rowById[e]||t.dataSource.dataItemById[e]:t.rows.dataItemById[e];if(!a)return;const l=a.data?a.data.$.id:a.$.id,i=t._selectedIds.indexOf(l),n=t.$.tableContainer.querySelector(`tr[row-id="${l}"]:not([unused])`);if(-1!==i&&t._selectedIds.splice(i,1),n){const e=n.firstElementChild;e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1),n.setAttribute("aria-selected",!1)}return t._handleHierarchicalSelection(a,!1),!0}_changeSelectionOfMultiple(e,t,a="programmatic",l){const i=this;l||(l=JSON.stringify(i._selectedIds.slice(0).sort()));for(let a=0;a<e.length;a++)i[`_${t}Single`](e[a]);l!==JSON.stringify(i._selectedIds.slice(0).sort())&&(i._updateSelectAllState(),i._updateState("selected"),i.$.fireEvent("change",{type:a}))}_handleHierarchicalSelection(e,t){const a=this;if(!a.hasAttribute("hierarchy"))return;if(!1===a.selectionByHierarchy)return;const l=e.data;let i=l;for(l&&l.children&&function e(t,l){const i=t.children;let n=0;for(let t=0;t<i.length;t++){const r=i[t];if(!1===r.$.filtered)continue;let o=a._setThreeStateCheckbox(r,l);r.children&&r.children.length>0&&(o=e(r,l)),l&&!1===o&&n++}if(l&&n>0)return a._setThreeStateCheckbox(t,n!==i.length&&null)}(l,t);i&&i.parent;){const e=i.parent,t=a._getChildCheckState(e).state;a._setThreeStateCheckbox(e,t),i=e}}_getChildCheckState(e){const t=this,a=t._selectedIds,l=t._disabledSelection,i=e.children;if(!i||0===i.length||!t.selectionByHierarchy){const t=e.$.id,i=-1!==a.indexOf(t);return{state:i,maxSelected:!!i||-1!==l.indexOf(t)}}let n=!0,r=0,o=0,s=0;for(let e=0;e<i.length;e++){const a=i[e];if(!1===a.$.filtered)continue;const l=t._getChildCheckState(a);r++,l.state?o++:null===l.state?s++:!1===l.maxSelected&&(n=!1)}return 0!==o&&o===r?{state:!0,maxSelected:!0}:0===o&&0===s?{state:!1,maxSelected:n}:{state:null,maxSelected:n}}_setThreeStateCheckbox(e,t){const a=this,l=e.$.id,i=a._selectedIds,n=i.indexOf(l);t&&(-1!==a._disabledSelection.indexOf(l)?t=!1:-1===n&&i.push(l)),t||-1===n||i.splice(n,1);const r=a.$.tableContainer.querySelector(`tr[row-id="${l}"]:not([unused])`);if(!r)return t;const o=r.firstElementChild,s=o.firstElementChild;return t?(o.classList.remove("indeterminate"),o.classList.add("selected"),s.setAttribute("aria-checked",!0),r.setAttribute("aria-selected",!0)):!1===t?(o.classList.remove("selected","indeterminate"),s.setAttribute("aria-checked",!1),r.setAttribute("aria-selected",!1)):(o.classList.remove("selected"),o.classList.add("indeterminate"),s.setAttribute("aria-checked","mixed"),r.setAttribute("aria-selected",!1)),t}_getSelectableGroupRecords(){const e=this,t=e.dataSource,a=t.boundHierarchy;e._selectableGroupRecords=[],a?(function t(a){a.forEach((a=>{a.groupDataField&&(e._selectableGroupRecords.push(a.$.id),t(a.children))}))}(a),e._selectedIds=e._selectedIds.filter((a=>void 0!==t.dataItemById[a]||-1!==e._selectableGroupRecords.indexOf(a)))):e._selectedIds=e._selectedIds.filter((e=>void 0!==t.dataItemById[e]))}_clearSelection(e){const t=this;if(0===t._selectedIds.length)return;const a=t.$.tableContainer.querySelector(".smart-table-select-all");Array.from(t.$.tableContainer.querySelectorAll(".smart-table-select-row")).forEach((e=>{e.parentElement.classList.contains("disable-select")||e.parentElement.setAttribute("aria-selected",!1),e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1)})),a&&(a.classList.remove("indeterminate","selected"),a.firstElementChild.setAttribute("aria-checked",!1)),t._selectedIds=[],e&&(t._updateState("selected"),t.$.fireEvent("change",{type:"programmatic"}))}_updateCellsWithFormulas(e){const t=this,a=t.formulas,l=t._cellsWithFormulas;if(a||e)for(let e in l){const a=/(.+):(.+)/.exec(e),l=t.columnByDataField[a[1]],i=t.rowById[a[2]];if(!l||!i)continue;const n=t.$.tableContainer.querySelector(`tr[row-id="${i.data.$.id}"]:not([unused]) td[data-field="${l.dataField}"]`);n&&t._setCellContent(n,t._formatCellValue(i,l,n),n.classList.contains("tree-cell"))}}_createVirtualDataRows(e){const t=this,a=t.rowDetailTemplate,l=t.selection,i=t.hasAttribute("hierarchy"),n=document.createDocumentFragment(),r=t.$.virtualizationContainer,o=t.$.tableContainer,s=t._rowHeight;t.isRendered&&(r.scrollWidth=0,r.scrollHeight=0,r.$.scrollViewerContainer.classList.remove("hscroll","vscroll"));const d=r.$.scrollViewerContainer.offsetHeight-o.firstElementChild.offsetHeight-(t.filtering&&t.filterRow?s:0)-(t.footerRow?o.lastElementChild.offsetHeight:0),c=d<5,u=t._getVirtualRecords(i,c),f=u.length;let m=i?2*d:d+3*s,h=s*f,p=0;t._rowsVirtual=u,t._rowsInDOM=[];for(let e=0;e<f;e++){const r=u[e],o=r.data;if(!r.detail){if(o.groupDataField)t._rowsInDOM.push(t._createGroupHeader(o,n));else{const e=t._createDataRow(r,n,{hierarchical:i,rowDetailTemplate:a,selection:l,virtualization:!0});t._rowsInDOM.push(e.row),e.detail&&(t._rowsInDOM.push(e.detail),p+=t._rowDetailHeight,m+=t._rowDetailHeight)}if(p+=s,!c&&p>m)break}}e.appendChild(n),t._updateState("expanded"),e.parentElement||t.$.tableContainer.insertBefore(e,t.$.tableContainer.querySelector("tfoot")),r.refresh(),a&&(h+=t._expandedRowDetailIds.length*(t._rowDetailHeight-s));let g=Math.max(0,h-d);g>0&&r.computedHorizontalScrollBarVisibility&&(g+=r.$.horizontalScrollBar.offsetHeight),r.$.scrollViewerContentContainer.style.top=0,r.$.verticalScrollBar.max=g,t._scrollHeight=h,t._start={view:0,data:0},!c&&t._rowsInDOM.length>0&&r.$.scrollViewerContentContainer.offsetHeight<r.$.scrollViewerContainer.offsetHeight&&t._rowsInDOM[t._rowsInDOM.length-1].classList.add("last-row"),t._fixFrozenHeaderFirefox(),t._focusEquivalentCell()}_getVirtualRecords(e,t){const a=this,l=e&&!t?a.rows.filter((e=>0===e.data.level||!a._isCollapsed(e.data))):a.rows;if(e||!a.rowDetailTemplate)return l;const i=[];return l.forEach((e=>{i.push(e),-1!==a._expandedRowDetailIds.indexOf(e.data.$.id)&&i.push({detail:!0,data:e.data})})),i}_onVerticalChange(e,t){const a=this;if(a._ignoreVerticalChange)return;const l=a.rows,i=a._rowHeight,n=a.$.virtualizationContainer;let r,o,s=e.detail.value;if(Smart.Utilities.Core.Browser.Firefox&&a.virtualization&&(n.$.scrollViewerContentContainer.style.top=null),a.setAttribute("ignore-detail-animation",""),a._rowsInDOM.length===l.length||0===n.$.verticalScrollBar.max){const e=Math.floor(s/i);return a._start={view:e,data:e},n.$.scrollViewerContentContainer.style.top=-s+"px",requestAnimationFrame((()=>a.removeAttribute("ignore-detail-animation"))),void a._fixFrozenHeaderFirefox()}if(a._expandedRowDetailIds.length>0){let e,t=0;r=1;for(let l=0;l<a._rowsVirtual.length;l++){const i=t;if(a._rowsVirtual[l].detail?t+=a._rowDetailHeight:t+=a._rowHeight,void 0===o&&s<=t){o=l,e=s-i;break}}n.computedVerticalScrollBarVisibility?s=e+a._rowHeight:r=0}else{for(s=s%(2*i)+i,s<i&&(s+=i);s+n.$.scrollViewerContainer.offsetHeight>a.$.tableContainer.offsetHeight;)s-=i;r=Math.floor(s/i),o=Math.floor(e.detail.value/i),r<0&&(o-=r,r=0)}n.$.scrollViewerContentContainer.style.top=-s+"px",a._updateVisibleRows(r,o,t||a._expandedRowDetailIds.length>0),a._fixFrozenHeaderFirefox(),requestAnimationFrame((()=>a.removeAttribute("ignore-detail-animation")))}_fixFrozenHeaderFirefox(){const e=this;e.virtualization&&e.$.virtualizationContainer&&e.$.virtualizationContainer.$.scrollViewerContentContainer&&(e._tableHeader.style.top=-parseFloat(e.$.virtualizationContainer.$.scrollViewerContentContainer.style.top)+"px"),Smart.Utilities.Core.Browser.Firefox&&e.virtualization}_focusEquivalentCell(e){const t=this,a=t._focusedCell;if(!e&&!a)return;let l;if(!e){if(!a.parentElement)return;e={rowId:a.parentElement.data.$.id,dataField:a.getAttribute("data-field")}}l=e.dataField?t.$.tableContainer.querySelector(`tr[row-id="${e.rowId}"]:not([unused]) td[data-field="${e.dataField}"]`):t.$.tableContainer.querySelector(`tr[row-id="${e.rowId}"]:not([unused]) td.group-header`),t._focusCell(l)}_detachCachedTemplates(){const e=this;e._cachedTemplates&&(delete e._cachedTemplates,e._tableCachedTemplates&&(e._tableCachedTemplates.remove(),delete e._tableCachedTemplates))}_clearCachedTemplates(){const e=this;if(e._cachedTemplates&&Object.keys(e._cachedTemplates).length>0){e._tableCachedTemplates||(e._tableCachedTemplates=document.createElement("div"),e._tableCachedTemplates.style.display="none",document.body.appendChild(e._tableCachedTemplates));const t=document.createDocumentFragment();for(let a in e._cachedTemplates)t.appendChild(e._cachedTemplates[a]);e._tableCachedTemplates.appendChild(t)}}_updateVisibleRows(e,t,a){const l=this,i=t-e,n=l._rowsVirtual.length,r={hierarchical:l.hasAttribute("hierarchy"),selection:l.selection};let o;if(a=a&&(r.hierarchical||!!l.rowDetailTemplate),r.hierarchical&&!l.grouping&&(a=!0),l._sortColumns&&l._sortColumns.length>0&&(a=!0),l._focusedCell){const e=l._focusedCell.parentElement;e&&(o={rowId:e.data.$.id,dataField:l._focusedCell.getAttribute("data-field")})}for(let t=0;t<e;t++){const e=l._rowsInDOM[t];let n=i+t;n>=0&&(a||e.data.$.index!==n||e.data.detail)&&l._updateVisibleRow(e,n,r),e.setAttribute("unused",""),e.setAttribute("aria-hidden",!0),e.classList.remove("smart-table-row-detail")}for(let t=e;t<l._rowsInDOM.length;t++){const e=l._rowsInDOM[t],o=i+t;o<n?(e.removeAttribute("unused"),e.removeAttribute("aria-hidden"),(a||e.data.$.index!==o||e.data.parent)&&l._updateVisibleRow(e,o,r)):e.setAttribute("aria-hidden",!0)}l._start={view:e,data:t},l._focusEquivalentCell(o)}_updateVisibleRow(e,t,a){const l=this,i=l._columns.filter((e=>e.visible));if(!i.length)return;const n=l._rowsVirtual[t],r=n.data,o=r.$.id,s=Number(a.selection),d=!r.groupDataField&&!e.firstElementChild.classList.contains("group-header")&&!n.detail&&!e.classList.contains("smart-table-row-detail")&&e.childElementCount>1;if(e.className="",d){const t=e.attributes;for(;t.length>0;)e.removeAttribute(t[0].name)}else e.innerHTML="";if(r.groupDataField)l._createGroupHeader(r,void 0,e);else if(n.detail)l._createRowDetailOnDemand(e,n,r);else{e.setAttribute("aria-rowindex",r.$.index+1),l._processAndRenderSelection(r,e,a.hierarchical,d);for(let t=0;t<i.length;t++){const c=i[t];let u=d?e.children[t+s]:document.createElement("td"),f=!1;if(u&&(l.grouping&&!r.groupDataField||l.dataSource&&l.dataSource.groupBy&&l.dataSource.groupBy.length>0)&&u.removeAttribute("colspan"),!u){if(!d)continue;u=document.createElement("td"),f=!0,e.appendChild(u)}d&&(u.className=""),u.setAttribute("data-field",c.dataField),u.setAttribute("aria-colindex",t+1+s);let m,h=l._formatCellValue(n,c,u);if(f&&l._setCellContent(u,h,m),c.freeze&&u.classList.add("freeze-"+("far"===c.freeze?"far":"near")),c.responsivePriority&&u.classList.add("priority-"+c.responsivePriority),!1===c.allowEdit?(u.classList.add("no-edit"),u.setAttribute("aria-readonly",!0)):u.removeAttribute("aria-readonly"),0===t&&a.hierarchical){const e=l._areChildrenFiltered(r);r.leaf||(u.classList.add("tree-cell"),m=e),r.level&&(u.classList.add("outline-level-"+Math.min(r.level,10)),!r.leaf&&e||u.classList.add("tree-leaf"))}if(c.templateElement){if(f&&l.grouping){const e=c.templateElement+"",t=u;e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=e}else if(a.hierarchical&&l.grouping&&r.leaf){const e=c.templateElement+"",t=u;if((!t.firstElementChild||!(t.firstElementChild.hasAttribute("ng-version")||t.innerHTML.indexOf("ng-version")>=0))&&t.firstElementChild&&!t.firstElementChild.classList.contains(".smart-table-cell-template")){const a=t.innerHTML;e.substring(e.lastIndexOf("</"))!==a.substring(a.lastIndexOf("</"))&&(e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=e)}}if(m&&!u.querySelector(".hierarchy-arrow")){l._setCellContent(u,h,m);const e=u.children[0].children[1],t=c.templateElement+"";t.indexOf("{{value}}")>=0?e.innerHTML=t.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):e.innerHTML=t}else if(a.hierarchical&&!l.grouping&&r.leaf){const e=u;if(!e.firstElementChild||!(e.firstElementChild.hasAttribute("ng-version")||e.innerHTML.indexOf("ng-version")>=0)){l._setCellContent(u,h,!1);const t=c.templateElement+"";t.indexOf("{{value}}")>=0?e.innerHTML=t.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):e.innerHTML=t}}if(!d){const e=c.templateElement+"",t=m?u.children[0].children[1]:u;e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=e}let e=m?u.children[0].children[1].firstElementChild:u.firstElementChild;if(!e&&a.hierarchical){l._setCellContent(u,h,!1);const t=u,a=c.templateElement+"";a.indexOf("{{value}}")>=0?t.innerHTML=a.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=a,e=m?u.children[0].children[1].firstElementChild:u.firstElementChild}c.templateElementSettings?c.templateElementSettings(r[c.dataField],o,e):c.templateElement.indexOf("{{value}}")>=0&&(u.querySelector(".smart-table-cell-template").textContent=r[c.dataField])}else c.formatFunction,l._setCellContent(u,h,m);l.onCellRender&&l.onCellRender(r,c.dataField,r[c.dataField],u),l._applyConditionalFormattingToCell(u,c.dataField,r.$.index),d||e.appendChild(u)}e.data=r,e.setAttribute("row-id",o),-1!==l._disabledSelection.indexOf(o)&&(e.removeAttribute("aria-selected"),e.classList.add("disable-select"),a.selection&&e.firstElementChild.firstElementChild.setAttribute("aria-disabled",!0)),r.expanded?(-1===l._expandedIds.indexOf(o)&&l._expandedIds.push(o),e.setAttribute("aria-expanded",!0),e.classList.add("expanded")):!1===r.expanded&&e.setAttribute("aria-expanded",!1),r.level&&l._isCollapsed(r)&&(e.setAttribute("aria-hidden",!0),e.classList.add("collapsed","smart-hidden"))}}_createRowDetailOnDemand(e,t,a){const l=this,i=Number(l.selection)+l._columns.filter((e=>e.visible)).length;e.data=Object.assign(a,{detail:!0}),e.classList.add("smart-table-row-detail"),e.removeAttribute("aria-rowindex"),e.removeAttribute("row-id"),e.innerHTML=`<td colspan="${i}"><div class="smart-table-detail-container">${l._applyRowDetailTemplate(t)}</div></td>`}_hierarchyArrowClickHandlerVirtualization(e,t){const a=this,l=!a.grouping,i=a.$.tableContainer,n={nextRow:e.nextElementSibling,tbody:i.children[1]},r=e.data,o=[],s=[],d=Math.ceil((a.$.virtualizationContainer.$.scrollViewerContainer.offsetHeight-i.firstElementChild.offsetHeight)/a._rowHeight);function c(){0===o.length?function(){if(a._ignoreVerticalChange=!0,r.expanded=!r.expanded,l)r.expanded?(-1===a._expandedIds.indexOf(r.$.id)&&a._expandedIds.push(r.$.id),a.$.fireEvent("expand",{id:r.$.id,record:r})):(a._expandedIds=a._expandedIds.filter((e=>e!==r.$.id)),a.$.fireEvent("collapse",{id:r.$.id,record:r})),a._updateState("expanded");else if(!0!==t){const e=t=>{for(let a=0;a<t.length;a++){const l=t[a];if(l.$.id===r.$.id)return l;if(l.children){let t=e(l.children);if(t)return t}}return null},t=e(a.dataSource.boundHierarchy);t&&(t.expanded=r.expanded);let l=""+r.$.id;l=l.replace("Item","").replace(/_/gi,"."),r.expanded?a.$.fireEvent("group",{action:"expand",path:l,dataField:r.groupDataField,label:r.label}):a.$.fireEvent("group",{action:"collapse",path:l,dataField:r.groupDataField,label:r.label})}for(const e of s)e.remove();let e=a.$.virtualizationContainer.$.verticalScrollBar,i=a.$.virtualizationContainer.$.verticalScrollBar.value;a._refreshDataRows(),i=Math.min(e.max,i),e.value=i,delete a._ignoreVerticalChange,a._onVerticalChange({detail:{value:i}},!0)}():requestAnimationFrame((()=>c()))}function u(e){for(const t of e){if(s.length>=d)break;!1!==t.$.filtered&&(s.push(a._expandSingleChildRowVirtualization(t,n,o)),t.children&&t.expanded&&u(t.children))}}r.expanded?function e(t){t.forEach((t=>{a._collapseSingleChildRow(i.querySelector(`tr[row-id="${t.$.id}"]:not([unused])`),o),t.children&&e(t.children)}))}(r.children):requestAnimationFrame((()=>u(r.children))),e.setAttribute("aria-expanded",!r.expanded),e.classList.toggle("expanded",!r.expanded),requestAnimationFrame((()=>c()))}_expandSingleChildRowVirtualization(e,t,a){const l=this,i=l.rowById[e.$.id],n=document.createDocumentFragment();let r;if(i){if(r=i.data.groupDataField?l._createGroupHeader(i.data,n):l._createDataRow(i,n,{virtualization:!0,hierarchical:!0,selection:l.selection}).row,-1===[...t.tbody.children].indexOf(t.nextRow)){let a=!1;e.children&&0===e.children.length&&(a=!0),e.children||(a=!0),l._rowsInDOM&&l._rowsInDOM.length===l.rows.length&&(a=!0),a||t.tbody.appendChild(n)}else t.tbody.insertBefore(n,t.nextRow);return l._expandSingleChildRow(r,a),r}}_getFractionOfMax(){const e=this;return e.isRendered&&e.virtualization?{vertical:function(){const t=e.$.virtualizationContainer.$.verticalScrollBar,a=t.max;return 0===a?0:t.value/a}(),horizontal:function(){const t=e.$.virtualizationContainer.$.horizontalScrollBar,a=t.max;return 0===a?0:t.value/a}()}:null}_setFractionOfMax(e){if(!this.virtualization||null===e)return;const t=this.$.virtualizationContainer,a=t.$.verticalScrollBar,l=t.$.horizontalScrollBar;a.value=a.max*e.vertical,l.value=l.max*e.horizontal}_refreshHorizontalScrollbar(){const e=this.$.virtualizationContainer;if(!e)return;const t=e.$.scrollViewerContainer,a=e.$.horizontalScrollBar,l=e.$.verticalScrollBar,i=e.$.scrollViewerContentContainer.offsetWidth-t.offsetWidth;let n,r;i>0&&!t.classList.contains("hscroll")?(t.classList.add("hscroll"),n="add"):i<=0&&t.classList.contains("hscroll")&&(r=a.offsetHeight,t.classList.remove("hscroll"),n="subtract"),e.scrollWidth!==i&&(e.scrollWidth=i),e.computedVerticalScrollBarVisibility&&("add"===n?(r=a.offsetHeight,l.max+=r):"subtract"===n&&(l.max-=r))}_scrollToVirtualization(e,t){const a=this;if(!a.virtualization)return;const l=a.$.virtualizationContainer,i=l.$.scrollViewerContentContainer,n=l.$.verticalScrollBar,r=l.$.horizontalScrollBar,o=a.$.tableContainer,s=i.offsetLeft,d=i.offsetTop,c=n.value;let u,f;switch(t&&(u=t.offsetLeft,f=t.offsetTop),e){case"nextArrow":{if(!t||!l.computedHorizontalScrollBarVisibility)return;const e=s+u+t.offsetWidth-l.offsetWidth;e>0&&(r.value+=e+n.offsetWidth);break}case"prevArrow":if(!t||!l.computedHorizontalScrollBarVisibility||u>=-s)return;r.value=u-s-r.value;break;case"ArrowUp":{const e=o.firstElementChild.offsetHeight-d-f;if(e<=0)return;let t;if(a._focusedCell){const e=a._focusedCell.parentElement;e&&(t={rowId:e.data.$.id,dataField:a._focusedCell.getAttribute("data-field")})}const l=Math.max(0,c-e);l!==c&&(n.value=l,a._focusEquivalentCell(t));break}case"ArrowDown":{const e=d+f+t.offsetHeight-l.offsetHeight;if(e<=0)return;const a=Math.min(n.max,c+e);a!==c&&(n.value=a);break}case"Home":case"End":if(!l.computedHorizontalScrollBarVisibility)return;r.value="Home"===e?0:r.max}}_getExpandedGroups(e){const t=this,a=[];return e?(function e(l){l.forEach((l=>{l.expanded&&a.push({groupDataField:l.groupDataField,label:l.label,ancestorSignature:t._getGroupAncestorSignature(l)}),l.children&&l.children.length>0&&!1===l.children[0].leaf&&e(l.children)}))}(e),a):[]}_getGroupAncestorSignature(e){const t=[];let a=e.parent;for(;a;)t.push({groupDataField:a.groupDataField,label:a.label}),a=a.parent;return JSON.stringify(t)}_restoreExpandedGroups(e){if(0===e.length)return;const t=this,a=t.dataSource,l=[];!function a(i){i&&i.forEach((i=>{if(e.some((e=>e.groupDataField===i.groupDataField&&e.label===i.label&&e.ancestorSignature===t._getGroupAncestorSignature(i)))){let e=i.$.id;"string"==typeof e&&(e=e.replace("Item","").replace(/_/g,".")),l.push(e)}i.children&&i.children.length>0&&!1===i.children[0].leaf&&a(i.children)}))}(a.boundHierarchy);const i=t._doNotFireEvent;t._doNotFireEvent=!0,l.forEach((e=>t.expandGroup(e))),t._doNotFireEvent=i}});
154
154
 
155
155
  /***/ }),
156
156
 
@@ -295,7 +295,7 @@ var __webpack_exports__ = {};
295
295
  /* harmony import */ var _smart_ganttchart_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(859);
296
296
  /* harmony import */ var _smart_ganttchart_js__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(_smart_ganttchart_js__WEBPACK_IMPORTED_MODULE_24__);
297
297
 
298
- /* Smart UI v14.0.2 (2022-04-18)
298
+ /* Smart UI v14.0.34 (2022-05-09)
299
299
  Copyright (c) 2011-2022 jQWidgets.
300
300
  License: https://htmlelements.com/license/ */ //
301
301