smart-webcomponents-react 18.0.2 → 18.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/accordion.d.ts +2 -0
- package/accordion/accordion.esm.js +1 -1
- package/accordion/accordion.umd.js +2 -3
- package/accordion/accordionitem.d.ts +2 -0
- package/alertwindow/alertwindow.d.ts +2 -0
- package/alertwindow/alertwindow.esm.js +1 -1
- package/alertwindow/alertwindow.umd.js +2 -3
- package/array/array.d.ts +2 -0
- package/array/array.esm.js +1 -1
- package/array/array.umd.js +2 -3
- package/barcode/barcode.d.ts +2 -0
- package/barcode/barcode.esm.js +1 -1
- package/barcode/barcode.umd.js +2 -3
- package/breadcrumb/breadcrumb.d.ts +2 -0
- package/breadcrumb/breadcrumb.esm.js +1 -1
- package/breadcrumb/breadcrumb.umd.js +2 -3
- package/button/button.d.ts +2 -0
- package/button/button.esm.js +1 -1
- package/button/button.umd.js +2 -3
- package/button/buttongroup.d.ts +2 -0
- package/button/dropdownbutton.d.ts +2 -0
- package/button/multisplitbutton.d.ts +2 -0
- package/button/powerbutton.d.ts +2 -0
- package/button/radiobutton.d.ts +2 -0
- package/button/repeatbutton.d.ts +2 -0
- package/button/switchbutton.d.ts +2 -0
- package/button/togglebutton.d.ts +2 -0
- package/buttongroup/buttongroup.d.ts +2 -0
- package/buttongroup/buttongroup.esm.js +1 -1
- package/buttongroup/buttongroup.umd.js +2 -3
- package/calendar/calendar.d.ts +7 -0
- package/calendar/calendar.esm.js +13 -2
- package/calendar/calendar.umd.js +14 -4
- package/card/card.d.ts +2 -0
- package/card/card.esm.js +1 -1
- package/card/card.umd.js +2 -3
- package/card/cardview.d.ts +2 -0
- package/cardview/cardview.d.ts +2 -0
- package/cardview/cardview.esm.js +1 -1
- package/cardview/cardview.umd.js +2 -3
- package/carousel/carousel.d.ts +2 -0
- package/carousel/carousel.esm.js +1 -1
- package/carousel/carousel.umd.js +2 -3
- package/chart/chart.d.ts +2 -0
- package/chart/chart.esm.js +1 -1
- package/chart/chart.umd.js +2 -3
- package/chart/ganttchart.d.ts +2 -0
- package/chart/threedchart.d.ts +2 -0
- package/checkbox/checkbox.d.ts +2 -0
- package/checkbox/checkbox.esm.js +1 -1
- package/checkbox/checkbox.umd.js +2 -3
- package/checkinput/checkinput.d.ts +2 -0
- package/checkinput/checkinput.esm.js +1 -1
- package/checkinput/checkinput.umd.js +2 -3
- package/chip/chip.d.ts +2 -0
- package/chip/chip.esm.js +1 -1
- package/chip/chip.umd.js +2 -3
- package/colorinput/colorinput.d.ts +2 -0
- package/colorinput/colorinput.esm.js +1 -1
- package/colorinput/colorinput.umd.js +2 -3
- package/colorpanel/colorpanel.d.ts +2 -0
- package/colorpanel/colorpanel.esm.js +1 -1
- package/colorpanel/colorpanel.umd.js +2 -3
- package/colorpicker/colorpicker.d.ts +2 -0
- package/colorpicker/colorpicker.esm.js +1 -1
- package/colorpicker/colorpicker.umd.js +2 -3
- package/columnpanel/columnpanel.d.ts +2 -0
- package/columnpanel/columnpanel.esm.js +1 -1
- package/columnpanel/columnpanel.umd.js +2 -3
- package/combobox/combobox.d.ts +2 -0
- package/combobox/combobox.esm.js +1 -1
- package/combobox/combobox.umd.js +2 -3
- package/countryinput/countryinput.d.ts +2 -0
- package/countryinput/countryinput.esm.js +1 -1
- package/countryinput/countryinput.umd.js +2 -3
- package/customizationdialog/customizationdialog.d.ts +2 -0
- package/customizationdialog/customizationdialog.esm.js +1 -1
- package/customizationdialog/customizationdialog.umd.js +2 -3
- package/dateinput/dateinput.d.ts +2 -0
- package/dateinput/dateinput.esm.js +1 -1
- package/dateinput/dateinput.umd.js +2 -3
- package/daterangeinput/daterangeinput.d.ts +2 -0
- package/daterangeinput/daterangeinput.esm.js +1 -1
- package/daterangeinput/daterangeinput.umd.js +2 -3
- package/datetimepicker/datetimepicker.d.ts +2 -0
- package/datetimepicker/datetimepicker.esm.js +1 -1
- package/datetimepicker/datetimepicker.umd.js +2 -3
- package/dialogwindow/dialogwindow.d.ts +2 -0
- package/dialogwindow/dialogwindow.esm.js +1 -1
- package/dialogwindow/dialogwindow.umd.js +2 -3
- package/dockinglayout/dockinglayout.d.ts +2 -0
- package/dockinglayout/dockinglayout.esm.js +1 -1
- package/dockinglayout/dockinglayout.umd.js +2 -3
- package/dropdownbutton/dropdownbutton.d.ts +2 -0
- package/dropdownbutton/dropdownbutton.esm.js +1 -1
- package/dropdownbutton/dropdownbutton.umd.js +2 -3
- package/dropdownlist/dropdownlist.d.ts +2 -0
- package/dropdownlist/dropdownlist.esm.js +1 -1
- package/dropdownlist/dropdownlist.umd.js +2 -3
- package/editor/editor.d.ts +2 -0
- package/editor/editor.esm.js +1 -1
- package/editor/editor.umd.js +2 -3
- package/element/element.d.ts +2 -0
- package/element/element.esm.js +1 -1
- package/element/element.umd.js +2 -3
- package/fileupload/fileupload.d.ts +2 -0
- package/fileupload/fileupload.esm.js +1 -1
- package/fileupload/fileupload.umd.js +2 -3
- package/filterbuilder/filterbuilder.d.ts +2 -0
- package/filterbuilder/filterbuilder.esm.js +1 -1
- package/filterbuilder/filterbuilder.umd.js +2 -3
- package/filterpanel/filterpanel.d.ts +2 -0
- package/filterpanel/filterpanel.esm.js +1 -1
- package/filterpanel/filterpanel.umd.js +2 -3
- package/filterpanel/multicolumnfilterpanel.d.ts +2 -0
- package/form/form.d.ts +2 -0
- package/form/form.esm.js +1 -1
- package/form/form.umd.js +2 -3
- package/form/formcontrol.d.ts +2 -0
- package/form/formgroup.d.ts +2 -0
- package/ganttchart/ganttchart.d.ts +2 -0
- package/ganttchart/ganttchart.esm.js +1 -1
- package/ganttchart/ganttchart.umd.js +2 -3
- package/gauge/gauge.d.ts +2 -0
- package/gauge/gauge.esm.js +1 -1
- package/gauge/gauge.umd.js +2 -3
- package/grid/grid.d.ts +23 -12
- package/grid/grid.esm.js +25 -14
- package/grid/grid.umd.js +26 -16
- package/grouppanel/grouppanel.d.ts +2 -0
- package/grouppanel/grouppanel.esm.js +1 -1
- package/grouppanel/grouppanel.umd.js +2 -3
- package/index.d.ts +54 -3
- package/input/checkinput.d.ts +2 -0
- package/input/colorinput.d.ts +2 -0
- package/input/countryinput.d.ts +2 -0
- package/input/dateinput.d.ts +2 -0
- package/input/daterangeinput.d.ts +2 -0
- package/input/input.d.ts +2 -0
- package/input/input.esm.js +1 -1
- package/input/input.umd.js +2 -3
- package/input/multicomboinput.d.ts +2 -0
- package/input/multiinput.d.ts +2 -0
- package/input/numberinput.d.ts +2 -0
- package/input/passwordinput.d.ts +2 -0
- package/input/phoneinput.d.ts +2 -0
- package/input/timeinput.d.ts +2 -0
- package/kanban/kanban.d.ts +2 -0
- package/kanban/kanban.esm.js +1 -1
- package/kanban/kanban.umd.js +2 -3
- package/layout/dockinglayout.d.ts +2 -0
- package/layout/layout.d.ts +2 -0
- package/layout/layout.esm.js +1 -1
- package/layout/layout.umd.js +2 -3
- package/layout/layoutgroup.d.ts +2 -0
- package/layout/layoutitem.d.ts +2 -0
- package/layout/tablayoutgroup.d.ts +2 -0
- package/layout/tablayoutitem.d.ts +2 -0
- package/led/led.d.ts +2 -0
- package/led/led.esm.js +1 -1
- package/led/led.umd.js +2 -3
- package/listbox/listbox.d.ts +2 -0
- package/listbox/listbox.esm.js +1 -1
- package/listbox/listbox.umd.js +2 -3
- package/listmenu/listmenu.d.ts +2 -0
- package/listmenu/listmenu.esm.js +1 -1
- package/listmenu/listmenu.umd.js +2 -3
- package/map/map.d.ts +2 -0
- package/map/map.esm.js +1 -1
- package/map/map.umd.js +2 -3
- package/maskedtextbox/maskedtextbox.d.ts +2 -0
- package/maskedtextbox/maskedtextbox.esm.js +1 -1
- package/maskedtextbox/maskedtextbox.umd.js +2 -3
- package/menu/listmenu.d.ts +2 -0
- package/menu/menu.d.ts +2 -0
- package/menu/menu.esm.js +1 -1
- package/menu/menu.umd.js +2 -3
- package/menu/menuitem.d.ts +2 -0
- package/menu/menuitemsgroup.d.ts +2 -0
- package/multicolumnfilterpanel/multicolumnfilterpanel.d.ts +2 -0
- package/multicolumnfilterpanel/multicolumnfilterpanel.esm.js +1 -1
- package/multicolumnfilterpanel/multicolumnfilterpanel.umd.js +2 -3
- package/multicomboinput/multicomboinput.d.ts +2 -0
- package/multicomboinput/multicomboinput.esm.js +1 -1
- package/multicomboinput/multicomboinput.umd.js +2 -3
- package/multiinput/multiinput.d.ts +2 -0
- package/multiinput/multiinput.esm.js +1 -1
- package/multiinput/multiinput.umd.js +2 -3
- package/multilinetextbox/multilinetextbox.d.ts +2 -0
- package/multilinetextbox/multilinetextbox.esm.js +1 -1
- package/multilinetextbox/multilinetextbox.umd.js +2 -3
- package/multilinewindow/multilinewindow.d.ts +2 -0
- package/multilinewindow/multilinewindow.esm.js +1 -1
- package/multilinewindow/multilinewindow.umd.js +2 -3
- package/multisplitbutton/multisplitbutton.d.ts +2 -0
- package/multisplitbutton/multisplitbutton.esm.js +1 -1
- package/multisplitbutton/multisplitbutton.umd.js +2 -3
- package/numberinput/numberinput.d.ts +2 -0
- package/numberinput/numberinput.esm.js +1 -1
- package/numberinput/numberinput.umd.js +2 -3
- package/numerictextbox/numerictextbox.d.ts +2 -0
- package/numerictextbox/numerictextbox.esm.js +1 -1
- package/numerictextbox/numerictextbox.umd.js +2 -3
- package/package.json +1 -1
- package/pager/pager.d.ts +2 -0
- package/pager/pager.esm.js +1 -1
- package/pager/pager.umd.js +2 -3
- package/passwordinput/passwordinput.d.ts +2 -0
- package/passwordinput/passwordinput.esm.js +1 -1
- package/passwordinput/passwordinput.umd.js +2 -3
- package/passwordtextbox/passwordtextbox.d.ts +2 -0
- package/passwordtextbox/passwordtextbox.esm.js +1 -1
- package/passwordtextbox/passwordtextbox.umd.js +2 -3
- package/path/path.d.ts +2 -0
- package/path/path.esm.js +1 -1
- package/path/path.umd.js +2 -3
- package/phoneinput/phoneinput.d.ts +2 -0
- package/phoneinput/phoneinput.esm.js +1 -1
- package/phoneinput/phoneinput.umd.js +2 -3
- package/pivottable/pivottable.d.ts +2 -0
- package/pivottable/pivottable.esm.js +1 -1
- package/pivottable/pivottable.umd.js +2 -3
- package/progressbar/circularprogressbar.d.ts +2 -0
- package/progressbar/progressbar.d.ts +2 -0
- package/progressbar/progressbar.esm.js +1 -1
- package/progressbar/progressbar.umd.js +2 -3
- package/progresswindow/progresswindow.d.ts +2 -0
- package/progresswindow/progresswindow.esm.js +1 -1
- package/progresswindow/progresswindow.umd.js +2 -3
- package/promptwindow/promptwindow.d.ts +2 -0
- package/promptwindow/promptwindow.esm.js +1 -1
- package/promptwindow/promptwindow.umd.js +2 -3
- package/qrcode/qrcode.d.ts +2 -0
- package/qrcode/qrcode.esm.js +1 -1
- package/qrcode/qrcode.umd.js +2 -3
- package/querybuilder/querybuilder.d.ts +2 -0
- package/querybuilder/querybuilder.esm.js +1 -1
- package/querybuilder/querybuilder.umd.js +2 -3
- package/radiobutton/radiobutton.d.ts +2 -0
- package/radiobutton/radiobutton.esm.js +1 -1
- package/radiobutton/radiobutton.umd.js +2 -3
- package/rating/rating.d.ts +2 -0
- package/rating/rating.esm.js +1 -1
- package/rating/rating.umd.js +2 -3
- package/ribbon/ribbon.d.ts +2 -0
- package/ribbon/ribbon.esm.js +1 -1
- package/ribbon/ribbon.umd.js +2 -3
- package/ribbon/ribbongroup.d.ts +2 -0
- package/ribbon/ribbonitem.d.ts +2 -0
- package/ribbon/ribbontab.d.ts +2 -0
- package/scheduler/scheduler.d.ts +2 -0
- package/scheduler/scheduler.esm.js +1 -1
- package/scheduler/scheduler.umd.js +2 -3
- package/scrollbar/scrollbar.d.ts +2 -0
- package/scrollbar/scrollbar.esm.js +1 -1
- package/scrollbar/scrollbar.umd.js +2 -3
- package/slider/slider.d.ts +2 -0
- package/slider/slider.esm.js +1 -1
- package/slider/slider.umd.js +2 -3
- package/sortable/sortable.d.ts +2 -0
- package/sortable/sortable.esm.js +1 -1
- package/sortable/sortable.umd.js +2 -3
- package/sortpanel/sortpanel.d.ts +2 -0
- package/sortpanel/sortpanel.esm.js +1 -1
- package/sortpanel/sortpanel.umd.js +2 -3
- package/source/modules/smart.3dchart.js +1 -1
- package/source/modules/smart.accordion.js +1 -1
- package/source/modules/smart.array.js +1 -1
- package/source/modules/smart.barcode.js +1 -1
- package/source/modules/smart.breadcrumb.js +1 -1
- package/source/modules/smart.button.js +1 -1
- package/source/modules/smart.buttongroup.js +1 -1
- package/source/modules/smart.calendar.js +3 -3
- package/source/modules/smart.card.js +1 -1
- package/source/modules/smart.cardview.js +5 -5
- package/source/modules/smart.carousel.js +1 -1
- package/source/modules/smart.chart.js +2 -2
- package/source/modules/smart.checkbox.js +1 -1
- package/source/modules/smart.checkinput.js +2 -2
- package/source/modules/smart.chip.js +1 -1
- package/source/modules/smart.colorinput.js +2 -2
- package/source/modules/smart.colorpanel.js +1 -1
- package/source/modules/smart.colorpicker.js +1 -1
- package/source/modules/smart.combobox.js +1 -1
- package/source/modules/smart.common.js +3 -3
- package/source/modules/smart.countryinput.js +2 -2
- package/source/modules/smart.dateinput.js +3 -3
- package/source/modules/smart.daterangeinput.js +3 -3
- package/source/modules/smart.datetimepicker.js +3 -3
- package/source/modules/smart.dockinglayout.js +1 -1
- package/source/modules/smart.dropdownbutton.js +1 -1
- package/source/modules/smart.dropdownlist.js +1 -1
- package/source/modules/smart.editor.js +2 -2
- package/source/modules/smart.element.js +1 -1
- package/source/modules/smart.fileupload.js +1 -1
- package/source/modules/smart.form.js +3 -3
- package/source/modules/smart.formulaparser.js +1 -1
- package/source/modules/smart.ganttchart.js +6 -6
- package/source/modules/smart.gauge.js +1 -1
- package/source/modules/smart.grid.js +15 -15
- package/source/modules/smart.gridpanel.js +5 -5
- package/source/modules/smart.input.js +2 -2
- package/source/modules/smart.kanban.js +5 -5
- package/source/modules/smart.layout.js +1 -1
- package/source/modules/smart.led.js +1 -1
- package/source/modules/smart.listbox.js +1 -1
- package/source/modules/smart.listmenu.js +1 -1
- package/source/modules/smart.map.js +1 -1
- package/source/modules/smart.maskedtextbox.js +2 -2
- package/source/modules/smart.menu.js +1 -1
- package/source/modules/smart.multicomboinput.js +2 -2
- package/source/modules/smart.multiinput.js +2 -2
- package/source/modules/smart.multilinetextbox.js +1 -1
- package/source/modules/smart.multisplitbutton.js +1 -1
- package/source/modules/smart.numberinput.js +2 -2
- package/source/modules/smart.numerictextbox.js +1 -1
- package/source/modules/smart.pager.js +2 -2
- package/source/modules/smart.passwordinput.js +2 -2
- package/source/modules/smart.passwordtextbox.js +2 -2
- package/source/modules/smart.path.js +1 -1
- package/source/modules/smart.phoneinput.js +2 -2
- package/source/modules/smart.pivottable.js +6 -6
- package/source/modules/smart.progressbar.js +1 -1
- package/source/modules/smart.qrcode.js +1 -1
- package/source/modules/smart.querybuilder.js +3 -3
- package/source/modules/smart.radiobutton.js +1 -1
- package/source/modules/smart.rating.js +1 -1
- package/source/modules/smart.ribbon.js +2 -2
- package/source/modules/smart.router.js +2 -2
- package/source/modules/smart.scheduler.js +5 -5
- package/source/modules/smart.scrollbar.js +1 -1
- package/source/modules/smart.slider.js +1 -1
- package/source/modules/smart.sortable.js +1 -1
- package/source/modules/smart.splitter.js +1 -1
- package/source/modules/smart.switchbutton.js +1 -1
- package/source/modules/smart.table.js +4 -4
- package/source/modules/smart.tabs.js +1 -1
- package/source/modules/smart.tank.js +1 -1
- package/source/modules/smart.textarea.js +3 -3
- package/source/modules/smart.textbox.js +1 -1
- package/source/modules/smart.timeinput.js +2 -2
- package/source/modules/smart.timepicker.js +1 -1
- package/source/modules/smart.toast.js +1 -1
- package/source/modules/smart.tooltip.js +1 -1
- package/source/modules/smart.tree.js +2 -2
- package/source/modules/smart.validator.js +1 -1
- package/source/modules/smart.window.js +1 -1
- package/source/smart.3dchart.js +1 -1
- package/source/smart.accordion.js +1 -1
- package/source/smart.ajax.js +1 -1
- package/source/smart.array.js +1 -1
- package/source/smart.barcode.js +1 -1
- package/source/smart.bootstrap.js +1 -1
- package/source/smart.breadcrumb.js +1 -1
- package/source/smart.button.js +1 -1
- package/source/smart.buttongroup.js +1 -1
- package/source/smart.calendar.js +2 -2
- package/source/smart.card.js +1 -1
- package/source/smart.cardview.js +1 -1
- package/source/smart.carousel.js +1 -1
- package/source/smart.chart.annotations.js +1 -1
- package/source/smart.chart.api.js +1 -1
- package/source/smart.chart.core.js +1 -1
- package/source/smart.chart.js +1 -1
- package/source/smart.chart.rangeselector.js +1 -1
- package/source/smart.chart.waterfall.js +1 -1
- package/source/smart.checkbox.js +1 -1
- package/source/smart.checkinput.js +1 -1
- package/source/smart.chip.js +1 -1
- package/source/smart.colorinput.js +1 -1
- package/source/smart.colorpanel.js +1 -1
- package/source/smart.colorpicker.js +1 -1
- package/source/smart.combobox.js +1 -1
- package/source/smart.complex.js +1 -1
- package/source/smart.core.js +1 -1
- package/source/smart.countryinput.js +1 -1
- package/source/smart.data.js +2 -2
- package/source/smart.date.js +1 -1
- package/source/smart.dateformatpanel.js +1 -1
- package/source/smart.dateinput.js +1 -1
- package/source/smart.daterangeinput.js +1 -1
- package/source/smart.datetimepicker.js +1 -1
- package/source/smart.dockinglayout.js +1 -1
- package/source/smart.draw.js +1 -1
- package/source/smart.dropdownbutton.js +1 -1
- package/source/smart.dropdownlist.js +1 -1
- package/source/smart.editor.js +1 -1
- package/source/smart.element.js +1 -1
- package/source/smart.elements.js +16 -16
- package/source/smart.export.js +1 -1
- package/source/smart.fileupload.js +1 -1
- package/source/smart.filter.js +2 -2
- package/source/smart.filterbuilder.js +1 -1
- package/source/smart.filterpanel.js +2 -2
- package/source/smart.form.js +1 -1
- package/source/smart.format.js +1 -1
- package/source/smart.formulaparser.js +1 -1
- package/source/smart.ganttchart.js +2 -2
- package/source/smart.gauge.js +1 -1
- package/source/smart.grid.cell.js +2 -2
- package/source/smart.grid.chart.js +1 -1
- package/source/smart.grid.column.js +2 -2
- package/source/smart.grid.core.js +2 -2
- package/source/smart.grid.dialog.js +2 -2
- package/source/smart.grid.edit.js +2 -2
- package/source/smart.grid.export.js +1 -1
- package/source/smart.grid.filter.js +1 -1
- package/source/smart.grid.group.js +1 -1
- package/source/smart.grid.js +1 -1
- package/source/smart.grid.menu.js +1 -1
- package/source/smart.grid.pager.js +1 -1
- package/source/smart.grid.reorder.js +1 -1
- package/source/smart.grid.resize.js +1 -1
- package/source/smart.grid.row.js +2 -2
- package/source/smart.grid.select.js +2 -2
- package/source/smart.grid.sort.js +1 -1
- package/source/smart.grid.toolbar.js +1 -1
- package/source/smart.grid.tree.js +1 -1
- package/source/smart.grid.view.js +1 -1
- package/source/smart.gridpanel.js +1 -1
- package/source/smart.input.js +2 -2
- package/source/smart.kanban.js +1 -1
- package/source/smart.layout.js +1 -1
- package/source/smart.led.js +1 -1
- package/source/smart.listbox.js +1 -1
- package/source/smart.listmenu.js +1 -1
- package/source/smart.map.js +1 -1
- package/source/smart.maskedtextbox.js +1 -1
- package/source/smart.math.js +1 -1
- package/source/smart.menu.js +1 -1
- package/source/smart.multicomboinput.js +1 -1
- package/source/smart.multiinput.js +1 -1
- package/source/smart.multilinetextbox.js +1 -1
- package/source/smart.multisplitbutton.js +1 -1
- package/source/smart.numberformatpanel.js +1 -1
- package/source/smart.numberinput.js +1 -1
- package/source/smart.numeric.js +1 -1
- package/source/smart.numerictextbox.js +1 -1
- package/source/smart.pager.js +1 -1
- package/source/smart.passwordinput.js +1 -1
- package/source/smart.passwordtextbox.js +1 -1
- package/source/smart.path.js +1 -1
- package/source/smart.phoneinput.js +1 -1
- package/source/smart.pivottable.js +1 -1
- package/source/smart.powerbutton.js +1 -1
- package/source/smart.progressbar.js +1 -1
- package/source/smart.qrcode.js +1 -1
- package/source/smart.radiobutton.js +1 -1
- package/source/smart.rating.js +1 -1
- package/source/smart.ribbon.js +1 -1
- package/source/smart.router.js +1 -1
- package/source/smart.scheduler.js +1 -1
- package/source/smart.scrollbar.js +1 -1
- package/source/smart.slider.js +1 -1
- package/source/smart.sortable.js +1 -1
- package/source/smart.sparkline.js +6 -0
- package/source/smart.splitter.js +1 -1
- package/source/smart.switchbutton.js +1 -1
- package/source/smart.table.js +1 -1
- package/source/smart.tabs.js +1 -1
- package/source/smart.tank.js +1 -1
- package/source/smart.textarea.js +2 -2
- package/source/smart.textbox.js +1 -1
- package/source/smart.tickintervalhandler.js +1 -1
- package/source/smart.timeinput.js +1 -1
- package/source/smart.timepicker.js +1 -1
- package/source/smart.toast.js +1 -1
- package/source/smart.tooltip.js +1 -1
- package/source/smart.tree.js +2 -2
- package/source/smart.validationpanel.js +1 -1
- package/source/smart.validator.js +1 -1
- package/source/smart.window.js +1 -1
- package/source/styles/components/smart.grid.css +1 -1
- package/source/styles/components/smart.validator.css +1 -1
- package/source/styles/default/scss/smart.grid.scss +230 -168
- package/source/styles/default/scss/smart.validator.scss +1 -0
- package/source/styles/default/smart.grid.css +48 -9
- package/source/styles/default/smart.validator.css +123 -121
- package/source/styles/smart.default.css +2 -2
- package/source/typescript/smart.calendar.d.ts +5 -0
- package/source/typescript/smart.elements.d.ts +54 -3
- package/source/typescript/smart.grid.d.ts +33 -3
- package/source/typescript/smart.textarea.d.ts +5 -0
- package/source/typescript/smart.tree.d.ts +11 -0
- package/splitter/splitter.d.ts +2 -0
- package/splitter/splitter.esm.js +1 -1
- package/splitter/splitter.umd.js +2 -3
- package/splitter/splitterbar.d.ts +2 -0
- package/splitter/splitteritem.d.ts +2 -0
- package/switchbutton/switchbutton.d.ts +2 -0
- package/switchbutton/switchbutton.esm.js +1 -1
- package/switchbutton/switchbutton.umd.js +2 -3
- package/table/pivottable.d.ts +2 -0
- package/table/sortable.d.ts +2 -0
- package/table/table.d.ts +2 -0
- package/table/table.esm.js +1 -1
- package/table/table.umd.js +2 -3
- package/tabs/tabs.d.ts +2 -0
- package/tabs/tabs.esm.js +1 -1
- package/tabs/tabs.umd.js +2 -3
- package/tabs/tabswindow.d.ts +2 -0
- package/tabswindow/tabswindow.d.ts +2 -0
- package/tabswindow/tabswindow.esm.js +1 -1
- package/tabswindow/tabswindow.umd.js +2 -3
- package/tank/tank.d.ts +2 -0
- package/tank/tank.esm.js +1 -1
- package/tank/tank.umd.js +2 -3
- package/textarea/textarea.d.ts +7 -0
- package/textarea/textarea.esm.js +13 -2
- package/textarea/textarea.umd.js +14 -4
- package/textbox/maskedtextbox.d.ts +2 -0
- package/textbox/multilinetextbox.d.ts +2 -0
- package/textbox/numerictextbox.d.ts +2 -0
- package/textbox/passwordtextbox.d.ts +2 -0
- package/textbox/textbox.d.ts +2 -0
- package/textbox/textbox.esm.js +1 -1
- package/textbox/textbox.umd.js +2 -3
- package/threedchart/threedchart.d.ts +2 -0
- package/threedchart/threedchart.esm.js +1 -1
- package/threedchart/threedchart.umd.js +2 -3
- package/timeinput/timeinput.d.ts +2 -0
- package/timeinput/timeinput.esm.js +1 -1
- package/timeinput/timeinput.umd.js +2 -3
- package/timepicker/datetimepicker.d.ts +2 -0
- package/timepicker/timepicker.d.ts +2 -0
- package/timepicker/timepicker.esm.js +1 -1
- package/timepicker/timepicker.umd.js +2 -3
- package/toast/toast.d.ts +2 -0
- package/toast/toast.esm.js +1 -1
- package/toast/toast.umd.js +2 -3
- package/tooltip/tooltip.d.ts +2 -0
- package/tooltip/tooltip.esm.js +1 -1
- package/tooltip/tooltip.umd.js +2 -3
- package/tree/tree.d.ts +12 -0
- package/tree/tree.esm.js +9 -2
- package/tree/tree.umd.js +10 -4
- package/tree/treeitem.d.ts +2 -0
- package/tree/treeitemsgroup.d.ts +2 -0
- package/validator/validator.d.ts +2 -0
- package/validator/validator.esm.js +1 -1
- package/validator/validator.umd.js +2 -3
- package/waitwindow/waitwindow.d.ts +2 -0
- package/waitwindow/waitwindow.esm.js +1 -1
- package/waitwindow/waitwindow.umd.js +2 -3
- package/window/alertwindow.d.ts +2 -0
- package/window/dialogwindow.d.ts +2 -0
- package/window/multilinewindow.d.ts +2 -0
- package/window/progresswindow.d.ts +2 -0
- package/window/promptwindow.d.ts +2 -0
- package/window/tabswindow.d.ts +2 -0
- package/window/waitwindow.d.ts +2 -0
- package/window/window.d.ts +2 -0
- package/window/window.esm.js +1 -1
- package/window/window.umd.js +2 -3
|
@@ -17,14 +17,14 @@ Smart("smart-button",class extends Smart.ContentElement{static get properties(){
|
|
|
17
17
|
/***/ 5810:
|
|
18
18
|
/***/ (() => {
|
|
19
19
|
|
|
20
|
-
Smart("smart-calendar",class extends Smart.BaseElement{static get properties(){return{animationSettings:{value:null,type:"object"},calendarMode:{value:"default",allowedValues:["default","classic"],type:"string"},dayNameFormat:{value:"firstTwoLetters",allowedValues:["narrow","firstTwoLetters","long","short"],type:"string"},dateFormatFunction:{value:null,type:"function"},disableAutoNavigation:{value:!1,type:"boolean"},displayMode:{value:"month",allowedValues:["month","year","decade"],type:"string"},displayModeView:{value:"table",allowedValues:["table","list"],type:"string"},dropDownHeight:{value:"200",type:"string"},dropDownWidth:{value:"",type:"string"},firstDayOfWeek:{value:0,type:"number",defaultValue:0,validator:"_firstDayOfWeekValidator"},footerTemplate:{value:null,type:"any"},headerTemplate:{value:null,type:"any"},hideDayNames:{value:!1,type:"boolean"},hideOtherMonthDays:{value:!1,type:"boolean"},hideTooltipArrow:{value:!1,type:"boolean"},importantDates:{value:[],type:"array",defaultValue:[]},importantDatesTemplate:{value:null,type:"any"},max:{value:new Date(2100,0,1),type:"any",defaultValue:new Date(2100,0,1)},min:{value:new Date(1900,0,1),type:"any",defaultValue:new Date(1900,0,1)},months:{value:1,type:"number",defaultValue:1,validator:"_monthsValidator"},monthNameFormat:{value:"long",allowedValues:["narrow","firstTwoLetters","long","short","2-digit","numeric"],type:"string"},name:{value:"",type:"string"},restrictedDates:{value:[],type:"array",defaultValue:[]},scrollButtonsNavigationMode:{value:"landscape",allowedValues:["portrait","landscape"],type:"string"},scrollButtonsPosition:{value:"both",allowedValues:["near","far","both"],type:"string"},selectedDates:{value:[],reflectToAttribute:!1,type:"array"},selectionMode:{value:"default",allowedValues:["none","default","one","oneExtended","many","zeroOrMany","oneOrMany","zeroOrOne","week","range"],type:"string"},spinButtonsDelay:{value:80,type:"number"},spinButtonsInitialDelay:{value:0,type:"number"},titleTemplate:{value:null,type:"any"},tooltip:{value:!1,type:"boolean"},tooltipArrow:{value:!0,type:"boolean"},tooltipArrowDirection:{allowedValues:["bottom","top","left","right","none"],value:"bottom",type:"string"},tooltipDelay:{value:100,type:"number"},tooltipOffset:{value:[],type:"array"},tooltipPosition:{value:"auto",allowedValues:["auto","bottom","top","left","right","absolute"],type:"string"},tooltipTemplate:{value:null,type:"any"},view:{value:"portrait",allowedValues:["landscape","portrait"],type:"string"},viewSections:{value:["header"],type:"array"},weekNumbers:{value:!1,type:"boolean"},weeks:{value:6,type:"number",defaultValue:6,validator:"_weeksValidator"},yearFormat:{value:"numeric",allowedValues:["2-digit","numeric"],type:"string"}}}static get listeners(){return{"container.down":"_downHandler","document.up":"_documentUpHandler","body.move":"_moveHandler","container.wheel":"_containerWheelHandler","body.focus":"_bodyFocusStateHandler","body.blur":"_bodyBlurStateHandler","header.click":"_headerClickHandler","header.change":"_headerChangeHandler",keydown:"_keyDownHandler",keyup:"_keyUpHandler",mouseenter:"_mouseEventsHandler",mouseleave:"_mouseEventsHandler","container.mouseover":"_mouseEventsHandler","container.mouseout":"_mouseEventsHandler","container.open":"_popupEventHandler","container.close":"_popupEventHandler"}}static get methods(){return{select:"select(date=new Date(): date|string): void",clearSelection:"clearSelection(): void",today:"today(): date",navigate:"navigate(step: date|string|int): bool"}}static get styleUrls(){return["smart.calendar.css"]}template(){return'<div id="container" role="presentation">\n <div id="title" class="smart-calendar-title" role="heading" aria-level="1">\n <div id="yearContainer" class="smart-calendar-year-container" role="button"></div>\n <div id="dateContainer" class="smart-calendar-date-container smart-calendar-selected" role="button"></div>\n </div>\n <div id="calendarContainer" class="smart-calendar-container">\n <div id="header" class="smart-calendar-header">\n <smart-repeat-button prev-month class="smart-calendar-button" id="previousMonthButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Previous month">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n <div id="dateElement" class="smart-calendar-date-element" role="presentation">\n <div id="defaultHeaderDate" role="button"></div>\n <div id="classicHeaderDate">\n <div id="monthElement" class="smart-calendar-month-element" disabled="[[disabled]]" role="presentation">\n </div>\n <input class="smart-calendar-year-element" id="yearElement" disabled="[[disabled]]" readonly="[[readonly]]" aria-label="Year" />\n <span class="smart-calendar-year-elements">\n <smart-repeat-button next-year class="smart-calendar-button" id="nextYearButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Next year">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n <smart-repeat-button prev-year class="smart-calendar-button" id="previousYearButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Previous year">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n </span>\n </div>\n </div>\n <smart-repeat-button next-month class="smart-calendar-button" id="nextMonthButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Next month">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n </div>\n <div id="body" class="smart-content smart-calendar-body" role="presentation">\n <div id="monthsContainer" class="smart-calendar-months-container" role="presentation">\n <div id="month" class="smart-calendar-month" role="grid">\n <div id="monthName" class="smart-calendar-month-name"></div>\n <div id="weekTitles" class="smart-calendar-week-titles" role="row">\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n </div>\n <div id="weeks" class="smart-calendar-weeks" role="rowgroup">\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n </div>\n </div>\n </div>\n <div id="dateViewContainer" class="smart-calendar-date-view-container smart-hidden">\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n </div>\n <div id="monthsSeparator" class="smart-calendar-month-separator"></div>\n <div id="nextMonthsContainer" class="smart-calendar-next-months-container" aria-hidden="true"></div>\n <div id="animationPanel" class="smart-calendar-animation-panel smart-hidden"></div>\n </div>\n <div id="footer" class="smart-calendar-footer smart-hidden">\n <div id="selectedDatesRange"></div>\n </div>\n <input id="hiddenInput" type="hidden" name="[[name]]">\n </div>\n </div>'}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const a=e.dataset.property,n=e.selectedDates.toString();a&&void 0!==t[a]&&(t[a]=n)}}}propertyChangedHandler(e,t,a){super.propertyChangedHandler(e,t,a);const n=this;switch(e){case"animationSettings":n._applyAnimationSettings();break;case"disabled":case"unfocusable":n._setFocusable();break;case"calendarMode":case"dropDownWidth":case"dropDownHeight":n.displayMode="month",n._refreshHeaderElements(),n._refreshCalendarMode(),n._setDisplayModeContent();break;case"dayNameFormat":n._refreshDayOfWeekTitles(n.$.month);break;case"dateFormatFunction":{let e=n.$.monthsContainer.children;for(let t=0;t<e.length;t++)e[t].firstElementChild.innerHTML=a?a(e[t]._date):n._monthsNames[e[t]._date.getMonth()]+" "+e[t]._date.toLocaleDateString(n.locale,{year:n.yearFormat});n._refreshHeaderTitle();break}case"displayMode":if("classic"===n.calendarMode&&"month"!==a){n[e]="month";break}n._setDisplayMode(t,a);break;case"displayModeView":n._applyAnimationSettings(!0),"month"!==n.displayMode&&n._setDisplayModeContent();break;case"firstDayOfWeek":n._handleMonths(),n._refreshDayOfWeekTitles();break;case"hideTooltipArrow":n.$.tooltip&&(n.$.tooltip.arrow=!a);break;case"titleTemplate":case"headerTemplate":case"footerTemplate":n._handleLayoutTemplate(n.$[e.split(/[T]/)[0]],a),"titleTemplate"===e?n._refreshTitle():"headerTemplate"===e?n._refreshHeaderTitle():n._refreshFooter();break;case"importantDates":n.importantDates=n._getValidDates(a),n._refreshImportantDates();break;case"importantDatesTemplate":n._handleImportantDateTemplate(),n._refreshImportantDates();break;case"locale":n._refreshMonthNames(),n._refreshDayOfWeekTitles(),n._refreshHeaderTitle(),n._refreshTitle(),n._refreshFooter(),n.displayMode&&"month"!==n.displayMode&&n._setDisplayModeContent();break;case"max":case"min":n._validateMinMax(e,a,t),n._validateSelectedDates(),n._noFocusingRequired=!1,n._refreshHeaderElements();break;case"months":n._handleMonths();break;case"monthNameFormat":n._refreshCalendarMode(),n._refreshHeaderTitle();break;case"restrictedDates":n._setRestrictedDates(n.restrictedDates=n._getValidDates(a));break;case"rightToLeft":n._refreshDayOfWeekTitles(),n._handleMonths();break;case"scrollButtonsNavigationMode":n._setScrollButtonsNavigationMode();break;case"selectedDates":if(n._clearSelection(!0),n._validateSelectedDates(n._getValidDates(a)),n._applySelectionMode(!0),n._viewDates){let e=n.selectedDates[n.selectedDates.length-1];n._isDateInView(e)?n.selectedDates.map((e=>n._selectDate(e,!0,!0))):n._handleMonths(e)}n._refreshFooter(),n._setWeeksVisibility(n.$.monthsContainer),n.$.hiddenInput.value=n.selectedDates.toString(),n.isInitialized&&(n.$.fireEvent("change",{value:n.selectedDates}),n._updateTargetValue()),n._refreshTitle(),"month"!==n.displayMode&&n._setDisplayModeContent();break;case"selectionMode":n._applySelectionMode(!1,t),n._refreshTitle();break;case"tooltip":n._handleTooltip();break;case"tooltipArrow":case"tooltipArrowDirection":case"tooltipDelay":case"tooltipOffset":case"tooltipPosition":case"tooltipTemplate":if(n.$.tooltip){const t=e.replace("tooltip","");n.$.tooltip[t.charAt(0).toLowerCase()+t.slice(1)]=a}break;case"view":n._refreshTitle();break;case"viewSections":a.indexOf("title")>-1?n.$title.removeClass("smart-hidden"):n.$title.addClass("smart-hidden"),n._refreshTitle(),a.indexOf("header")>-1?n.$header.removeClass("smart-hidden"):n.$header.addClass("smart-hidden"),n._refreshHeaderTitle(),a.indexOf("footer")>-1?n.$footer.removeClass("smart-hidden"):n.$footer.addClass("smart-hidden"),n._refreshFooter(),n._setFocusable();break;case"weeks":n._setWeeksVisibility(n.$.monthsContainer);break;case"yearFormat":if(n._refreshCalendarMode(),n._refreshFooter(),n.months>1&&"month"===n.displayMode){let e=n._animationStarted?n.$.nextMonthsContainer.children:n.$.monthsContainer.children;for(let t=0;t<e.length;t++)e[t].firstElementChild.innerHTML=n.dateFormatFunction?n.dateFormatFunction(e[t]._date):n._monthsNames[e[t]._date.getMonth()]+" "+e[t]._date.toLocaleDateString(n.locale,{year:a})}n._refreshTitle(),n._refreshHeaderTitle()}}ready(){super.ready();const e=this;e._keysPressed={},e._applyAnimationSettings(),e.importantDates=e._getValidDates(e.importantDates),e.restrictedDates=e._getValidDates(e.restrictedDates)}render(){const e=this;e.setAttribute("role","dialog"),e._refreshMonthNames(),e._validateMinMax(),e._validateSelectedDates(e._getValidDates(e.selectedDates)),e._handleLayoutTemplate(e.$.title,e.titleTemplate),e._handleLayoutTemplate(e.$.header,e.headerTemplate),e._handleLayoutTemplate(e.$.footer,e.footerTemplate),e._handleImportantDateTemplate(),e._setFocusable(),e._refreshDayOfWeekTitles(),e._applySelectionMode(!0),e._handleMonths(0===e.selectedDates.length?new Date((new Date).setHours(0,0,0,0)):e.selectedDates[e.selectedDates.length-1]),e._handleTooltip(),e._updateViewSectionsVisibility(),e._setScrollButtonsNavigationMode(),e._refreshCalendarMode(),e._setDisplayMode(),e._refreshTitle(),e._refreshFooter(),e._refreshImportantDates(),e.$.monthElement&&e.$.monthElement._setDropDownSize&&e.$.monthElement._setDropDownSize(),e._changeEventFired=0,e.$.hiddenInput.value=e.selectedDates.toString(),e.shadowRoot&&e.appendChild(e.$.hiddenInput),e.isInitialized=!0,super.render()}refresh(){this.isInitialized&&this.render()}_updateViewSectionsVisibility(){const e=this;e.viewSections.indexOf("title")>-1?e.$title.removeClass("smart-hidden"):e.$title.addClass("smart-hidden"),e.viewSections.indexOf("header")>-1?e.$header.removeClass("smart-hidden"):e.$header.addClass("smart-hidden"),e.viewSections.indexOf("footer")>-1?e.$footer.removeClass("smart-hidden"):e.$footer.addClass("smart-hidden")}clearSelection(){this._clearSelection()}_setFocusable(){const e=this;let t=e.tabIndex>0?e.tabIndex:0;function a(e,a){if(a)return e&&e instanceof a?("function"==typeof e._setFocusable&&e.isCompleted?e.unfocusable=t<=-1:e.setAttribute("tabindex",t),e):e||void 0}(e.disabled||e.unfocusable)&&(t=-1),e.$.previousMonthButton=a(e.$.previousMonthButton,Smart.Button),e.$.nextMonthButton=a(e.$.nextMonthButton,Smart.Button),e.$.nextYearButton=a(e.$.nextYearButton,Smart.Button),e.$.previousYearButton=a(e.$.previousYearButton,Smart.Button),e.$.monthElement=a(e.$.monthElement,Smart.Input),e.$.yearElement=a(e.$.yearElement,HTMLInputElement),e.viewSections.indexOf("title")>-1&&(e.$.dateContainer.setAttribute("tabindex",t),e.$.yearContainer.setAttribute("tabindex",t)),e.$.body.setAttribute("tabindex",t),"default"===e.calendarMode?e.$.dateElement.setAttribute("tabindex",t):e.$.dateElement.removeAttribute("tabindex"),e.unfocusable?e.removeAttribute("tabindex"):e.tabIndex=e.readonly&&!e.disabled?e.tabIndex>0?e.tabIndex:0:t}static get requires(){return{"Smart.DropDownList":"smart.dropdownlist.js","Smart.ListBox":"smart.listbox.js","Smart.RepeatButton":"smart.button.js","Smart.Tooltip":"smart.tooltip.js"}}navigate(e){const t=this;let a,n,l;if(e){if("number"==typeof e){if(e=parseInt(e),isNaN(e)||0===e)return!1;if(6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode){let l,i;t._focusedCell||t._focusCell();const s=[].slice.call(t._focusedCell.closest(".smart-calendar-weeks").children).filter((e=>!e.classList.contains("smart-hidden")));e<0?(i=s[0].querySelectorAll(".smart-calendar-cell"),l=t.rightToLeft?i[i.length-1]:i[0]):(i=s[s.length-1].querySelectorAll(".smart-calendar-cell"),l=t.rightToLeft?i[0]:i[i.length-1]),n=new Date(l.value),n.setDate(n.getDate()+e),a=n}else a=t._getNextDate(e)}else{if(a=e=t._getValidDate(e),l=!0,isNaN(a.getTime()))return!1;const i=t._viewDates[0];if(i&&a.getMonth()===i.getMonth()&&a.getFullYear()===i.getFullYear())return!1;6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&(n=a)}return!(!a||t.$.fireEvent("navigationChanging",{value:new Date(a),type:t.displayMode}).defaultPrevented||("month"!==t.displayMode?(!l&&t.hasAnimation?(t.$nextMonthsContainer.addClass("smart-calendar-date-view-container"),"list"===t.displayModeView?t._setDisplayModeContent(a):t._navigationDate&&t._navigationDate.getTime()===a.getTime()||t._animateNavigation(a,e)):t._setDisplayModeContent(a),t.$.fireEvent("navigationChange",{value:new Date(a),type:t.displayMode}),0):(t.hasAnimation?(t._animateNavigation(a,e),t.$nextMonthsContainer.hasClass("smart-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-date-view-container")):(t._handleMonths(a),t._refreshHeaderElements(),t._refreshHeaderTitle()),n&&(t._focusCell(t._getCellByDate(n,t._animationStarted?t.$.nextMonthsContainer:void 0),!0),t._updateWeeksVisibility(e)),t.$.fireEvent("navigationChange",{value:new Date(a),type:t.displayMode}),0)))}}set value(e){this._select(e)}get value(){return this.selectedDates&&this.selectedDates.length>0?this.selectedDates[0]:null}select(e){this._select(e)}_select(e){const t=this;t._viewDates&&void 0!==t._viewDates[0]&&"none"!==t.selectionMode&&e&&(e=t._getValidDate(e))instanceof Date&&("one"===t.selectionMode&&t.selectedDates.map(Number).indexOf(e.getTime())>-1||e.getTime()<t.min.getTime()||e.getTime()>t.max.getTime()||("one"!==t.selectionMode&&"default"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._clearSelection(!0),t._selectDate(e),1!==t.selectedDates.length||t._isDateInView(t.selectedDates[0])||t._handleMonths(t.selectedDates[0])))}today(){const e=this;let t=new Date;return t.setHours(0,0,0,0),t.getTime()<e.min.getTime()||t.getTime()>e.max.getTime()?t=new Date(e.max):e._selectDate(t),e._handleMonths(t),t}_animateNavigation(e,t,a){const n=this;n._navigationDate=e,n._animationSettings||n._applyAnimationSettings(),n.$animationPanel.addClass("smart-hidden"),n.$.dateViewContainer.style.transform="",n.$.dateViewContainer.style.opacity="",n.$.monthsContainer.style.transform="",n.$.monthsContainer.style.opacity="";const l="month"!==n.displayMode?n.$.dateViewContainer:n.$.monthsContainer,i=n.$.body[n._animationSettings.scrollMax]-n.$.body[n._animationSettings.size];n._scrollStep=n.$.body[n._animationSettings.size]*n._animationSettings.startSpeed,n._animationStarted&&n._getMonthCells(n.$.monthsContainer,n.rightToLeft).map((e=>{n._setCellState(e,"restricted",!1),n._setCellState(e,"selected",!1),n._setCellState(e,"otherMonth",!1),n._setCellState(e,"focus",!1),n._setCellState(e,"important",!1),n._setCellState(e,"today",!1),n._setCellState(e,"disabled",!1),n._setCellState(e,"hover",!1)})),n._animationStarted=!0,"month"!==n.displayMode?(n._setCellState(n._focusedCell,"focus",!1),n._setDisplayModeContent(e,n.$.nextMonthsContainer)):n._handleMonths(e,n.$.nextMonthsContainer),n.rightToLeft&&(t*=-1),a||(t>0?(l.style.order=1,n.$.nextMonthsContainer.style.order=3,(!n._animationStarted||n._animationStarted&&n.$.body[n._animationSettings.scrollSize]>n.$.body[n._animationSettings.scrollMax]*n._animationSettings.resetThreshold*2)&&(n.$.body[n._animationSettings.scrollSize]=0)):(l.style.order=3,n.$.nextMonthsContainer.style.order=1,(!n._animationStarted||n._animationStarted&&n.$.body[n._animationSettings.scrollSize]<n.$.body[n._animationSettings.scrollMax]*n._animationSettings.resetThreshold)&&(n.$.body[n._animationSettings.scrollSize]=n.$.body[n._animationSettings.scrollMax]))),cancelAnimationFrame(n._animationId),n._animationId=requestAnimationFrame((function e(){let a=t>0?n.$.body[n._animationSettings.scrollSize]>=i:0===n.$.body[n._animationSettings.scrollSize],l=n._scrollStep/2;a?n._animateNavigationCompleted():(t>0&&n.$.body[n._animationSettings.scrollSize]>i*n._animationSettings.easeThreshold?(l=Math.max(n.$.body[n._animationSettings.scrollSize]/n._animationSettings.stepEaseSize,Math.abs(l-(i-n.$.body[n._animationSettings.scrollSize])*n._animationSettings.step)),n._scrollStep=n._scrollStep*n._animationSettings.step+l):t<0&&n.$.body[n._animationSettings.scrollSize]<i*n._animationSettings.easeThreshold&&(l=Math.max(n.$.body[n._animationSettings.scrollMax]/n._animationSettings.stepEaseSize,Math.abs(l-n.$.body[n._animationSettings.scrollSize]*n._animationSettings.step)),n._scrollStep=n._scrollStep*n._animationSettings.step+l),n.$.body[n._animationSettings.scrollSize]+=t>0?n._scrollStep:-n._scrollStep,n._animationId=requestAnimationFrame(e))}))}_animateNavigationCompleted(){const e=this;let t,a,n,l="month"!==e.displayMode?e.$.dateViewContainer:e.$.monthsContainer;if(cancelAnimationFrame(e._animationId),"month"!==e.displayMode){let i=[].slice.call(l.children).indexOf(e._focusedCell);l.innerHTML=e.$.nextMonthsContainer.innerHTML;let s,o=l.children[i];a=l.children,n=e.$.nextMonthsContainer.children;for(let t=0;t<a.length;t++)a[t].value=n[t].value,a[t].restricted=n[t].restricted,a[t].important=n[t].important,a[t].otherMonth=n[t].otherMonth,a[t].value.getTime()<=e.max.getTime()&&(s=a[t]);t=o&&o.value.getTime()>=e.max.getTime()?s.value:e._focusedCell?e._focusedCell.value:void 0}else{let i=l.children,s=e.$.nextMonthsContainer.children;e._focusedCell&&e.$.nextMonthsContainer.contains(e._focusedCell)&&(t=e._focusedCell.value);for(let t=0;t<i.length&&s[t]._date;t++){i[t]._date=s[t]._date,i[t].innerHTML=s[t].innerHTML,a=e._getMonthCells(i[t]),n=e._getMonthCells(s[t]);for(let e=0;e<a.length;e++)a[e].value=n[e].value,a[e].restricted=n[e].restricted,a[e].important=n[e].important,a[e].otherMonth=n[e].otherMonth,a[e].removeAttribute("focus")}e._selectedCells.length>0&&(e._selectedCells=e._selectedCells.map((t=>e._getCellByDate(t.value))).filter((e=>void 0!==e)))}e._focusCell(e._getCellByDate(t)),l.style.order=1,e.$.nextMonthsContainer.style.order=3,e.$.body[e._animationSettings.scrollSize]=0,e._animationStarted=!1,delete e._navigationDate}_applyAnimationSettings(e){const t=this;t._animationSettings=t.animationSettings?t.animationSettings:t._animationSettings||{},"portrait"===t.scrollButtonsNavigationMode?(t._animationSettings.scrollMax="scrollHeight",t._animationSettings.size="offsetHeight",t._animationSettings.scrollSize="scrollTop"):(t._animationSettings.scrollMax="scrollWidth",t._animationSettings.size="offsetWidth",t._animationSettings.scrollSize="scrollLeft"),e||(t._animationSettings.startSpeed=t._animationSettings.startSpeed?t._animationSettings.startSpeed:.2,t._animationSettings.easeThreshold=t._animationSettings.easeThreshold?t._animationSettings.easeThreshold:.5,t._animationSettings.step=t._animationSettings.step?t._animationSettings.step:.25,t._animationSettings.stepEaseSize=t._animationSettings.stepEaseSize?t._animationSettings.stepEaseSize:200,t._animationSettings.resetThreshold=t._animationSettings.resetThreshold?t._animationSettings.resetThreshold:.2)}_applySelectionMode(e,t){const a=this;let n=[],l=!!e,i=a.selectionMode;function s(e,t){const n=a.$.monthsContainer.children;for(let l=0;l<n.length;l++)a._getMonthCells(n[l]).map((n=>{a._setCellState(n,e,t)}))}switch("many"===i&&"range"===i||s("hover",!1),a._newRangeSelectionStarted=a.selectedDates.length>0&&"range"===i,-1!==["default","many","zeroOrMany","oneOrMany","week","range"].indexOf(i)?Array.from(a.getElementsByClassName("smart-calendar-month")).forEach((e=>e.setAttribute("aria-multiselectable",!0))):Array.from(a.getElementsByClassName("smart-calendar-month")).forEach((e=>e.removeAttribute("aria-multiselectable"))),"none"!==i&&"none"!==t||s("selected",!1),i){case"none":return void a._clearSelection(l);case"range":return void(a.selectedDates.length>1&&a._selectMultipleDates(a.selectedDates[0],a.selectedDates[a.selectedDates.length-1]));case"many":case"default":case"oneOrMany":if(0===a.selectedDates.length){n.push(new Date(Math.min(Math.max(a.min.getTime(),(new Date).setHours(0,0,0,0)),a.max.getTime())));break}return;case"oneExtended":case"one":if(1===a.selectedDates.length)return;a.selectedDates.length>1?(n.push(a.selectedDates[a.selectedDates.length-1]),a._clearSelection(l)):n.push(new Date(Math.min(Math.max(a.min.getTime(),(new Date).setHours(0,0,0,0)),a.max.getTime())));break;case"zeroOrOne":if(a.selectedDates.length>1){n.push(a.selectedDates[a.selectedDates.length-1]),a._clearSelection(l);break}return;case"zeroOrMany":return;case"week":if(a.selectedDates.length>=1){let e=a.selectedDates[a.selectedDates.length-1];for(let t=0;t<7;t++)n.push(new Date(e)),e.setDate(e.getDate()+1);a._clearSelection(l)}}if(a.selectedDates=[],e)return void(a.selectedDates=n);const o=n.length;for(let e=0;e<o;e++)a._selectDate(n[e],e<o-1)}_clearSelection(e){const t=this,a=t.selectedDates.slice(0),n=t.selectionMode;if(t.isRendered){if(t._selectedCells&&t._selectedCells.map((e=>{t._setCellState(e,"selected",!1)})),t.selectedDates=[],t._selectedCells=[],"many"===n||"range"===n){const e=t.$.monthsContainer.children;for(let a=0;a<e.length;a++)t._getMonthCells(e[a]).map((e=>{t._setCellState(e,"hover",!1)}))}t.$.footer&&t._refreshFooter(),t.$.hiddenInput.value=t.selectedDates.toString(),!e&&t.isInitialized&&a.length&&(t.$.fireEvent("change",{value:[]}),t._updateTargetValue()),t.$.title&&t._refreshTitle()}else t.set("selectedDates",[])}_bodyBlurStateHandler(e){this._bodyStateHandler(e),this.$.fireEvent("blur")}_bodyFocusStateHandler(e){this._bodyStateHandler(e),this.$.fireEvent("focus")}_bodyStateHandler(e){const t=this;if(t._focusedCell){if("blur"===e.type||"focus"===e.type&&t._noFocusingRequired)return t._noFocusingRequired=!1,void t._setCellState(t._focusedCell,"focus",!1);if("month"!==t.displayMode)return void("focus"!==e.type||t.$.dateViewContainer.querySelector("smart-calendar-cell[focus]")||t._setCellState(t._focusedCell||t.$.dateViewContainer.querySelector(".smart-calendar-cell"),"focus",!0))}"focus"===e.type&&t._focusCell()}_containerWheelHandler(e){const t=this;if(t.disabled||t.readonly||"month"!==t.displayMode&&"list"===t.displayModeView)return;let a,n;n=document.activeElement,t.shadowRoot?n=t.shadowRoot.activeElement:t.isInShadowDOM&&(n=t.getRootNode().activeElement),t.$.yearElement===n&&(a=12),(n&&t.shadowRoot||n.closest("smart-calendar")===t)&&(a=e.target===t.$.yearElement?12:1),a&&(e.preventDefault(),a=12===a?a:a*t.months,e.deltaY>0?t.navigate(-a):t.navigate(a))}_downHandler(e){const t=this;let a=e.originalEvent.target;if(t._dragStartDetails=void 0,t.disabled||t.readonly)return;if(t.hasRippleAnimation&&(a.value instanceof Date||a.parentElement&&a.parentElement.classList.contains("smart-calendar-title")||a.parentElement===t.$.dateElement)&&Smart.Utilities.Animation.Ripple.animate(a,e.pageX,e.pageY),a=e.originalEvent.target.closest(".smart-calendar-header"),e.originalEvent.target.closest(".smart-calendar-year-container")&&"decade"!==t.displayMode){if("classic"===t.calendarMode)return;return void t._showDateView("year")}if(e.originalEvent.target.closest(".smart-calendar-date-container")&&"month"!==t.displayMode){if("classic"===t.calendarMode)return;return void t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell,"month")}if(t._animationStarted&&t._animateNavigationCompleted(),Smart.Utilities.Core.isMobile&&e.originalEvent.target.closest(".smart-calendar-body")===t.$.body)return void(t._dragStartDetails={x:e.pageX,y:e.pageY,startTime:Date.now(),target:e.originalEvent.target});if(a=e.originalEvent.target,a.closest(".smart-calendar-week")||a.parentElement===t.$.dateViewContainer){for(;a&&!(a.value instanceof Date);)a=a.parentElement;return void(a&&("month"!==t.displayMode?t._displayModeHandler(a):t._weeksDownHandler(e,a)))}if(a.closest(".smart-calendar-month-element"))return;if(e.originalEvent.stopPropagation(),"list"===t.displayModeView&&"month"!==t.displayMode)return a=(t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target).closest("smart-list-item"),void(a&&t._displayModeHandler(a));const n=document.scrollingElement||document.documentElement,l=n.scrollLeft,i=n.scrollTop;t.unfocusable||t.focus(),window.scrollTo(l,i)}_displayModeHandler(e,t){const a=this;if(a._animationStarted&&a._animateNavigationCompleted(),e instanceof HTMLElement&&e.closest(".smart-calendar-week")&&e.otherMonth){if("decade"===a.displayMode&&(e.value.getFullYear()<a.min.getFullYear()||e.value.getFullYear()>a.max.getFullYear()))return;if("year"===a.displayMode&&(e.value.getFullYear()<a.min.getFullYear()||e.value.getFullYear()===a.min.getFullYear()&&e.value.getMonth()<a.min.getMonth()||e.value.getFullYear()>a.max.getFullYear()||e.value.getFullYear()===a.max.getFullYear()&&e.value.getMonth()>a.max.getMonth()))return}switch(t=t||a.displayMode){case"year":t="month";break;case"decade":t="year"}if(a.displayMode===t)return;const n=a.$.listViewContainer,l=n&&n.contains(e);a.$.fireEvent("displayModeChanging",{oldDisplayMode:a.displayMode,newDisplayMode:t}).defaultPrevented||(a.set("displayMode",t),a.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),e.parentElement!==a.$.dateViewContainer||e.disabled||e.restricted||a._focusCell(e),a.hasAnimation?(l&&e instanceof HTMLLIElement?e.offsetHeight?a.$.animationPanel.style.transformOrigin=e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px":a.$.animationPanel.style.transformOrigin=n.offsetLeft+n.offsetWidth/2+"px "+(n.offsetTop+n.offsetHeight/2)+"px":(a.$.dateViewContainer.style.order=1,a.$.nextMonthsContainer.style.order=3,e=a._focusedCell,a.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px"),a._animateView(1,e)):a._setDisplayModeContent(e.value instanceof Date?e.value:new Date(e.getAttribute("value")||e.value)))}_animateView(e,t){const a=this;let n,l,i=t instanceof Date?t:new Date(t.getAttribute("value")||t.value),s=!1,o=1,r=1;const d=a.$.listViewContainer;"list"===a.displayModeView?n=d.contains(t)?d:l="month"!==a.displayMode?a.$.monthsContainer:d:t.value instanceof Date||(t=a._focusedCell?a._focusedCell:a._selectedCells.length>0?a._selectedCells[a._selectedCells.length-1]:a._getCellByDate(new Date)),n||(n=t.parentElement===a.$.dateViewContainer?a.$.dateViewContainer:a.$.monthsContainer),l||(l="month"===a.displayMode?a.$.monthsContainer:"list"===a.displayModeView?d:a.$.dateViewContainer),l.style.transformOrigin=a.$.animationPanel.style.transformOrigin,n===d?(a.$.animationPanel.innerHTML="",a.$.animationPanel.appendChild(n.cloneNode(!0))):a.$.animationPanel.innerHTML=n.innerHTML,a._setDisplayModeContent(i),n.style.order=1,a.$.nextMonthsContainer.style.order=3,a.$.body[a._animationSettings.scrollSize]=0,a.$.animationPanel.style.width=a.$.body.offsetWidth+"px",a.$.animationPanel.style.height=a.$.body.offsetHeight+"px",a.$.animationPanel.style.transform="scale(1)",a.$.animationPanel.style.opacity=1,a.$animationPanel.removeClass("smart-hidden"),l.style.opacity="0",l.style.transform="scale(3.5)",n.$.hasClass("smart-calendar-date-view-container")?a.$animationPanel.addClass("smart-calendar-date-view-container"):a.$animationPanel.removeClass("smart-calendar-date-view-container"),cancelAnimationFrame(a._animationId),a._animationId=requestAnimationFrame((function t(){if((e>0&&o>=3.5||e<0&&o<=0)&&(s=!0),s){if(cancelAnimationFrame(a._animationId),a.$animationPanel.addClass("smart-hidden"),a.$.animationPanel.style.transform="",a.$.animationPanel.style.opacity="",n.style.order=1,a.$.nextMonthsContainer.style.order=3,a.$.body[a._animationSettings.scrollSize]=0,l.style.transform="",l.style.opacity="",a.unfocusable)return;"month"===a.displayMode?a.$.body.focus():"list"===a.displayModeView&&a.focus()}else a.$.animationPanel.style.opacity=r,l.style.opacity=1-r,r-=.05,e>0?(a.$.animationPanel.style.transform="scale("+o+")",l.style.transform="scale("+Math.min((o-1)/2,1)+")",o+=.125):(a.$.animationPanel.style.transform="scale("+Math.max(o,0)+")",l.style.transform="scale("+Math.max(1+o,1)+")",o-=.06),a._animationId=requestAnimationFrame(t)}))}_documentUpHandler(e){const t=this;let a=e.originalEvent.target;if((t.isInShadowDOM||t.shadowRoot&&a===t)&&(a=e.originalEvent.composedPath()[0]),t._newRangeSelectionStarted&&!t.$.container.contains(a)&&delete t._newRangeSelectionStarted,a&&a.classList&&a.classList.contains("smart-calendar-cell")&&t._dragStartDetails&&(e.originalEvent.stopPropagation(),e.originalEvent.preventDefault(),e.preventDefault()),!Smart.Utilities.Core.isMobile||!t._dragStartDetails||e.originalEvent.target.closest(".smart-calendar-list-view"))return;delete t._previousIteration;const n=Date.now();let l={};(t.isInShadowDOM||t.shadowRoot&&a===t)&&(a=e.originalEvent.composedPath()[0]),"portrait"===t.scrollButtonsNavigationMode?(l.coordinate="y",l.direction="pageY"):(l.coordinate="x",l.direction="pageX");const i=t._dragStartDetails.step*(t.rightToLeft?-1:1);if(Math.abs(t._dragStartDetails[l.coordinate]-e[l.direction])<=10){if(a="list"===t.displayModeView&&"month"!==t.displayMode?a.closest("smart-list-item"):a,!a)return void(t._dragStartDetails=void 0);if("month"!==t.displayMode)return t._displayModeHandler(a),"portrait"===t.scrollButtonsNavigationMode?t.$.body.scrollTop=0:t.$.body.scrollLeft=0,void(t._dragStartDetails=void 0);if(t._weeksDownHandler(e,a),!t.disableAutoNavigation&&a.otherMonth)return}else{const a=Math.abs((e[l.direction]-t._dragStartDetails[l.coordinate])/(n-t._dragStartDetails.startTime));if(a>1){const e=parseInt(a);for(let a=0;a<e;a++)if(!t.navigate(i)){t._cancelAnimation();break}return void(t._dragStartDetails=void 0)}}if(!t.hasAnimation)return t.navigate(t._dragStartDetails.step),void(t._dragStartDetails=void 0);let s=("month"!==t.displayMode?t.$.dateViewContainer[t._animationSettings.scrollMax]:t.$.monthsContainer[t._animationSettings.scrollMax])+t.$.monthsSeparator[t._animationSettings.size];if(t._dragStartDetails.step>0&&t.$.body[t._animationSettings.scrollSize]>s*t._animationSettings.easeThreshold||t._dragStartDetails.step<0&&t.$.body[t._animationSettings.scrollSize]<s*t._animationSettings.easeThreshold)return t._animateNavigation(t._dragStartDetails.navigationDate,i,!0),6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&t._updateWeeksVisibility(i,t._getCellByDate(t._dragStartDetails.navigationDate,t.$.nextMonthsContainer)),t.$.fireEvent("navigationChange",{value:new Date(t._dragStartDetails.navigationDate),type:t.displayMode}),void(t._dragStartDetails=void 0);t._cancelAnimation(),t._dragStartDetails=void 0}_cancelAnimation(){const e=this,t="month"!==e.displayMode?e.$.dateViewContainer:e.$.monthsContainer;let a=e.$.animationPanel.style.transform,n=e.$.animationPanel.style.opacity;a&&(a=parseFloat(a.substring(a.indexOf("(")+1||0,a.indexOf(")")))),t.style.order=1,e.$.nextMonthsContainer.style.order=3,e.$.body[e._animationSettings.scrollSize]=0,e._animationId=requestAnimationFrame((function t(){if(!a||a>=3.5){cancelAnimationFrame(e._animationId),e.$animationPanel.addClass("smart-hidden"),e.$.animationPanel.style.transform="",e.$.animationPanel.style.opacity="";const t="month"===e.displayMode?e.$.monthsContainer:e.$.listViewContainer;return t.style.transform="",t.style.opacity="",e.unfocusable||("month"===e.displayMode?e.$.body.focus():"list"===e.displayModeView&&e.focus()),void(e._animationStarted=!1)}e.$.animationPanel.style.opacity=n-=.25,e.$.animationPanel.style.transform="scale("+(a+=.5)+")",e._animationId=requestAnimationFrame(t)}))}_focusCell(e,t){const a=this;if(a._focusedCell&&a._setCellState(a._focusedCell,"focus",!1),a.disabled||a.readonly)return;if(e){if("month"!==a.displayMode)return a._setCellState(e,"focus",!0),void(a._focusedCell=e);if(e.disabled||e.restricted)return;return t||a._setCellState(e,"focus",!0),void(a._focusedCell=e)}if("month"!==a.displayMode&&0===a.$.monthsContainer.offsetHeight)return;const n=a._selectedCells[a._selectedCells.length-1];if(n&&n.offsetHeight)a._setCellState(n,"focus",!0),a._focusedCell=n;else{const e=a.$.monthsContainer.children;if(!e[0]._date||a.min.getTime<e[0]._date.getTime())return;const t=a._getMonthCells(e[0],a.rightToLeft);for(let e=0;e<t.length;e++){const n=t[e];if(!n.otherMonth){if(n.disabled||n.restricted||!n.offsetHeight)continue;a._focusedCell=n;break}}}a._focusedCell&&a._setCellState(a._focusedCell,"focus",!0)}_getDays(e,t){const a=t.length;let n=[];if(a>0)for(let l=0;l<a;l++)t[l].getFullYear()===e.getFullYear()&&t[l].getMonth()===e.getMonth()&&n.push(t[l].getDate());return n}_getCellByDate(e,t){const a=this;if(!(e instanceof Date))return;if(t||(t=a.$.monthsContainer),"month"!==a.displayMode){if("list"===a.displayModeView)return;let t=arguments[1]?a.$.nextMonthsContainer.children:a.$.dateViewContainer.children;for(let n=0;n<t.length;n++)if("year"!==a.displayMode){if(t[n].value.getFullYear()===e.getFullYear())return t[n]}else if(t[n].value.getMonth()===e.getMonth())return t[n];return}let n,l,i=t.children;for(let t=0;t<i.length;t++)if(e.getFullYear()===i[t]._date.getFullYear()&&e.getMonth()===i[t]._date.getMonth()){n=i[t];break}if(n){l=a._getMonthCells(n);for(let t=0;t<l.length;t++)if((!l[t].otherMonth||l[t].hover)&&l[t].value.getMonth()===e.getMonth()&&l[t].value.getDate()===e.getDate())return l[t]}}_getMonthCells(e,t){const a=e.getElementsByClassName("smart-calendar-week");let n=[];if(t)for(let e=0;e<a.length;e++){let t=a[e].children;for(let e=t.length-1;e>0;e--)t[e].classList.contains("smart-calendar-cell")&&n.push(t[e])}else for(let e=0;e<a.length;e++){let t=a[e].children;for(let e=1;e<t.length;e++)t[e].classList.contains("smart-calendar-cell")&&n.push(t[e])}return n}_getWeekNumber(e){const t=this;let a,n=new Date(e.getFullYear(),0,1),l=Math.round((e.getTime()-n.getTime()-6e4*(e.getTimezoneOffset()-n.getTimezoneOffset()))/864e5)+1,i=n.getDay()-t.firstDayOfWeek;return i=i>=0?i:i+7,i<4?(a=Math.floor((l+i-1)/7)+1,a>52&&(n=new Date(e.getFullYear()+1,0,1),i=n.getDay()-t.firstDayOfWeek,i=i>=0?i:i+7,a=i<4?1:53)):a=Math.round((l+i-1)/7),a}_handleDateSelection(e){const t=this;if(void 0!==e&&!e.disabled&&!e.restricted)switch(t.selectionMode){case"none":t._focusCell(e);break;case"oneExtended":case"one":case"default":if(t._keysPressed.Control)return t.selectedDates.length>1||1===t.selectedDates.length&&!e.selected?void t._selectDate(e.value):void t._focusCell(e);if(t._keysPressed.Shift)return void t._selectMultipleDates(new Date(t.selectedDates[0]),e);t._clearSelection(!0),t._selectDate(e.value,t._selectedCells.indexOf(e.value)>-1);break;case"many":{if(0===t.selectedDates.length)return void t._selectDate(e.value);const a=t.selectedDates[t.selectedDates.length-1];let n=new Date(t.selectedDates[0]);if(e.value.getTime()===n.getTime()||e.value.getTime()===a.getTime())return t._clearSelection(),void t._focusCell(e);t.selectedDates.length>0&&t._selectMultipleDates(n,e);break}case"range":{if(t.selectedDates.length>1&&!t._keysPressed.Control&&!t._newRangeSelectionStarted&&t._clearSelection(!0),0===t.selectedDates.length||t._keysPressed.Control&&t.selectedDates.length>1&&!t._newRangeSelectionStarted){if(e.value&&t.selectedDates.find((t=>t.getTime()===e.value.getTime())))return;return t._newRangeSelectionStarted=!0,void t._selectDate(e.value)}const a=t.selectedDates[t.selectedDates.length-1];let n=t._keysPressed.Control||t._newRangeSelectionStarted?a:new Date(t.selectedDates[0]);t.selectedDates.length>0&&t._selectMultipleDates(n,e),delete t._newRangeSelectionStarted;break}case"zeroOrMany":t._selectDate(e.value);break;case"oneOrMany":if(1===t.selectedDates.length&&e.selected)return void t._focusCell(e);t._selectDate(e.value);break;case"zeroOrOne":if(1===t.selectedDates.length&&e.selected)return void t._selectDate(e.value);t._clearSelection(!0),t._selectDate(e.value);break;case"week":{if(e.selected&&(e.value.getTime()===t.selectedDates[0].getTime()||e.value.getTime()===t.selectedDates[t.selectedDates.length-1].getTime()))return t._clearSelection(),void t._focusCell(e);t._clearSelection(!0);let a=new Date(e.value);t._selectDate(a);for(let e=1;e<7;e++)a.setDate(a.getDate()+1),t._selectDate(a);t._isDateInView(a)||t.navigate(1);break}}}_handleImportantDateTemplate(){const e=this;if(e._importantDatesTemplate=e._validateTemplate("importantDatesTemplate",e.importantDatesTemplate),!e._importantDatesTemplate||!e._importantDatesTemplate.content)return;let t=e._importantDatesTemplate.content;const a=t.childNodes.length,n=/{{\w+}}/g;let l;e._bindingDetails=[];for(let i=0;i<a;i++)if(l=n.exec(t.childNodes[i].innerHTML),l)return void e._bindingDetails.push({childNodeIndex:i,bindingString:l[0]})}_handleLayoutTemplate(e,t){const a=this,n=a._validateTemplate(e.$.hasClass("smart-header")?"headerTemplate":e.$.hasClass("smart-calendar-footer")?"footerTemplate":"titleTemplate",t);if(!n||!n.content)return void("function"==typeof t&&t(e,{}));a._layoutTemplates||(a._layoutTemplates=[]);let l=document.importNode(n.content,!0);e.innerHTML="";const i=l.childNodes.length,s=/{{\w+}}/g;let o,r=[];for(let e=0;e<i;e++)o=s.exec(l.childNodes[e].innerHTML),o&&r.push({childNodeIndex:e,bindingString:o[0]});if(a._layoutTemplates=a._layoutTemplates.filter((t=>t.selector!==e)),a._layoutTemplates.push({selector:e,template:n,bindings:r}),a.shadowRoot)return e.innerHTML="<slot></slot>",void a.appendChild(l);e.appendChild(l)}_handleCalendarCellHover(e,t){const a=this;if(!a._animationStarted){if("month"===a.displayMode)if("mouseover"===e.type&&("many"===a.selectionMode||"range"===a.selectionMode&&a._newRangeSelectionStarted)&&a.selectedDates.length>0){const e=a.$.monthsContainer.children;for(let t=0;t<e.length;t++)a._getMonthCells(e[t]).map((e=>{a._setCellState(e,"hover",!1)}));let n=new Date("range"===a.selectionMode?a.selectedDates[a.selectedDates.length-1]:a.selectedDates[0]),l=new Date(t.value),i=t;const s=n.getTime()>l.getTime()?-1:1,o=function(){i=a._getCellByDate(n),!i||i.selected||i.restricted||a._setCellState(i,"hover",!0)};if(n.getTime()!==l.getTime()){for(n.setDate(n.getDate()+s);n.getTime()!==l.getTime();)o(),n.setDate(n.getDate()+s);o()}}else a._setCellState(t,"hover",!1);"mouseover"!==e.type||t.otherMonth?a._setCellState(t,"hover",!1):a._setCellState(t,"hover",!0)}}_handleMonths(e,t){const a=this;let n;function l(e){let t,n=e.children.length,l=document.createDocumentFragment();for(;n<a.months;n++)t=a.$.month.cloneNode(!1),t.innerHTML=a.$.month.innerHTML,l.appendChild(t);return l}function i(t){let n=t.children;for(let t=0;t<n.length;t++)a._setMonth(e,n[t]),e.setMonth(e.getMonth()+1);a._setWeeksVisibility(t),a._refreshHeaderElements(),a._refreshHeaderTitle(),a.tooltip&&a.$.tooltip&&a.$.tooltip.close(),a.$.body===document.activeElement&&a._focusCell()}if(e||(e=a._viewDates&&a._viewDates.length>0?a._viewDates[0]:new Date),e=new Date(Math.min(Math.max(a.min.getTime(),e.getTime()),a.max.getTime())),t||(t=a.$.monthsContainer),a._selectedCells=[],a.hasAnimation){for(n=a.$.nextMonthsContainer.children,n.length>0&&n[0].value instanceof Date&&(a.$.nextMonthsContainer.innerHTML="");a.$.nextMonthsContainer.childElementCount<a.months;)a.$.nextMonthsContainer.appendChild(l(a.$.nextMonthsContainer));for(;a.$.nextMonthsContainer.childElementCount>a.months;)a.$.nextMonthsContainer.removeChild(n[a.$.nextMonthsContainer.childElementCount-1]);if(arguments[1]===a.$.nextMonthsContainer)return void i(a.$.nextMonthsContainer)}if(n=a.$.monthsContainer.children,n.length>a.months){for(;a.$.monthsContainer.childElementCount>a.months;)a.$.monthsContainer.removeChild(n[a.$.monthsContainer.childElementCount-1]),a._viewDates.pop();i(a.$.monthsContainer)}else a.$.monthsContainer.children.length!==a.months?(a._viewDates=[],a.$.monthsContainer.appendChild(l(a.$.monthsContainer)),i(a.$.monthsContainer)):i(a.$.monthsContainer)}_headerChangeHandler(e){const t=this;if(e.stopPropagation(),t.disabled||t.readonly)return;if(e.target.ownerElement===t.$.monthElement&&0!==t._changeEventFired)return void t._changeEventFired--;const a=t.displayMode;e.target===t.$.yearElement&&(t._viewDates[0].setFullYear(Math.min(Math.max(t.min.getFullYear(),isNaN(parseInt(t.$.yearElement.value))?0:parseInt(t.$.yearElement.value)),t.max.getFullYear())),t._handleMonths(t._viewDates[0])),!t.$.monthElement||e.target!==t.$.monthElement&&e.target.ownerElement!==t.$.monthElement||(t._handleMonths(new Date(t.$.monthsContainer.children[0]._date.getFullYear(),t.$.monthElement.selectedIndex,1)),"month"!==a&&t._setDisplayMode(t.displayMode,t.displayMode="month"))}_headerClickHandler(e){const t=this;if(t.disabled||t.readonly)return;let a=e.target.closest("smart-repeat-button");if(!a||!a.disabled){switch(a){case t.$.previousMonthButton:return t._isInteractiveNavigation=!0,void t.navigate(-1*t.months*(t.rightToLeft?-1:1));case t.$.nextMonthButton:return t._isInteractiveNavigation=!0,void t.navigate(1*t.months*(t.rightToLeft?-1:1));case t.$.previousYearButton:return void t.navigate(-12);case t.$.nextYearButton:return void t.navigate(12)}"classic"!==t.calendarMode&&e.target.closest(".smart-calendar-date-element")&&(t._animationStarted&&t._animateNavigationCompleted(),t._isInteractiveNavigation=!0,t._showDateView())}}_selectMultipleDates(e,t){const a=this;if(t instanceof HTMLElement&&(t=t.value),a._newRangeSelectionStarted?a._selectDate(e,!0):a._clearSelection(!0),"range"!==a.selectionMode||t.getTime()!==e.getTime()){if((e=new Date(e)).getTime()<t.getTime())for(;e.getTime()<=t.getTime();)a.selectedDates.find((t=>t.getTime()===e.getTime()))||a._selectDate(e,!0),e.setDate(e.getDate()+1);else if(e.getTime()>t.getTime())for(;e.getTime()>=t.getTime();)a.selectedDates.find((t=>t.getTime()===e.getTime()))||a._selectDate(e,!0),e.setDate(e.getDate()-1);else a._selectDate(t,!0);a.$.hiddenInput.value=a.selectedDates.toString(),a._refreshFooter(),a.isInitialized&&(a.$.fireEvent("change",{value:a.selectedDates}),a._updateTargetValue()),a._refreshTitle()}}_setDisplayMode(e,t,a){const n=this;if(n.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),0!==arguments.length&&n.hasAnimation)if(n._animationStarted&&(n.displayMode=e,n._animateNavigationCompleted(),n.displayMode=t),"month"===e&&"year"===t||"year"===e&&"decade"===t)n.displayMode=e,n._showDateView(a?void 0:n.displayMode);else if("month"===e&&"decade"===t)n._showDateView(n.displayMode="year");else{let e;"list"===n.displayModeView?(e=n.$.listViewContainer.querySelector("li.active"),n.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop>0?e.offsetTop-e.offsetHeight/2:e.offsetTop+e.offsetHeight/2)+"px"):(n.$.dateViewContainer.style.order=1,n.$.nextMonthsContainer.style.order=3,e=n._focusedCell,n.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px"),n._animateView(1,e)}else{if("classic"===n.calendarMode)return void(n.displayMode="month");if("month"!==n.displayMode&&(n.$monthsContainer.addClass("smart-hidden"),n.$dateViewContainer.hasClass("smart-hidden")&&n.$dateViewContainer.removeClass("smart-hidden")),!n.isCompleted&&"month"===n.displayMode)return;n._setDisplayModeContent()}}_setDisplayModeContent(e,t){const a=this;let n=e&&"Invalid Date"!==e.toString()?e:a.selectedDates.length>0?a.selectedDates[a.selectedDates.length-1]:new Date;n.setTime(Math.min(Math.max(n.getTime(),a.min.getTime()),a.max.getTime())),n.setHours(0,0,0,0);const l=a._prepareView(n);if(!l)return;let i;t?(a.$.nextMonthsContainer.innerHTML=a.$.dateViewContainer.innerHTML,i=a.$.nextMonthsContainer):i=a.$.dateViewContainer;const s=i.children;let o;for(let e=0;e<s.length;e++){const t=s[e];t.innerHTML=l.viewContent[e],t.value=l.dates[e],"year"===a.displayMode?(t.value.getFullYear()<a.min.getFullYear()||t.value.getFullYear()===a.min.getFullYear()&&t.value.getMonth()<a.min.getMonth()||t.value.getFullYear()>a.max.getFullYear()||t.value.getFullYear()===a.max.getFullYear()&&t.value.getMonth()>a.max.getMonth()?a._setCellState(t,"otherMonth",!0):a._setCellState(t,"otherMonth",!1),n.getFullYear()===t.value.getFullYear()&&n.getMonth()===t.value.getMonth()&&(o=t)):"decade"===a.displayMode&&(0===e||e===s.length-1||t.value.getFullYear()<a.min.getFullYear()||t.value.getFullYear()>a.max.getFullYear()?a._setCellState(t,"otherMonth",!0):a._setCellState(t,"otherMonth",!1),n.getFullYear()===t.value.getFullYear()&&(o=t)),a._setCellState(t,"hover",!1),a._setCellState(t,"focus",!1)}if(o.otherMonth)for(let e=0;e<s.length;e++)if(!s[e].otherMonth){o=s[e];break}a._mobileScrolling||(a._focusedCell&&a._setCellState(a._focusedCell,"focus",!1),a._focusedCell=o,a._focusCell(a._focusedCell),a._refreshHeaderTitle(),a._refreshHeaderElements(),a.$.fireEvent("displayModeChange"),a._isInteractiveNavigation?a._isInteractiveNavigation=void 0:(a._setCellState(o,"focus",!0),setTimeout((function(){a.unfocusable||(a.$.body.focus(),a._focusCell(a._focusedCell))}),0)))}_prepareView(e){const t=this,a=t.$.listViewContainer;let n,l,i=[],s=[];function o(e,t,a){let n=new Date(e,t+1,0),l=n.getDate();return a>l?n.setDate(l):n.setDate(a),n}if("month"===t.displayMode)return t.$nextMonthsContainer.hasClass("smart-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-date-view-container"),a&&a.classList.add("smart-hidden"),t.$dateViewContainer.hasClass("smart-visibility-hidden")&&t.$dateViewContainer.removeClass("smart-visibility-hidden"),t._isDateInView(e)||t._handleMonths(e),t.$header.hasClass("smart-hidden")&&t.$header.removeClass("smart-hidden"),t.$body.hasClass("smart-calendar-list-view")&&t.$body.removeClass("smart-calendar-list-view"),t.$dateContainer.addClass("smart-calendar-selected"),t.$yearContainer.removeClass("smart-calendar-selected"),t.$dateViewContainer.addClass("smart-hidden"),t.$monthsContainer.removeClass("smart-hidden"),t._refreshHeaderTitle(),t.$.body.setAttribute("tabindex",t.tabIndex>0?t.tabIndex:0),t._refreshHeaderElements(),t.unfocusable||t.$.body.focus(),t._focusCell(t._getCellByDate(e)),void t.$.fireEvent("displayModeChange");if("list"===t.displayModeView)return t._setDisplayModeListContent(e),void t.$.fireEvent("displayModeChange");if(t.$header.hasClass("smart-hidden")&&t.$header.removeClass("smart-hidden"),t.$dateViewContainer.hasClass("smart-visibility-hidden")&&t.$dateViewContainer.removeClass("smart-visibility-hidden"),a&&a.classList.add("smart-hidden"),t.$.body.setAttribute("tabindex",t.tabIndex>0?t.tabIndex:0),"year"===t.displayMode){let a=new Date;for(let n=0;n<12;n++)a=o(a.getFullYear(),n,a.getDate()),i.push(a.toLocaleDateString(t.locale,{month:"short"})),s.push(o(e.getFullYear(),n,e.getDate()))}else{n=e?e.getFullYear():t._viewDates[0].getFullYear(),l=n%10,0!==l&&(n-=l),n-=1;for(let t=0;t<12;t++)i.push(n+""),s.push(new Date(n,e.getMonth(),e.getDate())),++n}return{viewContent:i,dates:s}}_setDisplayModeListContent(e){const t=this;let a=[];function n(e,t,a){let n=new Date(e,t+1,0),l=n.getDate();return a>l?n.setDate(l):n.setDate(a),n}if(t.$dateViewContainer.addClass("smart-visibility-hidden"),"year"===t.displayMode){let l=new Date;for(let i=0;i<12;i++)l=n(l.getFullYear(),i,l.getDate()),a.push({label:l.toLocaleDateString(t.locale,{month:"short"}),value:n(e.getFullYear(),i,e.getDate()).toDateString()});t.$yearContainer.removeClass("smart-calendar-selected"),t.$dateContainer.addClass("smart-calendar-selected")}else{let n=t.min.getFullYear(),l=t.max.getFullYear();l=Math.min(t.max.getFullYear(),e.getFullYear()+10),n=Math.max(t.min.getFullYear(),l-10);for(let t=n;t<l;t++)a.push({label:t.toString(),value:new Date(t,e.getMonth(),e.getDate()).toDateString()});t.$yearContainer.addClass("smart-calendar-selected"),t.$dateContainer.removeClass("smart-calendar-selected")}t._prepareListViewer(a,e.toDateString()),t._refreshHeaderTitle(),t._refreshHeaderElements(),t.unfocusable||t.focus()}_prepareListViewer(e=[],t){const a=this,n=a.$.body;let l=a.$.listViewContainer;l||(a.$.listViewContainer=l=document.createElement("smart-scroll-viewer"),l.classList.add("smart-input-drop-down-menu","smart-calendar-list-view"),l.ensureVisible=a._listViewerEnsureVisible.bind(a),l._handleKeyStrokes=a._listViewerKeyStrokesHandler.bind(a),l._setActiveDescendant=a._listViewerSetActiveDescendant.bind(a));let i=l.querySelector("ul");i||(i=document.createElement("ul"),i.onclick=a._listViewContainerItemClickHandler.bind(a),l.appendChild(i)),n.contains(l)&&n.removeChild(l),i.innerHTML="";for(let a=0;a<e.length;a++){const n=e[a],s=n.label,o=n.value,r=document.createElement("li"),d=document.createElement("a");t===o?(r.setAttribute("aria-selected",!0),r.classList.add("active"),t=r):r.setAttribute("aria-selected",!1),r.id=l.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),r.setAttribute("value",o),r.setAttribute("role","option"),r.setAttribute("aria-label",s),d.innerHTML=s,d.setAttribute("aria-hidden",!0),r.appendChild(d),i.appendChild(r)}l.classList.remove("smart-hidden"),n.classList.add("smart-calendar-list-view"),n.removeAttribute("tabindex"),n.insertBefore(l,a.$.animationPanel),l.refresh(),l.ensureVisible()}_listViewerEnsureVisible(){const e=this.$.listViewContainer,t=e.querySelector(".active");if(!t)return;const a=Array.from(e.querySelectorAll("li"));t.offsetTop+t.offsetHeight>=e.scrollTop+e.offsetHeight&&(e.scrollTop=t.offsetTop+t.offsetHeight),(t.offsetTop<=e.scrollTop||t.offsetTop>=e.scrollTop+e.offsetHeight)&&(e.scrollTop=t.offsetTop),0===a.indexOf(t)?e.scrollTop=0:a.indexOf(t)===a.length-1&&(e.scrollTop=e.scrollHeight)}_listViewerKeyStrokesHandler(e){if(["ArrowUp","ArrowDown"].indexOf(e)<0)return;event.preventDefault();const t=this.$.listViewContainer,a=t.querySelector(".active");if(!a){const e=t.querySelector("li");return e.classList.add("active"),void t._setActiveDescendant(e)}const n=a["ArrowDown"===e?"nextElementSibling":"previousElementSibling"];n&&(a.classList.remove("active"),n.classList.add("active"),t._setActiveDescendant(n),t.ensureVisible())}_listViewerSetActiveDescendant(e){const t=this.$.listViewContainer;e?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant")}_listViewContainerItemClickHandler(e){const t=this,a=e.target.closest("li");a&&"list"===t.displayModeView&&"month"!==t.displayMode&&t._displayModeHandler(a)}_isDateInView(e){const t=this;if(!e)return!1;for(let a=0;a<t._viewDates.length;a++)if(e.getFullYear()===t._viewDates[a].getFullYear()&&e.getMonth()===t._viewDates[a].getMonth()){let a=t._getCellByDate(e,t._animationStarted?t.$.nextMonthsContainer:void 0);if(!a)return;return!(a.otherMonth||!a.offsetHeight||a.classList.contains("smart-visibility-hidden"))}return!1}_keyDownHandler(e){const t=this;if(t.disabled||t.readonly)return;const a=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;switch(a){case t.$.yearElement:"Escape"===e.key&&t._refreshHeaderElements();break;case t.$.dateElement:if("default"===t.calendarMode&&" "===e.key||"Enter"===e.key)return e.preventDefault(),t._isInteractiveNavigation=!0,void t._showDateView();t._focusedCell||t._focusCell(),e.key.indexOf("Arrow")>-1&&t.$.dateElement===a&&!t.unfocusable&&t.$.body.focus(),t._navigateDays(e);break;case t.$.body:" "===e.key&&e.preventDefault(),t._navigateDays(e);break;case t.$.yearContainer:if(" "!==e.key&&"Enter"!==e.key||"decade"===t.displayMode||(e.preventDefault(),t._isInteractiveNavigation=!0,t._showDateView("year")),e.key.indexOf("Arrow")>-1){if(e.preventDefault(),t._focusedCell||t._focusCell(),"month"!==t.displayMode&&"list"===t.displayModeView)return t.unfocusable||t.focus(),void t.$.listViewContainer._handleKeyStrokes(e.key);t._navigateDays(e)}break;case t.$.dateContainer:if(" "!==e.key&&"Enter"!==e.key||"month"===t.displayMode||(e.preventDefault(),t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell,"month")),e.key.indexOf("Arrow")>-1){if(t._focusedCell||t._focusCell(),"month"!==t.displayMode&&"list"===t.displayModeView)return t.unfocusable||t.focus(),void t.$.listViewContainer._handleKeyStrokes(e.key);t._navigateDays(e)}break;default:if("month"!==t.displayMode&&"list"===t.displayModeView)return["Arrow","End","Home","Page"].indexOf(e.key)&&e.preventDefault()," "===e.key||"Enter"===e.key||e.ctrlKey&&("ArrowUp"===e.key||"ArrowDown"===e.key)?void t._navigateDays(e):void t.$.listViewContainer._handleKeyStrokes(e.key);e.key.indexOf("Arrow")>-1&&(t._focusedCell||t._focusCell(),t._navigateDays(e))}}_showDateView(e){const t=this;switch(e=e||t.displayMode){case"month":e="year";break;case"year":e="decade"}if(t.displayMode===e)return;if(t.$.fireEvent("displayModeChanging",{oldDisplayMode:t.displayMode,newDisplayMode:e}).defaultPrevented)return;let a;if(t.displayMode=e,"list"===t.displayModeView&&"month"!==t.displayMode){t._setDisplayModeListContent(t._focusedCell?t._focusedCell.value:t._viewDates[0]);const e=t.$.listViewContainer;e.classList.remove("smart-hidden"),a=e.querySelector("li.active"),a.offsetHeight?t.$.animationPanel.style.transformOrigin=a.offsetLeft+a.offsetWidth/2+"px "+(a.offsetTop>0?a.offsetTop-a.offsetHeight/2:a.offsetTop+a.offsetHeight/2)+"px":t.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(a.offsetTop>0?a.offsetTop-a.offsetHeight/2:e.offsetTop+e.offsetHeight/2)+"px"}else t._focusedCell||t._focusCell(),a=t._focusedCell,t.$.animationPanel.style.transformOrigin=a.offsetLeft+a.offsetWidth/2+"px "+(a.offsetTop+a.offsetHeight/2)+"px";t.$monthsContainer.addClass("smart-hidden"),t.$dateViewContainer.hasClass("smart-hidden")&&t.$dateViewContainer.removeClass("smart-hidden"),"decade"===t.displayMode&&(t.$yearContainer.addClass("smart-calendar-selected"),t.$dateContainer.removeClass("smart-calendar-selected")),t.hasAnimation?t._animateView(-1,a):t._setDisplayModeContent(t._focusedCell?t._focusedCell.value:t._viewDates[0])}_keyUpHandler(e){const t=this;t.disabled||t.readonly||"default"!==t.selectionMode&&"range"!==t.selectionMode||"Shift"!==e.key&&"Control"!==e.key||(t._keysPressed[e.key]=!1)}_handleTooltip(){const e=this,t=e.tooltip;let a=e.$.tooltip;t?(a||(a=document.createElement("smart-tooltip"),a.tooltipTemplate=e.tooltipTemplate,a.arrow=e.tooltipArrow,a.arrowDirection=e.tooltipArrowDirection,a.offset=e.tooltipOffset,a.position=e.tooltipPosition,a.delay=e.tooltipDelay,a.rightToLeft=e.rightToLeft,a.openMode="manual",e.$.tooltip=a),a.parentElement||e.$.calendarContainer.appendChild(a)):a&&a.remove()}_mouseEventsHandler(e){const t=this;if(t.disabled||t.readonly)return;const a=t.$.tooltip;if("mouseenter"===e.type)return void t.$.setAttributeValue("hover",!0);if("mouseleave"===e.type){if(t.$.setAttributeValue("hover",!1),t._newRangeSelectionStarted&&"range"===t.selectionMode){const e=t.$.monthsContainer.children;for(let a=0;a<e.length;a++)t._getMonthCells(e[a]).map((e=>{t._setCellState(e,"hover",!1)}))}return void(t.tooltip&&a&&a.close())}const n=t.shadowRoot||t.isInShadowDOM?e.composedPath()[0]:e.target;if(!n.closest(".smart-calendar-week"))return void(t.tooltip&&a&&(clearTimeout(t._tooltipAutoCloseTimeout),a[a.contains(n)?"open":"close"]()));const l=n.closest(".smart-calendar-cell");if(!l)return;if(Smart.Utilities.Core.isMobile||t._handleCalendarCellHover(e,l),!t.tooltip&&a)return void a.close();const i=l.hasAttribute("important");if(clearTimeout(t._tooltipAutoCloseTimeout),i&&a&&"mouseover"===e.type)return a.selector=l,void(a.selector!==l?a.close():(t.tooltipTemplate||(a.innerHTML=0===a.innerHTML.trim().length?"Important day!":a.innerHTML),a.open(),t.$.fireEvent("open",{target:a,value:new Date(l.value)})));t._tooltipAutoCloseTimeout=setTimeout(function(){!a||"mouseout"!==e.type&&l&&i||a.close(),clearTimeout(t._tooltipAutoCloseTimeout)}.bind(t),t.tooltipDelay)}_popupEventHandler(e){const t=this,a=t.$.tooltip;if(e.stopPropagation(),e.target!==t.$.monthElement)if(e.target===a)if("close"!==e.type);else{const e=a.selector;t.$.fireEvent("close",{target:a,value:e?new Date(e.value):null})}else t.$.fireEvent(e.type,{target:e.target})}_moveHandler(e){const t=this;if(!Smart.Utilities.Core.isMobile||!t._dragStartDetails||"list"===t.displayModeView&&"month"!==t.displayMode)return;e.originalEvent.preventDefault(),e.preventDefault(),e.stopPropagation();const a={x:Math.round(e.pageX),y:Math.round(e.pageY)};let n,l,i;if(n="portrait"===t.scrollButtonsNavigationMode?a.y>t._dragStartDetails.y?-1*t.months:1*t.months:a.x<t._dragStartDetails.x?1*t.months:-1*t.months,t._previousIteration&&n===t._previousIteration.step)l=t._previousIteration.date;else if(6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode){let e,a;t._focusedCell||t._focusCell();const i=[].slice.call(t._focusedCell.closest(".smart-calendar-weeks").children).filter((e=>!e.classList.contains("smart-hidden")));if(i.length){let s;!t.rightToLeft&&n<0||t.rightToLeft&&n>0?(s=i[0].querySelectorAll(".smart-calendar-cell"),a=t.rightToLeft?s[s.length-1]:s[0]):(s=i[i.length-1].querySelectorAll(".smart-calendar-cell"),a=t.rightToLeft?s[0]:s[s.length-1]),e=new Date(a.value),e.setDate(e.getDate()+n*(t.rightToLeft?-1:1)),l=e}else l=t._getNextDate(n*(t.rightToLeft?-1:1))}else l=t._getNextDate(n*(t.rightToLeft?-1:1));if(!l)return;if(!t._dragStartDetails.navigationDate&&t.$.fireEvent("navigationChanging",{value:new Date(l),type:t.displayMode}).defaultPrevented)return t._cancelAnimation(),void(t._dragStartDetails=void 0);if(t._dragStartDetails.step=n,t._dragStartDetails.navigationDate=new Date(l),!t.hasAnimation)return;if(t._previousIteration={step:n,date:l},t._mobileScrolling=!0,"month"!==t.displayMode)t.$nextMonthsContainer.addClass("smart-calendar-date-view-container"),i=t.$.dateViewContainer,t.$.nextMonthsContainer.children[0].value instanceof Date&&t.$.nextMonthsContainer.children[1].value.getFullYear()===l.getFullYear()||t._setDisplayModeContent(l,t.$.nextMonthsContainer);else if(t.$nextMonthsContainer.hasClass("smart-calendar-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),i=t.$.monthsContainer,!t.$.nextMonthsContainer.children[0]._date||t.$.nextMonthsContainer.children[0]._date.getTime()!==l.getTime()){let e=t.$.nextMonthsContainer.children;for(let a=0;a<e.length;a++)l.setMonth(t._dragStartDetails.navigationDate.getMonth()+a*(t.rightToLeft?-1:1)),t._setMonth(new Date(l),e[a],!0)}6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&t._updateWeeksVisibility(n*(t.rightToLeft?-1:1),t._getCellByDate(l,t.$.nextMonthsContainer)),delete t._mobileScrolling,n<0?(i.style.order=3,t.$.nextMonthsContainer.style.order=1,t.$.body[t._animationSettings.scrollSize]=t.$.body[t._animationSettings.scrollMax]):(i.style.order=1,t.$.nextMonthsContainer.style.order=3,t.$.body[t._animationSettings.scrollSize]=0);const s="portrait"===t.scrollButtonsNavigationMode?"y":"x";Math.abs(t._dragStartDetails[s]-a[s])>5&&(t.$.body[t._animationSettings.scrollSize]+=2*-(a[s]-t._dragStartDetails[s]))}_getNextDate(e){const t=this;let a;if("month"!==t.displayMode){let n;const l=t._focusedCell&&t._focusedCell.value.getFullYear();if("list"===t.displayModeView)a=new Date(t.$.listViewContainer.querySelector("li").getAttribute("value"));else{let e=t._animationStarted?t.$.nextMonthsContainer:t.$.dateViewContainer;a=new Date("year"===t.displayMode?e.children[0].value:e.children[1].value)}n="year"===t.displayMode?1:0!==e?10:1,a.setFullYear(a.getFullYear()+(e>0?n:-n)),a.getTime()<t.min.getTime()&&(a=t.min),a.getTime()>t.max.getTime()&&(a=t.max);const i="month"!==t.displayMode&&"list"===t.displayModeView;if(a.getFullYear()<t.min.getFullYear()||a.getFullYear()>t.max.getFullYear()||!i&&l===a.getFullYear())return}else{let n=t._viewDates[0];if(a=new Date(n),a.setDate(1),a.setMonth(a.getMonth()+e),a.setTime(Math.min(Math.max(a.getTime(),t.min.getTime()),t.max.getTime())),n.getMonth()===a.getMonth()&&n.getFullYear()===a.getFullYear())return}return a}_navigateDays(e){const t=this;let a="ArrowUp"===e.key||"ArrowDown"===e.key?7:1,n="ArrowUp"===e.key||"ArrowLeft"===e.key||"PageUp"===e.key?-1:1;switch(e.key){case"ArrowUp":case"ArrowLeft":case"ArrowDown":case"ArrowRight":if(!t._handleArrowKeys(e,a,n))return;break;case" ":case"Enter":{if("month"!==t.displayMode)return void t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell);const e=t._focusedCell;if("oneExtended"===t.selectionMode&&e)return t._clearSelection(!0),void t._selectDate(e.value,t._selectedCells.indexOf(e.value)>-1);break}case"Control":case"Shift":return"default"===t.selectionMode&&(t._keysPressed[e.key]=!0),void("range"===t.selectionMode&&(t._keysPressed[e.key]="Control"===e.key));case"Home":case"End":{e.preventDefault();let a,n=function(t){if("Home"===e.key){for(let e=0;e<t.length;e++)if(!t[e].otherMonth&&(!t[e].disabled||!t[e].restricted)&&t[e].offsetHeight)return t[e]}else for(let e=t.length-1;e>=0;e--)if(!t[e].otherMonth&&(!t[e].disabled||!t[e].restricted)&&t[e].offsetHeight)return t[e]};if(a="month"!==t.displayMode?n(t.$.dateViewContainer.children):n(t._getMonthCells(t._focusedCell.closest(".smart-calendar-month"),t.rightToLeft)),!a)return;if(t._focusCell(a),"month"!==t.displayMode)return;break}case"PageUp":case"PageDown":if(!t._handlePageUpDownKeys(e,n))return;break;default:return}"oneExtended"!==t.selectionMode&&t._focusedCell&&t._handleDateSelection(t._focusedCell)}_handleArrowKeys(e,t,a){const n=this;let l;if("month"!==n.displayMode||n._animationStarted||n.unfocusable||n.$.body.focus(),n._focusedCell||n._focusCell(n._getCellByDate(new Date)),e.altKey)return;if(e.ctrlKey){if("ArrowDown"===e.key||"ArrowUp"===e.key){if("classic"===n.calendarMode)return;let t;switch(n.displayMode){case"month":t="ArrowDown"===e.key?"month":"year";break;case"year":t="ArrowDown"===e.key?"month":"decade";break;case"decade":t="ArrowDown"===e.key?"year":"decade"}if(t!==n.displayMode){const e=n.displayMode;n.displayMode=t,n._setDisplayMode(e,t,"month"===e),n._keysPressed&&delete n._keysPressed.Control}}return}if(e.preventDefault(),!n.rightToLeft||"ArrowLeft"!==e.key&&"ArrowRight"!==e.key||(a*=-1),"month"!==n.displayMode&&"list"!==n.displayModeView){const i=n._animationStarted?n.$.nextMonthsContainer.children:n.$.dateViewContainer.children;if(t="ArrowUp"===e.key||"ArrowDown"===e.key?4:1,"year"===n.displayMode){const e=n._focusedCell.value.getMonth()+a*t;let i=new Date(n._focusedCell.value.getFullYear(),e+1,0);n._focusedCell.value.getDate()<=i.getDate()&&(i=n._focusedCell.value),l=new Date(n._focusedCell.value.getFullYear(),e,i.getDate())}else l=new Date(n._focusedCell.value.getFullYear()+a*t,n._focusedCell.value.getMonth(),n._focusedCell.value.getDate());if("year"===n.displayMode){if(l.getFullYear()<n.min.getFullYear()||l.getFullYear()===n.min.getFullYear()&&l.getMonth()<n.min.getMonth()||l.getFullYear()>n.max.getFullYear()||l.getFullYear()===n.max.getFullYear()&&l.getMonth()>n.max.getMonth())return;l.getTime()>i[i.length-1].value.getTime()?n.navigate(1):l.getTime()<i[0].value.getTime()&&n.navigate(-1)}else{if(l.getFullYear()<n.min.getFullYear()||l.getFullYear()>n.max.getFullYear())return;if(l.getFullYear()<i[1].value.getFullYear()||l.getFullYear()>i[10].value.getFullYear()){let t=n._focusedCell;n.navigate(a),"ArrowUp"!==e.key&&"ArrowDown"!==e.key||(t===i[3]||t===i[4]||t===i[7]||t===i[8]?l.setFullYear(l.getFullYear()+2*a):l.setFullYear(l.getFullYear()-2*a))}}return void n._focusCell(n._getCellByDate(l,n._animationStarted?n.$.nextMonthsContainer:void 0))}if(!n._focusedCell)return;const i=n.restrictedDates.map(Number);for(l=new Date(n._focusedCell.value.getFullYear(),n._focusedCell.value.getMonth(),n._focusedCell.value.getDate()+a*t,0,0,0,0);i.indexOf(l.getTime())>-1;)l.setDate(l.getDate()+a);if(l.getTime()<n.min.getTime()||l.getTime()>n.max.getTime())return;n._isDateInView(l)||n.navigate(a*n.months);let s=n._getCellByDate(l,n._animationStarted?n.$.nextMonthsContainer:void 0);return n._focusCell(s),n._updateWeeksVisibility(a),!(["zeroOrMany","oneOrMany","none","many","week","range"].indexOf(n.selectionMode)>-1)||void 0}_handlePageUpDownKeys(e,t){const a=this;let n;if(e.preventDefault(),"month"!==a.displayMode){if(n=a._focusedCell,!a.navigate(t))return;for(;n&&n.classList.contains("smart-visibility-hidden");)n=null===n.previousElementSibling?n.nextElementSibling:n.previousElementSibling;return a._focusCell(n),void(a.hasAnimation&&"decade"===a.displayMode&&a._focusedCell.value.setFullYear(a._focusedCell.value.getFullYear()+10*t))}n=new Date(a._focusedCell.value.getFullYear(),a._focusedCell.value.getMonth()+t,1,0,0,0,0);let l=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return a._focusedCell.value.getDate()>l?n.setDate(l):n.setDate(a._focusedCell.value.getDate()),a._isDateInView(n)||a.navigate(n),a._animationStarted?a._focusCell(a._getCellByDate(n,a.$.nextMonthsContainer)):a._focusCell(a._getCellByDate(n)),!0}_selectDate(e,t,a){const n=this;if(void 0===n._viewDates||"none"===n.selectionMode)return;let l,i=n.selectedDates.slice(0),s=n._getCellByDate(e,n._animationStarted?n.$.nextMonthsContainer:void 0);s&&n._selectCell(s),(e=new Date(e)).setHours(0,0,0,0),l=i.map(Number).indexOf(e.getTime()),n.restrictedDates.map(Number).indexOf(e.getTime())>-1||e.getTime()<n.min.getTime()||e.getTime()>n.max.getTime()||(l>-1?i.splice(l,1):i.push(e),a||(n.selectedDates=i),n._refreshFooter(),n.$.hiddenInput.value=n.selectedDates.toString(),!t&&n.isInitialized&&(n.$.fireEvent("change",{value:[e]}),n._updateTargetValue()),n._refreshTitle())}_selectCell(e){const t=this;if(!e||t.restrictedDates.map(Number).indexOf(e.value.getTime())>-1||t.disableAutoNavigation&&!1===e.otherMonth||e.value.getTime()<t.min.getTime()||e.value.getTime()>t.max.getTime())return;const a=t._selectedCells.indexOf(e);a>-1?(t._setCellState(e,"selected",!1),t._selectedCells.splice(a,1)):(t._setCellState(e,"selected",!0),t._selectedCells.push(e)),t._focusCell(e)}_refreshDayOfWeekTitles(){const e=this;let t,a=[],n=new Date;function l(t){let a;return"firstTwoLetters"===e.dayNameFormat?(a=new Intl.DateTimeFormat(e.locale,{weekday:"long"}).format(t),a=8206===a.charCodeAt(0)?a.substring(1,3):a.substring(0,2)):a=new Intl.DateTimeFormat(e.locale,{weekday:e.dayNameFormat}).format(t),a}for(let e=1;e<8;e++)n.setDate(e),t={number:n.getDay(),name:l(n)},a.push(t);a.sort(((e,t)=>e.number>t.number?1:-1));const i=e.$.monthsContainer.children;let s,o;for(let t=0;t<i.length;t++)if(s=i[t].getElementsByClassName("smart-calendar-week-titles")[0].children,o=e.firstDayOfWeek>6?0:e.firstDayOfWeek,e.rightToLeft)for(let e=s.length-1;e>=1;e--)s[e].textContent=a[o++].name,o=o>6?0:o;else for(let e=1;e<s.length;e++)s[e].textContent=a[o++].name,o=o>6?0:o;if(e.hasAnimation){const t=e.$.monthsContainer.getElementsByClassName("smart-calendar-week-titles")[0].innerHTML,a=e.$.nextMonthsContainer.getElementsByClassName("smart-calendar-week-titles");for(let e=0;e<a.length;e++)a[e].innerHTML=t}}_refreshCalendarMode(){const e=this;if(!e.headerTemplate)if(e._refreshMonthNames(),"default"===e.calendarMode){e.$classicHeaderDate.addClass("smart-hidden"),e.$defaultHeaderDate.removeClass("smart-hidden");const t=e._viewDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime())),a=t[0],n=t[t.length-1];a.setDate(2);let l=e.monthNameFormat;"firstTwoLetters"===l&&(l="long");let i=a.toLocaleDateString(e.locale,{year:e.yearFormat,month:l});e.months>1&&(n.setDate(2),i+=" - "+n.toLocaleDateString(e.locale,{year:e.yearFormat,month:l})),e.$.defaultHeaderDate.innerHTML=i,e.unfocusable||e.$.dateElement.setAttribute("tabindex",e.tabIndex>0?e.tabIndex:0)}else e.$defaultHeaderDate.addClass("smart-hidden"),e.$classicHeaderDate.removeClass("smart-hidden"),e.$.dateElement.removeAttribute("tabindex")}_refreshFooter(){const e=this;if(!(e.viewSections.indexOf("footer")<0||0===e.$.footer.offsetHeight))if(e.footerTemplate){if("function"==typeof e.footerTemplate)return;let a=e._layoutTemplates.filter((t=>t.selector===e.$.footer))[0],n=document.importNode(a.template.content,!0);if(a.bindings.length>0){let e=n.childNodes[a.bindings[0].childNodeIndex];a.selector.childNodes[a.bindings[0].childNodeIndex].innerHTML=e.innerHTML.replace(a.bindings[0].bindingString,t())}}else e.$.selectedDatesRange.innerHTML=t();function t(){if(0===e.selectedDates.length)return"";if(1===e.selectedDates.length)return e.selectedDates[0].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"});{let t=e.selectedDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime()));return t[0].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"})+" - "+t[t.length-1].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"})}}}_refreshImportantDates(){const e=this;if("month"===e.displayMode){e._clearImportantDates();for(let t=0;t<e.importantDates.length;t++)e._setImportantDate(e.importantDates[t])}}_clearImportantDates(){const e=this,t=e.$.monthsContainer.children;for(let a=0;a<t.length;a++)e._getMonthCells(t[a]).map((t=>{e._setCellState(t,"important",!1)}))}_setImportantDate(e,t){const a=this,n=a._getCellByDate(e);t||(t=n),t&&(a._setCellState(t,"important",!0),a._applyImportantDateTemplate(t))}_applyImportantDateTemplate(e){const t=this;if(!t._importantDatesTemplate)return"function"==typeof t.importantDatesTemplate?void t.importantDatesTemplate(e,{value:e.value}):void(e.innerHTML=e.value.getDate()+"");let a=document.importNode(t._importantDatesTemplate.content,!0);if(t._bindingDetails&&t._bindingDetails.length>0){let n=a.childNodes[t._bindingDetails[0].childNodeIndex];n.innerHTML=n.innerHTML.replace(t._bindingDetails[0].bindingString,e.value.getDate())}e.innerHTML="";for(let t=0;t<a.childNodes.length;t++)a.childNodes[t].outerHTML&&(e.innerHTML+=a.childNodes[t].outerHTML)}_setMonth(e,t,a){const n=this,l=n._getDays(e,n.selectedDates),i=n._getDays(e,n.importantDates),s=n._getDays(e,n.restrictedDates);e.setDate(1),t||(t=n.$.month),t._date=new Date(e),a||((!n._viewDates||n._viewDates.length>=n.months)&&(n._viewDates=[]),n._viewDates.push(new Date(e)));let o=((e=new Date(e)).getDay()-n.firstDayOfWeek+7)%7;e.setDate(0);let r=e.getDate();if(e.setDate(32),e.setDate(1),e.setDate(32),n._selectedCells)for(let e=0;e<n._selectedCells.length;e++)n._selectedCells[e].closest(".smart-calendar-month")===t&&n._setCellState(n._selectedCells[e],"selected",!1);n._setMonthContent(e,t,{previusMonthDays:r,firstDayOfWeek:o,selectedDates:l,importantDates:i,restrictedDates:s})}_setMonthContent(e,t,a){const n=this,l=32-e.getDate(),i=n._getMonthCells(t,n.rightToLeft),s=t._date.getMonth(),o=t._date.getFullYear(),r=new Date;let d,c=1,m=1;r.setHours(0,0,0,0),i.map((e=>{n._setCellState(e,"restricted",!1),n._setCellState(e,"selected",!1),n._setCellState(e,"otherMonth",!1),n._setCellState(e,"focus",!1),n._setCellState(e,"important",!1),n._setCellState(e,"today",!1),n._setCellState(e,"disabled",!1),n._setCellState(e,"hover",!1)}));for(let e=0;e<i.length;e++){const h=i[e];e===a.firstDayOfWeek&&m<=l?(h.className="smart-calendar-cell",h.value=new Date(o,s,m),h.innerHTML=h.value.getDate().toString(),a.restrictedDates.indexOf(m)>-1||h.value.getTime()<n.min.getTime()||h.value.getTime()>n.max.getTime()?n._setCellState(h,"restricted",!0):a.selectedDates.indexOf(m)>-1&&(n._setCellState(h,"selected",!0),n._selectedCells.indexOf(h)<0&&n._selectedCells.push(h)),a.importantDates.indexOf(m)>-1&&(n._setImportantDate(h.value,h),a.importantDates.splice(a.importantDates.indexOf(m),1)),h.value.getTime()===r.getTime()&&n._setCellState(h,"today",!0),a.firstDayOfWeek++,m++):(1===m?(h.value=new Date(o,s-1,++a.previusMonthDays-a.firstDayOfWeek),d=!!(h.value.getTime()<n.min.getTime()||t.previousElementSibling)):(h.value=new Date(o,s+1,c++),d=!!(h.value.getTime()>n.max.getTime()||t.nextElementSibling)),h.innerHTML=h.value.getDate().toString(),n._setCellState(h,"otherMonth",!0),d?h.classList.add("smart-visibility-hidden"):h.classList.remove("smart-visibility-hidden"))}n.months>1&&(t.firstElementChild.innerHTML=n.dateFormatFunction?n.dateFormatFunction(t._date):n._monthsNames[s]+" "+t._date.toLocaleDateString(n.locale,{year:n.yearFormat})),n._setMonthWeekNumbers(t)}_refreshMonthNames(){const e=this;let t,a=new Date;function n(t){let a=e.monthNameFormat;"firstTwoLetters"===a&&(a="long");let n=new Intl.DateTimeFormat(e.locale,{month:a}).format(t);return"firstTwoLetters"===e.monthNameFormat&&(n=8206===n.charCodeAt(0)?n.substring(0,2):n.substring(1,3)),n}a.setDate(1),e._monthsNames=[];for(let l=0;l<12;l++)a.setMonth(l),t=n(a),e._monthsNames.push(t);if("classic"===e.calendarMode&&e.$.monthElement){let t=e.$.monthsContainer.children;if(e.$.monthElement.dataSource&&(e._changeEventFired=1),e.shadowRoot?e._setMonthElementPropertyInShadowDOM("dataSource",e._monthsNames):e.$.monthElement.dataSource=e._monthsNames,e._viewDates){for(let a=0;a<t.length;a++)t[a].firstElementChild.textContent=e._monthsNames[t[a]._date.getMonth()]+" "+t[a]._date.getFullYear();e._changeEventFired=1,e.shadowRoot?e._setMonthElementPropertyInShadowDOM("selectedIndex",e._viewDates.map((e=>e.getMonth()))[0]):e.$.monthElement.selectedIndex=e._viewDates.map((e=>e.getMonth()))[0]}}}_setMonthWeekNumbers(e){const t=this,a=function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!0};let n=e.getElementsByClassName("smart-calendar-week");n=[].slice.call(n);for(let l=0;l<n.length;l++){if(!a(n[l])){n[l].children[0].innerHTML="";continue}const i=n[l].children[1],s=i.otherMonth?i.value.getTime()>e._date.getTime()?1:-1:0;n[l].children[0].innerHTML=t._getWeekNumber(new Date(e._date.getFullYear(),e._date.getMonth()+s,i.value.getDate()))}}_setRestrictedDates(e){const t=this,a=t.$.monthsContainer.children;for(let e=0;e<a.length;e++)t._getMonthCells(a[e]).map((e=>{t._setCellState(e,"restricted",!1)}));if(t._viewDates){const a=function(e){for(let a=0;a<t._viewDates.length;a++)if(t._viewDates[a].getFullYear()===e.getFullYear()&&t._viewDates[a].getMonth()===e.getMonth())return!0};for(let n=0;n<e.length;n++)if(a(e[n])){const a=t._getCellByDate(e[n]);t._setCellState(a,"restricted",!0)}}}_setScrollButtonsNavigationMode(){const e=this;"landscape"!==e.scrollButtonsNavigationMode?(e.$.previousMonthButton&&(e.$.previousMonthButton.$.button.firstElementChild.className="smart-arrow-down smart-arrow"),e.$.nextMonthButton&&(e.$.nextMonthButton.$.button.firstElementChild.className="smart-arrow-up smart-arrow")):(e.$.previousMonthButton&&(e.$.previousMonthButton.$.button.firstElementChild.className="smart-arrow-left smart-arrow"),e.$.nextMonthButton&&(e.$.nextMonthButton.$.button.firstElementChild.className="smart-arrow-right smart-arrow")),e._applyAnimationSettings(!0)}_refreshTitle(){const e=this;let t=e.selectedDates.length>0?e.selectedDates[e.selectedDates.length-1]:new Date;if(e.titleTemplate){if("function"==typeof e.titleTemplate)return;let a=e._layoutTemplates.filter((t=>t.selector===e.$.title))[0],n=document.importNode(a.template.content,!0);if(a.bindings.length>0){let l=n.childNodes[a.bindings[0].childNodeIndex];return t=t.toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"}),void(a.selector.childNodes[a.bindings[0].childNodeIndex].innerHTML=l.innerHTML.replace(a.bindings[0].bindingString,t))}}e.$.title.children[0].innerHTML=t.toLocaleDateString(e.locale,{year:e.yearFormat}),e.$.title.children[1].innerHTML="landscape"===e.view?t.toLocaleDateString(e.locale,{weekday:"short"})+",</br>"+t.toLocaleDateString(e.locale,{month:"short",day:"numeric"}):t.toLocaleDateString(e.locale,{weekday:"short"})+", "+t.toLocaleDateString(e.locale,{month:"short",day:"numeric"})}_setWeeksVisibility(e){const t=this,a=e.children;let n;function l(e){(function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!1;return!0})(e)||n>=t.weeks?e.classList.add("smart-hidden"):n<t.weeks&&(e.classList.remove("smart-hidden"),n++)}for(let e=0;e<a.length;e++){let i=a[e].getElementsByClassName("smart-calendar-week");i=[].slice.call(i);let s=t._selectedCells.filter((t=>t.closest(".smart-calendar-month")===a[e]));if(6!==t.weeks)if(n=0,s.length>0){let e=s[s.length-1],t=i.indexOf(e.parentElement);for(let e=t;e<i.length;e++)l(i[e]);for(let e=t-1;e>=0;e--)l(i[e])}else for(let e=0;e<i.length;e++)l(i[e]);else i.map((e=>e.classList.remove("smart-hidden")))}}_refreshHeaderElements(){const e=this,t=document.activeElement.closest("smart-calendar")===e,a=e._animationStarted?e.$.nextMonthsContainer:e.$.dateViewContainer;let n,l,i=e._viewDates[e._viewDates.length-1],s=e._viewDates.map((e=>e.getFullYear()));if("month"===e.displayMode||"list"!==e.displayModeView){if("classic"===e.calendarMode&&e.$.monthElement&&e.$.monthElement instanceof HTMLDivElement){const t=document.createElement("smart-input");t.setAttribute("smart-id","monthElement"),t.classList.add("smart-calendar-month-element"),t.dropDownPosition="bottom",t.selectionMode="one",t.disabled=e.disabled,t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.dropDownWidth=e.dropDownWidth,t.dropDownHeight=e.dropDownHeight,t.readonly=!0,t.dropDownButtonPosition="right";const a=e.$.monthElement;e.$.monthElement.parentNode.insertBefore(t,e.$.monthElement),e.$.monthElement=t,a.remove()}if(e.$.previousMonthButton&&!e.disabled&&("month"!==e.displayMode&&e.$.dateViewContainer.children[0].value?l="year"===e.displayMode?a.children[0].value.getFullYear()-1:a.children[1].value.getFullYear()-1:e._viewDates[0].getMonth()-1<0?(n=11,l=e._viewDates[0].getFullYear()-1):(n=e._viewDates[0].getMonth()-1,l=e._viewDates[0].getFullYear()),e.$.previousMonthButton.disabled=l<e.min.getFullYear()||l===e.min.getFullYear()&&n<e.min.getMonth(),e.$.previousMonthButton.disabled&&t&&e.$.body.focus()),e.$.nextMonthButton&&!e.disabled&&("month"!==e.displayMode&&e.$.dateViewContainer.children[0].value?l="year"===e.displayMode?a.children[0].value.getFullYear()+1:a.children[1].value.getFullYear()+11:i.getMonth()+1>11?(n=0,l=i.getFullYear()+1):(n=i.getMonth()+1,l=i.getFullYear()),e.$.nextMonthButton.disabled=l>e.max.getFullYear()||l===e.max.getFullYear()&&n>e.max.getMonth(),e.$.nextMonthButton.disabled&&t&&e.$.body.focus()),"classic"===e.calendarMode&&e.$.monthElement){let t=[...e._monthsNames];if(s.indexOf(e.min.getFullYear())>-1)for(let a=0;a<e.min.getMonth();a++)t[a]="";if(s.indexOf(e.max.getFullYear())>-1)for(let a=e.max.getMonth()+1;a<t.length;a++)t[a]="";t=t.filter((e=>""!==e));const a=Math.max(0,e.$.monthElement.selectedIndex);e.$.monthElement.dataSource=t,e._changeEventFired=0!==e.$.monthElement.selectedIndex,e.shadowRoot?e._setMonthElementPropertyInShadowDOM("selectedIndex",e._viewDates[0].getMonth()):e.$.monthElement.selectedIndex=a,e._changeEventFired=0}e.$.previousYearButton&&!e.disabled&&(l=e._viewDates[0].getFullYear()-1,e.$.previousYearButton.disabled=l<e.min.getFullYear(),e.$.previousYearButton.disabled&&t&&e.$.body.focus()),e.$.nextYearButton&&!e.disabled&&(l=i.getFullYear()+1,e.$.nextYearButton.disabled=l>e.max.getFullYear(),e.$.nextYearButton.disabled&&t&&e.$.body.focus()),e.$.yearElement&&(e.$.yearElement.value=s[0],e.$.yearElement.disabled=i.getFullYear()+1>e.max.getFullYear()&&e._viewDates[0].getFullYear()-1<e.min.getFullYear())}}_setMonthElementPropertyInShadowDOM(e,t){const a=this.$.monthElement,n=a.context;a.context=document,this.$.monthElement[e]=t,a.context=n}_refreshHeaderTitle(){const e=this;let t;function a(){if("month"!==e.displayMode){if("list"===e.displayModeView){const a=e.$.listViewContainer;if(!a)return;const n=a.querySelectorAll("li");if(!n.length)return"";let l;a.querySelector("li.active")&&(l=a.querySelector("li.active").getAttribute("value")),t="year"===e.displayMode?new Date(l||n[0].getAttribute("value")).getFullYear():new Date(n[0].getAttribute("value")).getFullYear()+" - "+new Date(n[n.length-1].getAttribute("value")).getFullYear()}else if(e.$.dateViewContainer.children[0].value){let a=e._animationStarted?e.$.nextMonthsContainer.children:e.$.dateViewContainer.children;t="year"===e.displayMode?a[0].value.getFullYear():a[1].value.getFullYear()+" - "+a[a.length-2].value.getFullYear()}if(t)return t}const a=e._viewDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime())),n=a[0],l=a[a.length-1];n.setDate(2);let i=e.monthNameFormat;return"firstTwoLetters"===i&&(i="long"),t=n.toLocaleDateString(e.locale,{year:e.yearFormat,month:i}),e.months>1&&(l.setDate(2),t+=" - "+l.toLocaleDateString(e.locale,{year:e.yearFormat,month:i})),t}if("default"===e.calendarMode&&(e.$.defaultHeaderDate.innerHTML=a()),"function"==typeof e.headerTemplate||!e._layoutTemplates)return;let n=e._layoutTemplates.filter((t=>t.selector===e.$.header))[0];if(!n)return;let l=document.importNode(n.template.content,!0);if(n.bindings.length>0){const t=l.childNodes[n.bindings[0].childNodeIndex];(e.shadowRoot?e:n.selector).childNodes[n.bindings[0].childNodeIndex].innerHTML=t.innerHTML.replace(n.bindings[0].bindingString,e.dateFormatFunction?e.dateFormatFunction(e._viewDates):a())}}_updateWeeksVisibility(e,t){const a=this;let n=(t||a._focusedCell).parentElement;function l(){for(let e=o;e<s.length;e++)if(s[e].classList.contains("smart-hidden")&&!r(s[e])&&(s[e].classList.remove("smart-hidden"),d++,d===a.weeks))return!0}function i(){for(let e=o;e>=0;--e)if(s[e].classList.contains("smart-hidden")&&!r(s[e])&&(s[e].classList.remove("smart-hidden"),d++,d===a.weeks))return!0}if(!t&&!n.classList.contains("smart-hidden"))return;const s=[].slice.call(n.parentElement.children),o=s.indexOf(n),r=function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!1;return!0};let d=0;if(s.map((e=>e.classList.add("smart-hidden"))),e>0){if(l())return;i()}else{if(i())return;l()}}_getValidDates(e){let t=[];function a(e){if(e instanceof Date)return e;if(Smart.Utilities.DateTime&&e instanceof Smart.Utilities.DateTime)return e.toDate();if("string"==typeof e){if("new Date()"===e.trim()||"new Smart.Utilities.DateTime()"===e.trim())return new Date;let t=/(\d+[,-.\/]{1}\s*\d+[,-.\/]{1}\s*\d+)/;const a=()=>(e=e.replace(/[,-.\/]/g,",").split(",")).length>2?e=new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):new Date;return t.test(e)&&(e=t.exec(e)[0].replace(/[,-.\/]/g,",").split(","))?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):a()}}if(void 0===e)return null;if(Array.isArray(e))for(let n=0;n<e.length;n++)t.push(a(e[n]));else t.push(a(e));return t=t.filter((e=>e&&"Invalid Date"!==e.toDateString())),t.map((e=>e.setHours(0,0,0,0))),t}_getValidDate(e){const t=this._getValidDates(e);return t.length>0?t[0]:null}_validateSelectedDates(e){const t=this;let a=[];e||(e=t.selectedDates);let n=e.slice(0),l=function(e){for(let a=0;a<t.restrictedDates.length;a++)if(t.restrictedDates[a].getTime()===e.getTime())return!0};t.selectedDates=n.filter((function(e){if(e.getTime()>=t.min.getTime()&&e.getTime()<=t.max.getTime()&&!l(e))return!0;a.push(e)})),t._viewDates&&(a.map((e=>t._selectDate(e))),t._focusCell())}_validateMinMax(e,t,a){const n=this;switch(e){case"min":t=n._getValidDate(n[e]),n.min=t||a||n.properties.min.defaultValue;break;case"max":t=n._getValidDate(n[e]),n.max=t||a||n.properties.max.defaultValue;break;default:t=n._getValidDate(n.min),n.min=t||a||n.properties.min.defaultValue,t=n._getValidDate(n.max),n.max=t||a||n.properties.max.defaultValue}n.min=n.min.getTime()>n.max.getTime()?n.max:n.min,n.min.setHours(0,0,0,0),n.max.setHours(0,0,0,0);let l,i=n.$.monthsContainer.children;if(n._viewDates){if(n._viewDates[0].getTime()>n.max.getTime()||n._viewDates[0].getTime()<n.min.getTime())return void n._handleMonths();for(let e=0;e<i.length;e++){l=n._getMonthCells(i[e]);for(let t=0;t<l.length;t++){const a=l[t];if(a.value.getTime()>=n.min.getTime()&&a.value.getTime()<=n.max.getTime())n._setCellState(a,"restricted",!1),a.value.getMonth()===i[e]._date.getMonth()?a.classList.remove("smart-visibility-hidden"):n.hideOtherMonthDays||(n._setCellState(a,"otherMonth",!0),a.classList.remove("smart-visibility-hidden")),"month"!==n.displayMode&&n._setCellState(a,"otherMonth",!1);else{if(a.otherMonth){if(a.classList.contains("smart-visibility-hidden")){n._setCellState(a,"restricted",!1);continue}}else n._setCellState(a,"restricted",!0);"month"!==n.displayMode&&(a.classList.remove("smart-visibility-hidden"),n._setCellState(a,"otherMonth",!0))}}}}}_setCellState(e,t,a){e[t]=a;const n=Smart.Utilities.Core.toDash(t);a?(e.setAttribute(n,""),"selected"===t?e.setAttribute("aria-selected",!0):"today"===t?e.setAttribute("aria-current","date"):"restricted"===t?e.removeAttribute("aria-selected"):"disabled"===t&&(e.removeAttribute("aria-selected"),e.setAttribute("aria-disabled",!0))):(e.removeAttribute(n),"selected"===t?"none"===this.selectionMode||e.restricted||e.disabled?e.removeAttribute("aria-selected"):e.setAttribute("aria-selected",!1):"today"===t?e.removeAttribute("aria-current"):"restricted"!==t||e.disabled?"disabled"===t&&(e.removeAttribute("aria-disabled"),e.restricted||e.setAttribute("aria-selected",!1)):e.setAttribute("aria-selected",!1))}_validateTemplate(e,t){if(null===t||!t)return;if("function"==typeof t)return;const a=this;if("content"in document.createElement("template")){if("string"==typeof t&&(t=document.getElementById(t)),null!==t&&"content"in t)return t;a.error(a.localize("invalidTemplate",{elementType:a.nodeName.toLowerCase(),property:e}))}else a.error(a.localize("htmlTemplateNotSuported",{elementType:a.nodeName.toLowerCase()}))}_weeksDownHandler(e,t){const a=this,n=t.value;let l;if(a.$.body.contains(t))if(t.otherMonth&&(l=t.value.getTime()>t.closest(".smart-calendar-month")._date.getTime()?1:-1),n&&a.hasRippleAnimation&&Smart.Utilities.Animation.Ripple.animate(t,e.pageX,e.pageY),l){if(a._isDateInView(n))return;a.disableAutoNavigation||a.navigate(l*a.months)}else(t=a._getCellByDate(n))&&(t.disabled||t.restricted)||a._handleDateSelection(t)}_firstDayOfWeekValidator(e,t){return Math.min(Math.max(0,isNaN(t)?6:t),6)}_weeksValidator(e,t){return Math.min(Math.max(1,isNaN(t)?6:t),6)}_monthsValidator(e,t){return Math.min(Math.max(1,isNaN(t)?1:t),12)}});
|
|
20
|
+
Smart("smart-calendar",class extends Smart.BaseElement{static get properties(){return{animationSettings:{value:null,type:"object"},calendarMode:{value:"default",allowedValues:["default","classic"],type:"string"},dayNameFormat:{value:"firstTwoLetters",allowedValues:["narrow","firstTwoLetters","long","short"],type:"string"},dateFormatFunction:{value:null,type:"function"},disableAutoNavigation:{value:!1,type:"boolean"},disableMouseWheel:{value:!1,type:"boolean"},displayMode:{value:"month",allowedValues:["month","year","decade"],type:"string"},displayModeView:{value:"table",allowedValues:["table","list"],type:"string"},dropDownHeight:{value:"200",type:"string"},dropDownWidth:{value:"",type:"string"},firstDayOfWeek:{value:0,type:"number",defaultValue:0,validator:"_firstDayOfWeekValidator"},footerTemplate:{value:null,type:"any"},headerTemplate:{value:null,type:"any"},hideDayNames:{value:!1,type:"boolean"},hideOtherMonthDays:{value:!1,type:"boolean"},hideTooltipArrow:{value:!1,type:"boolean"},importantDates:{value:[],type:"array",defaultValue:[]},importantDatesTemplate:{value:null,type:"any"},max:{value:new Date(2100,0,1),type:"any",defaultValue:new Date(2100,0,1)},min:{value:new Date(1900,0,1),type:"any",defaultValue:new Date(1900,0,1)},months:{value:1,type:"number",defaultValue:1,validator:"_monthsValidator"},monthNameFormat:{value:"long",allowedValues:["narrow","firstTwoLetters","long","short","2-digit","numeric"],type:"string"},name:{value:"",type:"string"},restrictedDates:{value:[],type:"array",defaultValue:[]},scrollButtonsNavigationMode:{value:"landscape",allowedValues:["portrait","landscape"],type:"string"},scrollButtonsPosition:{value:"both",allowedValues:["near","far","both"],type:"string"},selectedDates:{value:[],reflectToAttribute:!1,type:"array"},selectionMode:{value:"default",allowedValues:["none","default","one","oneExtended","many","zeroOrMany","oneOrMany","zeroOrOne","week","range"],type:"string"},spinButtonsDelay:{value:80,type:"number"},spinButtonsInitialDelay:{value:0,type:"number"},titleTemplate:{value:null,type:"any"},tooltip:{value:!1,type:"boolean"},tooltipArrow:{value:!0,type:"boolean"},tooltipArrowDirection:{allowedValues:["bottom","top","left","right","none"],value:"bottom",type:"string"},tooltipDelay:{value:100,type:"number"},tooltipOffset:{value:[],type:"array"},tooltipPosition:{value:"auto",allowedValues:["auto","bottom","top","left","right","absolute"],type:"string"},tooltipTemplate:{value:null,type:"any"},view:{value:"portrait",allowedValues:["landscape","portrait"],type:"string"},viewSections:{value:["header"],type:"array"},weekNumbers:{value:!1,type:"boolean"},weeks:{value:6,type:"number",defaultValue:6,validator:"_weeksValidator"},yearFormat:{value:"numeric",allowedValues:["2-digit","numeric"],type:"string"}}}static get listeners(){return{"container.down":"_downHandler","document.up":"_documentUpHandler","body.move":"_moveHandler","container.wheel":"_containerWheelHandler","body.focus":"_bodyFocusStateHandler","body.blur":"_bodyBlurStateHandler","header.click":"_headerClickHandler","header.change":"_headerChangeHandler",keydown:"_keyDownHandler",keyup:"_keyUpHandler",mouseenter:"_mouseEventsHandler",mouseleave:"_mouseEventsHandler","container.mouseover":"_mouseEventsHandler","container.mouseout":"_mouseEventsHandler","container.open":"_popupEventHandler","container.close":"_popupEventHandler"}}static get methods(){return{select:"select(date=new Date(): date|string): void",clearSelection:"clearSelection(): void",today:"today(): date",navigate:"navigate(step: date|string|int): bool"}}static get styleUrls(){return["smart.calendar.css"]}template(){return'<div id="container" role="presentation">\n <div id="title" class="smart-calendar-title" role="heading" aria-level="1">\n <div id="yearContainer" class="smart-calendar-year-container" role="button"></div>\n <div id="dateContainer" class="smart-calendar-date-container smart-calendar-selected" role="button"></div>\n </div>\n <div id="calendarContainer" class="smart-calendar-container">\n <div id="header" class="smart-calendar-header">\n <smart-repeat-button prev-month class="smart-calendar-button" id="previousMonthButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Previous month">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n <div id="dateElement" class="smart-calendar-date-element" role="presentation">\n <div id="defaultHeaderDate" role="button"></div>\n <div id="classicHeaderDate">\n <div id="monthElement" class="smart-calendar-month-element" disabled="[[disabled]]" role="presentation">\n </div>\n <input class="smart-calendar-year-element" id="yearElement" disabled="[[disabled]]" readonly="[[readonly]]" aria-label="Year" />\n <span class="smart-calendar-year-elements">\n <smart-repeat-button next-year class="smart-calendar-button" id="nextYearButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Next year">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n <smart-repeat-button prev-year class="smart-calendar-button" id="previousYearButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Previous year">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n </span>\n </div>\n </div>\n <smart-repeat-button next-month class="smart-calendar-button" id="nextMonthButton" animation="[[animation]]" initial-delay="[[spinButtonsInitialDelay]]" delay="[[spinButtonsDelay]]" disabled="[[disabled]]" readonly="[[readonly]]" right-to-left="[[rightToLeft]]" aria-label="Next month">\n <span aria-hidden="true"></span>\n </smart-repeat-button>\n </div>\n <div id="body" class="smart-content smart-calendar-body" role="presentation">\n <div id="monthsContainer" class="smart-calendar-months-container" role="presentation">\n <div id="month" class="smart-calendar-month" role="grid">\n <div id="monthName" class="smart-calendar-month-name"></div>\n <div id="weekTitles" class="smart-calendar-week-titles" role="row">\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n <div class="smart-calendar-week-title" role="columnheader"></div>\n </div>\n <div id="weeks" class="smart-calendar-weeks" role="rowgroup">\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n <div class="smart-calendar-week" role="row">\n <div class="smart-calendar-week-number" role="rowheader"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"></div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n <div class="smart-calendar-cell" role="gridcell"> </div>\n </div>\n </div>\n </div>\n </div>\n <div id="dateViewContainer" class="smart-calendar-date-view-container smart-hidden">\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n <div class="smart-calendar-cell" role="button"></div>\n </div>\n <div id="monthsSeparator" class="smart-calendar-month-separator"></div>\n <div id="nextMonthsContainer" class="smart-calendar-next-months-container" aria-hidden="true"></div>\n <div id="animationPanel" class="smart-calendar-animation-panel smart-hidden"></div>\n </div>\n <div id="footer" class="smart-calendar-footer smart-hidden">\n <div id="selectedDatesRange"></div>\n </div>\n <input id="hiddenInput" type="hidden" name="[[name]]">\n </div>\n </div>'}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const a=e.dataset.property,n=e.selectedDates.toString();a&&void 0!==t[a]&&(t[a]=n)}}}propertyChangedHandler(e,t,a){super.propertyChangedHandler(e,t,a);const n=this;switch(e){case"animationSettings":n._applyAnimationSettings();break;case"disabled":case"unfocusable":n._setFocusable();break;case"calendarMode":case"dropDownWidth":case"dropDownHeight":n.displayMode="month",n._refreshHeaderElements(),n._refreshCalendarMode(),n._setDisplayModeContent();break;case"dayNameFormat":n._refreshDayOfWeekTitles(n.$.month);break;case"dateFormatFunction":{let e=n.$.monthsContainer.children;for(let t=0;t<e.length;t++)e[t].firstElementChild.innerHTML=a?a(e[t]._date):n._monthsNames[e[t]._date.getMonth()]+" "+e[t]._date.toLocaleDateString(n.locale,{year:n.yearFormat});n._refreshHeaderTitle();break}case"displayMode":if("classic"===n.calendarMode&&"month"!==a){n[e]="month";break}n._setDisplayMode(t,a);break;case"displayModeView":n._applyAnimationSettings(!0),"month"!==n.displayMode&&n._setDisplayModeContent();break;case"firstDayOfWeek":n._handleMonths(),n._refreshDayOfWeekTitles();break;case"hideTooltipArrow":n.$.tooltip&&(n.$.tooltip.arrow=!a);break;case"titleTemplate":case"headerTemplate":case"footerTemplate":n._handleLayoutTemplate(n.$[e.split(/[T]/)[0]],a),"titleTemplate"===e?n._refreshTitle():"headerTemplate"===e?n._refreshHeaderTitle():n._refreshFooter();break;case"importantDates":n.importantDates=n._getValidDates(a),n._refreshImportantDates();break;case"importantDatesTemplate":n._handleImportantDateTemplate(),n._refreshImportantDates();break;case"locale":n._refreshMonthNames(),n._refreshDayOfWeekTitles(),n._refreshHeaderTitle(),n._refreshTitle(),n._refreshFooter(),n.displayMode&&"month"!==n.displayMode&&n._setDisplayModeContent();break;case"max":case"min":n._validateMinMax(e,a,t),n._validateSelectedDates(),n._noFocusingRequired=!1,n._refreshHeaderElements();break;case"months":n._handleMonths();break;case"monthNameFormat":n._refreshCalendarMode(),n._refreshHeaderTitle();break;case"restrictedDates":n._setRestrictedDates(n.restrictedDates=n._getValidDates(a));break;case"rightToLeft":n._refreshDayOfWeekTitles(),n._handleMonths();break;case"scrollButtonsNavigationMode":n._setScrollButtonsNavigationMode();break;case"selectedDates":if(n._clearSelection(!0),n._validateSelectedDates(n._getValidDates(a)),n._applySelectionMode(!0),n._viewDates){let e=n.selectedDates[n.selectedDates.length-1];n._isDateInView(e)?n.selectedDates.map((e=>n._selectDate(e,!0,!0))):n._handleMonths(e)}n._refreshFooter(),n._setWeeksVisibility(n.$.monthsContainer),n.$.hiddenInput.value=n.selectedDates.toString(),n.isInitialized&&(n.$.fireEvent("change",{value:n.selectedDates}),n._updateTargetValue()),n._refreshTitle(),"month"!==n.displayMode&&n._setDisplayModeContent();break;case"selectionMode":n._applySelectionMode(!1,t),n._refreshTitle();break;case"tooltip":n._handleTooltip();break;case"tooltipArrow":case"tooltipArrowDirection":case"tooltipDelay":case"tooltipOffset":case"tooltipPosition":case"tooltipTemplate":if(n.$.tooltip){const t=e.replace("tooltip","");n.$.tooltip[t.charAt(0).toLowerCase()+t.slice(1)]=a}break;case"view":n._refreshTitle();break;case"viewSections":a.indexOf("title")>-1?n.$title.removeClass("smart-hidden"):n.$title.addClass("smart-hidden"),n._refreshTitle(),a.indexOf("header")>-1?n.$header.removeClass("smart-hidden"):n.$header.addClass("smart-hidden"),n._refreshHeaderTitle(),a.indexOf("footer")>-1?n.$footer.removeClass("smart-hidden"):n.$footer.addClass("smart-hidden"),n._refreshFooter(),n._setFocusable();break;case"weeks":n._setWeeksVisibility(n.$.monthsContainer);break;case"yearFormat":if(n._refreshCalendarMode(),n._refreshFooter(),n.months>1&&"month"===n.displayMode){let e=n._animationStarted?n.$.nextMonthsContainer.children:n.$.monthsContainer.children;for(let t=0;t<e.length;t++)e[t].firstElementChild.innerHTML=n.dateFormatFunction?n.dateFormatFunction(e[t]._date):n._monthsNames[e[t]._date.getMonth()]+" "+e[t]._date.toLocaleDateString(n.locale,{year:a})}n._refreshTitle(),n._refreshHeaderTitle()}}ready(){super.ready();const e=this;e._keysPressed={},e._applyAnimationSettings(),e.importantDates=e._getValidDates(e.importantDates),e.restrictedDates=e._getValidDates(e.restrictedDates)}render(){const e=this;e.setAttribute("role","dialog"),e._refreshMonthNames(),e._validateMinMax(),e._validateSelectedDates(e._getValidDates(e.selectedDates)),e._handleLayoutTemplate(e.$.title,e.titleTemplate),e._handleLayoutTemplate(e.$.header,e.headerTemplate),e._handleLayoutTemplate(e.$.footer,e.footerTemplate),e._handleImportantDateTemplate(),e._setFocusable(),e._refreshDayOfWeekTitles(),e._applySelectionMode(!0),e._handleMonths(0===e.selectedDates.length?new Date((new Date).setHours(0,0,0,0)):e.selectedDates[e.selectedDates.length-1]),e._handleTooltip(),e._updateViewSectionsVisibility(),e._setScrollButtonsNavigationMode(),e._refreshCalendarMode(),e._setDisplayMode(),e._refreshTitle(),e._refreshFooter(),e._refreshImportantDates(),e.$.monthElement&&e.$.monthElement._setDropDownSize&&e.$.monthElement._setDropDownSize(),e._changeEventFired=0,e.$.hiddenInput.value=e.selectedDates.toString(),e.shadowRoot&&e.appendChild(e.$.hiddenInput),e.isInitialized=!0,super.render()}refresh(){this.isInitialized&&this.render()}_updateViewSectionsVisibility(){const e=this;e.viewSections.indexOf("title")>-1?e.$title.removeClass("smart-hidden"):e.$title.addClass("smart-hidden"),e.viewSections.indexOf("header")>-1?e.$header.removeClass("smart-hidden"):e.$header.addClass("smart-hidden"),e.viewSections.indexOf("footer")>-1?e.$footer.removeClass("smart-hidden"):e.$footer.addClass("smart-hidden")}clearSelection(){this._clearSelection()}_setFocusable(){const e=this;let t=e.tabIndex>0?e.tabIndex:0;function a(e,a){if(a)return e&&e instanceof a?("function"==typeof e._setFocusable&&e.isCompleted?e.unfocusable=t<=-1:e.setAttribute("tabindex",t),e):e||void 0}(e.disabled||e.unfocusable)&&(t=-1),e.$.previousMonthButton=a(e.$.previousMonthButton,Smart.Button),e.$.nextMonthButton=a(e.$.nextMonthButton,Smart.Button),e.$.nextYearButton=a(e.$.nextYearButton,Smart.Button),e.$.previousYearButton=a(e.$.previousYearButton,Smart.Button),e.$.monthElement=a(e.$.monthElement,Smart.Input),e.$.yearElement=a(e.$.yearElement,HTMLInputElement),e.viewSections.indexOf("title")>-1&&(e.$.dateContainer.setAttribute("tabindex",t),e.$.yearContainer.setAttribute("tabindex",t)),e.$.body.setAttribute("tabindex",t),"default"===e.calendarMode?e.$.dateElement.setAttribute("tabindex",t):e.$.dateElement.removeAttribute("tabindex"),e.unfocusable?e.removeAttribute("tabindex"):e.tabIndex=e.readonly&&!e.disabled?e.tabIndex>0?e.tabIndex:0:t}static get requires(){return{"Smart.DropDownList":"smart.dropdownlist.js","Smart.ListBox":"smart.listbox.js","Smart.RepeatButton":"smart.button.js","Smart.Tooltip":"smart.tooltip.js"}}navigate(e){const t=this;let a,n,l;if(e){if("number"==typeof e){if(e=parseInt(e),isNaN(e)||0===e)return!1;if(6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode){let l,i;t._focusedCell||t._focusCell();const s=[].slice.call(t._focusedCell.closest(".smart-calendar-weeks").children).filter((e=>!e.classList.contains("smart-hidden")));e<0?(i=s[0].querySelectorAll(".smart-calendar-cell"),l=t.rightToLeft?i[i.length-1]:i[0]):(i=s[s.length-1].querySelectorAll(".smart-calendar-cell"),l=t.rightToLeft?i[0]:i[i.length-1]),n=new Date(l.value),n.setDate(n.getDate()+e),a=n}else a=t._getNextDate(e)}else{if(a=e=t._getValidDate(e),l=!0,isNaN(a.getTime()))return!1;const i=t._viewDates[0];if(i&&a.getMonth()===i.getMonth()&&a.getFullYear()===i.getFullYear())return!1;6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&(n=a)}return!(!a||t.$.fireEvent("navigationChanging",{value:new Date(a),type:t.displayMode}).defaultPrevented||("month"!==t.displayMode?(!l&&t.hasAnimation?(t.$nextMonthsContainer.addClass("smart-calendar-date-view-container"),"list"===t.displayModeView?t._setDisplayModeContent(a):t._navigationDate&&t._navigationDate.getTime()===a.getTime()||t._animateNavigation(a,e)):t._setDisplayModeContent(a),t.$.fireEvent("navigationChange",{value:new Date(a),type:t.displayMode}),0):(t.hasAnimation?(t._animateNavigation(a,e),t.$nextMonthsContainer.hasClass("smart-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-date-view-container")):(t._handleMonths(a),t._refreshHeaderElements(),t._refreshHeaderTitle()),n&&(t._focusCell(t._getCellByDate(n,t._animationStarted?t.$.nextMonthsContainer:void 0),!0),t._updateWeeksVisibility(e)),t.$.fireEvent("navigationChange",{value:new Date(a),type:t.displayMode}),0)))}}set value(e){this._select(e)}get value(){return this.selectedDates&&this.selectedDates.length>0?this.selectedDates[0]:null}select(e){this._select(e)}_select(e){const t=this;t._viewDates&&void 0!==t._viewDates[0]&&"none"!==t.selectionMode&&e&&(e=t._getValidDate(e))instanceof Date&&("one"===t.selectionMode&&t.selectedDates.map(Number).indexOf(e.getTime())>-1||e.getTime()<t.min.getTime()||e.getTime()>t.max.getTime()||("one"!==t.selectionMode&&"default"!==t.selectionMode&&"zeroOrOne"!==t.selectionMode||t._clearSelection(!0),t._selectDate(e),1!==t.selectedDates.length||t._isDateInView(t.selectedDates[0])||t._handleMonths(t.selectedDates[0])))}today(){const e=this;let t=new Date;return t.setHours(0,0,0,0),t.getTime()<e.min.getTime()||t.getTime()>e.max.getTime()?t=new Date(e.max):e._selectDate(t),e._handleMonths(t),t}_animateNavigation(e,t,a){const n=this;n._navigationDate=e,n._animationSettings||n._applyAnimationSettings(),n.$animationPanel.addClass("smart-hidden"),n.$.dateViewContainer.style.transform="",n.$.dateViewContainer.style.opacity="",n.$.monthsContainer.style.transform="",n.$.monthsContainer.style.opacity="";const l="month"!==n.displayMode?n.$.dateViewContainer:n.$.monthsContainer,i=n.$.body[n._animationSettings.scrollMax]-n.$.body[n._animationSettings.size];n._scrollStep=n.$.body[n._animationSettings.size]*n._animationSettings.startSpeed,n._animationStarted&&n._getMonthCells(n.$.monthsContainer,n.rightToLeft).map((e=>{n._setCellState(e,"restricted",!1),n._setCellState(e,"selected",!1),n._setCellState(e,"otherMonth",!1),n._setCellState(e,"focus",!1),n._setCellState(e,"important",!1),n._setCellState(e,"today",!1),n._setCellState(e,"disabled",!1),n._setCellState(e,"hover",!1)})),n._animationStarted=!0,"month"!==n.displayMode?(n._setCellState(n._focusedCell,"focus",!1),n._setDisplayModeContent(e,n.$.nextMonthsContainer)):n._handleMonths(e,n.$.nextMonthsContainer),n.rightToLeft&&(t*=-1),a||(t>0?(l.style.order=1,n.$.nextMonthsContainer.style.order=3,(!n._animationStarted||n._animationStarted&&n.$.body[n._animationSettings.scrollSize]>n.$.body[n._animationSettings.scrollMax]*n._animationSettings.resetThreshold*2)&&(n.$.body[n._animationSettings.scrollSize]=0)):(l.style.order=3,n.$.nextMonthsContainer.style.order=1,(!n._animationStarted||n._animationStarted&&n.$.body[n._animationSettings.scrollSize]<n.$.body[n._animationSettings.scrollMax]*n._animationSettings.resetThreshold)&&(n.$.body[n._animationSettings.scrollSize]=n.$.body[n._animationSettings.scrollMax]))),cancelAnimationFrame(n._animationId),n._animationId=requestAnimationFrame((function e(){let a=t>0?n.$.body[n._animationSettings.scrollSize]>=i:0===n.$.body[n._animationSettings.scrollSize],l=n._scrollStep/2;a?n._animateNavigationCompleted():(t>0&&n.$.body[n._animationSettings.scrollSize]>i*n._animationSettings.easeThreshold?(l=Math.max(n.$.body[n._animationSettings.scrollSize]/n._animationSettings.stepEaseSize,Math.abs(l-(i-n.$.body[n._animationSettings.scrollSize])*n._animationSettings.step)),n._scrollStep=n._scrollStep*n._animationSettings.step+l):t<0&&n.$.body[n._animationSettings.scrollSize]<i*n._animationSettings.easeThreshold&&(l=Math.max(n.$.body[n._animationSettings.scrollMax]/n._animationSettings.stepEaseSize,Math.abs(l-n.$.body[n._animationSettings.scrollSize]*n._animationSettings.step)),n._scrollStep=n._scrollStep*n._animationSettings.step+l),n.$.body[n._animationSettings.scrollSize]+=t>0?n._scrollStep:-n._scrollStep,n._animationId=requestAnimationFrame(e))}))}_animateNavigationCompleted(){const e=this;let t,a,n,l="month"!==e.displayMode?e.$.dateViewContainer:e.$.monthsContainer;if(cancelAnimationFrame(e._animationId),"month"!==e.displayMode){let i=[].slice.call(l.children).indexOf(e._focusedCell);l.innerHTML=e.$.nextMonthsContainer.innerHTML;let s,o=l.children[i];a=l.children,n=e.$.nextMonthsContainer.children;for(let t=0;t<a.length;t++)a[t].value=n[t].value,a[t].restricted=n[t].restricted,a[t].important=n[t].important,a[t].otherMonth=n[t].otherMonth,a[t].value.getTime()<=e.max.getTime()&&(s=a[t]);t=o&&o.value.getTime()>=e.max.getTime()?s.value:e._focusedCell?e._focusedCell.value:void 0}else{let i=l.children,s=e.$.nextMonthsContainer.children;e._focusedCell&&e.$.nextMonthsContainer.contains(e._focusedCell)&&(t=e._focusedCell.value);for(let t=0;t<i.length&&s[t]._date;t++){i[t]._date=s[t]._date,i[t].innerHTML=s[t].innerHTML,a=e._getMonthCells(i[t]),n=e._getMonthCells(s[t]);for(let e=0;e<a.length;e++)a[e].value=n[e].value,a[e].restricted=n[e].restricted,a[e].important=n[e].important,a[e].otherMonth=n[e].otherMonth,a[e].removeAttribute("focus")}e._selectedCells.length>0&&(e._selectedCells=e._selectedCells.map((t=>e._getCellByDate(t.value))).filter((e=>void 0!==e)))}e._focusCell(e._getCellByDate(t)),l.style.order=1,e.$.nextMonthsContainer.style.order=3,e.$.body[e._animationSettings.scrollSize]=0,e._animationStarted=!1,delete e._navigationDate}_applyAnimationSettings(e){const t=this;t._animationSettings=t.animationSettings?t.animationSettings:t._animationSettings||{},"portrait"===t.scrollButtonsNavigationMode?(t._animationSettings.scrollMax="scrollHeight",t._animationSettings.size="offsetHeight",t._animationSettings.scrollSize="scrollTop"):(t._animationSettings.scrollMax="scrollWidth",t._animationSettings.size="offsetWidth",t._animationSettings.scrollSize="scrollLeft"),e||(t._animationSettings.startSpeed=t._animationSettings.startSpeed?t._animationSettings.startSpeed:.2,t._animationSettings.easeThreshold=t._animationSettings.easeThreshold?t._animationSettings.easeThreshold:.5,t._animationSettings.step=t._animationSettings.step?t._animationSettings.step:.25,t._animationSettings.stepEaseSize=t._animationSettings.stepEaseSize?t._animationSettings.stepEaseSize:200,t._animationSettings.resetThreshold=t._animationSettings.resetThreshold?t._animationSettings.resetThreshold:.2)}_applySelectionMode(e,t){const a=this;let n=[],l=!!e,i=a.selectionMode;function s(e,t){const n=a.$.monthsContainer.children;for(let l=0;l<n.length;l++)a._getMonthCells(n[l]).map((n=>{a._setCellState(n,e,t)}))}switch("many"===i&&"range"===i||s("hover",!1),a._newRangeSelectionStarted=a.selectedDates.length>0&&"range"===i,-1!==["default","many","zeroOrMany","oneOrMany","week","range"].indexOf(i)?Array.from(a.getElementsByClassName("smart-calendar-month")).forEach((e=>e.setAttribute("aria-multiselectable",!0))):Array.from(a.getElementsByClassName("smart-calendar-month")).forEach((e=>e.removeAttribute("aria-multiselectable"))),"none"!==i&&"none"!==t||s("selected",!1),i){case"none":return void a._clearSelection(l);case"range":return void(a.selectedDates.length>1&&a._selectMultipleDates(a.selectedDates[0],a.selectedDates[a.selectedDates.length-1]));case"many":case"default":case"oneOrMany":if(0===a.selectedDates.length){n.push(new Date(Math.min(Math.max(a.min.getTime(),(new Date).setHours(0,0,0,0)),a.max.getTime())));break}return;case"oneExtended":case"one":if(1===a.selectedDates.length)return;a.selectedDates.length>1?(n.push(a.selectedDates[a.selectedDates.length-1]),a._clearSelection(l)):n.push(new Date(Math.min(Math.max(a.min.getTime(),(new Date).setHours(0,0,0,0)),a.max.getTime())));break;case"zeroOrOne":if(a.selectedDates.length>1){n.push(a.selectedDates[a.selectedDates.length-1]),a._clearSelection(l);break}return;case"zeroOrMany":return;case"week":if(a.selectedDates.length>=1){let e=a.selectedDates[a.selectedDates.length-1];for(let t=0;t<7;t++)n.push(new Date(e)),e.setDate(e.getDate()+1);a._clearSelection(l)}}if(a.selectedDates=[],e)return void(a.selectedDates=n);const o=n.length;for(let e=0;e<o;e++)a._selectDate(n[e],e<o-1)}_clearSelection(e){const t=this,a=t.selectedDates.slice(0),n=t.selectionMode;if(t.isRendered){if(t._selectedCells&&t._selectedCells.map((e=>{t._setCellState(e,"selected",!1)})),t.selectedDates=[],t._selectedCells=[],"many"===n||"range"===n){const e=t.$.monthsContainer.children;for(let a=0;a<e.length;a++)t._getMonthCells(e[a]).map((e=>{t._setCellState(e,"hover",!1)}))}t.$.footer&&t._refreshFooter(),t.$.hiddenInput.value=t.selectedDates.toString(),!e&&t.isInitialized&&a.length&&(t.$.fireEvent("change",{value:[]}),t._updateTargetValue()),t.$.title&&t._refreshTitle()}else t.set("selectedDates",[])}_bodyBlurStateHandler(e){this._bodyStateHandler(e),this.$.fireEvent("blur")}_bodyFocusStateHandler(e){this._bodyStateHandler(e),this.$.fireEvent("focus")}_bodyStateHandler(e){const t=this;if(t._focusedCell){if("blur"===e.type||"focus"===e.type&&t._noFocusingRequired)return t._noFocusingRequired=!1,void t._setCellState(t._focusedCell,"focus",!1);if("month"!==t.displayMode)return void("focus"!==e.type||t.$.dateViewContainer.querySelector("smart-calendar-cell[focus]")||t._setCellState(t._focusedCell||t.$.dateViewContainer.querySelector(".smart-calendar-cell"),"focus",!0))}"focus"===e.type&&t._focusCell()}_containerWheelHandler(e){const t=this;if(t.disabled||t.readonly||"month"!==t.displayMode&&"list"===t.displayModeView)return;if(t.disableMouseWheel)return;let a,n;n=document.activeElement,t.shadowRoot?n=t.shadowRoot.activeElement:t.isInShadowDOM&&(n=t.getRootNode().activeElement),t.$.yearElement===n&&(a=12),(n&&t.shadowRoot||n.closest("smart-calendar")===t)&&(a=e.target===t.$.yearElement?12:1),a&&(e.preventDefault(),a=12===a?a:a*t.months,e.deltaY>0?t.navigate(-a):t.navigate(a))}_downHandler(e){const t=this;let a=e.originalEvent.target;if(t._dragStartDetails=void 0,t.disabled||t.readonly)return;if(t.hasRippleAnimation&&(a.value instanceof Date||a.parentElement&&a.parentElement.classList.contains("smart-calendar-title")||a.parentElement===t.$.dateElement)&&Smart.Utilities.Animation.Ripple.animate(a,e.pageX,e.pageY),a=e.originalEvent.target.closest(".smart-calendar-header"),e.originalEvent.target.closest(".smart-calendar-year-container")&&"decade"!==t.displayMode){if("classic"===t.calendarMode)return;return void t._showDateView("year")}if(e.originalEvent.target.closest(".smart-calendar-date-container")&&"month"!==t.displayMode){if("classic"===t.calendarMode)return;return void t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell,"month")}if(t._animationStarted&&t._animateNavigationCompleted(),Smart.Utilities.Core.isMobile&&e.originalEvent.target.closest(".smart-calendar-body")===t.$.body)return void(t._dragStartDetails={x:e.pageX,y:e.pageY,startTime:Date.now(),target:e.originalEvent.target});if(a=e.originalEvent.target,a.closest(".smart-calendar-week")||a.parentElement===t.$.dateViewContainer){for(;a&&!(a.value instanceof Date);)a=a.parentElement;return void(a&&("month"!==t.displayMode?t._displayModeHandler(a):t._weeksDownHandler(e,a)))}if(a.closest(".smart-calendar-month-element"))return;if(e.originalEvent.stopPropagation(),"list"===t.displayModeView&&"month"!==t.displayMode)return a=(t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target).closest("smart-list-item"),void(a&&t._displayModeHandler(a));const n=document.scrollingElement||document.documentElement,l=n.scrollLeft,i=n.scrollTop;t.unfocusable||t.focus(),window.scrollTo(l,i)}_displayModeHandler(e,t){const a=this;if(a._animationStarted&&a._animateNavigationCompleted(),e instanceof HTMLElement&&e.closest(".smart-calendar-week")&&e.otherMonth){if("decade"===a.displayMode&&(e.value.getFullYear()<a.min.getFullYear()||e.value.getFullYear()>a.max.getFullYear()))return;if("year"===a.displayMode&&(e.value.getFullYear()<a.min.getFullYear()||e.value.getFullYear()===a.min.getFullYear()&&e.value.getMonth()<a.min.getMonth()||e.value.getFullYear()>a.max.getFullYear()||e.value.getFullYear()===a.max.getFullYear()&&e.value.getMonth()>a.max.getMonth()))return}switch(t=t||a.displayMode){case"year":t="month";break;case"decade":t="year"}if(a.displayMode===t)return;const n=a.$.listViewContainer,l=n&&n.contains(e);a.$.fireEvent("displayModeChanging",{oldDisplayMode:a.displayMode,newDisplayMode:t}).defaultPrevented||(a.set("displayMode",t),a.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),e.parentElement!==a.$.dateViewContainer||e.disabled||e.restricted||a._focusCell(e),a.hasAnimation?(l&&e instanceof HTMLLIElement?e.offsetHeight?a.$.animationPanel.style.transformOrigin=e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px":a.$.animationPanel.style.transformOrigin=n.offsetLeft+n.offsetWidth/2+"px "+(n.offsetTop+n.offsetHeight/2)+"px":(a.$.dateViewContainer.style.order=1,a.$.nextMonthsContainer.style.order=3,e=a._focusedCell,a.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px"),a._animateView(1,e)):a._setDisplayModeContent(e.value instanceof Date?e.value:new Date(e.getAttribute("value")||e.value)))}_animateView(e,t){const a=this;let n,l,i=t instanceof Date?t:new Date(t.getAttribute("value")||t.value),s=!1,o=1,r=1;const d=a.$.listViewContainer;"list"===a.displayModeView?n=d.contains(t)?d:l="month"!==a.displayMode?a.$.monthsContainer:d:t.value instanceof Date||(t=a._focusedCell?a._focusedCell:a._selectedCells.length>0?a._selectedCells[a._selectedCells.length-1]:a._getCellByDate(new Date)),n||(n=t.parentElement===a.$.dateViewContainer?a.$.dateViewContainer:a.$.monthsContainer),l||(l="month"===a.displayMode?a.$.monthsContainer:"list"===a.displayModeView?d:a.$.dateViewContainer),l.style.transformOrigin=a.$.animationPanel.style.transformOrigin,n===d?(a.$.animationPanel.innerHTML="",a.$.animationPanel.appendChild(n.cloneNode(!0))):a.$.animationPanel.innerHTML=n.innerHTML,a._setDisplayModeContent(i),n.style.order=1,a.$.nextMonthsContainer.style.order=3,a.$.body[a._animationSettings.scrollSize]=0,a.$.animationPanel.style.width=a.$.body.offsetWidth+"px",a.$.animationPanel.style.height=a.$.body.offsetHeight+"px",a.$.animationPanel.style.transform="scale(1)",a.$.animationPanel.style.opacity=1,a.$animationPanel.removeClass("smart-hidden"),l.style.opacity="0",l.style.transform="scale(3.5)",n.$.hasClass("smart-calendar-date-view-container")?a.$animationPanel.addClass("smart-calendar-date-view-container"):a.$animationPanel.removeClass("smart-calendar-date-view-container"),cancelAnimationFrame(a._animationId),a._animationId=requestAnimationFrame((function t(){if((e>0&&o>=3.5||e<0&&o<=0)&&(s=!0),s){if(cancelAnimationFrame(a._animationId),a.$animationPanel.addClass("smart-hidden"),a.$.animationPanel.style.transform="",a.$.animationPanel.style.opacity="",n.style.order=1,a.$.nextMonthsContainer.style.order=3,a.$.body[a._animationSettings.scrollSize]=0,l.style.transform="",l.style.opacity="",a.unfocusable)return;"month"===a.displayMode?a.$.body.focus():"list"===a.displayModeView&&a.focus()}else a.$.animationPanel.style.opacity=r,l.style.opacity=1-r,r-=.05,e>0?(a.$.animationPanel.style.transform="scale("+o+")",l.style.transform="scale("+Math.min((o-1)/2,1)+")",o+=.125):(a.$.animationPanel.style.transform="scale("+Math.max(o,0)+")",l.style.transform="scale("+Math.max(1+o,1)+")",o-=.06),a._animationId=requestAnimationFrame(t)}))}_documentUpHandler(e){const t=this;let a=e.originalEvent.target;if((t.isInShadowDOM||t.shadowRoot&&a===t)&&(a=e.originalEvent.composedPath()[0]),t._newRangeSelectionStarted&&!t.$.container.contains(a)&&delete t._newRangeSelectionStarted,a&&a.classList&&a.classList.contains("smart-calendar-cell")&&t._dragStartDetails&&(e.originalEvent.stopPropagation(),e.originalEvent.preventDefault(),e.preventDefault()),!Smart.Utilities.Core.isMobile||!t._dragStartDetails||e.originalEvent.target.closest(".smart-calendar-list-view"))return;delete t._previousIteration;const n=Date.now();let l={};(t.isInShadowDOM||t.shadowRoot&&a===t)&&(a=e.originalEvent.composedPath()[0]),"portrait"===t.scrollButtonsNavigationMode?(l.coordinate="y",l.direction="pageY"):(l.coordinate="x",l.direction="pageX");const i=t._dragStartDetails.step*(t.rightToLeft?-1:1);if(Math.abs(t._dragStartDetails[l.coordinate]-e[l.direction])<=10){if(a="list"===t.displayModeView&&"month"!==t.displayMode?a.closest("smart-list-item"):a,!a)return void(t._dragStartDetails=void 0);if("month"!==t.displayMode)return t._displayModeHandler(a),"portrait"===t.scrollButtonsNavigationMode?t.$.body.scrollTop=0:t.$.body.scrollLeft=0,void(t._dragStartDetails=void 0);if(t._weeksDownHandler(e,a),!t.disableAutoNavigation&&a.otherMonth)return}else{const a=Math.abs((e[l.direction]-t._dragStartDetails[l.coordinate])/(n-t._dragStartDetails.startTime));if(a>1){const e=parseInt(a);for(let a=0;a<e;a++)if(!t.navigate(i)){t._cancelAnimation();break}return void(t._dragStartDetails=void 0)}}if(!t.hasAnimation)return t.navigate(t._dragStartDetails.step),void(t._dragStartDetails=void 0);let s=("month"!==t.displayMode?t.$.dateViewContainer[t._animationSettings.scrollMax]:t.$.monthsContainer[t._animationSettings.scrollMax])+t.$.monthsSeparator[t._animationSettings.size];if(t._dragStartDetails.step>0&&t.$.body[t._animationSettings.scrollSize]>s*t._animationSettings.easeThreshold||t._dragStartDetails.step<0&&t.$.body[t._animationSettings.scrollSize]<s*t._animationSettings.easeThreshold)return t._animateNavigation(t._dragStartDetails.navigationDate,i,!0),6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&t._updateWeeksVisibility(i,t._getCellByDate(t._dragStartDetails.navigationDate,t.$.nextMonthsContainer)),t.$.fireEvent("navigationChange",{value:new Date(t._dragStartDetails.navigationDate),type:t.displayMode}),void(t._dragStartDetails=void 0);t._cancelAnimation(),t._dragStartDetails=void 0}_cancelAnimation(){const e=this,t="month"!==e.displayMode?e.$.dateViewContainer:e.$.monthsContainer;let a=e.$.animationPanel.style.transform,n=e.$.animationPanel.style.opacity;a&&(a=parseFloat(a.substring(a.indexOf("(")+1||0,a.indexOf(")")))),t.style.order=1,e.$.nextMonthsContainer.style.order=3,e.$.body[e._animationSettings.scrollSize]=0,e._animationId=requestAnimationFrame((function t(){if(!a||a>=3.5){cancelAnimationFrame(e._animationId),e.$animationPanel.addClass("smart-hidden"),e.$.animationPanel.style.transform="",e.$.animationPanel.style.opacity="";const t="month"===e.displayMode?e.$.monthsContainer:e.$.listViewContainer;return t.style.transform="",t.style.opacity="",e.unfocusable||("month"===e.displayMode?e.$.body.focus():"list"===e.displayModeView&&e.focus()),void(e._animationStarted=!1)}e.$.animationPanel.style.opacity=n-=.25,e.$.animationPanel.style.transform="scale("+(a+=.5)+")",e._animationId=requestAnimationFrame(t)}))}_focusCell(e,t){const a=this;if(a._focusedCell&&a._setCellState(a._focusedCell,"focus",!1),a.disabled||a.readonly)return;if(e){if("month"!==a.displayMode)return a._setCellState(e,"focus",!0),void(a._focusedCell=e);if(e.disabled||e.restricted)return;return t||a._setCellState(e,"focus",!0),void(a._focusedCell=e)}if("month"!==a.displayMode&&0===a.$.monthsContainer.offsetHeight)return;const n=a._selectedCells[a._selectedCells.length-1];if(n&&n.offsetHeight)a._setCellState(n,"focus",!0),a._focusedCell=n;else{const e=a.$.monthsContainer.children;if(!e[0]._date||a.min.getTime<e[0]._date.getTime())return;const t=a._getMonthCells(e[0],a.rightToLeft);for(let e=0;e<t.length;e++){const n=t[e];if(!n.otherMonth){if(n.disabled||n.restricted||!n.offsetHeight)continue;a._focusedCell=n;break}}}a._focusedCell&&a._setCellState(a._focusedCell,"focus",!0)}_getDays(e,t){const a=t.length;let n=[];if(a>0)for(let l=0;l<a;l++)t[l].getFullYear()===e.getFullYear()&&t[l].getMonth()===e.getMonth()&&n.push(t[l].getDate());return n}_getCellByDate(e,t){const a=this;if(!(e instanceof Date))return;if(t||(t=a.$.monthsContainer),"month"!==a.displayMode){if("list"===a.displayModeView)return;let t=arguments[1]?a.$.nextMonthsContainer.children:a.$.dateViewContainer.children;for(let n=0;n<t.length;n++)if("year"!==a.displayMode){if(t[n].value.getFullYear()===e.getFullYear())return t[n]}else if(t[n].value.getMonth()===e.getMonth())return t[n];return}let n,l,i=t.children;for(let t=0;t<i.length;t++)if(e.getFullYear()===i[t]._date.getFullYear()&&e.getMonth()===i[t]._date.getMonth()){n=i[t];break}if(n){l=a._getMonthCells(n);for(let t=0;t<l.length;t++)if((!l[t].otherMonth||l[t].hover)&&l[t].value.getMonth()===e.getMonth()&&l[t].value.getDate()===e.getDate())return l[t]}}_getMonthCells(e,t){const a=e.getElementsByClassName("smart-calendar-week");let n=[];if(t)for(let e=0;e<a.length;e++){let t=a[e].children;for(let e=t.length-1;e>0;e--)t[e].classList.contains("smart-calendar-cell")&&n.push(t[e])}else for(let e=0;e<a.length;e++){let t=a[e].children;for(let e=1;e<t.length;e++)t[e].classList.contains("smart-calendar-cell")&&n.push(t[e])}return n}_getWeekNumber(e){const t=this;let a,n=new Date(e.getFullYear(),0,1),l=Math.round((e.getTime()-n.getTime()-6e4*(e.getTimezoneOffset()-n.getTimezoneOffset()))/864e5)+1,i=n.getDay()-t.firstDayOfWeek;return i=i>=0?i:i+7,i<4?(a=Math.floor((l+i-1)/7)+1,a>52&&(n=new Date(e.getFullYear()+1,0,1),i=n.getDay()-t.firstDayOfWeek,i=i>=0?i:i+7,a=i<4?1:53)):a=Math.round((l+i-1)/7),a}_handleDateSelection(e){const t=this;if(void 0!==e&&!e.disabled&&!e.restricted)switch(t.selectionMode){case"none":t._focusCell(e);break;case"oneExtended":case"one":case"default":if(t._keysPressed.Control)return t.selectedDates.length>1||1===t.selectedDates.length&&!e.selected?void t._selectDate(e.value):void t._focusCell(e);if(t._keysPressed.Shift)return void t._selectMultipleDates(new Date(t.selectedDates[0]),e);t._clearSelection(!0),t._selectDate(e.value,t._selectedCells.indexOf(e.value)>-1);break;case"many":{if(0===t.selectedDates.length)return void t._selectDate(e.value);const a=t.selectedDates[t.selectedDates.length-1];let n=new Date(t.selectedDates[0]);if(e.value.getTime()===n.getTime()||e.value.getTime()===a.getTime())return t._clearSelection(),void t._focusCell(e);t.selectedDates.length>0&&t._selectMultipleDates(n,e);break}case"range":{if(t.selectedDates.length>1&&!t._keysPressed.Control&&!t._newRangeSelectionStarted&&t._clearSelection(!0),0===t.selectedDates.length||t._keysPressed.Control&&t.selectedDates.length>1&&!t._newRangeSelectionStarted){if(e.value&&t.selectedDates.find((t=>t.getTime()===e.value.getTime())))return;return t._newRangeSelectionStarted=!0,void t._selectDate(e.value)}const a=t.selectedDates[t.selectedDates.length-1];let n=t._keysPressed.Control||t._newRangeSelectionStarted?a:new Date(t.selectedDates[0]);t.selectedDates.length>0&&t._selectMultipleDates(n,e),delete t._newRangeSelectionStarted;break}case"zeroOrMany":t._selectDate(e.value);break;case"oneOrMany":if(1===t.selectedDates.length&&e.selected)return void t._focusCell(e);t._selectDate(e.value);break;case"zeroOrOne":if(1===t.selectedDates.length&&e.selected)return void t._selectDate(e.value);t._clearSelection(!0),t._selectDate(e.value);break;case"week":{if(e.selected&&(e.value.getTime()===t.selectedDates[0].getTime()||e.value.getTime()===t.selectedDates[t.selectedDates.length-1].getTime()))return t._clearSelection(),void t._focusCell(e);t._clearSelection(!0);let a=new Date(e.value);t._selectDate(a);for(let e=1;e<7;e++)a.setDate(a.getDate()+1),t._selectDate(a);t._isDateInView(a)||t.navigate(1);break}}}_handleImportantDateTemplate(){const e=this;if(e._importantDatesTemplate=e._validateTemplate("importantDatesTemplate",e.importantDatesTemplate),!e._importantDatesTemplate||!e._importantDatesTemplate.content)return;let t=e._importantDatesTemplate.content;const a=t.childNodes.length,n=/{{\w+}}/g;let l;e._bindingDetails=[];for(let i=0;i<a;i++)if(l=n.exec(t.childNodes[i].innerHTML),l)return void e._bindingDetails.push({childNodeIndex:i,bindingString:l[0]})}_handleLayoutTemplate(e,t){const a=this,n=a._validateTemplate(e.$.hasClass("smart-header")?"headerTemplate":e.$.hasClass("smart-calendar-footer")?"footerTemplate":"titleTemplate",t);if(!n||!n.content)return void("function"==typeof t&&t(e,{}));a._layoutTemplates||(a._layoutTemplates=[]);let l=document.importNode(n.content,!0);e.innerHTML="";const i=l.childNodes.length,s=/{{\w+}}/g;let o,r=[];for(let e=0;e<i;e++)o=s.exec(l.childNodes[e].innerHTML),o&&r.push({childNodeIndex:e,bindingString:o[0]});if(a._layoutTemplates=a._layoutTemplates.filter((t=>t.selector!==e)),a._layoutTemplates.push({selector:e,template:n,bindings:r}),a.shadowRoot)return e.innerHTML="<slot></slot>",void a.appendChild(l);e.appendChild(l)}_handleCalendarCellHover(e,t){const a=this;if(!a._animationStarted){if("month"===a.displayMode)if("mouseover"===e.type&&("many"===a.selectionMode||"range"===a.selectionMode&&a._newRangeSelectionStarted)&&a.selectedDates.length>0){const e=a.$.monthsContainer.children;for(let t=0;t<e.length;t++)a._getMonthCells(e[t]).map((e=>{a._setCellState(e,"hover",!1)}));let n=new Date("range"===a.selectionMode?a.selectedDates[a.selectedDates.length-1]:a.selectedDates[0]),l=new Date(t.value),i=t;const s=n.getTime()>l.getTime()?-1:1,o=function(){i=a._getCellByDate(n),!i||i.selected||i.restricted||a._setCellState(i,"hover",!0)};if(n.getTime()!==l.getTime()){for(n.setDate(n.getDate()+s);n.getTime()!==l.getTime();)o(),n.setDate(n.getDate()+s);o()}}else a._setCellState(t,"hover",!1);"mouseover"!==e.type||t.otherMonth?a._setCellState(t,"hover",!1):a._setCellState(t,"hover",!0)}}_handleMonths(e,t){const a=this;let n;function l(e){let t,n=e.children.length,l=document.createDocumentFragment();for(;n<a.months;n++)t=a.$.month.cloneNode(!1),t.innerHTML=a.$.month.innerHTML,l.appendChild(t);return l}function i(t){let n=t.children;for(let t=0;t<n.length;t++)a._setMonth(e,n[t]),e.setMonth(e.getMonth()+1);a._setWeeksVisibility(t),a._refreshHeaderElements(),a._refreshHeaderTitle(),a.tooltip&&a.$.tooltip&&a.$.tooltip.close(),a.$.body===document.activeElement&&a._focusCell()}if(e||(e=a._viewDates&&a._viewDates.length>0?a._viewDates[0]:new Date),e=new Date(Math.min(Math.max(a.min.getTime(),e.getTime()),a.max.getTime())),t||(t=a.$.monthsContainer),a._selectedCells=[],a.hasAnimation){for(n=a.$.nextMonthsContainer.children,n.length>0&&n[0].value instanceof Date&&(a.$.nextMonthsContainer.innerHTML="");a.$.nextMonthsContainer.childElementCount<a.months;)a.$.nextMonthsContainer.appendChild(l(a.$.nextMonthsContainer));for(;a.$.nextMonthsContainer.childElementCount>a.months;)a.$.nextMonthsContainer.removeChild(n[a.$.nextMonthsContainer.childElementCount-1]);if(arguments[1]===a.$.nextMonthsContainer)return void i(a.$.nextMonthsContainer)}if(n=a.$.monthsContainer.children,n.length>a.months){for(;a.$.monthsContainer.childElementCount>a.months;)a.$.monthsContainer.removeChild(n[a.$.monthsContainer.childElementCount-1]),a._viewDates.pop();i(a.$.monthsContainer)}else a.$.monthsContainer.children.length!==a.months?(a._viewDates=[],a.$.monthsContainer.appendChild(l(a.$.monthsContainer)),i(a.$.monthsContainer)):i(a.$.monthsContainer)}_headerChangeHandler(e){const t=this;if(e.stopPropagation(),t.disabled||t.readonly)return;if(e.target.ownerElement===t.$.monthElement&&0!==t._changeEventFired)return void t._changeEventFired--;const a=t.displayMode;e.target===t.$.yearElement&&(t._viewDates[0].setFullYear(Math.min(Math.max(t.min.getFullYear(),isNaN(parseInt(t.$.yearElement.value))?0:parseInt(t.$.yearElement.value)),t.max.getFullYear())),t._handleMonths(t._viewDates[0])),!t.$.monthElement||e.target!==t.$.monthElement&&e.target.ownerElement!==t.$.monthElement||(t._handleMonths(new Date(t.$.monthsContainer.children[0]._date.getFullYear(),t.$.monthElement.selectedIndex,1)),"month"!==a&&t._setDisplayMode(t.displayMode,t.displayMode="month"))}_headerClickHandler(e){const t=this;if(t.disabled||t.readonly)return;let a=e.target.closest("smart-repeat-button");if(!a||!a.disabled){switch(a){case t.$.previousMonthButton:return t._isInteractiveNavigation=!0,void t.navigate(-1*t.months*(t.rightToLeft?-1:1));case t.$.nextMonthButton:return t._isInteractiveNavigation=!0,void t.navigate(1*t.months*(t.rightToLeft?-1:1));case t.$.previousYearButton:return void t.navigate(-12);case t.$.nextYearButton:return void t.navigate(12)}"classic"!==t.calendarMode&&e.target.closest(".smart-calendar-date-element")&&(t._animationStarted&&t._animateNavigationCompleted(),t._isInteractiveNavigation=!0,t._showDateView())}}_selectMultipleDates(e,t){const a=this;if(t instanceof HTMLElement&&(t=t.value),a._newRangeSelectionStarted?a._selectDate(e,!0):a._clearSelection(!0),"range"!==a.selectionMode||t.getTime()!==e.getTime()){if((e=new Date(e)).getTime()<t.getTime())for(;e.getTime()<=t.getTime();)a.selectedDates.find((t=>t.getTime()===e.getTime()))||a._selectDate(e,!0),e.setDate(e.getDate()+1);else if(e.getTime()>t.getTime())for(;e.getTime()>=t.getTime();)a.selectedDates.find((t=>t.getTime()===e.getTime()))||a._selectDate(e,!0),e.setDate(e.getDate()-1);else a._selectDate(t,!0);a.$.hiddenInput.value=a.selectedDates.toString(),a._refreshFooter(),a.isInitialized&&(a.$.fireEvent("change",{value:a.selectedDates}),a._updateTargetValue()),a._refreshTitle()}}_setDisplayMode(e,t,a){const n=this;if(n.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),0!==arguments.length&&n.hasAnimation)if(n._animationStarted&&(n.displayMode=e,n._animateNavigationCompleted(),n.displayMode=t),"month"===e&&"year"===t||"year"===e&&"decade"===t)n.displayMode=e,n._showDateView(a?void 0:n.displayMode);else if("month"===e&&"decade"===t)n._showDateView(n.displayMode="year");else{let e;"list"===n.displayModeView?(e=n.$.listViewContainer.querySelector("li.active"),n.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop>0?e.offsetTop-e.offsetHeight/2:e.offsetTop+e.offsetHeight/2)+"px"):(n.$.dateViewContainer.style.order=1,n.$.nextMonthsContainer.style.order=3,e=n._focusedCell,n.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(e.offsetTop+e.offsetHeight/2)+"px"),n._animateView(1,e)}else{if("classic"===n.calendarMode)return void(n.displayMode="month");if("month"!==n.displayMode&&(n.$monthsContainer.addClass("smart-hidden"),n.$dateViewContainer.hasClass("smart-hidden")&&n.$dateViewContainer.removeClass("smart-hidden")),!n.isCompleted&&"month"===n.displayMode)return;n._setDisplayModeContent()}}_setDisplayModeContent(e,t){const a=this;let n=e&&"Invalid Date"!==e.toString()?e:a.selectedDates.length>0?a.selectedDates[a.selectedDates.length-1]:new Date;n.setTime(Math.min(Math.max(n.getTime(),a.min.getTime()),a.max.getTime())),n.setHours(0,0,0,0);const l=a._prepareView(n);if(!l)return;let i;t?(a.$.nextMonthsContainer.innerHTML=a.$.dateViewContainer.innerHTML,i=a.$.nextMonthsContainer):i=a.$.dateViewContainer;const s=i.children;let o;for(let e=0;e<s.length;e++){const t=s[e];t.innerHTML=l.viewContent[e],t.value=l.dates[e],"year"===a.displayMode?(t.value.getFullYear()<a.min.getFullYear()||t.value.getFullYear()===a.min.getFullYear()&&t.value.getMonth()<a.min.getMonth()||t.value.getFullYear()>a.max.getFullYear()||t.value.getFullYear()===a.max.getFullYear()&&t.value.getMonth()>a.max.getMonth()?a._setCellState(t,"otherMonth",!0):a._setCellState(t,"otherMonth",!1),n.getFullYear()===t.value.getFullYear()&&n.getMonth()===t.value.getMonth()&&(o=t)):"decade"===a.displayMode&&(0===e||e===s.length-1||t.value.getFullYear()<a.min.getFullYear()||t.value.getFullYear()>a.max.getFullYear()?a._setCellState(t,"otherMonth",!0):a._setCellState(t,"otherMonth",!1),n.getFullYear()===t.value.getFullYear()&&(o=t)),a._setCellState(t,"hover",!1),a._setCellState(t,"focus",!1)}if(o.otherMonth)for(let e=0;e<s.length;e++)if(!s[e].otherMonth){o=s[e];break}a._mobileScrolling||(a._focusedCell&&a._setCellState(a._focusedCell,"focus",!1),a._focusedCell=o,a._focusCell(a._focusedCell),a._refreshHeaderTitle(),a._refreshHeaderElements(),a.$.fireEvent("displayModeChange"),a._isInteractiveNavigation?a._isInteractiveNavigation=void 0:(a._setCellState(o,"focus",!0),setTimeout((function(){a.unfocusable||(a.$.body.focus(),a._focusCell(a._focusedCell))}),0)))}_prepareView(e){const t=this,a=t.$.listViewContainer;let n,l,i=[],s=[];function o(e,t,a){let n=new Date(e,t+1,0),l=n.getDate();return a>l?n.setDate(l):n.setDate(a),n}if("month"===t.displayMode)return t.$nextMonthsContainer.hasClass("smart-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-date-view-container"),a&&a.classList.add("smart-hidden"),t.$dateViewContainer.hasClass("smart-visibility-hidden")&&t.$dateViewContainer.removeClass("smart-visibility-hidden"),t._isDateInView(e)||t._handleMonths(e),t.$header.hasClass("smart-hidden")&&t.$header.removeClass("smart-hidden"),t.$body.hasClass("smart-calendar-list-view")&&t.$body.removeClass("smart-calendar-list-view"),t.$dateContainer.addClass("smart-calendar-selected"),t.$yearContainer.removeClass("smart-calendar-selected"),t.$dateViewContainer.addClass("smart-hidden"),t.$monthsContainer.removeClass("smart-hidden"),t._refreshHeaderTitle(),t.$.body.setAttribute("tabindex",t.tabIndex>0?t.tabIndex:0),t._refreshHeaderElements(),t.unfocusable||t.$.body.focus(),t._focusCell(t._getCellByDate(e)),void t.$.fireEvent("displayModeChange");if("list"===t.displayModeView)return t._setDisplayModeListContent(e),void t.$.fireEvent("displayModeChange");if(t.$header.hasClass("smart-hidden")&&t.$header.removeClass("smart-hidden"),t.$dateViewContainer.hasClass("smart-visibility-hidden")&&t.$dateViewContainer.removeClass("smart-visibility-hidden"),a&&a.classList.add("smart-hidden"),t.$.body.setAttribute("tabindex",t.tabIndex>0?t.tabIndex:0),"year"===t.displayMode){let a=new Date;for(let n=0;n<12;n++)a=o(a.getFullYear(),n,a.getDate()),i.push(a.toLocaleDateString(t.locale,{month:"short"})),s.push(o(e.getFullYear(),n,e.getDate()))}else{n=e?e.getFullYear():t._viewDates[0].getFullYear(),l=n%10,0!==l&&(n-=l),n-=1;for(let t=0;t<12;t++)i.push(n+""),s.push(new Date(n,e.getMonth(),e.getDate())),++n}return{viewContent:i,dates:s}}_setDisplayModeListContent(e){const t=this;let a=[];function n(e,t,a){let n=new Date(e,t+1,0),l=n.getDate();return a>l?n.setDate(l):n.setDate(a),n}if(t.$dateViewContainer.addClass("smart-visibility-hidden"),"year"===t.displayMode){let l=new Date;for(let i=0;i<12;i++)l=n(l.getFullYear(),i,l.getDate()),a.push({label:l.toLocaleDateString(t.locale,{month:"short"}),value:n(e.getFullYear(),i,e.getDate()).toDateString()});t.$yearContainer.removeClass("smart-calendar-selected"),t.$dateContainer.addClass("smart-calendar-selected")}else{let n=t.min.getFullYear(),l=t.max.getFullYear();l=Math.min(t.max.getFullYear(),e.getFullYear()+10),n=Math.max(t.min.getFullYear(),l-10);for(let t=n;t<l;t++)a.push({label:t.toString(),value:new Date(t,e.getMonth(),e.getDate()).toDateString()});t.$yearContainer.addClass("smart-calendar-selected"),t.$dateContainer.removeClass("smart-calendar-selected")}t._prepareListViewer(a,e.toDateString()),t._refreshHeaderTitle(),t._refreshHeaderElements(),t.unfocusable||t.focus()}_prepareListViewer(e=[],t){const a=this,n=a.$.body;let l=a.$.listViewContainer;l||(a.$.listViewContainer=l=document.createElement("smart-scroll-viewer"),l.classList.add("smart-input-drop-down-menu","smart-calendar-list-view"),l.ensureVisible=a._listViewerEnsureVisible.bind(a),l._handleKeyStrokes=a._listViewerKeyStrokesHandler.bind(a),l._setActiveDescendant=a._listViewerSetActiveDescendant.bind(a));let i=l.querySelector("ul");i||(i=document.createElement("ul"),i.onclick=a._listViewContainerItemClickHandler.bind(a),l.appendChild(i)),n.contains(l)&&n.removeChild(l),i.innerHTML="";for(let a=0;a<e.length;a++){const n=e[a],s=n.label,o=n.value,r=document.createElement("li"),d=document.createElement("a");t===o?(r.setAttribute("aria-selected",!0),r.classList.add("active"),t=r):r.setAttribute("aria-selected",!1),r.id=l.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),r.setAttribute("value",o),r.setAttribute("role","option"),r.setAttribute("aria-label",s),d.innerHTML=s,d.setAttribute("aria-hidden",!0),r.appendChild(d),i.appendChild(r)}l.classList.remove("smart-hidden"),n.classList.add("smart-calendar-list-view"),n.removeAttribute("tabindex"),n.insertBefore(l,a.$.animationPanel),l.refresh(),l.ensureVisible()}_listViewerEnsureVisible(){const e=this.$.listViewContainer,t=e.querySelector(".active");if(!t)return;const a=Array.from(e.querySelectorAll("li"));t.offsetTop+t.offsetHeight>=e.scrollTop+e.offsetHeight&&(e.scrollTop=t.offsetTop+t.offsetHeight),(t.offsetTop<=e.scrollTop||t.offsetTop>=e.scrollTop+e.offsetHeight)&&(e.scrollTop=t.offsetTop),0===a.indexOf(t)?e.scrollTop=0:a.indexOf(t)===a.length-1&&(e.scrollTop=e.scrollHeight)}_listViewerKeyStrokesHandler(e){if(["ArrowUp","ArrowDown"].indexOf(e)<0)return;event.preventDefault();const t=this.$.listViewContainer,a=t.querySelector(".active");if(!a){const e=t.querySelector("li");return e.classList.add("active"),void t._setActiveDescendant(e)}const n=a["ArrowDown"===e?"nextElementSibling":"previousElementSibling"];n&&(a.classList.remove("active"),n.classList.add("active"),t._setActiveDescendant(n),t.ensureVisible())}_listViewerSetActiveDescendant(e){const t=this.$.listViewContainer;e?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant")}_listViewContainerItemClickHandler(e){const t=this,a=e.target.closest("li");a&&"list"===t.displayModeView&&"month"!==t.displayMode&&t._displayModeHandler(a)}_isDateInView(e){const t=this;if(!e)return!1;for(let a=0;a<t._viewDates.length;a++)if(e.getFullYear()===t._viewDates[a].getFullYear()&&e.getMonth()===t._viewDates[a].getMonth()){let a=t._getCellByDate(e,t._animationStarted?t.$.nextMonthsContainer:void 0);if(!a)return;return!(a.otherMonth||!a.offsetHeight||a.classList.contains("smart-visibility-hidden"))}return!1}_keyDownHandler(e){const t=this;if(t.disabled||t.readonly)return;const a=(t.shadowRoot||t.getRootNode()).activeElement||document.activeElement;switch(a){case t.$.yearElement:"Escape"===e.key&&t._refreshHeaderElements();break;case t.$.dateElement:if("default"===t.calendarMode&&" "===e.key||"Enter"===e.key)return e.preventDefault(),t._isInteractiveNavigation=!0,void t._showDateView();t._focusedCell||t._focusCell(),e.key.indexOf("Arrow")>-1&&t.$.dateElement===a&&!t.unfocusable&&t.$.body.focus(),t._navigateDays(e);break;case t.$.body:" "===e.key&&e.preventDefault(),t._navigateDays(e);break;case t.$.yearContainer:if(" "!==e.key&&"Enter"!==e.key||"decade"===t.displayMode||(e.preventDefault(),t._isInteractiveNavigation=!0,t._showDateView("year")),e.key.indexOf("Arrow")>-1){if(e.preventDefault(),t._focusedCell||t._focusCell(),"month"!==t.displayMode&&"list"===t.displayModeView)return t.unfocusable||t.focus(),void t.$.listViewContainer._handleKeyStrokes(e.key);t._navigateDays(e)}break;case t.$.dateContainer:if(" "!==e.key&&"Enter"!==e.key||"month"===t.displayMode||(e.preventDefault(),t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell,"month")),e.key.indexOf("Arrow")>-1){if(t._focusedCell||t._focusCell(),"month"!==t.displayMode&&"list"===t.displayModeView)return t.unfocusable||t.focus(),void t.$.listViewContainer._handleKeyStrokes(e.key);t._navigateDays(e)}break;default:if("month"!==t.displayMode&&"list"===t.displayModeView)return["Arrow","End","Home","Page"].indexOf(e.key)&&e.preventDefault()," "===e.key||"Enter"===e.key||e.ctrlKey&&("ArrowUp"===e.key||"ArrowDown"===e.key)?void t._navigateDays(e):void t.$.listViewContainer._handleKeyStrokes(e.key);e.key.indexOf("Arrow")>-1&&(t._focusedCell||t._focusCell(),t._navigateDays(e))}}_showDateView(e){const t=this;switch(e=e||t.displayMode){case"month":e="year";break;case"year":e="decade"}if(t.displayMode===e)return;if(t.$.fireEvent("displayModeChanging",{oldDisplayMode:t.displayMode,newDisplayMode:e}).defaultPrevented)return;let a;if(t.displayMode=e,"list"===t.displayModeView&&"month"!==t.displayMode){t._setDisplayModeListContent(t._focusedCell?t._focusedCell.value:t._viewDates[0]);const e=t.$.listViewContainer;e.classList.remove("smart-hidden"),a=e.querySelector("li.active"),a.offsetHeight?t.$.animationPanel.style.transformOrigin=a.offsetLeft+a.offsetWidth/2+"px "+(a.offsetTop>0?a.offsetTop-a.offsetHeight/2:a.offsetTop+a.offsetHeight/2)+"px":t.$.animationPanel.style.transformOrigin=e.offsetLeft+e.offsetWidth/2+"px "+(a.offsetTop>0?a.offsetTop-a.offsetHeight/2:e.offsetTop+e.offsetHeight/2)+"px"}else t._focusedCell||t._focusCell(),a=t._focusedCell,t.$.animationPanel.style.transformOrigin=a.offsetLeft+a.offsetWidth/2+"px "+(a.offsetTop+a.offsetHeight/2)+"px";t.$monthsContainer.addClass("smart-hidden"),t.$dateViewContainer.hasClass("smart-hidden")&&t.$dateViewContainer.removeClass("smart-hidden"),"decade"===t.displayMode&&(t.$yearContainer.addClass("smart-calendar-selected"),t.$dateContainer.removeClass("smart-calendar-selected")),t.hasAnimation?t._animateView(-1,a):t._setDisplayModeContent(t._focusedCell?t._focusedCell.value:t._viewDates[0])}_keyUpHandler(e){const t=this;t.disabled||t.readonly||"default"!==t.selectionMode&&"range"!==t.selectionMode||"Shift"!==e.key&&"Control"!==e.key||(t._keysPressed[e.key]=!1)}_handleTooltip(){const e=this,t=e.tooltip;let a=e.$.tooltip;t?(a||(a=document.createElement("smart-tooltip"),a.tooltipTemplate=e.tooltipTemplate,a.arrow=e.tooltipArrow,a.arrowDirection=e.tooltipArrowDirection,a.offset=e.tooltipOffset,a.position=e.tooltipPosition,a.delay=e.tooltipDelay,a.rightToLeft=e.rightToLeft,a.openMode="manual",e.$.tooltip=a),a.parentElement||e.$.calendarContainer.appendChild(a)):a&&a.remove()}_mouseEventsHandler(e){const t=this;if(t.disabled||t.readonly)return;const a=t.$.tooltip;if("mouseenter"===e.type)return void t.$.setAttributeValue("hover",!0);if("mouseleave"===e.type){if(t.$.setAttributeValue("hover",!1),t._newRangeSelectionStarted&&"range"===t.selectionMode){const e=t.$.monthsContainer.children;for(let a=0;a<e.length;a++)t._getMonthCells(e[a]).map((e=>{t._setCellState(e,"hover",!1)}))}return void(t.tooltip&&a&&a.close())}const n=t.shadowRoot||t.isInShadowDOM?e.composedPath()[0]:e.target;if(!n.closest(".smart-calendar-week"))return void(t.tooltip&&a&&(clearTimeout(t._tooltipAutoCloseTimeout),a[a.contains(n)?"open":"close"]()));const l=n.closest(".smart-calendar-cell");if(!l)return;if(Smart.Utilities.Core.isMobile||t._handleCalendarCellHover(e,l),!t.tooltip&&a)return void a.close();const i=l.hasAttribute("important");if(clearTimeout(t._tooltipAutoCloseTimeout),i&&a&&"mouseover"===e.type)return a.selector=l,void(a.selector!==l?a.close():(t.tooltipTemplate||(a.innerHTML=0===a.innerHTML.trim().length?"Important day!":a.innerHTML),a.open(),t.$.fireEvent("open",{target:a,value:new Date(l.value)})));t._tooltipAutoCloseTimeout=setTimeout(function(){!a||"mouseout"!==e.type&&l&&i||a.close(),clearTimeout(t._tooltipAutoCloseTimeout)}.bind(t),t.tooltipDelay)}_popupEventHandler(e){const t=this,a=t.$.tooltip;if(e.stopPropagation(),e.target!==t.$.monthElement)if(e.target===a)if("close"!==e.type);else{const e=a.selector;t.$.fireEvent("close",{target:a,value:e?new Date(e.value):null})}else t.$.fireEvent(e.type,{target:e.target})}_moveHandler(e){const t=this;if(!Smart.Utilities.Core.isMobile||!t._dragStartDetails||"list"===t.displayModeView&&"month"!==t.displayMode)return;e.originalEvent.preventDefault(),e.preventDefault(),e.stopPropagation();const a={x:Math.round(e.pageX),y:Math.round(e.pageY)};let n,l,i;if(n="portrait"===t.scrollButtonsNavigationMode?a.y>t._dragStartDetails.y?-1*t.months:1*t.months:a.x<t._dragStartDetails.x?1*t.months:-1*t.months,t._previousIteration&&n===t._previousIteration.step)l=t._previousIteration.date;else if(6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode){let e,a;t._focusedCell||t._focusCell();const i=[].slice.call(t._focusedCell.closest(".smart-calendar-weeks").children).filter((e=>!e.classList.contains("smart-hidden")));if(i.length){let s;!t.rightToLeft&&n<0||t.rightToLeft&&n>0?(s=i[0].querySelectorAll(".smart-calendar-cell"),a=t.rightToLeft?s[s.length-1]:s[0]):(s=i[i.length-1].querySelectorAll(".smart-calendar-cell"),a=t.rightToLeft?s[0]:s[s.length-1]),e=new Date(a.value),e.setDate(e.getDate()+n*(t.rightToLeft?-1:1)),l=e}else l=t._getNextDate(n*(t.rightToLeft?-1:1))}else l=t._getNextDate(n*(t.rightToLeft?-1:1));if(!l)return;if(!t._dragStartDetails.navigationDate&&t.$.fireEvent("navigationChanging",{value:new Date(l),type:t.displayMode}).defaultPrevented)return t._cancelAnimation(),void(t._dragStartDetails=void 0);if(t._dragStartDetails.step=n,t._dragStartDetails.navigationDate=new Date(l),!t.hasAnimation)return;if(t._previousIteration={step:n,date:l},t._mobileScrolling=!0,"month"!==t.displayMode)t.$nextMonthsContainer.addClass("smart-calendar-date-view-container"),i=t.$.dateViewContainer,t.$.nextMonthsContainer.children[0].value instanceof Date&&t.$.nextMonthsContainer.children[1].value.getFullYear()===l.getFullYear()||t._setDisplayModeContent(l,t.$.nextMonthsContainer);else if(t.$nextMonthsContainer.hasClass("smart-calendar-date-view-container")&&t.$nextMonthsContainer.removeClass("smart-calendar-date-view-container"),i=t.$.monthsContainer,!t.$.nextMonthsContainer.children[0]._date||t.$.nextMonthsContainer.children[0]._date.getTime()!==l.getTime()){let e=t.$.nextMonthsContainer.children;for(let a=0;a<e.length;a++)l.setMonth(t._dragStartDetails.navigationDate.getMonth()+a*(t.rightToLeft?-1:1)),t._setMonth(new Date(l),e[a],!0)}6!==t.weeks&&0!==t.weeks&&"month"===t.displayMode&&t._updateWeeksVisibility(n*(t.rightToLeft?-1:1),t._getCellByDate(l,t.$.nextMonthsContainer)),delete t._mobileScrolling,n<0?(i.style.order=3,t.$.nextMonthsContainer.style.order=1,t.$.body[t._animationSettings.scrollSize]=t.$.body[t._animationSettings.scrollMax]):(i.style.order=1,t.$.nextMonthsContainer.style.order=3,t.$.body[t._animationSettings.scrollSize]=0);const s="portrait"===t.scrollButtonsNavigationMode?"y":"x";Math.abs(t._dragStartDetails[s]-a[s])>5&&(t.$.body[t._animationSettings.scrollSize]+=2*-(a[s]-t._dragStartDetails[s]))}_getNextDate(e){const t=this;let a;if("month"!==t.displayMode){let n;const l=t._focusedCell&&t._focusedCell.value.getFullYear();if("list"===t.displayModeView)a=new Date(t.$.listViewContainer.querySelector("li").getAttribute("value"));else{let e=t._animationStarted?t.$.nextMonthsContainer:t.$.dateViewContainer;a=new Date("year"===t.displayMode?e.children[0].value:e.children[1].value)}n="year"===t.displayMode?1:0!==e?10:1,a.setFullYear(a.getFullYear()+(e>0?n:-n)),a.getTime()<t.min.getTime()&&(a=t.min),a.getTime()>t.max.getTime()&&(a=t.max);const i="month"!==t.displayMode&&"list"===t.displayModeView;if(a.getFullYear()<t.min.getFullYear()||a.getFullYear()>t.max.getFullYear()||!i&&l===a.getFullYear())return}else{let n=t._viewDates[0];if(a=new Date(n),a.setDate(1),a.setMonth(a.getMonth()+e),a.setTime(Math.min(Math.max(a.getTime(),t.min.getTime()),t.max.getTime())),n.getMonth()===a.getMonth()&&n.getFullYear()===a.getFullYear())return}return a}_navigateDays(e){const t=this;let a="ArrowUp"===e.key||"ArrowDown"===e.key?7:1,n="ArrowUp"===e.key||"ArrowLeft"===e.key||"PageUp"===e.key?-1:1;switch(e.key){case"ArrowUp":case"ArrowLeft":case"ArrowDown":case"ArrowRight":if(!t._handleArrowKeys(e,a,n))return;break;case" ":case"Enter":{if("month"!==t.displayMode)return void t._displayModeHandler("list"===t.displayModeView?t.$.listViewContainer.querySelector("li.active"):t._focusedCell);const e=t._focusedCell;if("oneExtended"===t.selectionMode&&e)return t._clearSelection(!0),void t._selectDate(e.value,t._selectedCells.indexOf(e.value)>-1);break}case"Control":case"Shift":return"default"===t.selectionMode&&(t._keysPressed[e.key]=!0),void("range"===t.selectionMode&&(t._keysPressed[e.key]="Control"===e.key));case"Home":case"End":{e.preventDefault();let a,n=function(t){if("Home"===e.key){for(let e=0;e<t.length;e++)if(!t[e].otherMonth&&(!t[e].disabled||!t[e].restricted)&&t[e].offsetHeight)return t[e]}else for(let e=t.length-1;e>=0;e--)if(!t[e].otherMonth&&(!t[e].disabled||!t[e].restricted)&&t[e].offsetHeight)return t[e]};if(a="month"!==t.displayMode?n(t.$.dateViewContainer.children):n(t._getMonthCells(t._focusedCell.closest(".smart-calendar-month"),t.rightToLeft)),!a)return;if(t._focusCell(a),"month"!==t.displayMode)return;break}case"PageUp":case"PageDown":if(!t._handlePageUpDownKeys(e,n))return;break;default:return}"oneExtended"!==t.selectionMode&&t._focusedCell&&t._handleDateSelection(t._focusedCell)}_handleArrowKeys(e,t,a){const n=this;let l;if("month"!==n.displayMode||n._animationStarted||n.unfocusable||n.$.body.focus(),n._focusedCell||n._focusCell(n._getCellByDate(new Date)),e.altKey)return;if(e.ctrlKey){if("ArrowDown"===e.key||"ArrowUp"===e.key){if("classic"===n.calendarMode)return;let t;switch(n.displayMode){case"month":t="ArrowDown"===e.key?"month":"year";break;case"year":t="ArrowDown"===e.key?"month":"decade";break;case"decade":t="ArrowDown"===e.key?"year":"decade"}if(t!==n.displayMode){const e=n.displayMode;n.displayMode=t,n._setDisplayMode(e,t,"month"===e),n._keysPressed&&delete n._keysPressed.Control}}return}if(e.preventDefault(),!n.rightToLeft||"ArrowLeft"!==e.key&&"ArrowRight"!==e.key||(a*=-1),"month"!==n.displayMode&&"list"!==n.displayModeView){const i=n._animationStarted?n.$.nextMonthsContainer.children:n.$.dateViewContainer.children;if(t="ArrowUp"===e.key||"ArrowDown"===e.key?4:1,"year"===n.displayMode){const e=n._focusedCell.value.getMonth()+a*t;let i=new Date(n._focusedCell.value.getFullYear(),e+1,0);n._focusedCell.value.getDate()<=i.getDate()&&(i=n._focusedCell.value),l=new Date(n._focusedCell.value.getFullYear(),e,i.getDate())}else l=new Date(n._focusedCell.value.getFullYear()+a*t,n._focusedCell.value.getMonth(),n._focusedCell.value.getDate());if("year"===n.displayMode){if(l.getFullYear()<n.min.getFullYear()||l.getFullYear()===n.min.getFullYear()&&l.getMonth()<n.min.getMonth()||l.getFullYear()>n.max.getFullYear()||l.getFullYear()===n.max.getFullYear()&&l.getMonth()>n.max.getMonth())return;l.getTime()>i[i.length-1].value.getTime()?n.navigate(1):l.getTime()<i[0].value.getTime()&&n.navigate(-1)}else{if(l.getFullYear()<n.min.getFullYear()||l.getFullYear()>n.max.getFullYear())return;if(l.getFullYear()<i[1].value.getFullYear()||l.getFullYear()>i[10].value.getFullYear()){let t=n._focusedCell;n.navigate(a),"ArrowUp"!==e.key&&"ArrowDown"!==e.key||(t===i[3]||t===i[4]||t===i[7]||t===i[8]?l.setFullYear(l.getFullYear()+2*a):l.setFullYear(l.getFullYear()-2*a))}}return void n._focusCell(n._getCellByDate(l,n._animationStarted?n.$.nextMonthsContainer:void 0))}if(!n._focusedCell)return;const i=n.restrictedDates.map(Number);for(l=new Date(n._focusedCell.value.getFullYear(),n._focusedCell.value.getMonth(),n._focusedCell.value.getDate()+a*t,0,0,0,0);i.indexOf(l.getTime())>-1;)l.setDate(l.getDate()+a);if(l.getTime()<n.min.getTime()||l.getTime()>n.max.getTime())return;n._isDateInView(l)||n.navigate(a*n.months);let s=n._getCellByDate(l,n._animationStarted?n.$.nextMonthsContainer:void 0);return n._focusCell(s),n._updateWeeksVisibility(a),!(["zeroOrMany","oneOrMany","none","many","week","range"].indexOf(n.selectionMode)>-1)||void 0}_handlePageUpDownKeys(e,t){const a=this;let n;if(e.preventDefault(),"month"!==a.displayMode){if(n=a._focusedCell,!a.navigate(t))return;for(;n&&n.classList.contains("smart-visibility-hidden");)n=null===n.previousElementSibling?n.nextElementSibling:n.previousElementSibling;return a._focusCell(n),void(a.hasAnimation&&"decade"===a.displayMode&&a._focusedCell.value.setFullYear(a._focusedCell.value.getFullYear()+10*t))}n=new Date(a._focusedCell.value.getFullYear(),a._focusedCell.value.getMonth()+t,1,0,0,0,0);let l=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return a._focusedCell.value.getDate()>l?n.setDate(l):n.setDate(a._focusedCell.value.getDate()),a._isDateInView(n)||a.navigate(n),a._animationStarted?a._focusCell(a._getCellByDate(n,a.$.nextMonthsContainer)):a._focusCell(a._getCellByDate(n)),!0}_selectDate(e,t,a){const n=this;if(void 0===n._viewDates||"none"===n.selectionMode)return;let l,i=n.selectedDates.slice(0),s=n._getCellByDate(e,n._animationStarted?n.$.nextMonthsContainer:void 0);s&&n._selectCell(s),(e=new Date(e)).setHours(0,0,0,0),l=i.map(Number).indexOf(e.getTime()),n.restrictedDates.map(Number).indexOf(e.getTime())>-1||e.getTime()<n.min.getTime()||e.getTime()>n.max.getTime()||(l>-1?i.splice(l,1):i.push(e),a||(n.selectedDates=i),n._refreshFooter(),n.$.hiddenInput.value=n.selectedDates.toString(),!t&&n.isInitialized&&(n.$.fireEvent("change",{value:[e]}),n._updateTargetValue()),n._refreshTitle())}_selectCell(e){const t=this;if(!e||t.restrictedDates.map(Number).indexOf(e.value.getTime())>-1||t.disableAutoNavigation&&!1===e.otherMonth||e.value.getTime()<t.min.getTime()||e.value.getTime()>t.max.getTime())return;const a=t._selectedCells.indexOf(e);a>-1?(t._setCellState(e,"selected",!1),t._selectedCells.splice(a,1)):(t._setCellState(e,"selected",!0),t._selectedCells.push(e)),t._focusCell(e)}_refreshDayOfWeekTitles(){const e=this;let t,a=[],n=new Date;function l(t){let a;return"firstTwoLetters"===e.dayNameFormat?(a=new Intl.DateTimeFormat(e.locale,{weekday:"long"}).format(t),a=8206===a.charCodeAt(0)?a.substring(1,3):a.substring(0,2)):a=new Intl.DateTimeFormat(e.locale,{weekday:e.dayNameFormat}).format(t),a}for(let e=1;e<8;e++)n.setDate(e),t={number:n.getDay(),name:l(n)},a.push(t);a.sort(((e,t)=>e.number>t.number?1:-1));const i=e.$.monthsContainer.children;let s,o;for(let t=0;t<i.length;t++)if(s=i[t].getElementsByClassName("smart-calendar-week-titles")[0].children,o=e.firstDayOfWeek>6?0:e.firstDayOfWeek,e.rightToLeft)for(let e=s.length-1;e>=1;e--)s[e].textContent=a[o++].name,o=o>6?0:o;else for(let e=1;e<s.length;e++)s[e].textContent=a[o++].name,o=o>6?0:o;if(e.hasAnimation){const t=e.$.monthsContainer.getElementsByClassName("smart-calendar-week-titles")[0].innerHTML,a=e.$.nextMonthsContainer.getElementsByClassName("smart-calendar-week-titles");for(let e=0;e<a.length;e++)a[e].innerHTML=t}}_refreshCalendarMode(){const e=this;if(!e.headerTemplate)if(e._refreshMonthNames(),"default"===e.calendarMode){e.$classicHeaderDate.addClass("smart-hidden"),e.$defaultHeaderDate.removeClass("smart-hidden");const t=e._viewDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime())),a=t[0],n=t[t.length-1];a.setDate(2);let l=e.monthNameFormat;"firstTwoLetters"===l&&(l="long");let i=a.toLocaleDateString(e.locale,{year:e.yearFormat,month:l});e.months>1&&(n.setDate(2),i+=" - "+n.toLocaleDateString(e.locale,{year:e.yearFormat,month:l})),e.$.defaultHeaderDate.innerHTML=i,e.unfocusable||e.$.dateElement.setAttribute("tabindex",e.tabIndex>0?e.tabIndex:0)}else e.$defaultHeaderDate.addClass("smart-hidden"),e.$classicHeaderDate.removeClass("smart-hidden"),e.$.dateElement.removeAttribute("tabindex")}_refreshFooter(){const e=this;if(!(e.viewSections.indexOf("footer")<0||0===e.$.footer.offsetHeight))if(e.footerTemplate){if("function"==typeof e.footerTemplate)return;let a=e._layoutTemplates.filter((t=>t.selector===e.$.footer))[0],n=document.importNode(a.template.content,!0);if(a.bindings.length>0){let e=n.childNodes[a.bindings[0].childNodeIndex];a.selector.childNodes[a.bindings[0].childNodeIndex].innerHTML=e.innerHTML.replace(a.bindings[0].bindingString,t())}}else e.$.selectedDatesRange.innerHTML=t();function t(){if(0===e.selectedDates.length)return"";if(1===e.selectedDates.length)return e.selectedDates[0].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"});{let t=e.selectedDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime()));return t[0].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"})+" - "+t[t.length-1].toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"})}}}_refreshImportantDates(){const e=this;if("month"===e.displayMode){e._clearImportantDates();for(let t=0;t<e.importantDates.length;t++)e._setImportantDate(e.importantDates[t])}}_clearImportantDates(){const e=this,t=e.$.monthsContainer.children;for(let a=0;a<t.length;a++)e._getMonthCells(t[a]).map((t=>{e._setCellState(t,"important",!1)}))}_setImportantDate(e,t){const a=this,n=a._getCellByDate(e);t||(t=n),t&&(a._setCellState(t,"important",!0),a._applyImportantDateTemplate(t))}_applyImportantDateTemplate(e){const t=this;if(!t._importantDatesTemplate)return"function"==typeof t.importantDatesTemplate?void t.importantDatesTemplate(e,{value:e.value}):void(e.innerHTML=e.value.getDate()+"");let a=document.importNode(t._importantDatesTemplate.content,!0);if(t._bindingDetails&&t._bindingDetails.length>0){let n=a.childNodes[t._bindingDetails[0].childNodeIndex];n.innerHTML=n.innerHTML.replace(t._bindingDetails[0].bindingString,e.value.getDate())}e.innerHTML="";for(let t=0;t<a.childNodes.length;t++)a.childNodes[t].outerHTML&&(e.innerHTML+=a.childNodes[t].outerHTML)}_setMonth(e,t,a){const n=this,l=n._getDays(e,n.selectedDates),i=n._getDays(e,n.importantDates),s=n._getDays(e,n.restrictedDates);e.setDate(1),t||(t=n.$.month),t._date=new Date(e),a||((!n._viewDates||n._viewDates.length>=n.months)&&(n._viewDates=[]),n._viewDates.push(new Date(e)));let o=((e=new Date(e)).getDay()-n.firstDayOfWeek+7)%7;e.setDate(0);let r=e.getDate();if(e.setDate(32),e.setDate(1),e.setDate(32),n._selectedCells)for(let e=0;e<n._selectedCells.length;e++)n._selectedCells[e].closest(".smart-calendar-month")===t&&n._setCellState(n._selectedCells[e],"selected",!1);n._setMonthContent(e,t,{previusMonthDays:r,firstDayOfWeek:o,selectedDates:l,importantDates:i,restrictedDates:s})}_setMonthContent(e,t,a){const n=this,l=32-e.getDate(),i=n._getMonthCells(t,n.rightToLeft),s=t._date.getMonth(),o=t._date.getFullYear(),r=new Date;let d,c=1,m=1;r.setHours(0,0,0,0),i.map((e=>{n._setCellState(e,"restricted",!1),n._setCellState(e,"selected",!1),n._setCellState(e,"otherMonth",!1),n._setCellState(e,"focus",!1),n._setCellState(e,"important",!1),n._setCellState(e,"today",!1),n._setCellState(e,"disabled",!1),n._setCellState(e,"hover",!1)}));for(let e=0;e<i.length;e++){const h=i[e];e===a.firstDayOfWeek&&m<=l?(h.className="smart-calendar-cell",h.value=new Date(o,s,m),h.innerHTML=h.value.getDate().toString(),a.restrictedDates.indexOf(m)>-1||h.value.getTime()<n.min.getTime()||h.value.getTime()>n.max.getTime()?n._setCellState(h,"restricted",!0):a.selectedDates.indexOf(m)>-1&&(n._setCellState(h,"selected",!0),n._selectedCells.indexOf(h)<0&&n._selectedCells.push(h)),a.importantDates.indexOf(m)>-1&&(n._setImportantDate(h.value,h),a.importantDates.splice(a.importantDates.indexOf(m),1)),h.value.getTime()===r.getTime()&&n._setCellState(h,"today",!0),a.firstDayOfWeek++,m++):(1===m?(h.value=new Date(o,s-1,++a.previusMonthDays-a.firstDayOfWeek),d=!!(h.value.getTime()<n.min.getTime()||t.previousElementSibling)):(h.value=new Date(o,s+1,c++),d=!!(h.value.getTime()>n.max.getTime()||t.nextElementSibling)),h.innerHTML=h.value.getDate().toString(),n._setCellState(h,"otherMonth",!0),d?h.classList.add("smart-visibility-hidden"):h.classList.remove("smart-visibility-hidden"))}n.months>1&&(t.firstElementChild.innerHTML=n.dateFormatFunction?n.dateFormatFunction(t._date):n._monthsNames[s]+" "+t._date.toLocaleDateString(n.locale,{year:n.yearFormat})),n._setMonthWeekNumbers(t)}_refreshMonthNames(){const e=this;let t,a=new Date;function n(t){let a=e.monthNameFormat;"firstTwoLetters"===a&&(a="long");let n=new Intl.DateTimeFormat(e.locale,{month:a}).format(t);return"firstTwoLetters"===e.monthNameFormat&&(n=8206===n.charCodeAt(0)?n.substring(0,2):n.substring(1,3)),n}a.setDate(1),e._monthsNames=[];for(let l=0;l<12;l++)a.setMonth(l),t=n(a),e._monthsNames.push(t);if("classic"===e.calendarMode&&e.$.monthElement){let t=e.$.monthsContainer.children;if(e.$.monthElement.dataSource&&(e._changeEventFired=1),e.shadowRoot?e._setMonthElementPropertyInShadowDOM("dataSource",e._monthsNames):e.$.monthElement.dataSource=e._monthsNames,e._viewDates){for(let a=0;a<t.length;a++)t[a].firstElementChild.textContent=e._monthsNames[t[a]._date.getMonth()]+" "+t[a]._date.getFullYear();e._changeEventFired=1,e.shadowRoot?e._setMonthElementPropertyInShadowDOM("selectedIndex",e._viewDates.map((e=>e.getMonth()))[0]):e.$.monthElement.selectedIndex=e._viewDates.map((e=>e.getMonth()))[0]}}}_setMonthWeekNumbers(e){const t=this,a=function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!0};let n=e.getElementsByClassName("smart-calendar-week");n=[].slice.call(n);for(let l=0;l<n.length;l++){if(!a(n[l])){n[l].children[0].innerHTML="";continue}const i=n[l].children[1],s=i.otherMonth?i.value.getTime()>e._date.getTime()?1:-1:0;n[l].children[0].innerHTML=t._getWeekNumber(new Date(e._date.getFullYear(),e._date.getMonth()+s,i.value.getDate()))}}_setRestrictedDates(e){const t=this,a=t.$.monthsContainer.children;for(let e=0;e<a.length;e++)t._getMonthCells(a[e]).map((e=>{t._setCellState(e,"restricted",!1)}));if(t._viewDates){const a=function(e){for(let a=0;a<t._viewDates.length;a++)if(t._viewDates[a].getFullYear()===e.getFullYear()&&t._viewDates[a].getMonth()===e.getMonth())return!0};for(let n=0;n<e.length;n++)if(a(e[n])){const a=t._getCellByDate(e[n]);t._setCellState(a,"restricted",!0)}}}_setScrollButtonsNavigationMode(){const e=this;"landscape"!==e.scrollButtonsNavigationMode?(e.$.previousMonthButton&&(e.$.previousMonthButton.$.button.firstElementChild.className="smart-arrow-down smart-arrow"),e.$.nextMonthButton&&(e.$.nextMonthButton.$.button.firstElementChild.className="smart-arrow-up smart-arrow")):(e.$.previousMonthButton&&(e.$.previousMonthButton.$.button.firstElementChild.className="smart-arrow-left smart-arrow"),e.$.nextMonthButton&&(e.$.nextMonthButton.$.button.firstElementChild.className="smart-arrow-right smart-arrow")),e._applyAnimationSettings(!0)}_refreshTitle(){const e=this;let t=e.selectedDates.length>0?e.selectedDates[e.selectedDates.length-1]:new Date;if(e.titleTemplate){if("function"==typeof e.titleTemplate)return;let a=e._layoutTemplates.filter((t=>t.selector===e.$.title))[0],n=document.importNode(a.template.content,!0);if(a.bindings.length>0){let l=n.childNodes[a.bindings[0].childNodeIndex];return t=t.toLocaleDateString(e.locale,{year:e.yearFormat,weekday:"short",month:"short",day:"numeric"}),void(a.selector.childNodes[a.bindings[0].childNodeIndex].innerHTML=l.innerHTML.replace(a.bindings[0].bindingString,t))}}e.$.title.children[0].innerHTML=t.toLocaleDateString(e.locale,{year:e.yearFormat}),e.$.title.children[1].innerHTML="landscape"===e.view?t.toLocaleDateString(e.locale,{weekday:"short"})+",</br>"+t.toLocaleDateString(e.locale,{month:"short",day:"numeric"}):t.toLocaleDateString(e.locale,{weekday:"short"})+", "+t.toLocaleDateString(e.locale,{month:"short",day:"numeric"})}_setWeeksVisibility(e){const t=this,a=e.children;let n;function l(e){(function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!1;return!0})(e)||n>=t.weeks?e.classList.add("smart-hidden"):n<t.weeks&&(e.classList.remove("smart-hidden"),n++)}for(let e=0;e<a.length;e++){let i=a[e].getElementsByClassName("smart-calendar-week");i=[].slice.call(i);let s=t._selectedCells.filter((t=>t.closest(".smart-calendar-month")===a[e]));if(6!==t.weeks)if(n=0,s.length>0){let e=s[s.length-1],t=i.indexOf(e.parentElement);for(let e=t;e<i.length;e++)l(i[e]);for(let e=t-1;e>=0;e--)l(i[e])}else for(let e=0;e<i.length;e++)l(i[e]);else i.map((e=>e.classList.remove("smart-hidden")))}}_refreshHeaderElements(){const e=this,t=document.activeElement.closest("smart-calendar")===e,a=e._animationStarted?e.$.nextMonthsContainer:e.$.dateViewContainer;let n,l,i=e._viewDates[e._viewDates.length-1],s=e._viewDates.map((e=>e.getFullYear()));if("month"===e.displayMode||"list"!==e.displayModeView){if("classic"===e.calendarMode&&e.$.monthElement&&e.$.monthElement instanceof HTMLDivElement){const t=document.createElement("smart-input");t.setAttribute("smart-id","monthElement"),t.classList.add("smart-calendar-month-element"),t.dropDownPosition="bottom",t.selectionMode="one",t.disabled=e.disabled,t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.dropDownWidth=e.dropDownWidth,t.dropDownHeight=e.dropDownHeight,t.readonly=!0,t.dropDownButtonPosition="right";const a=e.$.monthElement;e.$.monthElement.parentNode.insertBefore(t,e.$.monthElement),e.$.monthElement=t,a.remove()}if(e.$.previousMonthButton&&!e.disabled&&("month"!==e.displayMode&&e.$.dateViewContainer.children[0].value?l="year"===e.displayMode?a.children[0].value.getFullYear()-1:a.children[1].value.getFullYear()-1:e._viewDates[0].getMonth()-1<0?(n=11,l=e._viewDates[0].getFullYear()-1):(n=e._viewDates[0].getMonth()-1,l=e._viewDates[0].getFullYear()),e.$.previousMonthButton.disabled=l<e.min.getFullYear()||l===e.min.getFullYear()&&n<e.min.getMonth(),e.$.previousMonthButton.disabled&&t&&e.$.body.focus()),e.$.nextMonthButton&&!e.disabled&&("month"!==e.displayMode&&e.$.dateViewContainer.children[0].value?l="year"===e.displayMode?a.children[0].value.getFullYear()+1:a.children[1].value.getFullYear()+11:i.getMonth()+1>11?(n=0,l=i.getFullYear()+1):(n=i.getMonth()+1,l=i.getFullYear()),e.$.nextMonthButton.disabled=l>e.max.getFullYear()||l===e.max.getFullYear()&&n>e.max.getMonth(),e.$.nextMonthButton.disabled&&t&&e.$.body.focus()),"classic"===e.calendarMode&&e.$.monthElement){let t=[...e._monthsNames];if(s.indexOf(e.min.getFullYear())>-1)for(let a=0;a<e.min.getMonth();a++)t[a]="";if(s.indexOf(e.max.getFullYear())>-1)for(let a=e.max.getMonth()+1;a<t.length;a++)t[a]="";t=t.filter((e=>""!==e));const a=Math.max(0,e.$.monthElement.selectedIndex);e.$.monthElement.dataSource=t,e._changeEventFired=0!==e.$.monthElement.selectedIndex,e.shadowRoot?e._setMonthElementPropertyInShadowDOM("selectedIndex",e._viewDates[0].getMonth()):e.$.monthElement.selectedIndex=a,e._changeEventFired=0}e.$.previousYearButton&&!e.disabled&&(l=e._viewDates[0].getFullYear()-1,e.$.previousYearButton.disabled=l<e.min.getFullYear(),e.$.previousYearButton.disabled&&t&&e.$.body.focus()),e.$.nextYearButton&&!e.disabled&&(l=i.getFullYear()+1,e.$.nextYearButton.disabled=l>e.max.getFullYear(),e.$.nextYearButton.disabled&&t&&e.$.body.focus()),e.$.yearElement&&(e.$.yearElement.value=s[0],e.$.yearElement.disabled=i.getFullYear()+1>e.max.getFullYear()&&e._viewDates[0].getFullYear()-1<e.min.getFullYear())}}_setMonthElementPropertyInShadowDOM(e,t){const a=this.$.monthElement,n=a.context;a.context=document,this.$.monthElement[e]=t,a.context=n}_refreshHeaderTitle(){const e=this;let t;function a(){if("month"!==e.displayMode){if("list"===e.displayModeView){const a=e.$.listViewContainer;if(!a)return;const n=a.querySelectorAll("li");if(!n.length)return"";let l;a.querySelector("li.active")&&(l=a.querySelector("li.active").getAttribute("value")),t="year"===e.displayMode?new Date(l||n[0].getAttribute("value")).getFullYear():new Date(n[0].getAttribute("value")).getFullYear()+" - "+new Date(n[n.length-1].getAttribute("value")).getFullYear()}else if(e.$.dateViewContainer.children[0].value){let a=e._animationStarted?e.$.nextMonthsContainer.children:e.$.dateViewContainer.children;t="year"===e.displayMode?a[0].value.getFullYear():a[1].value.getFullYear()+" - "+a[a.length-2].value.getFullYear()}if(t)return t}const a=e._viewDates.slice(0).sort(((e,t)=>e.getTime()-t.getTime())),n=a[0],l=a[a.length-1];n.setDate(2);let i=e.monthNameFormat;return"firstTwoLetters"===i&&(i="long"),t=n.toLocaleDateString(e.locale,{year:e.yearFormat,month:i}),e.months>1&&(l.setDate(2),t+=" - "+l.toLocaleDateString(e.locale,{year:e.yearFormat,month:i})),t}if("default"===e.calendarMode&&(e.$.defaultHeaderDate.innerHTML=a()),"function"==typeof e.headerTemplate||!e._layoutTemplates)return;let n=e._layoutTemplates.filter((t=>t.selector===e.$.header))[0];if(!n)return;let l=document.importNode(n.template.content,!0);if(n.bindings.length>0){const t=l.childNodes[n.bindings[0].childNodeIndex];(e.shadowRoot?e:n.selector).childNodes[n.bindings[0].childNodeIndex].innerHTML=t.innerHTML.replace(n.bindings[0].bindingString,e.dateFormatFunction?e.dateFormatFunction(e._viewDates):a())}}_updateWeeksVisibility(e,t){const a=this;let n=(t||a._focusedCell).parentElement;function l(){for(let e=o;e<s.length;e++)if(s[e].classList.contains("smart-hidden")&&!r(s[e])&&(s[e].classList.remove("smart-hidden"),d++,d===a.weeks))return!0}function i(){for(let e=o;e>=0;--e)if(s[e].classList.contains("smart-hidden")&&!r(s[e])&&(s[e].classList.remove("smart-hidden"),d++,d===a.weeks))return!0}if(!t&&!n.classList.contains("smart-hidden"))return;const s=[].slice.call(n.parentElement.children),o=s.indexOf(n),r=function(e){for(let t=1;t<e.children.length;t++)if(!e.children[t].classList.contains("smart-visibility-hidden"))return!1;return!0};let d=0;if(s.map((e=>e.classList.add("smart-hidden"))),e>0){if(l())return;i()}else{if(i())return;l()}}_getValidDates(e){let t=[];function a(e){if(e instanceof Date)return e;if(Smart.Utilities.DateTime&&e instanceof Smart.Utilities.DateTime)return e.toDate();if("string"==typeof e){if("new Date()"===e.trim()||"new Smart.Utilities.DateTime()"===e.trim())return new Date;let t=/(\d+[,-.\/]{1}\s*\d+[,-.\/]{1}\s*\d+)/;const a=()=>(e=e.replace(/[,-.\/]/g,",").split(",")).length>2?e=new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):new Date;return t.test(e)&&(e=t.exec(e)[0].replace(/[,-.\/]/g,",").split(","))?new Date(parseInt(e[0]),parseInt(e[1])-1,parseInt(e[2])):a()}}if(void 0===e)return null;if(Array.isArray(e))for(let n=0;n<e.length;n++)t.push(a(e[n]));else t.push(a(e));return t=t.filter((e=>e&&"Invalid Date"!==e.toDateString())),t.map((e=>e.setHours(0,0,0,0))),t}_getValidDate(e){const t=this._getValidDates(e);return t.length>0?t[0]:null}_validateSelectedDates(e){const t=this;let a=[];e||(e=t.selectedDates);let n=e.slice(0),l=function(e){for(let a=0;a<t.restrictedDates.length;a++)if(t.restrictedDates[a].getTime()===e.getTime())return!0};t.selectedDates=n.filter((function(e){if(e.getTime()>=t.min.getTime()&&e.getTime()<=t.max.getTime()&&!l(e))return!0;a.push(e)})),t._viewDates&&(a.map((e=>t._selectDate(e))),t._focusCell())}_validateMinMax(e,t,a){const n=this;switch(e){case"min":t=n._getValidDate(n[e]),n.min=t||a||n.properties.min.defaultValue;break;case"max":t=n._getValidDate(n[e]),n.max=t||a||n.properties.max.defaultValue;break;default:t=n._getValidDate(n.min),n.min=t||a||n.properties.min.defaultValue,t=n._getValidDate(n.max),n.max=t||a||n.properties.max.defaultValue}n.min=n.min.getTime()>n.max.getTime()?n.max:n.min,n.min.setHours(0,0,0,0),n.max.setHours(0,0,0,0);let l,i=n.$.monthsContainer.children;if(n._viewDates){if(n._viewDates[0].getTime()>n.max.getTime()||n._viewDates[0].getTime()<n.min.getTime())return void n._handleMonths();for(let e=0;e<i.length;e++){l=n._getMonthCells(i[e]);for(let t=0;t<l.length;t++){const a=l[t];if(a.value.getTime()>=n.min.getTime()&&a.value.getTime()<=n.max.getTime())n._setCellState(a,"restricted",!1),a.value.getMonth()===i[e]._date.getMonth()?a.classList.remove("smart-visibility-hidden"):n.hideOtherMonthDays||(n._setCellState(a,"otherMonth",!0),a.classList.remove("smart-visibility-hidden")),"month"!==n.displayMode&&n._setCellState(a,"otherMonth",!1);else{if(a.otherMonth){if(a.classList.contains("smart-visibility-hidden")){n._setCellState(a,"restricted",!1);continue}}else n._setCellState(a,"restricted",!0);"month"!==n.displayMode&&(a.classList.remove("smart-visibility-hidden"),n._setCellState(a,"otherMonth",!0))}}}}}_setCellState(e,t,a){e[t]=a;const n=Smart.Utilities.Core.toDash(t);a?(e.setAttribute(n,""),"selected"===t?e.setAttribute("aria-selected",!0):"today"===t?e.setAttribute("aria-current","date"):"restricted"===t?e.removeAttribute("aria-selected"):"disabled"===t&&(e.removeAttribute("aria-selected"),e.setAttribute("aria-disabled",!0))):(e.removeAttribute(n),"selected"===t?"none"===this.selectionMode||e.restricted||e.disabled?e.removeAttribute("aria-selected"):e.setAttribute("aria-selected",!1):"today"===t?e.removeAttribute("aria-current"):"restricted"!==t||e.disabled?"disabled"===t&&(e.removeAttribute("aria-disabled"),e.restricted||e.setAttribute("aria-selected",!1)):e.setAttribute("aria-selected",!1))}_validateTemplate(e,t){if(null===t||!t)return;if("function"==typeof t)return;const a=this;if("content"in document.createElement("template")){if("string"==typeof t&&(t=document.getElementById(t)),null!==t&&"content"in t)return t;a.error(a.localize("invalidTemplate",{elementType:a.nodeName.toLowerCase(),property:e}))}else a.error(a.localize("htmlTemplateNotSuported",{elementType:a.nodeName.toLowerCase()}))}_weeksDownHandler(e,t){const a=this,n=t.value;let l;if(a.$.body.contains(t))if(t.otherMonth&&(l=t.value.getTime()>t.closest(".smart-calendar-month")._date.getTime()?1:-1),n&&a.hasRippleAnimation&&Smart.Utilities.Animation.Ripple.animate(t,e.pageX,e.pageY),l){if(a._isDateInView(n))return;a.disableAutoNavigation||a.navigate(l*a.months)}else(t=a._getCellByDate(n))&&(t.disabled||t.restricted)||a._handleDateSelection(t)}_firstDayOfWeekValidator(e,t){return Math.min(Math.max(0,isNaN(t)?6:t),6)}_weeksValidator(e,t){return Math.min(Math.max(1,isNaN(t)?6:t),6)}_monthsValidator(e,t){return Math.min(Math.max(1,isNaN(t)?1:t),12)}});
|
|
21
21
|
|
|
22
22
|
/***/ }),
|
|
23
23
|
|
|
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),void 0===e.skipFirstRow&&(t.skipFirstRow=!1),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()}forEach(e){const t=this;if(e)if(t.boundHierarchy&&t.boundHierarchy.length>0){const a=(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})(t.boundHierarchy);for(let t=0;t<a.length;t++){e(a[t],t)}}else for(let a=0;a<t.boundSource.length;a++){e(t.boundSource[a],a)}}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("parent")&&-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()};if("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}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".xml")>=0)t.url=t.dataSource,t.dataSourceType="xml",new e(t,(e=>{t.dataSource=e}));else if("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()}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".csv")>=0)t.url=t.dataSource,t.dataSourceType="csv",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".tsv")>=0)t.url=t.dataSource,t.dataSourceType="tsv",new e(t,(e=>{t.dataSource=e}));else if("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}));else if("string"==typeof t.dataSource&&(t.dataSource.indexOf("BEGIN:VCALENDAR")>=0||"ics"===t.dataSourceType))t._bindToICS(),a();else if("string"==typeof t.dataSource&&(t.dataSource.indexOf("<?xml")>=0||"xml"===t.dataSourceType))t._bindToXML(),a();else if("string"==typeof t.dataSource&&(t.dataSource.indexOf(" ")>=0||t.dataSource.indexOf(",")>=0||"tsv"===t.dataSourceType||"csv"===t.dataSourceType||"tab"===t.dataSourceType))t._bindToCSV(),a();else if("array"===t.dataSourceType)t._bindToArray(),a();else if("json"===t.dataSourceType){if(t.dataSource&&t.dataSource.url)return t.url=t.dataSource.url,t.dataSource.method&&(t.type=t.dataSource.method),t.dataSource.type&&(t.type=t.dataSource.type),t.dataSource.data&&(t.data=t.dataSource.data),void new e(t,(e=>{t.dataSource=e}));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={};let l=i[t].split(a);if(t>0){let e=[],a=0,n=!1,r=i[t];for(let t=0;t<r.length;t++)if('"'===r.charAt(t))n=!n;else if(","===r.charAt(t)&&!n){let n=r.substring(a,t);n=n.trim(),n=n.replaceAll('"',""),e.push(n),a=t+1}let o=r.substring(a);o=o.trim(),o=o.replaceAll('"',""),","===o?e.push('""'):e.push(o),l=e}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("/")&&-1===i.indexOf("-"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):i.indexOf(".")>=0&&i.lastIndexOf(".")!==i.indexOf(".")?-1===i.indexOf(",")&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}o[r.map||r.name||a.toString()]=i}0===t&&e.skipFirstRow||(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),t.data=r.data,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)=>{let a=t.value,n=t.valueTo;if(a&&a instanceof Date){a=`'${new Smart.Utilities.DateTime(a).toString("yyyy-MM-dd")}'`}if(t.valueTo&&t.valueTo instanceof Date){n=`'${new Smart.Utilities.DateTime(n).toString("yyyy-MM-dd")}'`}switch(t.condition){case"EQUAL":return e+" = "+a;case"NOT_EQUAL":return e+" != "+a;case"GREATER_THAN":return e+" > "+a;case"GREATER_THAN_OR_EQUAL":return e+" >= "+a;case"LESS_THAN":return e+" < "+a;case"LESS_THAN_OR_EQUAL":return e+" <= "+a;case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL";case"RANGE":return"("+e+" >= "+a+" and "+e+" <= "+n+")"}},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]&&"or"!==o.logicalOperators[t]||(s=" OR ")}l.length&&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).replace(/</g,"<").replace(/>/g,">")}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].replace(/</g,"<").replace(/>/g,">")+"'");null===a.id?d.update=" SET "+e.join(", "):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),null!==t.edit.row[n]?e.push("'"+t.edit.row[n]+"'"):e.push("null"));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.where.indexOf("undefined")>=0&&(d.where=""),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,edit:t.edit,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}removeById(e){const t=this,a=t.indexOf(t.dataItemById[e]);t.boundSource[a]&&t.removeAt(a)}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=JSON.parse(JSON.stringify(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=s.boundSource.canNotify;s.boundSource.canNotify=!1;const f=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()};let h=new Array;for(let t=0;t<e.length;t++)h[t]=f();t||(t="children"),a||(a="group"),r||(r="item"),o||(o="parent"),void 0===i&&(i="value");const p=new Array,g=new Array;let S=0;const y=function(t){let a=t;for(let n=0;n<e.length;n++){if(void 0===t[e[n]]){a=s._getDataItem(t,t.$.index);break}}if(n)for(let e in n){const t=n[e];t.name&&t.map&&(a[t.map]=a[t.name])}return a};let m=!1;for(let n=0;n<d.length;n++){let u=y(d[n]);u[c.leaf]=!1;let T=new Array,b=0;for(let t=0;t<e.length;t++){const a=e[t],n=u[a];null!=n?((""===n||void 0===n&&0===t)&&(m=!0),T[b++]={value:n,group:a,hash:h[t]}):(T[b++]={value:null,group:a,hash:h[t]},0===t&&(m=!0))}if(T.length!==e.length)break;let x=null,v="";for(let e=0;e<T.length;e++){const n=T[e].value,d=T[e].group;if(v=v+"_"+T[e].hash+"_"+n,void 0===g[v]||null===g[v]){if(null===x){x={$:{}},x[c.level]=0,x[c.leaf]=!1,x[o]=null,x[a]=n,x[r]=u,x.groupDataField=d,x[d]||(x[d]=x.data[d]),void 0!==u[c.expanded]?x[c.expanded]=u[c.expanded]:(x[c.expanded]=!1,s.expandHierarchy&&(x[c.expanded]=!0)),i&&(x[i]=u[i]),x[t]=new Array;let e=p.length+l;this.id&&"number"!=typeof u.$.id&&!isFinite(u.$.id)||(e="Item"+e),void 0===x.$.id&&(x.$.id=e),s._expandedRowIds[x.$.id]&&(x[c.expanded]=!0),s.expandHierarchy&&s._collapsedIds&&s._collapsedIds[x.$.id]&&(x[c.expanded]=!1),p[S++]=x}else{const e={$:{}};e[c.level]=x[c.level]+1,e[o]=x,e[a]=n,e[t]=new Array,e[r]=u,e.groupDataField=d,e[c.leaf]=!1,e[d]||(e[d]=e.data[d]),void 0!==u[c.expanded]?e[c.expanded]=u[c.expanded]:(e[c.expanded]=!1,s.expandHierarchy&&(e[c.expanded]=!0)),i&&(e[i]=u[i]),void 0===e.$.id&&(e.$.id=x.$.id+"_"+x[t].length),s.expandHierarchy&&s._collapsedIds&&s._collapsedIds[e.$.id]&&(e[c.expanded]=!1),s._expandedRowIds[e.$.id]&&(e[c.expanded]=!0),x[t][x[t].length]=e,x=e}g[v]=x}else x=g[v]}u&&(u[c.leaf]=!0),null!==x?(null===this.id?void 0===u.$.id&&(u.$.id=x.$.id+"_"+x[t].length):void 0===u.$.id&&-1===u.$.id.toString().indexOf(x.$.id)&&(u.$.id=x.$.id+"_"+u.$.id),u[o]=x,u[c.level]=x[c.level]+1,x[t][x[t].length]=u):void 0===u.$.id&&(u.$.id=f())}if(m){let e=null,t=!1;for(let a=0;a<p.length;a++){const n=p[a];if(!n[n.groupDataField]){e=n,e.$.id.toString().startsWith("Item")&&(t=!0),p.splice(a,1);break}}if(e&&(p.push(e),t))for(let e=0;e<p.length;e++){const t=p[e];t.$.id="Item"+e,Object.keys(s._expandedRowIds).length>0&&(s._expandedRowIds[t.$.id]?t[c.expanded]=!0:t[c.expanded]=!1,s.expandHierarchy&&(t[c.expanded]=!0,s._collapsedIds&&s._collapsedIds[t.$.id]&&(t[c.expanded]=!1)))}}return s.boundSource.canNotify=u,p}_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),null===o&&(o=n[e]=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(void 0!==d&&"uncategorized"!==d||(d=""),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("status"===t)n=r[o.dataField][t],null==n&&(n=[]),n[d]||(n[d]=[]),n[d].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}else if("status"===t){let e=r[o.dataField][t];null==e&&(e=[]),e[d]||(e[d]=[]),e[d].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].status){const e=r[n.dataField].status;r[n.dataField].status=e}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=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(o&&"string"==typeof o&&o.indexOf("[")>=0){const e=JSON.parse(o);if(r.formatString&&Smart.Utilities.DateTime){const t=Smart.Utilities.DateTime.ParseDate(e[0],r.formatString),a=Smart.Utilities.DateTime.ParseDate(e[1],r.formatString);e[0]=t,e[1]=a}else{const t=a.$document.deserialize(""+e[0],r.dataType,!0),n=a.$document.deserialize(""+e[1],r.dataType,!0);e[0]=t,e[1]=n}o=e,n[r.name]=o;continue}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="string"===r.dataType&&"null"===o?"null":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,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""):"blackList"===a.sanitizeHTML&&(o=window.Smart.Utilities.Core.sanitizeHTML(o),o.indexOf("<br")>=0&&(o=o.replaceAll("<br/>","\n\r"),o=o.replaceAll("<br>","\n\r")))),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];if(""!==t&&" "!==t){if("true"===t.trim()){i.push(!0);continue}if("false"===t.trim()){i.push(!1);continue}if(t.indexOf("or ")>=0||t.indexOf("and ")>=0||t.indexOf("1 ")>=0||t.indexOf("0 ")>=0||t.indexOf("| ")>=0||t.indexOf("& ")>=0){const e=t.trim().split(" ");if(e.length>1){const t=e[0].trim(),a=e[1].trim();"1"===t?i.push("or"):"0"===t?i.push("and"):i.push(t),i.push(a)}else i.push(t.trim())}else 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=r.length>2?"":"and",i=0,d=[];for(let o=0;o<r.length;o++){let l=r[o];if("and"!==l&&"or"!==l){if(i++,2===i){let s=a[r[o-1]];s||(s=r[o-1]),"number"===e&&(l=parseFloat(l)),"date"===e&&(l=new Date(l));const c=t.createFilter(e,l,s);if(i=0,d.push(c),n){for(let e=0;e<d.length;e++)t.addFilter(n,d[e]);d=[]}}}else n=l}o.push(t)}else{let e=r[0];if(e&&a[e]&&(e="and"),"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){if(o.virtualDataSource)return;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 d=e[0][t[r]];if(void 0===d&&e[0]&&e[0].children&&e[0].data&&(d=e[0].data[t[r]]),i&&i){const e=t[r];if(i[e]){s[r]=i[e];continue}}o.sortComparators&&o.sortComparators[t[r]]?s[r]=o.sortComparators[t[r]]:s[r]=c(d,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),void 0===e.skipFirstRow&&(t.skipFirstRow=!1),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()}forEach(e){const t=this;if(e)if(t.boundHierarchy&&t.boundHierarchy.length>0){const a=(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})(t.boundHierarchy);for(let t=0;t<a.length;t++){e(a[t],t)}}else for(let a=0;a<t.boundSource.length;a++){e(t.boundSource[a],a)}}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("parent")&&-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()};if("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}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".xml")>=0)t.url=t.dataSource,t.dataSourceType="xml",new e(t,(e=>{t.dataSource=e}));else if("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()}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".csv")>=0)t.url=t.dataSource,t.dataSourceType="csv",new e(t,(e=>{t.dataSource=e}));else if("string"==typeof t.dataSource&&t.dataSource.indexOf(".tsv")>=0)t.url=t.dataSource,t.dataSourceType="tsv",new e(t,(e=>{t.dataSource=e}));else if("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}));else if("string"==typeof t.dataSource&&(t.dataSource.indexOf("BEGIN:VCALENDAR")>=0||"ics"===t.dataSourceType))t._bindToICS(),a();else if("string"==typeof t.dataSource&&(t.dataSource.indexOf("<?xml")>=0||"xml"===t.dataSourceType))t._bindToXML(),a();else if("string"==typeof t.dataSource&&(t.dataSource.indexOf(" ")>=0||t.dataSource.indexOf(",")>=0||"tsv"===t.dataSourceType||"csv"===t.dataSourceType||"tab"===t.dataSourceType))t._bindToCSV(),a();else if("array"===t.dataSourceType)t._bindToArray(),a();else if("json"===t.dataSourceType){if(t.dataSource&&t.dataSource.url)return t.url=t.dataSource.url,t.dataSource.method&&(t.type=t.dataSource.method),t.dataSource.type&&(t.type=t.dataSource.type),t.dataSource.data&&(t.data=t.dataSource.data),void new e(t,(e=>{t.dataSource=e}));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={};let l=i[t].split(a);if(t>0){let e=[],a=0,n=!1,r=i[t];for(let t=0;t<r.length;t++)if('"'===r.charAt(t))n=!n;else if(","===r.charAt(t)&&!n){let n=r.substring(a,t);n=n.trim(),n=n.replaceAll('"',""),e.push(n),a=t+1}let o=r.substring(a);o=o.trim(),o=o.replaceAll('"',""),","===o?e.push('""'):e.push(o),l=e}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("/")&&-1===i.indexOf("-"))?(i.indexOf("-")>=0||i.indexOf("/")>=0||i.indexOf(":")>=0)&&"Invalid Date"!==new Date(i).toString()&&(e="date",i=new Date(i)):i.indexOf(".")>=0&&i.lastIndexOf(".")!==i.indexOf(".")?-1===i.indexOf(",")&&(e="date",i=new Date(i)):(e="number",i=parseFloat(i)),r.dataType||(r.dataType=e)}o[r.map||r.name||a.toString()]=i}0===t&&e.skipFirstRow||(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),t.data=r.data,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)=>{let a=t.value,n=t.valueTo;if(a&&a instanceof Date){a=`'${new Smart.Utilities.DateTime(a).toString("yyyy-MM-dd")}'`}if(t.valueTo&&t.valueTo instanceof Date){n=`'${new Smart.Utilities.DateTime(n).toString("yyyy-MM-dd")}'`}switch(t.condition){case"EQUAL":return e+" = "+a;case"NOT_EQUAL":return e+" != "+a;case"GREATER_THAN":return e+" > "+a;case"GREATER_THAN_OR_EQUAL":return e+" >= "+a;case"LESS_THAN":return e+" < "+a;case"LESS_THAN_OR_EQUAL":return e+" <= "+a;case"NULL":return e+" IS NULL";case"NOT_NULL":return e+" IS NOT NULL";case"RANGE":return"("+e+" >= "+a+" and "+e+" <= "+n+")"}},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]&&"or"!==o.logicalOperators[t]||(s=" OR ")}l.length&&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).replace(/</g,"<").replace(/>/g,">")}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].replace(/</g,"<").replace(/>/g,">")+"'");null===a.id?d.update=" SET "+e.join(", "):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),null!==t.edit.row[n]?e.push("'"+t.edit.row[n]+"'"):e.push("null"));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.where.indexOf("undefined")>=0&&(d.where=""),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,edit:t.edit,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}removeById(e){const t=this,a=t.indexOf(t.dataItemById[e]);t.boundSource[a]&&t.removeAt(a)}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=JSON.parse(JSON.stringify(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=s.boundSource.canNotify;s.boundSource.canNotify=!1;const f=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()};let h=new Array;for(let t=0;t<e.length;t++)h[t]=f();t||(t="children"),a||(a="group"),r||(r="item"),o||(o="parent"),void 0===i&&(i="value");const p=new Array,g=new Array;let S=0;const y=function(t){let a=t;for(let n=0;n<e.length;n++){if(void 0===t[e[n]]){a=s._getDataItem(t,t.$.index);break}}if(n)for(let e in n){const t=n[e];t.name&&t.map&&(a[t.map]=a[t.name])}return a};let m=!1;for(let n=0;n<d.length;n++){let u=y(d[n]);u[c.leaf]=!1;let T=new Array,b=0;for(let t=0;t<e.length;t++){const a=e[t],n=u[a];null!=n?((""===n||void 0===n&&0===t)&&(m=!0),T[b++]={value:n,group:a,hash:h[t]}):(T[b++]={value:null,group:a,hash:h[t]},0===t&&(m=!0))}if(T.length!==e.length)break;let x=null,v="";for(let e=0;e<T.length;e++){const n=T[e].value,d=T[e].group;if(v=v+"_"+T[e].hash+"_"+n,void 0===g[v]||null===g[v]){if(null===x){x={$:{}},x[c.level]=0,x[c.leaf]=!1,x[o]=null,x[a]=n,x[r]=u,x.groupDataField=d,x[d]||(x[d]=x.data[d]),void 0!==u[c.expanded]?x[c.expanded]=u[c.expanded]:(x[c.expanded]=!1,s.expandHierarchy&&(x[c.expanded]=!0)),i&&(x[i]=u[i]),x[t]=new Array;let e=p.length+l;this.id&&"number"!=typeof u.$.id&&!isFinite(u.$.id)||(e="Item"+e),void 0===x.$.id&&(x.$.id=e),s._expandedRowIds[x.$.id]&&(x[c.expanded]=!0),s.expandHierarchy&&s._collapsedIds&&s._collapsedIds[x.$.id]&&(x[c.expanded]=!1),p[S++]=x}else{const e={$:{}};e[c.level]=x[c.level]+1,e[o]=x,e[a]=n,e[t]=new Array,e[r]=u,e.groupDataField=d,e[c.leaf]=!1,e[d]||(e[d]=e.data[d]),void 0!==u[c.expanded]?e[c.expanded]=u[c.expanded]:(e[c.expanded]=!1,s.expandHierarchy&&(e[c.expanded]=!0)),i&&(e[i]=u[i]),void 0===e.$.id&&(e.$.id=x.$.id+"_"+x[t].length),s.expandHierarchy&&s._collapsedIds&&s._collapsedIds[e.$.id]&&(e[c.expanded]=!1),s._expandedRowIds[e.$.id]&&(e[c.expanded]=!0),x[t][x[t].length]=e,x=e}g[v]=x}else x=g[v]}u&&(u[c.leaf]=!0),null!==x?(null===this.id?void 0===u.$.id&&(u.$.id=x.$.id+"_"+x[t].length):void 0===u.$.id&&-1===u.$.id.toString().indexOf(x.$.id)&&(u.$.id=x.$.id+"_"+u.$.id),u[o]=x,u[c.level]=x[c.level]+1,x[t][x[t].length]=u):void 0===u.$.id&&(u.$.id=f())}if(m){let e=null,t=!1;for(let a=0;a<p.length;a++){const n=p[a];if(!n[n.groupDataField]){e=n,e.$.id.toString().startsWith("Item")&&(t=!0),p.splice(a,1);break}}if(e&&(p.push(e),t))for(let e=0;e<p.length;e++){const t=p[e];t.$.id="Item"+e,Object.keys(s._expandedRowIds).length>0&&(s._expandedRowIds[t.$.id]?t[c.expanded]=!0:t[c.expanded]=!1,s.expandHierarchy&&(t[c.expanded]=!0,s._collapsedIds&&s._collapsedIds[t.$.id]&&(t[c.expanded]=!1)))}}return s.boundSource.canNotify=u,p}_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),null===o&&(o=n[e]=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(void 0!==d&&"uncategorized"!==d||(d=""),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("status"===t)n=r[o.dataField][t],null==n&&(n=[]),n[d]||(n[d]=[]),n[d].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}else if("status"===t){let e=r[o.dataField][t];null==e&&(e=[]),e[d]||(e[d]=[]),e[d].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].status){const e=r[n.dataField].status;r[n.dataField].status=e}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=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(o&&"string"==typeof o&&o.indexOf("[")>=0){const e=JSON.parse(o);if(r.formatString&&Smart.Utilities.DateTime){const t=Smart.Utilities.DateTime.ParseDate(e[0],r.formatString),a=Smart.Utilities.DateTime.ParseDate(e[1],r.formatString);e[0]=t,e[1]=a}else{const t=a.$document.deserialize(""+e[0],r.dataType,!0),n=a.$document.deserialize(""+e[1],r.dataType,!0);e[0]=t,e[1]=n}o=e,n[r.name]=o;continue}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="string"===r.dataType&&"null"===o?"null":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,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""):"blackList"===a.sanitizeHTML&&(o=window.Smart.Utilities.Core.sanitizeHTML(o),o.indexOf("<br")>=0&&(o=o.replaceAll("<br/>","\n\r"),o=o.replaceAll("<br>","\n\r")))),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];if(""!==t&&" "!==t){if("true"===t.trim()){i.push(!0);continue}if("false"===t.trim()){i.push(!1);continue}if(t.indexOf(" GMT")>=0)i.push(t.trim());else if(t.indexOf("or ")>=0||t.indexOf("and ")>=0||t.indexOf("1 ")>=0||t.indexOf("0 ")>=0||t.indexOf("| ")>=0||t.indexOf("& ")>=0){const e=t.trim().split(" ");if(e.length>1){const t=e[0].trim(),a=e[1].trim();"1"===t?i.push("or"):"0"===t?i.push("and"):i.push(t),i.push(a)}else i.push(t.trim())}else 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=r.length>2?"":"and",i=0,d=[];for(let o=0;o<r.length;o++){let l=r[o];if("and"!==l&&"or"!==l){if(i++,2===i){let s=a[r[o-1]];s||(s=r[o-1]),"number"===e&&(l=parseFloat(l)),"date"===e&&(l=new Date(l));const c=t.createFilter(e,l,s);if(i=0,d.push(c),n){for(let e=0;e<d.length;e++)t.addFilter(n,d[e]);d=[]}}}else n=l}o.push(t)}else{let e=r[0];if(e&&a[e]&&(e="and"),"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){if(o.virtualDataSource)return;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 d=e[0][t[r]];if(void 0===d&&e[0]&&e[0].children&&e[0].data&&(d=e[0].data[t[r]]),i&&i){const e=t[r];if(i[e]){s[r]=i[e];continue}}o.sortComparators&&o.sortComparators[t[r]]?s[r]=o.sortComparators[t[r]]:s[r]=c(d,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
|
|
|
@@ -73,7 +73,7 @@ Smart.Utilities.Assign("DataExporter",class{constructor(e,t,a,o){const l=this;e|
|
|
|
73
73
|
/***/ 6170:
|
|
74
74
|
/***/ (() => {
|
|
75
75
|
|
|
76
|
-
Smart.Utilities.Assign("FilterGroup",class t{constructor(){const t=this;t.stringConditions=["EMPTY","NOT_EMPTY","CONTAINS","CONTAINS_CASE_SENSITIVE","DOES_NOT_CONTAIN","DOES_NOT_CONTAIN_CASE_SENSITIVE","STARTS_WITH","STARTS_WITH_CASE_SENSITIVE","ENDS_WITH","ENDS_WITH_CASE_SENSITIVE","EQUAL","NOT_EQUAL","EQUAL_CASE_SENSITIVE","NOT_EQUAL_CASE_SENSITIVE","NULL","NOT_NULL"],t.numericConditions=["EQUAL","NOT_EQUAL","LESS_THAN","LESS_THAN_OR_EQUAL","GREATER_THAN","GREATER_THAN_OR_EQUAL","NULL","NOT_NULL"],t.dateConditions=["EQUAL","NOT_EQUAL","LESS_THAN","LESS_THAN_OR_EQUAL","GREATER_THAN","GREATER_THAN_OR_EQUAL","NULL","NOT_NULL"],t.booleanConditions=["EQUAL","NOT_EQUAL","NULL","NOT_NULL"],t.filters=new Array,t.logicalOperators=new Array}toString(){const t=this;let e="";for(let r=0;r<t.filters.length;r++){r>0&&(e+=" "+t.logicalOperators[r-1]+" ");let n=t.filters[r].toString();n.indexOf("[object")>=0&&"object"==typeof t.filters[r]&&(n=t.filters[r].condition+' "'+t.filters[r].value+'"'),e+=n}return e}evaluate(t){const e=this;let r=!0;for(let n=0;n<e.filters.length;n++){if(!e.filters[n].evaluate)continue;let i=e.filters[n].evaluate(t);r=0===n?i:1===e.logicalOperators[n]||"or"===e.logicalOperators[n]?r||i:r&&i}return r}getFiltersCount(){return this.filters.length}setConditions(t,e){const r=this;switch(t){case"numeric":r.numericConditions=e;break;case"string":r.stringConditions=e;break;case"date":case"time":r.dateConditions=e;break;case"bool":case"boolean":r.booleanConditions=e}}getConditions(t){const e=this;let r=new Array;switch(t){case"numeric":r=e.numericConditions.slice(0);break;case"string":r=e.stringConditions.slice(0);break;case"date":case"time":r=e.dateConditions.slice(0);break;case"bool":case"boolean":r=e.booleanConditions.slice(0)}return r}generateFilterKey(){const t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+"-"+t()+"-"+t()}createFilter(t,e,r,n,i,s,l){if(null==t)return null;switch(t){case"int":case"float":case"int64":case"double":case"numeric":case"number":case"numericFilter":return new Smart.Utilities.NumericFilter(e,r.toUpperCase());case"string":case"stringFilter":return new Smart.Utilities.StringFilter(e,r.toUpperCase(),s);case"date":case"time":case"dateFilter":return new Smart.Utilities.DateFilter(e,r.toUpperCase(),i,s,l);case"bool":case"boolean":case"booleanFilter":return new Smart.Utilities.BooleanFilter(e,r.toUpperCase());case"custom":return new Smart.Utilities.CustomFilter(e,r.toUpperCase(),n)}throw new Error('smartGrid: There is no such filter type. The available filter types are: "numericFilter", "stringFilter", "dateFilter" and "booleanFilter"')}getFilters(){const e=this;let r=new Array;for(let n=0;n<e.filters.length;n++){const i=e.filters[n];if(i instanceof t){let t=i.getFilters();r.push({value:t,logicalOperator:e.logicalOperators[n],type:"FilterGroup"})}else{const t={value:i.value,condition:i.condition,logicalOperator:e.logicalOperators[n],type:i.type};i.data&&(t.id=i.data),r.push(t)}}return r}addFilter(t,e){const r=this;r.filters[r.filters.length]=e,e.key=r.generateFilterKey(),r.logicalOperators[r.logicalOperators.length]=t}removeFilter(t){const e=this;for(let r=0;r<e.filters.length;r++)if(e.filters[r].key===t.key){e.filters.splice(r,1),e.logicalOperators.splice(r,1);break}}getOperatorAt(t){return null==t||t<0||t>this.filters.length?null:this.logicalOperators[t]}setOperatorAt(t,e){return null==t||t<0||t>this.filters.length?null:void(this.logicalOperators[e]=e)}getFilterAt(t){return null==t||t<0||t>this.filters.length?null:this.filters[t]}setFilterAt(t,e){const r=this;return null==t||t<0||t>r.filters.length?null:(e.key=r.generateFilterKey(),void(r.filters[t]=e))}clear(){this.filters=new Array,this.logicalOperators=new Array}getUniqueValues(t,e){const r=t.data,n=[],i=[],s="dateFilter"===t.filterType&&"timePicker"===t.displayMode;let l,a=!1;for(let e=0;e<r.length;e++){let l,o=r[e][t.dataField];""!==o&&null!=o?(l=s?new Smart.Utilities.DateTime(o).toString(t.formatString):o.toString(),-1===n.indexOf(l)&&(n.push(l),i.push({label:l,value:o,customAttribute:"default-item"}))):a=!0}switch(t.filterType){case"numericFilter":case"booleanFilter":l=function(t,e){return t.value-e.value};break;case"stringFilter":l=function(t,e){return(new Intl.Collator).compare(t.value,e.value)};break;case"dateFilter":l=s?function(t,e){try{const r=t.value.getHours(),n=e.value.getHours();if(r!==n)return r-n;const i=t.value.getMinutes(),s=e.value.getMinutes();if(i!==s)return i-s;const l=t.value.getSeconds(),a=e.value.getSeconds();return l!==a?l-a:0}catch(t){return-1}}:function(t,e){try{return t.value.getTime()-e.value.getTime()}catch(t){return-1}}}return i.sort(l),"booleanFilter"===t.filterType&&i.map((function(t){t.label=t.label.toUpperCase()})),a&&i.push({label:e.localize("blanks"),value:"",customAttribute:"default-item"}),i}}),Smart.Utilities.Assign("StringFilter",class{constructor(t,e,r){const n=this;n.value=t,n.condition=e,n.locale=r||"en",n.type="stringFilter"}toString(){return this.condition+' "'+this.value+'"'}evaluate(t){const e=this,r=e.value,n=e.condition;if(null==t||""===t){if("NULL"===n)return!0;if("EQUAL"===n&&t===r)return!0;if("NOT_EQUAL"===n&&t!==r)return!0;if("CONTAINS"===n&&t===r)return!0;if("EMPTY"!==n)return!1;if(""===t)return!0}let i="";try{i=t.toString()}catch(t){return!0}const s=function(t,r){const i=e.locale;switch(n){case"EQUAL":return 0===t.localeCompare(r,i,{sensitivity:"accent"});case"EQUAL_CASE_SENSITIVE":return 0===t.localeCompare(r,i,{sensitivity:"variant"});case"NOT_EQUAL":return 0!==t.localeCompare(r,i,{sensitivity:"accent"});case"NOT_EQUAL_CASE_SENSITIVE":return 0!==t.localeCompare(r,i,{sensitivity:"variant"});case"CONTAINS":return"number"==typeof r?t===r:-1!==t.toLowerCase().indexOf(r.toLowerCase());case"CONTAINS_CASE_SENSITIVE":return-1!==t.indexOf(r);case"DOES_NOT_CONTAIN":return-1===t.toLowerCase().indexOf(r.toLowerCase());case"DOES_NOT_CONTAIN_CASE_SENSITIVE":return-1===t.indexOf(r);case"EMPTY":return""===t;case"NOT_EMPTY":return""!==t;case"NOT_NULL":return null!==t;case"STARTS_WITH":return 0===(t=t.substring(0,r.length)).localeCompare(r,i,{sensitivity:"accent"});case"ENDS_WITH":return 0===(t=t.substring(t.length-r.length,t.length)).localeCompare(r,i,{sensitivity:"accent"});case"ENDS_WITH_CASE_SENSITIVE":return 0===(t=t.substring(t.length-r.length,t.length)).localeCompare(r,i,{sensitivity:"variant"});case"STARTS_WITH_CASE_SENSITIVE":return 0===(t=t.substring(0,r.length)).localeCompare(r,i,{sensitivity:"variant"});default:return!1}},l=new Array;if(r&&r.indexOf&&(r.indexOf("|")>=0||r.indexOf(" AND ")>=0||r.indexOf(" OR ")>=0||r.indexOf(" and ")>=0||r.indexOf(" or ")>=0)){const t=s(i,r);if(t)return t;const e=r.indexOf(" and ")>=0?r.split(" and "):new Array,n=r.indexOf(" or ")>=0?r.split(" or "):new Array,a=r.indexOf("|")>=0?r.split("|"):new Array;let o=r.indexOf(" AND ")>=0?r.split(" AND "):new Array,c=r.indexOf(" OR ")>=0?r.split(" OR "):new Array;if(a.length>0)for(let t=0;t<a.length;t++)a[t]=a[t].trim;const u=r.indexOf(" ")>=0?r.split(" "):new Array;if(u.length>0)for(let t=0;t<u.length;t++)u[t]=u[t].trim;if(o=o.concat(u),o=o.concat(e),c=c.concat(a),c=c.concat(n),o.length>0)for(let t=0;t<o.length;t++)!o[t].indexOf(" OR ")>=0&&l.push(o[t]);if(c.length>0)for(let t=0;t<c.length;t++)!c[t].indexOf(" AND ")>=0&&l.push(c[t]);let S;for(let t=0;t<l.length;t++){const e=s(i,l[t]),r=t<o.length?"and":"or";S=void 0===S?e:"or"===r?S||e:S&&e}return S}return s(i,r)}}),Smart.Utilities.Assign("BooleanFilter",class{constructor(t,e){const r=this;r.value=t,r.condition=e,r.type="booleanFilter"}toString(){return this.condition+" "+this.value}evaluate(t){const e=this.value,r=t;switch(this.condition){case"EQUAL":return r===e;case"NOT_EQUAL":return r!==e;case"NULL":return null==t||""===t;case"NOT_NULL":return!(null==t||""===t);default:return!1}}}),Smart.Utilities.Assign("NumericFilter",class{constructor(t,e){const r=this;r.value=t,r.condition=e,r.type="numericFilter"}toString(){return this.condition+" "+this.value}evaluate(t){let e=this.value,r=this.condition;if(null==t||""===t){if("NOT_NULL"===r)return!1;if("NULL"===r)return!0;switch(r){case"EQUAL":return t===e;case"NOT_EQUAL":return t!==e}return!1}if("NULL"===r)return!1;if("NOT_NULL"===r)return!0;let n=t;try{n=parseFloat(n)}catch(e){if(null!==t&&""!==t.toString())return!1}const i=function(t,e){switch("number"==typeof t&&"number"!=typeof e&&(e=parseFloat(e)),r){case"EQUAL":return t===e;case"NOT_EQUAL":return t!==e;case"GREATER_THAN":return t>e;case"GREATER_THAN_OR_EQUAL":return t>=e;case"LESS_THAN":return t<e;case"LESS_THAN_OR_EQUAL":return t<=e;case"STARTS_WITH":return e=e.toString().toLowerCase(),t.toString().toLowerCase().substring(0,e.length)===e;case"ENDS_WITH":return t=t.toString().toLowerCase(),e=e.toString().toLowerCase(),t.substring(t.length-e.length,t.length)===e;case"ENDS_WITH_CASE_SENSITIVE":return t=t.toString(),e=e.toString(),t.substring(t.length-e.length,t.length)===e;case"STARTS_WITH_CASE_SENSITIVE":return e=e.toString(),t.toString().substring(0,e.length)===e;case"CONTAINS":return-1!==t.toString().toLowerCase().indexOf(e.toString().toLowerCase());case"CONTAINS_CASE_SENSITIVE":return-1!==t.toString().indexOf(e.toString());case"DOES_NOT_CONTAIN":return-1===t.toString().toLowerCase().indexOf(e.toString().toLowerCase());case"DOES_NOT_CONTAIN_CASE_SENSITIVE":return-1===t.toString().indexOf(e.toString());default:return!0}};let s=new Array;if(e&&e.indexOf&&(e.indexOf("|")>=0||e.indexOf(" AND ")>=0||e.indexOf(" OR ")>=0||e.indexOf(" and ")>=0||e.indexOf(" or ")>=0)){let t=i(n,e);if(t)return t;e=e.toString();const r=e.indexOf(" and ")>=0?e.split(" and "):new Array,l=e.indexOf(" or ")>=0?e.split(" or "):new Array,a=e.indexOf("|")>=0?e.split("|"):new Array;let o,c=e.indexOf(" AND ")>=0?e.split(" AND "):new Array,u=e.indexOf(" OR ")>=0?e.split(" OR "):new Array;if(c=c.concat(r),u=u.concat(l),a.length>0)for(let t=0;t<a.length;t++)a[t]=a[t].trim;if(u=u.concat(a),c.length>0)for(let t=0;t<c.length;t++)!c[t].indexOf(" OR ")>=0&&s.push(c[t]);if(u.length>0)for(let t=0;t<u.length;t++)!u[t].indexOf(" AND ")>=0&&s.push(u[t]);for(let e=0;e<s.length;e++){const r=s[e];if(r&&r.indexOf&&r.indexOf("..")>=0){const e=r.toString().split("..");2===e.length&&(t=n>=e[0]&&n<=e[1])}else t=i(n,r);const l=e<c.length?"and":"or";o=void 0===o?t:"or"===l?o||t:o&&t}return o}return e&&e.indexOf&&e.indexOf("..")>=0&&(s=e.toString().split(".."),2===s.length)?n>=s[0]&&n<=s[1]:i(n,e)}}),Smart.Utilities.Assign("DateFilter",class{constructor(t,e,r,n,i){const s=this,l=new Smart.Utilities.DateTime;if(s.value=t,s.type="dateFilter",void 0!==r){const e=l.parseDate(t,r);if(null!==e)s.filterdate=e;else{const e=l.tryparseDate(t);null!==e&&(s.filterdate=e)}}else{const e=new Date(t);"NaN"===e.toString()||"Invalid Date"===e.toString()?s.filterdate=l.tryparseDate(t):s.filterdate=e}if(!s.filterdate){const e=new Date(t);"NaN"===e.toString()||"Invalid Date"===e.toString()?s.filterdate=l.tryparseDate(t):s.filterdate=e}s.condition=e,s.formatString=r,s.timeOnly=i}toString(){return this.value&&this.value instanceof Date?this.condition+' "'+this.value.toISOString()+'"':this.condition+" "+this.value}evaluate(t){const e=this,r=e.condition,n=e.formatString;let i=e.value;if(e.timeOnly)return e.evaluateTimeOnly(t);if(null==t||""===t){if("NOT_NULL"===r)return!1;if("NULL"===r)return!0;switch(r){case"EQUAL":return t===i;case"NOT_EQUAL":return t!==i}return!1}if("NULL"===r)return!1;if("NOT_NULL"===r)return!0;let s,l=new Date;l.setFullYear(1900,0,1),l.setHours(12,0,0,0);try{const r=new Smart.Utilities.DateTime,a=new Date(t);if(l=t="NaN"===a.toString()||"Invalid Date"===a.toString()?r.tryparseDate(t):a,s=!1,void 0!==n&&(n.indexOf("t")>=0||n.indexOf("T")>=0||n.indexOf(":")>=0||n.indexOf("f")>=0)&&(s=!0,i&&-1===i.toString().indexOf(":"))){const t=r.tryparseDate(i.toString()+":00");null!==t&&(e.filterdate=t)}s||(l.setHours(0),l.setMinutes(0),l.setSeconds(0))}catch(e){if(null!==t&&""!==t.toString())return!1}if(null!==e.filterdate)i=e.filterdate;else if(i&&i.indexOf&&(-1!==i.indexOf(":")||!isNaN(parseInt(i)))){const t=new Date(l);t.setHours(12,0,0,0);const e=i.split(":");for(let r=0;r<e.length;r++)0===r&&t.setHours(e[r]),1===r&&t.setMinutes(e[r]),2===r&&t.setSeconds(e[r]);i=t}s&&i&&i.setFullYear&&l&&l.getFullYear&&-1===n.indexOf("d")&&-1===n.indexOf("M")&&-1===n.indexOf("y")&&i.setFullYear(l.getFullYear(),l.getMonth(),l.getDate());const a=function(t,e){switch(null===t&&(t=""),r){case"EQUAL":return t.toString()===e.toString();case"NOT_EQUAL":return t.toString()!==e.toString();case"GREATER_THAN":return t>e;case"GREATER_THAN_OR_EQUAL":return t>=e;case"LESS_THAN":return t<e;case"LESS_THAN_OR_EQUAL":return t<=e;case"STARTS_WITH":return e=e.toString().toLowerCase(),t.toString().toLowerCase().substring(0,e.length)===e;case"ENDS_WITH":return t=t.toString().toLowerCase(),e=e.toString().toLowerCase(),t.substring(t.length-e.length,t.length)===e;case"ENDS_WITH_CASE_SENSITIVE":return t=t.toString(),e=e.toString(),t.substring(t.length-e.length,t.length)===e;case"STARTS_WITH_CASE_SENSITIVE":return e=e.toString(),t.toString().substring(0,e.length)===e;case"CONTAINS":return-1!==t.toString().toLowerCase().indexOf(e.toString().toLowerCase());case"CONTAINS_CASE_SENSITIVE":return-1!==t.toString().indexOf(e.toString());case"DOES_NOT_CONTAIN":return-1===t.toString().toLowerCase().indexOf(e.toString().toLowerCase());case"DOES_NOT_CONTAIN_CASE_SENSITIVE":return-1===t.toString().indexOf(e.toString());default:return!0}};let o=new Array;if(i&&i.indexOf&&(i.indexOf("|")>=0||i.indexOf(" AND ")>=0||i.indexOf(" OR ")>=0||i.indexOf(" and ")>=0||i.indexOf(" or ")>=0)){let t=a(l,i);if(t)return t;const e=i.indexOf(" and ")>=0?i.split(" and "):new Array,r=i.indexOf(" or ")>=0?i.split(" or "):new Array,n=i.indexOf("|")>=0?i.split("|"):new Array;let s,c=i.indexOf(" AND ")>=0?i.split(" AND "):new Array,u=i.indexOf(" OR ")>=0?i.split(" OR "):new Array;if(c=c.concat(e),u=u.concat(r),n.length>0)for(let t=0;t<n.length;t++)n[t]=n[t].trim;if(u=u.concat(n),c.length>0)for(let t=0;t<c.length;t++)!c[t].indexOf(" OR ")>=0&&o.push(c[t]);if(u.length>0)for(let t=0;t<u.length;t++)!u[t].indexOf(" AND ")>=0&&o.push(u[t]);for(let e=0;e<o.length;e++){const r=o[e];if(r&&r.indexOf&&r.indexOf("..")>=0){const e=r.toString().split("..");2===e.length&&(t=l>=e[0]&&l<=e[1])}else t=a(l,r);const n=e<c.length?"and":"or";s=void 0===s?t:"or"===n?s||t:s&&t}return s}return i&&i.indexOf&&i.indexOf("..")>=0&&(o=i.toString().split(".."),2===o.length)?l>=o[0]&&l<=o[1]:a(l,i)}evaluateTimeOnly(t){const e=this.value;return e?!!(t&&t instanceof Date)&&(t.getHours()===e.getHours()&&(t.getMinutes()===e.getMinutes()&&t.getSeconds()===e.getSeconds())):!t}}),Smart.Utilities.Assign("CustomFilter",class{constructor(t,e,r){const n=this;n.value=t,n.condition=e,n.customfilter=r}toString(){return this.condition+" "+this.value}evaluate(t){const e=this;return e.customfilter(e.value,t,e.condition)}}),Smart.FilterGroup=Smart.Utilities.FilterGroup,Smart.StringFilter=Smart.Utilities.StringFilter,Smart.NumericFilter=Smart.Utilities.NumericFilter,Smart.DateFilter=Smart.Utilities.DateFilter,Smart.CustomFilter=Smart.Utilities.CustomFilter;
|
|
76
|
+
Smart.Utilities.Assign("FilterGroup",class t{constructor(){const t=this;t.stringConditions=["EMPTY","NOT_EMPTY","CONTAINS","CONTAINS_CASE_SENSITIVE","DOES_NOT_CONTAIN","DOES_NOT_CONTAIN_CASE_SENSITIVE","STARTS_WITH","STARTS_WITH_CASE_SENSITIVE","ENDS_WITH","ENDS_WITH_CASE_SENSITIVE","EQUAL","NOT_EQUAL","EQUAL_CASE_SENSITIVE","NOT_EQUAL_CASE_SENSITIVE","NULL","NOT_NULL"],t.numericConditions=["EQUAL","NOT_EQUAL","LESS_THAN","LESS_THAN_OR_EQUAL","GREATER_THAN","GREATER_THAN_OR_EQUAL","NULL","NOT_NULL"],t.dateConditions=["EQUAL","NOT_EQUAL","LESS_THAN","LESS_THAN_OR_EQUAL","GREATER_THAN","GREATER_THAN_OR_EQUAL","NULL","NOT_NULL"],t.booleanConditions=["EQUAL","NOT_EQUAL","NULL","NOT_NULL"],t.filters=new Array,t.logicalOperators=new Array}toString(){const t=this;let e="";for(let r=0;r<t.filters.length;r++){r>0&&(e+=" "+t.logicalOperators[r-1]+" ");let n=t.filters[r].toString();n.indexOf("[object")>=0&&"object"==typeof t.filters[r]&&(n=t.filters[r].condition+' "'+t.filters[r].value+'"'),e+=n}return e}evaluate(t){const e=this;let r=!0;for(let n=0;n<e.filters.length;n++){if(!e.filters[n].evaluate)continue;let i=e.filters[n].evaluate(t);r=0===n?i:1===e.logicalOperators[n]||"or"===e.logicalOperators[n]?r||i:r&&i}return r}getFiltersCount(){return this.filters.length}setConditions(t,e){const r=this;switch(t){case"numeric":r.numericConditions=e;break;case"string":r.stringConditions=e;break;case"date":case"time":r.dateConditions=e;break;case"bool":case"boolean":r.booleanConditions=e}}getConditions(t){const e=this;let r=new Array;switch(t){case"numeric":r=e.numericConditions.slice(0);break;case"string":r=e.stringConditions.slice(0);break;case"date":case"time":r=e.dateConditions.slice(0);break;case"bool":case"boolean":r=e.booleanConditions.slice(0)}return r}generateFilterKey(){const t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+"-"+t()+"-"+t()}createFilter(t,e,r,n,i,s,l){if(null==t)return null;switch(t){case"int":case"float":case"int64":case"double":case"numeric":case"number":case"numericFilter":return new Smart.Utilities.NumericFilter(e,r.toUpperCase());case"string":case"stringFilter":return new Smart.Utilities.StringFilter(e,r.toUpperCase(),s);case"date":case"time":case"dateFilter":return new Smart.Utilities.DateFilter(e,r.toUpperCase(),i,s,l);case"bool":case"boolean":case"booleanFilter":return new Smart.Utilities.BooleanFilter(e,r.toUpperCase());case"custom":return new Smart.Utilities.CustomFilter(e,r.toUpperCase(),n)}throw new Error('smartGrid: There is no such filter type. The available filter types are: "numericFilter", "stringFilter", "dateFilter" and "booleanFilter"')}getFilters(){const e=this;let r=new Array;for(let n=0;n<e.filters.length;n++){const i=e.filters[n];if(i instanceof t){let t=i.getFilters();r.push({value:t,logicalOperator:e.logicalOperators[n],type:"FilterGroup"})}else{const t={value:i.value,condition:i.condition,logicalOperator:e.logicalOperators[n],type:i.type};i.data&&(t.id=i.data),r.push(t)}}return r}addFilter(t,e){const r=this;r.filters[r.filters.length]=e,e.key=r.generateFilterKey(),r.logicalOperators[r.logicalOperators.length]=t}removeFilter(t){const e=this;for(let r=0;r<e.filters.length;r++)if(e.filters[r].key===t.key){e.filters.splice(r,1),e.logicalOperators.splice(r,1);break}}getOperatorAt(t){return null==t||t<0||t>this.filters.length?null:this.logicalOperators[t]}setOperatorAt(t,e){return null==t||t<0||t>this.filters.length?null:void(this.logicalOperators[e]=e)}getFilterAt(t){return null==t||t<0||t>this.filters.length?null:this.filters[t]}setFilterAt(t,e){const r=this;return null==t||t<0||t>r.filters.length?null:(e.key=r.generateFilterKey(),void(r.filters[t]=e))}clear(){this.filters=new Array,this.logicalOperators=new Array}getUniqueValues(t,e){const r=t.data,n=[],i=[],s="dateFilter"===t.filterType&&"timePicker"===t.displayMode;let l,a=!1;for(let e=0;e<r.length;e++){let l,o=r[e][t.dataField];""!==o&&null!=o?(l=s?new Smart.Utilities.DateTime(o).toString(t.formatString):o.toString(),-1===n.indexOf(l)&&(n.push(l),i.push({label:l,value:o,customAttribute:"default-item"}))):a=!0}switch(t.filterType){case"numericFilter":case"booleanFilter":l=function(t,e){return t.value-e.value};break;case"stringFilter":l=function(t,e){return(new Intl.Collator).compare(t.value,e.value)};break;case"dateFilter":l=s?function(t,e){try{const r=t.value.getHours(),n=e.value.getHours();if(r!==n)return r-n;const i=t.value.getMinutes(),s=e.value.getMinutes();if(i!==s)return i-s;const l=t.value.getSeconds(),a=e.value.getSeconds();return l!==a?l-a:0}catch(t){return-1}}:function(t,e){try{return t.value.getTime()-e.value.getTime()}catch(t){return-1}}}return i.sort(l),"booleanFilter"===t.filterType&&i.map((function(t){const r=e.localize(t.label);t.label=""+r})),a&&i.push({label:e.localize("blanks"),value:"",customAttribute:"default-item"}),i}}),Smart.Utilities.Assign("StringFilter",class{constructor(t,e,r){const n=this;n.value=t,n.condition=e,n.locale=r||"en",n.type="stringFilter"}toString(){return this.condition+' "'+this.value+'"'}evaluate(t){const e=this,r=e.value,n=e.condition;if(null==t||""===t){if("NULL"===n)return!0;if("EQUAL"===n&&t===r)return!0;if("NOT_EQUAL"===n&&t!==r)return!0;if("CONTAINS"===n&&t===r)return!0;if("EMPTY"!==n)return!1;if(""===t)return!0}let i="";try{i=t.toString()}catch(t){return!0}const s=function(t,r){const i=e.locale;switch(n){case"EQUAL":return 0===t.localeCompare(r,i,{sensitivity:"accent"});case"EQUAL_CASE_SENSITIVE":return 0===t.localeCompare(r,i,{sensitivity:"variant"});case"NOT_EQUAL":return 0!==t.localeCompare(r,i,{sensitivity:"accent"});case"NOT_EQUAL_CASE_SENSITIVE":return 0!==t.localeCompare(r,i,{sensitivity:"variant"});case"CONTAINS":return"number"==typeof r?t===r:-1!==t.toLowerCase().indexOf(r.toLowerCase());case"CONTAINS_CASE_SENSITIVE":return-1!==t.indexOf(r);case"DOES_NOT_CONTAIN":return-1===t.toLowerCase().indexOf(r.toLowerCase());case"DOES_NOT_CONTAIN_CASE_SENSITIVE":return-1===t.indexOf(r);case"EMPTY":return""===t;case"NOT_EMPTY":return""!==t;case"NOT_NULL":return null!==t;case"STARTS_WITH":return 0===(t=t.substring(0,r.length)).localeCompare(r,i,{sensitivity:"accent"});case"ENDS_WITH":return 0===(t=t.substring(t.length-r.length,t.length)).localeCompare(r,i,{sensitivity:"accent"});case"ENDS_WITH_CASE_SENSITIVE":return 0===(t=t.substring(t.length-r.length,t.length)).localeCompare(r,i,{sensitivity:"variant"});case"STARTS_WITH_CASE_SENSITIVE":return 0===(t=t.substring(0,r.length)).localeCompare(r,i,{sensitivity:"variant"});default:return!1}},l=new Array;if(r&&r.indexOf&&(r.indexOf("|")>=0||r.indexOf(" AND ")>=0||r.indexOf(" OR ")>=0||r.indexOf(" and ")>=0||r.indexOf(" or ")>=0)){const t=s(i,r);if(t)return t;const e=r.indexOf(" and ")>=0?r.split(" and "):new Array,n=r.indexOf(" or ")>=0?r.split(" or "):new Array,a=r.indexOf("|")>=0?r.split("|"):new Array;let o=r.indexOf(" AND ")>=0?r.split(" AND "):new Array,c=r.indexOf(" OR ")>=0?r.split(" OR "):new Array;if(a.length>0)for(let t=0;t<a.length;t++)a[t]=a[t].trim;const u=r.indexOf(" ")>=0?r.split(" "):new Array;if(u.length>0)for(let t=0;t<u.length;t++)u[t]=u[t].trim;if(o=o.concat(u),o=o.concat(e),c=c.concat(a),c=c.concat(n),o.length>0)for(let t=0;t<o.length;t++)!o[t].indexOf(" OR ")>=0&&l.push(o[t]);if(c.length>0)for(let t=0;t<c.length;t++)!c[t].indexOf(" AND ")>=0&&l.push(c[t]);let S;for(let t=0;t<l.length;t++){const e=s(i,l[t]),r=t<o.length?"and":"or";S=void 0===S?e:"or"===r?S||e:S&&e}return S}return s(i,r)}}),Smart.Utilities.Assign("BooleanFilter",class{constructor(t,e){const r=this;r.value=t,r.condition=e,r.type="booleanFilter"}toString(){return this.condition+" "+this.value}evaluate(t){const e=this.value,r=t;switch(this.condition){case"EQUAL":return r===e;case"NOT_EQUAL":return r!==e;case"NULL":return null==t||""===t;case"NOT_NULL":return!(null==t||""===t);default:return!1}}}),Smart.Utilities.Assign("NumericFilter",class{constructor(t,e){const r=this;r.value=t,r.condition=e,r.type="numericFilter"}toString(){return this.condition+" "+this.value}evaluate(t){let e=this.value,r=this.condition;if(null==t||""===t){if("NOT_NULL"===r)return!1;if("NULL"===r)return!0;switch(r){case"EQUAL":return t===e;case"NOT_EQUAL":return t!==e}return!1}if("NULL"===r)return!1;if("NOT_NULL"===r)return!0;let n=t;try{n=parseFloat(n)}catch(e){if(null!==t&&""!==t.toString())return!1}const i=function(t,e){switch("number"==typeof t&&"number"!=typeof e&&(e=parseFloat(e)),r){case"EQUAL":return t===e;case"NOT_EQUAL":return t!==e;case"GREATER_THAN":return t>e;case"GREATER_THAN_OR_EQUAL":return t>=e;case"LESS_THAN":return t<e;case"LESS_THAN_OR_EQUAL":return t<=e;case"STARTS_WITH":return e=e.toString().toLowerCase(),t.toString().toLowerCase().substring(0,e.length)===e;case"ENDS_WITH":return t=t.toString().toLowerCase(),e=e.toString().toLowerCase(),t.substring(t.length-e.length,t.length)===e;case"ENDS_WITH_CASE_SENSITIVE":return t=t.toString(),e=e.toString(),t.substring(t.length-e.length,t.length)===e;case"STARTS_WITH_CASE_SENSITIVE":return e=e.toString(),t.toString().substring(0,e.length)===e;case"CONTAINS":return-1!==t.toString().toLowerCase().indexOf(e.toString().toLowerCase());case"CONTAINS_CASE_SENSITIVE":return-1!==t.toString().indexOf(e.toString());case"DOES_NOT_CONTAIN":return-1===t.toString().toLowerCase().indexOf(e.toString().toLowerCase());case"DOES_NOT_CONTAIN_CASE_SENSITIVE":return-1===t.toString().indexOf(e.toString());default:return!0}};let s=new Array;if(e&&e.indexOf&&(e.indexOf("|")>=0||e.indexOf(" AND ")>=0||e.indexOf(" OR ")>=0||e.indexOf(" and ")>=0||e.indexOf(" or ")>=0)){let t=i(n,e);if(t)return t;e=e.toString();const r=e.indexOf(" and ")>=0?e.split(" and "):new Array,l=e.indexOf(" or ")>=0?e.split(" or "):new Array,a=e.indexOf("|")>=0?e.split("|"):new Array;let o,c=e.indexOf(" AND ")>=0?e.split(" AND "):new Array,u=e.indexOf(" OR ")>=0?e.split(" OR "):new Array;if(c=c.concat(r),u=u.concat(l),a.length>0)for(let t=0;t<a.length;t++)a[t]=a[t].trim;if(u=u.concat(a),c.length>0)for(let t=0;t<c.length;t++)!c[t].indexOf(" OR ")>=0&&s.push(c[t]);if(u.length>0)for(let t=0;t<u.length;t++)!u[t].indexOf(" AND ")>=0&&s.push(u[t]);for(let e=0;e<s.length;e++){const r=s[e];if(r&&r.indexOf&&r.indexOf("..")>=0){const e=r.toString().split("..");2===e.length&&(t=n>=e[0]&&n<=e[1])}else t=i(n,r);const l=e<c.length?"and":"or";o=void 0===o?t:"or"===l?o||t:o&&t}return o}return e&&e.indexOf&&e.indexOf("..")>=0&&(s=e.toString().split(".."),2===s.length)?n>=s[0]&&n<=s[1]:i(n,e)}}),Smart.Utilities.Assign("DateFilter",class{constructor(t,e,r,n,i){const s=this,l=new Smart.Utilities.DateTime;if(s.value=t,s.type="dateFilter",void 0!==r){const e=l.parseDate(t,r);if(null!==e)s.filterdate=e;else{const e=l.tryparseDate(t);null!==e&&(s.filterdate=e)}}else{const e=new Date(t);"NaN"===e.toString()||"Invalid Date"===e.toString()?s.filterdate=l.tryparseDate(t):s.filterdate=e}if(!s.filterdate){const e=new Date(t);"NaN"===e.toString()||"Invalid Date"===e.toString()?s.filterdate=l.tryparseDate(t):s.filterdate=e}s.condition=e,s.formatString=r,s.timeOnly=i}toString(){return this.value&&this.value instanceof Date?this.condition+' "'+this.value.toISOString()+'"':this.condition+" "+this.value}evaluate(t){const e=this,r=e.condition,n=e.formatString;let i=e.value;if(e.timeOnly)return e.evaluateTimeOnly(t);if(null==t||""===t){if("NOT_NULL"===r)return!1;if("NULL"===r)return!0;switch(r){case"EQUAL":return t===i;case"NOT_EQUAL":return t!==i}return!1}if("NULL"===r)return!1;if("NOT_NULL"===r)return!0;let s,l=new Date;l.setFullYear(1900,0,1),l.setHours(12,0,0,0);try{const r=new Smart.Utilities.DateTime,a=new Date(t);if(l=t="NaN"===a.toString()||"Invalid Date"===a.toString()?r.tryparseDate(t):a,s=!1,void 0!==n&&(n.indexOf("t")>=0||n.indexOf("T")>=0||n.indexOf(":")>=0||n.indexOf("f")>=0)&&(s=!0,i&&-1===i.toString().indexOf(":"))){const t=r.tryparseDate(i.toString()+":00");null!==t&&(e.filterdate=t)}s||(l.setHours(0),l.setMinutes(0),l.setSeconds(0))}catch(e){if(null!==t&&""!==t.toString())return!1}if(null!==e.filterdate)i=e.filterdate;else if(i&&i.indexOf&&(-1!==i.indexOf(":")||!isNaN(parseInt(i)))){const t=new Date(l);t.setHours(12,0,0,0);const e=i.split(":");for(let r=0;r<e.length;r++)0===r&&t.setHours(e[r]),1===r&&t.setMinutes(e[r]),2===r&&t.setSeconds(e[r]);i=t}s&&i&&i.setFullYear&&l&&l.getFullYear&&-1===n.indexOf("d")&&-1===n.indexOf("M")&&-1===n.indexOf("y")&&i.setFullYear(l.getFullYear(),l.getMonth(),l.getDate());const a=function(t,e){switch(null===t&&(t=""),r){case"EQUAL":return t.toString()===e.toString();case"NOT_EQUAL":return t.toString()!==e.toString();case"GREATER_THAN":return t>e;case"GREATER_THAN_OR_EQUAL":return t>=e;case"LESS_THAN":return t<e;case"LESS_THAN_OR_EQUAL":return t<=e;case"STARTS_WITH":return e=e.toString().toLowerCase(),t.toString().toLowerCase().substring(0,e.length)===e;case"ENDS_WITH":return t=t.toString().toLowerCase(),e=e.toString().toLowerCase(),t.substring(t.length-e.length,t.length)===e;case"ENDS_WITH_CASE_SENSITIVE":return t=t.toString(),e=e.toString(),t.substring(t.length-e.length,t.length)===e;case"STARTS_WITH_CASE_SENSITIVE":return e=e.toString(),t.toString().substring(0,e.length)===e;case"CONTAINS":return-1!==t.toString().toLowerCase().indexOf(e.toString().toLowerCase());case"CONTAINS_CASE_SENSITIVE":return-1!==t.toString().indexOf(e.toString());case"DOES_NOT_CONTAIN":return-1===t.toString().toLowerCase().indexOf(e.toString().toLowerCase());case"DOES_NOT_CONTAIN_CASE_SENSITIVE":return-1===t.toString().indexOf(e.toString());default:return!0}};let o=new Array;if(i&&i.indexOf&&(i.indexOf("|")>=0||i.indexOf(" AND ")>=0||i.indexOf(" OR ")>=0||i.indexOf(" and ")>=0||i.indexOf(" or ")>=0)){let t=a(l,i);if(t)return t;const e=i.indexOf(" and ")>=0?i.split(" and "):new Array,r=i.indexOf(" or ")>=0?i.split(" or "):new Array,n=i.indexOf("|")>=0?i.split("|"):new Array;let s,c=i.indexOf(" AND ")>=0?i.split(" AND "):new Array,u=i.indexOf(" OR ")>=0?i.split(" OR "):new Array;if(c=c.concat(e),u=u.concat(r),n.length>0)for(let t=0;t<n.length;t++)n[t]=n[t].trim;if(u=u.concat(n),c.length>0)for(let t=0;t<c.length;t++)!c[t].indexOf(" OR ")>=0&&o.push(c[t]);if(u.length>0)for(let t=0;t<u.length;t++)!u[t].indexOf(" AND ")>=0&&o.push(u[t]);for(let e=0;e<o.length;e++){const r=o[e];if(r&&r.indexOf&&r.indexOf("..")>=0){const e=r.toString().split("..");2===e.length&&(t=l>=e[0]&&l<=e[1])}else t=a(l,r);const n=e<c.length?"and":"or";s=void 0===s?t:"or"===n?s||t:s&&t}return s}return i&&i.indexOf&&i.indexOf("..")>=0&&(o=i.toString().split(".."),2===o.length)?l>=o[0]&&l<=o[1]:a(l,i)}evaluateTimeOnly(t){const e=this.value;return e?!!(t&&t instanceof Date)&&(t.getHours()===e.getHours()&&(t.getMinutes()===e.getMinutes()&&t.getSeconds()===e.getSeconds())):!t}}),Smart.Utilities.Assign("CustomFilter",class{constructor(t,e,r){const n=this;n.value=t,n.condition=e,n.customfilter=r}toString(){return this.condition+" "+this.value}evaluate(t){const e=this;return e.customfilter(e.value,t,e.condition)}}),Smart.FilterGroup=Smart.Utilities.FilterGroup,Smart.StringFilter=Smart.Utilities.StringFilter,Smart.NumericFilter=Smart.Utilities.NumericFilter,Smart.DateFilter=Smart.Utilities.DateFilter,Smart.CustomFilter=Smart.Utilities.CustomFilter;
|
|
77
77
|
|
|
78
78
|
/***/ }),
|
|
79
79
|
|
|
@@ -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"},currentTime:{value:new Date,type:"any",validator:"_dateValidator"},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"},dayScale:{value:"hour",allowedValues:["hour","halfHour","quarterHour"],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"},firstDayOfWeek:{value:-1,type:"number"},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"},hideTimelineSecondHeaderDetails:{value:!0,type:"boolean"},hideTimelineHeader:{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",quarter:"Quarter",quarterShort:"Q"}},type:"object"},monthFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},monthScale:{value:"week",allowedValues:["day","week"],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"},onTaskRender:{value:null,reflectToAttribute:!1,type:"function?"},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"},quarterFormat:{value:"short",allowedValues:["long","short","numeric"],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"},selectionMode:{value:"many",type:"string",allowedValues:["one","many","extended"]},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","quarter","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-details smart-hidden" id="timelineViewSubDetails" 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 a=t[i];if(e.$[a]&&e.$[a].opened){const t=e["$"+a];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.$[a])}}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 a=t[i],n=e["$"+a];e.$[a]&&e.$[a].remove(),n&&(n.unlisten("open"),n.unlisten("close"),n.unlisten("closing"),n.unlisten("click"),n.unlisten("change"),n.unlisten("transitionend"))}e._handleTooltipEvents(),clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval}propertyChangedHandler(e,t,i){const a=this;switch(e){case"adjustToNonworkingTime":for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i),a._refreshTableColumnsData(t,["dateEnd","duration"])}a._refreshTimeline();break;case"animation":break;case"autoSchedule":i?a._autoSchedule():a._autoScheduleRestore();break;case"autoScheduleStrictMode":i&&(a._autoSchedule(),a._refreshTimeline());break;case"columnMinWidth":case"columnResizeFeedback":case"columnResize":{const t=a.$.taskTable,n=a.$.resourceTable;t[e]=i,n&&(n[e]=i);break}case"currentTimeIndicator":case"shadeUntilCurrentTime":a._setCurrentTimeIndicators();break;case"dataSource":if(a.scrollLeft=a.scrollTop=0,a._createTasks(),a._refreshTableDataSource(),a._createTimeline(),a._createResourceTimeline(),a._setAriaControls(),a.snapToNearest){for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i),a._refreshTableColumnsData(t,["dateEnd","duration"])}a._refreshTimeline()}break;case"dateMarkers":a._createDateMarkers();break;case"hideDateMarkers":a._recycleDateMarkers();break;case"selectionMode":{const e=a.$.taskTable,t=a.$.resourceTable;e&&(e.selectionMode=a.selectionMode),t&&(t.selectionMode=a.selectionMode);break}case"disableSelection":{const e=a.$.taskTable,t=a.$.resourceTable;e&&(e.selection=!a.disableSelection),t&&(t.selection=!a.disableSelection);break}case"durationUnit":for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDuration(t),a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i)}a._createTimelineCells(),a._insertTimelineTasks(),a.taskColumns.some((e=>(e.value+"").toLowerCase().indexOf("duration")>-1))&&a._refreshTableDataSource();break;case"filterRow":a.$.taskTable[e]=i;break;case"groupByResources":a._setTable(a.$.taskTable),a._createTimelineContent(),a._recycleTimelineTasks(),a._refresh();break;case"infiniteTimeline":i?a._scrollView.hScrollBar.value===a._scrollView.hScrollBar.max&&a._handleInfiniteTimeline():a.set("dateEnd","");break;case"keyboardNavigation":a.$.taskTable[e]=i,a.$.resourceTable&&(a.$.resourceTable[e]=i);break;case"popupWindowTabs":case"popupWindowCustomizationFunction":{const e=a.$.taskPopupWindow;e&&(e.opened&&(e.close(),delete e._target),e.clear());break}case"taskFiltering":a.$.taskTable.filtering=i,a._refresh();break;case"resourceFiltering":{const e=a.$.resourceTable;e&&(e.filtering=i,a._refresh());break}case"tooltip_enabled":{const e=a.$.tooltip;e&&(i||e.remove(),a._handleTooltipEvents(i));break}case"tooltip_arrow":case"tooltip_delay":case"tooltip_offset":{const t=a.$.tooltip;t&&(t[e.replace("tooltip_","")]=i);break}case"headerTemplate":a._handleHeaderTemplate();break;case"inverted":if(a._handleInverted(),a.scrollLeft){const e=a._getScrollLeft(a.scrollLeft);a.$.timelineHeader.scrollLeft=a.$.taskTimelineContainer.scrollLeft=e,a.$.mainSplitter.contains(a.$.resourceTimelineHeader)&&(a.$.resourceTimelineHeader.scrollLeft=a.$.resourceTimelineContent.scrollLeft=e)}break;case"rightToLeft":Array.from(a.querySelectorAll("smart-splitter, smart-table, smart-scroll-bar")).forEach((t=>t[e]=i)),a.closeWindow(),a._handleInverted(),a._refreshTimeline();break;case"firstDayOfWeek":case"dateStart":case"dateEnd":a._refreshTimeline();break;case"messages":case"locale":case"dayFormat":case"hourFormat":case"timelineHeaderFormatFunction":case"monthFormat":case"yearFormat":a._refreshHeaderDate(!0),a._refreshColumnsHeaders(),a._recycleResourceHeaderCells();break;case"hideResourcePanel":a._createResourceTimeline(),a._refreshTimeline();break;case"nonworkingDays":case"nonworkingHours":a._refreshAfterWorkingTimeChange();break;case"selectedTaskIds":a.$.taskTable.selected=a._getSelection("task",i);break;case"selectedResourceIds":a.$.resourceTable&&(a.$.resourceTable.selected=a._getSelection("resource",i));break;case"resourceColumns":a._setTable(a.$.resourceTable),a._highlightAssignedItem("task",a._getSelection("task",a.selectedTaskIds));break;case"resourcePanelHeaderTemplate":a._handleHeaderTemplate("resource");break;case"resourceTimelineView":case"resourceTimelineMode":case"resourceTimelineFormatFunction":a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._resources.forEach((e=>a._refreshResourceTimelineContent(e)));break;case"showProgressLabel":case"progressLabelFormatFunction":a._tasks.forEach((e=>a._setTaskBarProgress(e)));break;case"sortFunction":a.$.taskTable.sort=i,a.$.resourceTable&&(a.$.resourceTable.sort=i);break;case"showSelectionColumn":a.$.taskTable.hideSelectionColumn=!i,a.$.resourceTable&&(a.$.resourceTable.hideSelectionColumn=!i);break;case"columnMenu":case"hideSelectionColumn":case"sortMode":a.$.taskTable[e]=i,a.$.resourceTable&&(a.$.resourceTable[e]=i);break;case"taskColumns":a._setTable(a.$.taskTable);break;case"timelineMin":a.$.timelineSplitterItem.min=i,a.$.taskSplitter.refresh(),a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._synchronizeSplitters(a.$.taskSplitter,a.$.resourceSplitter);break;case"treeMin":case"treeSize":{const t=e.toLowerCase().indexOf("size")>-1?"size":"min";a.$.tableSplitterItem[t]=i,a.$.taskSplitter.refresh(),a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._synchronizeSplitters(a.$.taskSplitter,a.$.resourceSplitter);break}case"taskPanelMin":case"taskPanelSize":case"resourcePanelSize":case"resourcePanelMin":{const t=e.indexOf("Min")>-1?"min":"size",n=e.indexOf("resource")>-1?"resource":"task";a.$.mainSplitter.contains(a.$.resourceSplitter)&&(a.$[`${n}SplitterItem`][t]=i,a.$.taskSplitterItem._setSize("size",a.taskPanelSize),a.refresh());break}case"unfocusable":a._setFocusable();break;case"monthScale":case"dayScale":case"view":a._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 a=0;a<e.length;a++){const n=e[a];let s=t._getProjectTasks(n);s&&Array.isArray(s)&&(s=i(s.filter((e=>e.$&&e.$.project===n)))),e[a]=t._cloneObject(n),s&&s.length?e[a].tasks=s:delete e[a].tasks}return e},a=t.properties[e].value;return a instanceof Smart.DataAdapter?a:i(a.slice(0))}case"dateStart":case"dateEnd":{const i=t._timelineCells;if(i.length){const a=t._getCellDateRange({_date:i["dateStart"===e?0:i.length-1].date});return new Date(a[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 a=i.taskColumns,n=i.resourceColumns,s=i.$.taskTable,r=i.$.resourceTable;for(let i=0;i<e.length;i++){const o=e[i],l=o.type,[d,c]="resource"===l||n.includes(o)?[r,n]:[s,a],m=c.find((e=>o.value&&e.value===o.value));m&&d.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,a=i._getValidItemAndIndex(e,t);(e=a?a.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 a=i._getValidItemAndIndex(e),n=i._getValidItemAndIndex(t);e=a?a.index:void 0,t=n?n.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 a=1===Object.keys(e._isUpdating.type).length?Object.keys(e._isUpdating.type)[0]:void 0;let n,s;switch(e._selected&&({task:n,resource:s}=e._selected),delete e._isUpdating,a){case"task":t();break;case"resource":i();break;default:t(),i()}n&&(e._refreshSelectedItems("task",n),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,a=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted||0===t.length)return;if(i=1===a.length?(a[0]+"").split("-"):a,!e._getValidConnectionId(i[0],i[1],i[2],"createConnection"))return;const n=parseInt(i[3]);e._connectTask([i[0],i[1],i[2],isNaN(n)?0:n]),e._recycleConnections(),e.$.fireEvent("itemInsert",{type:"connection",item:{source:i[0],target:i[1],type:i[2],lag:n}})}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 a="task"===i.dataExport.itemType?i.$.taskTable:i.$.resourceTable;return a?a.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"),a=window.open("","","width=800,height=500"),n=a.document.open(),s='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+i+"</body></html>";try{n.write(s),n.close(),setTimeout((function(){a.print(),a.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 a=i.startTask,n=i.endTask,s={startTask:t._cloneObject(i.startTask),endTask:t._cloneObject(i.endTask),startTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,endTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.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,a=t.endTask;return{id:t.startIndex+"-"+t.endIndex+"-"+t.type,startTask:e._cloneObject(i),endTask:e._cloneObject(a),startIndex:t.startIndex,startTaskId:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,endTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.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,a=23;i<a;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),a=JSON.stringify(e.selectedTaskIds),n=JSON.stringify(e.resources);if(i&&(i=JSON.parse(i)),a&&(a=JSON.parse(a)),n&&(n=JSON.parse(n)),t._noChangeEvent=!0,Array.isArray(i)&&(t._createTasks(i),t.set("dataSource",i)),Array.isArray(n)){let e=n;for(let i=0;i<e.length;i++){const e=n[i];let a=t._resources.find((t=>t.id&&t.id.toString()===e.id.toString()))||{};t._setResource(a,e),Object.values(a).length&&!t._resources.includes(a)&&t._resources.push(a)}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(a)&&(t.$.taskTable.selected=t._getSelection("task",a)),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 a=this;if("object"!=typeof e)return void a.error(a.localize("incorrectArgument",{elementType:a.nodeName.toLowerCase(),methodName:"insertTask",argumentName:"newTask"}));const n=a._tasks;if(n.indexOf(e)>-1)return void a.error(a.localize("alreadyExists",{elementType:a.nodeName.toLowerCase(),methodName:"insertTask"}));const s=a._createTasks([e],!0);if(!n)return;let r,o,l;const d=a._getSelection("task",a.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=n.find((e=>e.id&&e.id.toString()===t)),r||(r=a._getItemByTableId("task",t))):"number"==typeof t&&(r=n[t]),r){if("project"!==r.type)return void a.error(a.localize("notAProject",{elementType:a.nodeName.toLowerCase(),argumentName:"project",methodName:"insertTask"}));s[0].$.project=r}return a._synchronizeProjectVisibility(s[0].$.project,s[0]),a._insertTasks(s,r,i),a._refreshItemIds(),a._refreshConnectionIds(),a._isUpdating?(a._isUpdating.type.task=!0,void(a._isUpdating.type.resource=!0)):(a._selected&&a._selected.task&&a._setSelection("task",l=a._selected.task.map((e=>e.$.id))),a._refreshTableDataSource(),a._refreshTimeline(),l&&d.toString()!==l.toString()&&(a.$.taskTable.selected=l.slice(0)),a._refreshTaskResources(o),a._ensureVisible(o),a.$.fireEvent("itemInsert",{type:"task",item:a._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),a=i?i.task:void 0;return void(a&&t._openPopupWindow(a))}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 a=e.$[t[i]+"PopupWindow"];a&&(a.close(),delete a._target)}}updateTask(e,t){const i=this,a=i._getValidItemAndIndex(e),n=a?a.item:void 0;"object"==typeof n?"object"==typeof t?i._updateTask(n,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,a=t._getValidItemAndIndex(e),n=a?a.item:void 0;i&&i.length&&("object"==typeof n?t._removeTask(n):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,a=e.length;i<a;i+=1){const a=parseInt(e[i]),n=t.indexOf(a);n>-1&&t.splice(n,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,a=t.resourceColumns,n=t.$.taskTable,s=t.$.resourceTable;for(let t=0;t<e.length;t++){const r=e[t],o="desc"===r.sortOrder?"desc":"asc",[l,d]="resource"===r.type||a.includes(r)?[s,a]:[n,i],c=d.find((e=>r.value&&e.value===r.value));c&&l.sortBy(c.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,a=e.length;i<a;i+=1){const a=parseInt(e[i]);t.indexOf(a)<0&&t.push(a)}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`],a=t._getSelection(e,"task"===e?t.selectedTaskIds:t.selectedResourceIds);if(!a.length)return[];let n=[];for(let e=0,s=i.length;e<s;e+=1){const s=i[e];a.indexOf(s.$.id)>-1&&n.push(t._cloneObject(s))}return n}_getTasksAssigned(e){const t=this,i=t._tasks||[];let a=[];for(let n=0;n<i.length;n++){const s=i[n];!s.disableResources&&s.resources.find((t=>t===e.id))&&a.push(t._cloneObject(s))}return a}_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 a="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(a.every((a=>Array.isArray(e[a])?JSON.stringify(e[a])===JSON.stringify(i[t][a]):a.indexOf("date")>-1?new Date(e[a]).getTime()===new Date(i[t][a]).getTime():e[a]===i[t][a])))return i.indexOf(i[t]);return-1}_handleItemSelection(e,t="task",i){const a=this,n=a._getValidItemAndIndex(e,t);if(n.item){const s=n.item,r=a._getSelection(t,"task"===t?a.selectedTaskIds:a.selectedResourceIds);if(e=s.$.id,i){const i=r.indexOf(e);i>-1&&(r.splice(i,1),a.$[`${t}Table`].selected=r)}else r.indexOf(e)<0&&(r.push(e),a.$[`${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],a=i.$.project;e._validateTaskDates(i,a),e._synchronizeProjectDates(i,a),e._refreshTableColumnsData(i,["dateEnd","duration"])}e._refreshTimeline()}_refreshItemIds(e="task"){const t=this[`_${e}s`];if(!t)return;let i={},a=0;for(let e=0,n=t.length;e<n;e+=1){const n=t[e],s=n.$.project;if(void 0!==s){const e=s.$.id;i[e]||(i[e]=0),n.$.id=e+"."+i[e],i[e]++}else n.$.id=a+"",a++}}_refreshConnectionIds(){const e=this._tasks,t=this._connections;if(t&&t.length)for(let i=0,a=t.length;i<a;i+=1){const n=t[i],s=e.indexOf(n.startTask),r=e.indexOf(n.endTask);(s<0||r<0)&&(t.splice(i,1),a--),n.startIndex=s,n.endIndex=r}}_refreshSelectedItems(e="task",t){const i=this,a=i[`_${e}s`];if(a&&(!t&&i._selected&&i._selected[e]&&(t=i._selected[e]),t)){for(let e=0,i=t.length;e<i;e+=1){const n=t[e];(a.indexOf(n)<0||n.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 a(){i.$.taskTable[t](),i._createTimelineContent(),i._recycleTimelineTasks()}function n(){const e=i.$.resourceTable;e&&(e[t](),i._createResourceTimelineVCells(),i._recycleResourceContent())}"resource"===e?n():"task"===e?a():(a(),n())}_setWorkTime(e,t,i){const a=this;if("object"!=typeof e)return;let n,s=e.days,r=e.hours;null!=s&&(Array.isArray(s)||(s=[s]),s=a._nonworkingDayValidator(void 0,s),n=t(s,i?a.nonworkingDays:[0,1,2,3,4,5,6]),a.set("nonworkingDays",7===n.length?[]:n),a._refreshAfterWorkingTimeChange()),null!=r&&(Array.isArray(r)||(r=[r]),r=a._nonworkingTimeValidator(void 0,r),n=t(r,i?a.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]),a.set("nonworkingHours",24===n.length?[]:n),a._refreshAfterWorkingTimeChange())}_getValidConnectionId(e,t,i,a){const n=this,s=n._tasks,r=0===a.indexOf("_");let o;if("string"==typeof e&&(o=n._getTaskIndexById(e),o>=0&&(e=o)),"string"==typeof t&&(o=n._getTaskIndexById(t),o>=0&&(t=o)),e=parseInt(e),t=parseInt(t),i=parseInt(i),isNaN(e)||isNaN(t)||e===t)r||n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"taskIndex"}));else if(e>=s.length||e<0||t>=s.length||t<0)r||n.error(n.localize("outOfBounds",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"taskIndex"}));else{if(!(isNaN(i)||i<0||i>3))return r?[e,t,i]:e+"-"+t+"-"+i;r||n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:a,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 a=e[i];"project"===a.type&&a.synchronized||(a.minDateStart=a.minDateEnd=void 0,t._autoScheduleTasks(a))}t._isUpdateRequired&&(t._createTimelineCells(),t._recycleTimelineTasks(!0),delete t._isUpdateRequired)}}_getTaskConnections(e){const t=this._tasks,i=this._connections;let a=[],n=[];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?a.push(t):t.endIndex===s&&n.push(t)}}return{taskConnections:a,connectedTasks:n}}_autoScheduleTasks(e){const t=this,i=t._tasks,a=t._getTaskConnections(e),n=a.taskConnections,s=a.connectedTasks;let r,o,l;for(let a=0;a<n.length;a++)t._isAutoScheduled(e,i[n[a].endIndex],!0);for(let a=0;a<s.length;a++){const n=s[a],d=i[n.startIndex],c=n.type,m=n.lag,u=e.$.project;d&&"project"===d.type&&d.synchronized||(0===c||1===c?(l=new Date((0===c?d.dateStart:d.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===c?d.dateEnd:d.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<n.length;e++){const a=i[n[e].endIndex];!a||"project"===a.type&&a.synchronized||(a.minDateStart=a.minDateEnd=void 0,t._autoScheduleTasks(a))}}_autoScheduleRestore(e,t){const i=this._tasks;e||(e=i),Array.isArray(e)||(e=[e]);for(let a=0;a<e.length;a++){const n=e[a];i.indexOf(e[a])>-1&&(t?0===t||1===t?n.minDateStart=void 0:n.minDateEnd=void 0:n.minDateStart=n.minDateEnd=void 0)}}_autoScroll(e){const t=this,i=t.hasAttribute("dragged"),a=t.hasAttribute("resized");function n(n,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*n,t._dragDetails.coordinates.y+=t.autoScrollStep*n):(t.scrollLeft-=(t.rightToLeft?-1:1)*t.autoScrollStep*n,t._dragDetails.coordinates.x+=t.autoScrollStep*n),i?t._handleTaskBarDrag(e):a&&t._handleTaskBarResize(e)}if(t.disableAutoScroll||!e||!i&&!a&&!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?n(1):t.scrollLeft!==(t.rightToLeft?0:t.scrollWidth)&&e.clientX>=s.left+s.width-20?n(-1):t.scrollTop&&e.clientY<=s.top+20?n(1,!0):t.scrollTop!==t.scrollHeight&&e.clientY>=s.top+s.height-20?n(-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 a=t.$.timeline;if(!i.closest)return void a.removeAttribute("task-bar-hovered");let n,s=i.closest(".smart-timeline-row")||i.closest(".smart-timeline-task");if(t.disabled||t.disableTaskResize||!s||!a.contains(s))return void a.removeAttribute("task-bar-hovered");const r=s._cellObj.task,o=t._getTaskDOMIndex(r);if(s.classList.contains("smart-timeline-row")?n=t.$.timelineTasksContainer.children[o]:s.classList.contains("smart-timeline-task")&&(n=s,s=t.$.taskTimelineCellsContainer.children[o]),!n||n.classList.contains("milestone")||r.synchronized||r.disableResize)return;const l=i.closest(".smart-task-segment"),d=r.segments?r.segments.length:1;if(i.classList&&i.classList.contains("smart-task-connection-point")||l&&(d>1&&t.disableSegmentResize||l._segmentObj&&l._segmentObj.disableResize))return void a.removeAttribute("task-bar-hovered");const c=e.pageX-window.pageXOffset,m="visible"===t.resizeHandlesVisibility||t._isMobile?20:5,u=(l||n).getBoundingClientRect(),h=s.getBoundingClientRect(),g=Math.min(m,c-h.left),f=Math.min(m,h.left+h.width-c);Math.round(u.left)+g>=c&&Math.round(u.left)-g<=c?a.setAttribute("task-bar-hovered","left"):Math.round(u.left+u.width)+f>=c&&Math.round(u.left+u.width)-f<=c?a.setAttribute("task-bar-hovered","right"):a.removeAttribute("task-bar-hovered")}_onShadowDomLoaded(e,t,i){requestAnimationFrame((function a(){const n=(e.shadowRoot||e.getRootNode()).querySelectorAll("link");for(let e=0;e<n.length;e++)if(-1!==n[e].href.indexOf(t))return void i();requestAnimationFrame(a)}))}_getConnectionObjById(e){const t=this._connections;if(!e||!t||!t.length)return;const i=e.split("-"),a=parseInt(i[0]),n=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===a&&i.endIndex===n&&i.type===s)return i}}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),i=[e.$.taskPopupWindow,e.$.connectionPopupWindow,e.$.confirmPopupWindow];for(let a=0;a<i.length;a++){const n=i[a];if(!n||!t.contains(n))continue;const s=e.getBoundingClientRect();n.opened||(n.style.left=n.style.top=""),e._isMobile?(n.setAttribute("mobile",""),n.style.left=s.left+window.pageXOffset+"px",n.style.top=s.top+window.pageYOffset+"px",n.style.width=s.width+"px",n.style.height=s.height+"px"):(n.style.left=Math.max(s.left+window.pageXOffset,s.left+window.pageXOffset+s.width/2-n.offsetWidth/2)+"px",n.style.top=Math.max(s.top+window.pageYOffset,s.top+window.pageYOffset+s.height/2-n.offsetHeight/2)+"px")}}_openPopupWindow(e,t){const i=this;function a(){function t(){i._positionWindow(),s.opened?(s.bringToFront(),s._onOpenCallback?s._onOpenCallback():s._handleActiveState()):s.open()}if(i.popupWindowCustomizationFunction?i.popupWindowCustomizationFunction(s,n,"connection"===n?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",n,e),i._setPopupWindowTemplate("footer",n,e),i._setPopupWindowTemplate("content",n,e),!i._popupWindow[n+"PopupWindow"]){const e=i["$"+n+"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 a=(i.getAttribute("aria-owns")||"")+" "+s.id;i.setAttribute("aria-owns",a.trim()),i._popupWindow[n+"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",a=i._getVCellById(t,e.getAttribute("row-id"));e=a?a[t]:void 0}else e=e._cellObj.task;if(!e||e.isGroup)return;const n=t?"confirm":"string"==typeof e.type?"task":"connection",s=i._createPopupWindow(n);!t&&i.$.fireEvent("opening",{target:s,type:n}).defaultPrevented||(i._closeTooltip(),s._target=e,i._popupWindow||(i._popupWindow={}),s.parentElement||i.getShadowRootOrBody().appendChild(s),s.isCompleted?a():s.whenReady((()=>a())))}_createPopupWindow(e){const t=this,i=e+"PopupWindow";if(t.$[i])return t.$[i];const a=document.createElement("smart-window");return a.classList.add("smart-"+e+"-popup-window"),a.classList.add("smart-gantt-chart-popup-window"),a.setAttribute("smart-id",i),t.$[i]=a,t["$"+i]=Smart.Utilities.Extend(a),a.rightToLeft=t.rightToLeft,a.theme=t.theme,a.animation=t.animation,a.disableSnap=!0,a.headerButtons=["close"],a}_popupWindowOpenHandler(e){const t=this,i=t["$"+e.target.getAttribute("smart-id")];if(i){const a=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:a,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"),a=t["$"+i];if(a){const n=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:n,target:e.target},e.detail)),a.unlisten("close"),a.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,a=i.length;t<a;t+=1){const a=i[t];if(a.getAttribute("value")===e)return a}}_createTaskEditor(e,t,i){const a=this,n=e.value,s=t[e.value];let r,o,l=i.find((e=>e._label===n));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"===n){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",n||""),l._label=n,e.customEditor)return l.appendChild(e.customEditor(n,s)),l;if("number"==typeof s||"string"==typeof s)o=document.createElement("input"),o.classList.add("smart-input");else if(s instanceof Date||"deadline"===n)Smart.DateTimePicker?(o=document.createElement("smart-date-time-picker"),o.locale=a.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;a._setPopupWindowEditors(e,t,l)}_setAriaControls(){this.setAttribute("role","treegrid")}_setPopupWindowEditors(e,t,i){const a=this,n=i.querySelector("label"),s=i.querySelector(".smart-popup-window-editor-toggle"),r=i.lastElementChild,o=e.value+"",l=o.split(/(?=[A-Z])/).join(" "),d=t[o];if(e.customEditor)e.setCustomEditorValue&&e.setCustomEditorValue(i,l,d);else{if(n.innerHTML=a.localize(e.value)||l.charAt(0).toUpperCase()+l.slice(1),s)if("deadline"===o){const e=null==d?"add":"remove";r.classList[e]("smart-hidden"),s.textContent=a.localize(e)}else s.remove();if("number"==typeof d)r.value=parseFloat(d);else if("string"==typeof d)r.value=d;else if(d instanceof Date)r.value=new Date(d);else if(Array.isArray(d)){const e=a._resources;if(r.placeholder=a.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 a=i.querySelector("datalist"),n=document.createDocumentFragment();a.innerHTML="";for(let t=0;t<e.length;t++){const i=e[t],a=document.createElement("option");a.value=i.id,a.innerHTML=i.label,n.appendChild(a)}r.value=t.resources.toString(),a.appendChild(n)}}"project"===t.type&&t.synchronized&&["duration","date"].indexOf(l.toLowerCase())>-1||"resources"===l&&t.disableResources?r.disabled=!0:r.disabled=!!e.disableEdit,r.rightToLeft=a.rightToLeft,r.animation=a.animation,r.theme=a.theme}}_setupPopupWindowTabs(e,t){const i=this,a=i.popupWindowTabs,n="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];a.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=n&&"segments"===i)}return r}_setPopupWindowContent(e,t){const i=this,a=i.$[e+"PopupWindow"],n=[].slice.call(a.querySelectorAll(".smart-gantt-chart-popup-window-editor"));if(a.content&&(!a.content.innerHTML||n.length))if("task"===e&&t){const e=i.taskColumns;let s=[];const r=i._setupPopupWindowTabs(a,t);0!==r.selectedIndex&&(r.selectedIndex=0);const o=r.getTabs()[0];if("general"!==o.getAttribute("value"))return void i._handleTabsContent(o,a);"string"==typeof o.content?o.content="":o.content.innerHTML="";for(let a=0;a<e.length;a++){const r=e[a],l=r.value;if(void 0===t[l]&&"deadline"!==l||"overdue"===l)continue;let d=i._findTaskEditor(l,o);d||(d=i._createTaskEditor(r,t,n),d&&o.appendChild(d)),d&&(i._setPopupWindowEditors(r,t,d),s.push(d))}for(let e=0,t=n.length;e<t;e+=1){const t=n[e];s.indexOf(t)<0&&t.remove()}t.id&&a.setAttribute("aria-controls",t.id)}else if("confirm"===e){if(a.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&&a.setAttribute("aria-controls",i._popupWindow[e[e.length-1]].id)}}else{const e=t.startTask,n=t.endTask;a.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("deleteLink")+"<b> "+e.label+" - "+n.label+"?</b></div>"}}_setPopupWindowTemplate(e,t,i){const a=this,n=a.$[t+"PopupWindow"];if("content"!==e){if(n[e+"Template"]||(n[e+"Template"]=a._createPopupWindowTemplate(e,t)),"header"===e&&i&&"string"==typeof i.type){const e=(n.shadowRoot||n).querySelector(".smart-popup-window-label");e&&(e.innerHTML=i.label)}else if("footer"===e){const e=(n.shadowRoot||n).querySelectorAll(".smart-popup-window-button");for(let i=0;i<e.length;i++){const n=e[i];n.innerHTML="task"===t?'<span class="smart-icon"></span>':"",n.theme=a.theme,n.rightToLeft=a.rightToLeft,n.animation=a.animation,n.disabled=!1,n.classList.contains("ok")?(n.innerHTML+=a.localize("ok"),n.setAttribute("aria-label","ok")):n.classList.contains("cancel")?(n.innerHTML+=a.localize("cancel"),n.setAttribute("aria-label","cancel")):n.classList.contains("delete")&&(n.innerHTML+=a.localize("delete"),n.setAttribute("aria-label","delete"));const s=n.querySelector(".smart-ripple");s&&s.parentElement.removeChild(s)}}}else a._setPopupWindowContent(t,i)}_createPopupWindowTemplate(e,t){const i=this,a=document.createElement("template");if("footer"===e)switch(t){case"task":a.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":a.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||(a.innerHTML='<span class="smart-popup-window-label"></span>');return a}_handleTabsContent(e,t){const i=this,a=t._target;if(!e|!a)return;const n=e.getAttribute("value");if("general"===n)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(n){case"dependency":{const e=i._tasks,t=o.name,n=e.indexOf(a),r=e.findIndex((e=>e.$.id===t));r>-1&&s.updateRow(o.$.id,{id:`${r}-${n}-${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(n,a);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 a=this,n=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 d="";if("segments"===n)if(l<2)d=a.localize("segmentsCountValidation");else{const e=i._target,t=e.dateStart.getTime(),n=e.dateEnd.getTime();let s={};for(let e=0;e<l;e+=1){const i=o[e],r=i.label,l=i.dateStart.getTime(),c=i.dateEnd.getTime();for(let e in s){const t=s[e],n=t.timeStart,r=t.timeEnd,o=l<=n&&c>=n,m=l<=r&&c>=r;(o||m)&&(d+=a.localize("segmentConflictError",{dateConflict:o?"dateStart":"dateEnd",label:i.label,conflictLabel:t.label})+"\r\n")}l>c?d+=a.localize("segmentStartError",{label:i.label})+"\r\n":l===c&&(d+=a.localize("segmentEndError",{label:i.label})+"\r\n"),(l<t||c>n)&&(d+=a.localize("segmentRangeError",{label:i.label})+"\r\n"),void 0===s[e]&&(s[e]={label:r,timeStart:l,timeEnd:c})}}else if("dependency"===n)for(let e=0;e<l;e+=1){const t=o[e].id.split("-");t[0]===t[1]&&(d+=a.localize("dependencyValidation")+"\r\n")}s.textContent=d,r&&(r.disabled=d.length>0)}_getTabsTableData(e,t){const i=this;if("dependency"===e){const e=i._getTaskConnections(t).connectedTasks,a={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 a=[];for(let i=0,n=e.length;i<n;i+=1){const n=e[i];n!==t&&a.push({value:n.$.id,label:n.label})}return a})()};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",a),formatFunction:e=>{const t=a.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",a),formatFunction:e=>{const t=a.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,a,n,s)=>{const r=t.task;s||(s=new Date(r.dateStart)),n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.min=r.dateStart,n.max=r.dateEnd,n.locale=i.locale,n.calendarButton=!0,n.dropDownDisplayMode="auto",n.enableMouseWheelAction=!0,n.formatString="yyyy-MMM-dd HH:mm:ss",n.value=new Date(Math.max(r.dateStart.getTime(),Math.min(r.dateEnd.getTime(),s.getTime()))),n.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,a,n,s)=>{n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.dataSource=t.tasks,n.selectedValues=[s],n.removeAttribute("wait")},getValue:e=>e.selectedValues[0]};case"type":return{template:"<smart-input wait></smart-input>",onInit:(e,a,n,s)=>{const r=t.connectionTypes,o=r.find((e=>e.value===s));n.readonly=!0,n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.dropDownButtonPosition="right",n.dataSource=r,n.value=(o||r[0]).label+"",n.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,a=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0);if(a._target)if(i.classList.contains("smart-gantt-chart-popup-window-tabs")){const n=a.querySelector(".smart-popup-window-button.ok");n&&(n.disabled=!1),t._handleTabsContent(i.getTabs()[e.detail.index],a)}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 a=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0),n=a._target;if(i.closest(".smart-popup-window-button.cancel"))return t._popupWindow&&t._popupWindow.confirmPopupWindow&&a!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),a.close(),void delete a._target;if(i.closest(".smart-popup-window-button.ok")){if(a===t.$.connectionPopupWindow&&"number"==typeof n.type)t._removeConnection(n.startIndex+"-"+n.endIndex+"-"+n.type);else if(a===t.$.confirmPopupWindow){const e=n;void 0!==e.$._resourceId?t._removeResource(e):t._removeTask(e),a.close(),t.$.taskPopupWindow&&t.$.taskPopupWindow.close(),delete a._target}else{const e=a.shadowRoot||a,i=e.querySelectorAll(".smart-gantt-chart-popup-window-editor"),s=n;let r={};for(let e=0;e<i.length;e++){const a=i[e]._label,n=t.taskColumns.find((e=>e.value===a));if(n.customEditor&&n.getCustomEditorValue)r[a]=n.getCustomEditorValue(i[e]);else{const t=i[e].lastElementChild;let n;if(!t)continue;if(t.classList.contains("smart-hidden")){r[a]=void 0;continue}n=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,n instanceof Date&&isNaN(n.getTime())&&(n=void 0),null!=n&&(r[a]=n)}}if(void 0!==s.$._resourceId)t._updateResource(s,r);else{const i=r.dateStart?r.dateStart:void 0,a=r.dateEnd?r.dateEnd:void 0;if((i&&i.getTime&&i.getTime()!==s.dateStart.getTime()||a&&a.getTime&&a.getTime()!==s.dateEnd.getTime())&&(r.duration=void 0),t._isPopupWindowTableModified){const i=e.querySelectorAll(".smart-gantt-popup-window-table");for(let e=0,a=i.length;e<a;e+=1){const a=i[e];a.closest('.smart-tab-item[value="dependency"]')?t._updateTaskDependencies(a,s):a.closest('.smart-tab-item[value="segments"]')&&t._updateTaskSegments(a,s)}}t._updateTask(s,r)}}return t._popupWindow&&t._popupWindow.confirmPopupWindow&&a!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),a.close(),void delete a._target}if(i.closest(".smart-popup-window-button.delete"))return void t._openPopupWindow(a._target,!0);if(i.closest(".smart-popup-window-editor-toggle")){const e=i.closest('.smart-gantt-chart-popup-window-editor[value="deadline"]'),a=e?e.lastElementChild:void 0;if(a){const e=a.classList.contains("smart-hidden")?"remove":"add";a.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"),d=n;switch(o){case"add":{let e;e="segments"===l?{label:`${t.localize("segment")} ${r.dataSource.length+1}`,dateStart:new Date(d.dateStart),dateEnd:new Date(d.dateEnd),duration:parseFloat((d.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,a)}}_updateTaskDependencies(e,t){const i=this,a=i._tasks.indexOf(t),n=i._getTaskConnections(t).connectedTasks,s=e.rows;for(let e=0,t=n.length;e<t;e+=1){const t=n[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,n=t.name,r=t.type;if(!i._getValidConnectionId(n,a,r,"_"))continue;const o=parseInt(t.lag);i._connectTask([n,a,r,isNaN(o)?0:o])}i._recycleConnections()}_updateTaskSegments(e,t){const i=e.rows;let a=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e].data,n=t.label,s=new Date(t.dateStart),r=new Date(t.dateEnd);isNaN(s)||isNaN(r)||a.push({label:"string"==typeof n?n:"",dateStart:s,dateEnd:r})}t.segments=a,this._validateTaskSegments(t)}_createTasks(e,t){const i=this,a={},n=[];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 d=0;d<r.length;d++){let c,m=r[d];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+"."+d:d+"","string"!=typeof h&&"number"!=typeof h||(a[h]?n.push(h):a[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",c=e(u,m),c.length&&(m.hidden=!c.some((e=>!e.hidden)),m.hidden?c.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&&c&&c.length>0?(l.push(m),l=l.concat(c)):(o||((t&&"project"===m.type&&m.synchronized||m.dateStart&&m.dateEnd&&!isNaN(m.dateStart.getTime())&&!isNaN(m.dateEnd.getTime()))&&s.push(m),c&&(s=s.concat(c))),l.push(m))}return o&&i._synchronizeProjectDates(o,l),l}(e),t)return s.slice(0);n.length&&console.warn(i.localize("duplicateIds",{elementType:i.nodeName.toLowerCase(),duplicates:n.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,a=t.length;i<a;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 a=t.$tooltip;e?(a=t.$tooltip=Smart.Utilities.Extend(i),a.listen("close",t._tooltipVisibilityHandler.bind(t)),a.listen("closing",t._tooltipVisibilityHandler.bind(t)),a.listen("open",t._tooltipVisibilityHandler.bind(t)),a.listen("opening",t._tooltipVisibilityHandler.bind(t))):a&&(a.unlisten("close"),a.unlisten("closing"),a.unlisten("open"),a.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(),a={"smart-task-segment":null,"smart-timeline-task":null,"smart-gantt-chart-task-indicator":null,"smart-resource-timeline-view-cell":null,"smart-task-connection":null},n=(i.host?i.host.shadowRoot:i).elementsFromPoint(e.clientX,e.clientY);let s;for(let e=0,t=n.length;e<t;e+=1){const t=n[e],i=t.classList;if(i.contains("smart-task-container"))a["smart-timeline-task"]=t.closest(".smart-timeline-task");else for(let e in a)i.contains(e)&&(a[e]=t)}if(a["smart-task-segment"]){const e=a["smart-timeline-task"],t=e?e._cellObj.task:void 0;s=t&&t.segments&&t.segments.length?a["smart-task-segment"]:e}else if(a["smart-gantt-chart-task-indicator"])s=a["smart-gantt-chart-task-indicator"];else for(let e in a)if(a[e]){s=a[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,a=t.length;i<a;i+=1){const a=t[i];if(Array.isArray(a.segments)&&a.segments.indexOf(e)>-1)return a}}_getTooltipContent(e){const t=this;if(!e)return;const i=e.classList;let a,n;if(i.contains("smart-task-segment")){if(n=e._segmentObj,n){let e=n.label;if(void 0===e){const i=t._getSegmentTask(n);i&&(e=i.label)}a=`<label><b>${t.localize("segment")}</b>: ${e||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(n.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(n.dateEnd)||""}</label>`}}else if(i.contains("smart-timeline-task"))n=e._cellObj.task,n&&!n.segments&&(a=`<label><b>${t.localize("task")}</b>: ${n.label||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(n.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(n.dateEnd)||""}</label>`);else if(i.contains("smart-gantt-chart-task-indicator"))n=e._indicatorObj,n&&(a=n.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&&(n=e._cellObj.resource),n){const s=t._getResourceTasks(n),r="hours"===t.resourceTimelineView?"h":"",o=t._tasks,l=t.$.resourceTimelineViewCells.children,d=Array.from(e.children).findIndex((e=>e===i));a=`<label><b>${t.localize("resource")}</b>: ${n.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],c=o.indexOf(i),m=t._getResourceCellCapacity({cellDateRange:t._getCellDateRange(l[d]),cellTaskIndexAssigned:[c],index:d,resource:n,task:i,cellIndex:d});void 0!==m&&(a+=`<label>${t.localize("task")} #${c}: (${parseFloat(m.capacity.toFixed(1))}${r}) ${i.label||""}</label>`)}}}else i.contains("smart-task-connection")&&(n=t.getConnectionDetails(e.getAttribute("connection-id")),void 0!==n&&(a=`<label><b>${t.localize("startTask")}</b>: ${n.startTask.label||""}</label>\n <label><b>${t.localize("endTask")}</b>: ${n.endTask.label||""}</label>\n <label><b>${t.localize("type")}</b>: ${t._getConnectionTypeName(n.type)||""}</label>`,n.lag&&(a+=`<label><b>${t.localize("lag")}</b>: ${parseFloat(n.lag.toFixed(1))}</label>`)));return n?n.tooltip?n.tooltip+"":a||"":void 0}_openTooltip(e,t,i){const a=this,n=a.tooltip;if(i="string"==typeof i?i:a._getTooltipContent(e),!(n.enabled&&i&&e&&e.nodeName))return void a._closeTooltip();const s=a.$.tooltip||a._createTooltip();let r,o;if(i&&s.value!==i&&(s.value=i),s.selector=e,t&&t.pageX){const i=document.body.getBoundingClientRect(),a=e.getBoundingClientRect(),l=n,d=l.offset[0]||0,c=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-d),r=a.top-u-c,r<i.top&&(r=a.bottom+c,h="top"),o<i.left&&(o=i.left+d,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=n.offset);s.visible||(a.getShadowRootOrBody().appendChild(s),s.open())}_closeTooltip(){const e=this.$.tooltip;e&&e.visible&&e.close()}_tooltipVisibilityHandler(e){const t=this,i=e.type,a=t.$.tooltip;e.target===a&&(e.stopPropagation(),t._fireTooltipVisibilityEvent(e)?e.preventDefault():"opening"===i?a.classList.remove("smart-visibility-hidden"):"closing"===i&&(a.hasAnimation?a.addEventListener("transitionend",(()=>{a.visible||(a.classList.add("smart-visibility-hidden"),a.style.top=a.style.left=0,t.$.container.appendChild(a))}),{once:!0}):t.$.container.appendChild(a)))}_fireTooltipVisibilityEvent(e){const t=this,i=e.type,a=t.$.tooltip,n=e.detail.owner;let s={target:a,owner:n};if(n)if(n.classList.contains("smart-task-connection")){s.type="connection";const e=t.getConnectionDetails(n.getAttribute("connection-id"));e&&(s.item=e)}else if(n.classList.contains("smart-gantt-chart-task-indicator"))s.type="indicator",n._indicatorObj&&(s.item=t._cloneObject(n._indicatorObj));else if(n.classList.contains("smart-task-segment"))s.type="segment",n._segmentObj&&(s.item=t._cloneObject(n._segmentObj));else if(n.classList.contains("smart-timeline-task"))s.type="task",n._cellObj&&n._cellObj.task&&(s.item=t._cloneObject(n._cellObj.task));else if(n.classList.contains("smart-resource-timeline-view-cell")){s.type="resource";const e=n.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+" "+a.id).trim()),t.$.fireEvent(i,s);break;case"close":r=r.replace(a.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,a=e.length;i<a;i+=1){const a=e[i],n=Object.assign({},a),s=a.parent,r=a.$.id;if(s&&s!==a){const e=s.$.id;t[e]||(t[e]=Object.assign({},s));const i=t[e];i.tasks||(i.tasks=[]),i.tasks.push(n)}else t[r]=n;delete n.parent,delete n.children,delete n.$}return Object.values(t)}_handleTaskConnections(e){const t=this,i=t._tasks;let a;if("number"==typeof e&&(a=e,e=i[e]),!e)return;void 0===a&&(a=i.indexOf(e));const n=e.connections,s=i.length;for(let e=0;e<n.length;e++){const i=n[e],r=t._getTaskIndexById(i.target);null==r||isNaN(r)||r<0||r>=s||r===a||t._connectTask([a,r,i.type,i.lag])}delete e.connections}_insertTasks(e,t,i){const a=this,n=a._tasks;if(t){const s=a._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=a._getProjectTasks(r);i=o&&l.length?n.indexOf(l[l.length-1]):n.indexOf(r),n.splice.apply(n,[i+(o?1:0),0].concat(e))}else n.splice.apply(n,[n.indexOf(t)+1,0].concat(e))}else"number"==typeof i?(i+="",(i=n.findIndex((e=>e.$.id===i)))<0&&(i=n.length)):i=n.length,n.splice.apply(n,[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,a=i.children,n=t.$.taskTimelineCellsContainer.childElementCount,s=t._timelineVCells;for(;i.childElementCount>n;)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,d=n;i<d;i++){const n=a[i],d=s[r+i];if(!d){n&&n.remove();continue}const c=d.task;t._snapToNearestDates(c),t._recycleTaskBars(d,i,o),t._setTimelineTaskBar(d,i),t._setTimelineTaskBaseline(d,i),t._setTaskBarProgress(c,i),t._setTaskBarLabel(c,i),t._setTaskIndicators(d,i,l),t._setTaskDeadline(d,i,l),e&&t._refreshTableColumnsData(c)}t._recycleConnections()}_ensureVisible(e,t="task"){const i=this;if(null==e)return;let a,n="task"===t?i._timelineVCells:i._timelineResourceVCells;a||(a=i.$[`${t}Table`]);const s=n.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,a=i.$.taskTimelineContainer.offsetWidth;t.left+t.width>e+a?i.scrollLeft=Math.max(0,t.left+t.width-a):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,a=e.$[this.groupByResources?"group":"project"];if(!a)return!0;for(;a;){if(i=a.expanded,!i)return!1;if(a=a.$.project,a===t)break}return i}_getItemByTreeIndex(e,t,i){if(!t)return;const a=t.split(".");let n=this[`_${e}s`].filter((e=>!e.$.project))[t.split(".")[0]];if(n){if(!n[`${e}s`]||!n[`${e}s`].length)return i?null:n;for(let t=1;t<a.length;t++){const s=n[`${e}s`].filter((e=>!e.hidden&&e.$.project===n))[a[t]];if(!s||i&&"project"!==s.type)break;if(n=s,"project"!==n.type)break}return i?n&&"project"===n.type?n:void 0:n}}_getItemByTableId(e,t,i){if(null==t)return;const a=this[`_${e}s`];let n;for(let e=0,i=a.length;e<i;e+=1){const i=a[e];if(i.$.id===t){n=i;break}}return n?i?"project"===n.type?n:void 0:n: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,a=t.classList.contains("smart-task-table");if(!a&&!t.classList.contains("smart-resource-table"))return;e.stopPropagation();const n=i.dataField,s=this[(a?"task":"resource")+"Columns"].find((e=>e.value===n));s&&(s.size=i.width),this.$.fireEvent("columnResize",i)}_tableSortFilterHandler(e){const t=this,i=e.target;let a;i.classList.contains("smart-task-table")?(a="task",t._createTimelineContent(),t._recycleTimelineTasks()):i.classList.contains("smart-resource-table")&&(a="resource",t._createResourceTimelineContent(),t._recycleResourceContent()),a&&(t._refresh(),e.stopPropagation(),t.$.fireEvent(e.type,Object.assign({type:a},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 a=i===t.$.taskTable?"task":"resource";if(e.stopPropagation(),!t[`${a}s`]||!t[`${a}s`].length)return;const n=e.detail.record.itemId,s=t._getItemByTableId(a,n,!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 a=e.closest("tbody tr");if(!a)return;const n=t._getVCellById("task",a.getAttribute("row-id"));n&&t._openPopupWindow(n.task,"Delete"===i);break}}}_getVCellById(e="task",t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let a=0,n=i.length;a<n;a+=1){const n=i[a][e];if(n.$&&n.$.id===t)return i[a]}}_getGroupVCellByPath(e,t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let a=0,n=i.length;a<n;a+=1){const n=i[a][e];if(n.$&&n.$.id===t)return i[a]}}_taskTableGroupEventHandler(e){const t=this,i=e.detail.action,a=e.target;if(["collapse","expand"].indexOf(i)<0||!a.classList.contains("smart-task-table")&&!a.classList.contains("smart-resource-table"))return;const n=a===t.$.taskTable?"task":"resource",s=t.$.taskTable._getGroupByIndex(e.detail.path),r=t._getGroupVCellByPath(n,s.$.id);if(!r||!r[n].isGroup)return;const o=r[n];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),a=t.scrollTop;t._refreshing=!0,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._refreshing=!1,t._scrollTo(i),t.scrollTop=a}_scrollTo(e,t){const i=this,a=i._timelineCells;let n;if(void 0!==e&&!isNaN(new Date(e).getTime()))for(let s=0;s<a.length;s++){const r=a[s],o=r.date;switch(i.view){case"quarter":case"year":if(o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()){if(t){n=r.left;break}let i=new Date(e);i.setMonth(e.getMonth()+1),i.setDate(0),i=i.getDate(),n=r.left+(e.getDate()-1)/i*r.width}break;case"month":{let i=new Date(o),a=new Date(o);i.setDate(i.getDate()-i.getDay()),a.setDate(a.getDate()+(6-a.getDay())+1),a.setMilliseconds(a.getMilliseconds()-1),e.getTime()>=i.getTime()&&e.getTime()<=a.getTime()&&(n=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()&&(n=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()&&(n=r.left+(t?0:parseFloat(e.getMinutes()+e.getSeconds())/60*r.width))}if(void 0!==n)return i.scrollLeft=n,void(i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=i.$.resourceTimelineContent.scrollLeft=n,i._refreshResourceTimeline()))}}_updateConnection(e,t){const i=this,a=i._tasks,[n,s,r,o]=e,l=a[n],d=a[s];if(!l||!d||"number"!=typeof r)return;let c=i._connections,m=-1;c||(c=i._connections=[]);for(let e=0,t=c.length;e<t;e+=1){const t=c[e],i=t.startIndex,a=t.endIndex;if(i===n&&a===s||i===s&&a===n){m=e;break}}if(!t){if(m<0)c.push({startTask:a[n],endTask:a[s],startIndex:n,endIndex:s,type:r,lag:o});else{const e=c[m];if(!e)return;if(e.startIndex=n,e.startTask=a[n],e.endIndex=s,e.endTask=a[s],e.type=r,o!==e.lag){const t=parseInt(o);isNaN(t)||(e.lag=t)}}return!0}m>-1&&c.splice(m,1)}_createTimelineCells(){const e=this,t=e._tasks,i=new Date(e.properties.dateStart.value),a=new Date(e.properties.dateEnd.value);let n,s;if(isNaN(i.getTime())||(n=i),isNaN(a.getTime())||(s=a),t.length>0){let e=t[0].dateStart,i=t[0].dateEnd;for(let a=0;a<t.length;a++)t[a].dateStart&&t[a].dateEnd&&(e||(e=t[a].dateStart),i||(i=t[a].dateEnd),e.getTime()>t[a].dateStart.getTime()&&(e=t[a].dateStart),i.getTime()<t[a].dateEnd.getTime()&&(i=t[a].dateEnd));(!n||n.getTime()>e.getTime())&&(n=e),(!s||s.getTime()<i.getTime())&&(s=i)}if(n&&s){if(n=e._minMaxDateValidator(n),s=e._minMaxDateValidator(s),-1!==e.firstDayOfWeek){const t=n.getDay()-e.firstDayOfWeek,i=new Date(n.getTime());i.setDate(n.getDate()-n.getDay()+e.firstDayOfWeek-(t>=0?0:7)),n=i}e._createTimelineHeader(n,e._getCellsCount(n,s)),e._createTimelineContent(),e._createDateMarkers(),e._refresh()}}_getCellsCount(e,t,i){let a,n,s,r,o,l,d=new Date(e),c=new Date(t);const m=this,u=t.getFullYear()-e.getFullYear();if(n=a=Math.round(u)+1,"year"===i)return{year:n};if(d.setHours(d.getHours(),0,0,0),c.setHours(c.getHours(),0,0,0),l=Math.floor((t.getTime()-e.getTime())/36e5),l>0){let e=new Date(d);if(l=1,d.getFullYear()!==c.getFullYear()){let t=new Date(d.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=c.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()<c.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(d.setHours(0,0,0,0),c.setHours(23,59,59,999),o=a=Math.round((c.getTime()-d.getTime())/864e5),"day"===i)return{day:o};if(d.setDate(d.getDate()-d.getDay()),c.setDate(c.getDate()+6-c.getDay()),r=a=Math.round((c.getTime()-d.getTime())/6048e5),"week"===i){if(-1!==m.firstDayOfWeek){const t=e.getDay()-m.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+m.firstDayOfWeek-(t>=0?0:7))}return{week:r}}if("month"===this.view&&"day"!==m.monthScale&&(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()))),-1!==m.firstDayOfWeek)){const t=e.getDay()-m.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+m.firstDayOfWeek-(t>=0?0:7))}if(e.getFullYear()!==t.getFullYear()){a=12-e.getMonth();const i=t.getFullYear();for(let n=e.getFullYear()+1;n<=i;n++)a+=n===t.getFullYear()?t.getMonth()+1:12}else a=t.getMonth()-e.getMonth()+1;return s=Math.ceil(a),"months"===i?{month:s}:("day"===this.view&&0===l&&(l=1),{year:n,month:s,week:r,day:o,hour:l})}_recycleTaskBars(e,t,i){const a=this,n=e.task,s=a.$.timelineTasksContainer,r=a.$.taskTimelineCellsContainer,o="project"===n.type&&n.synchronized,l=n.type,d=n.$.id,c=s.children[t],m=r.children[t];m._cellObj=e,m.setAttribute("row-id",d),m.style.top=e.top+"px",m.removeAttribute("hover"),c.removeAttribute("hover"),c.classList.contains(l)||(c.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.connectionType&&(n.connectionType.includes("start")||c.querySelector(".start").classList.add("smart-hidden"),n.connectionType.includes("end")||c.querySelector(".end").classList.add("smart-hidden")),a._recycleSegments(n,c),delete c._cellStart,delete c._cellEnd,n.disableDrag||o&&!n.dragProject?c.setAttribute("disable-drag",""):c.removeAttribute("disable-drag"),n.disableResize||o?c.setAttribute("disable-resize",""):c.removeAttribute("disable-resize"),n.isGroup?c.setAttribute("resource-group",""):c.removeAttribute("resource-group"),i&&(i.indexOf(d)>-1?(c.setAttribute("selected",""),m.setAttribute("selected","")):(c.removeAttribute("selected"),m.removeAttribute("selected"))),n.id?c.id=n.id:c.id="ganttTask"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),c._cellObj=e,c.className="smart-timeline-task "+l,c.setAttribute("row-id",d),n.class&&c.classList.add(n.class),c.setAttribute("aria-label",n.label+" Start date: "+a._toISODate(n.dateStart)+", End date: "+a._toISODate(n.dateEnd)),c.setAttribute("aria-selected","false")}_toISODate(e){const t=e.getFullYear(),i=e.getMonth()+1,a=e.getDate();return t+"-"+(i<10?"0"+i:i)+"-"+(a<10?"0"+a:a)}_recycleSegments(e,t){const i=this,a=t.querySelector(".smart-task-segments");let n,s=e.segments;if(!a)return;for(Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);a.childElementCount>s.length;)a.children[0].remove();const r=document.createDocumentFragment(),o=a.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,a=s.length;t<a;t+=1){const a=s[t];let d=o[t];a.dateStart=new Date(Math.max(e.dateStart.getTime(),a.dateStart.getTime())),a.dateEnd=new Date(Math.min(e.dateEnd.getTime(),a.dateEnd.getTime())),d?(delete d._cellStart,delete d._cellEnd):(d=document.createElement("div"),d.classList.add("smart-task-segment"),d.innerHTML=l,r.appendChild(d)),a.disableDrag?d.setAttribute("disable-drag",""):d.removeAttribute("disable-drag"),a.disableResize?d.setAttribute("disable-resize",""):d.removeAttribute("disable-resize"),d._segmentObj=a,d.setAttribute("aria-label",(a.label||"")+" Start date: "+i._toISODate(a.dateStart)+", End date: "+i._toISODate(a.dateEnd)),n=d}r.childElementCount&&a.appendChild(r),i._setTaskBarDeadline(e,n)}_createCells(e){let t,i=document.createDocumentFragment();for(let a=0;a<e;a++)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 a=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))+a))}_getHeaderVisibleCellsCount(){const e=this;if(!e._timelineHeaderCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,a=e._timelineHeaderCells;let n=0;for(let e=0;e<a.length;e++){const s=a[e];s.left+s.width>t&&s.left<i+t&&n++}return n}_getHeaderSubVisibleCellsCount(){const e=this;if(!e._timelineHeaderSubCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,a=e._timelineHeaderSubCells;let n=0;for(let e=0;e<a.length;e++){const s=a[e];s.left+s.width>t&&s.left<i+t&&n++}return n}_refreshHeaderDate(e){const t=this,i=t._getCellsViewType(),a=t.$.timelineHeader.scrollLeft,n=t.$.timelineViewCells.children,s=t._timelineCells;let r;t._refreshHeaderSubDetailsDate(e),t._refreshHeaderDetailsDate(e);for(let e=0;e<s.length;e++){const t=s[e];if(a<=t.left+t.width){r=e;break}}for(let a=0;a<n.length;a++){const o=n[a],l=s[r];if(!l)break;r++;const d=l.date;o.innerHTML=`<div>${t._getDateString(new Date(d),i)}</div>`,e||(o._date=new Date(d),o.setAttribute("date",d.toLocaleDateString()),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 a=this,n=["2-digit","numeric"][a.dayFormat]||"numeric";let s;if("year"===t||"quarter"===t)s=e.toLocaleDateString(a.locale,{year:a.yearFormat});else if("month"===t)s=e.toLocaleDateString(a.locale,{month:a.monthFormat}),"month"===a.view&&(s+=" "+e.toLocaleDateString(a.locale,{year:a.yearFormat}));else if("week"===t)s="numeric"!==a.weekFormat&&i?e.toLocaleDateString(a.locale,{day:n,month:a.monthFormat,year:a.yearFormat}):a._getWeekNumber(e);else if("day"===t)s="month"===a.view?"numeric"!==a.dayFormat&&"2-digit"!==a.dayFormat?e.toLocaleDateString(a.locale,{day:"numeric"})+" "+e.toLocaleDateString(a.locale,{weekday:a.dayFormat}):e.toLocaleDateString(a.locale,{day:"numeric"})+" "+e.toLocaleDateString(a.locale,{weekday:"short"}):e.toLocaleDateString(a.locale,"day"===a.view?{day:n,month:a.monthFormat,year:a.yearFormat}:["long","short","narrow"].indexOf(a.dayFormat)>-1?{weekday:a.dayFormat}:{day:a.dayFormat});else if("hour"===t)if(s="default"===a.hourFormat?e.toLocaleTimeString(a.locale,{hour12:!1}):e.toLocaleDateString(a.locale,{hour:a.hourFormat}),"default"!==a.hourFormat)s.indexOf(",")>=0&&(s=s.substring(s.indexOf(",")+1).trim());else if(s.indexOf(":")!==s.lastIndexOf(":")&&s.indexOf(":")>=0){let e=s.toLowerCase().indexOf("am")>=0?" AM":"";e=s.toLowerCase().indexOf("pm")>=0?" PM":e,s=s.substring(0,s.lastIndexOf(":"))+e}return a.timelineHeaderFormatFunction?a.timelineHeaderFormatFunction(new Date(e),t,i,s):s}_refreshHeaderSubDetailsDate(e){const t=this,i=(t.view,t.scrollLeft),a=t.$.timelineViewSubDetails.children,n=t._timelineHeaderSubCells;let s;if(t.$.timelineViewSubDetails.classList.contains("smart-hidden"))return;for(let e=0;e<n.length;e++){const t=n[e];if(i<=t.left+t.width){s=e;break}}let r=[],o=0;for(let i=0;i<a.length;i++){const l=n[s],d=a[i];if(!l)continue;let c=new Date(l.date);"week"===t.view&&c.setDate(c.getDate()-c.getDay()),s++,c=new Date(Math.max(l.date.getTime(),c.getTime()));const m=e=>{var i,a=e.getMonth();return i=a>=9?4:a>=6?3:a>=3?2:1,"long"===t.quarterFormat?t.localize("quarter")+" "+i:"numeric"===t.quarterFormat?i:t.localize("quarterShort")+i};let u="";"quarter"===t.view||"year"===t.view?(u=m(c),"quarter"===t.view&&t.hideTimelineSecondHeaderDetails&&(u+=" "+c.getFullYear())):"month"===t.view&&(-1===t.firstDayOfWeek?u=t._getWeekNumber(c):((c.getDay()-t.firstDayOfWeek)%7==0&&i>0&&o++,u=o));const h=u+"_"+c.getFullYear();r[h]||(r[h]=[]),d.classList.remove("smart-visibility-hidden"),r[h].push({element:d,cell:l}),d.innerHTML=`<div>${u}</div>`,d.classList.add("middle"),e||(d._date=c,d.style[t.rightToLeft?"right":"left"]=l.left+"px",d.style.width=l.width+"px")}for(let e in r){const i=r[e];let a=0;for(let e=0;e<i.length;e++)a+=i[e].cell.width;if(i[0].element.style.width=a+"px","year"===t.view){const e=i[0].cell.date.toLocaleDateString(t.locale,{month:t.monthFormat}),a=i[i.length-1].cell.date.toLocaleDateString(t.locale,{month:t.monthFormat});i.length>1?i[0].element.innerHTML=`<div>${e}-${a}</div>`:i[0].element.innerHTML=`<div>${e}</div>`}else if("month"===t.view){const e="numeric"!==t.dayFormat&&"2-digit"!==t.dayFormat?t.dayFormat:"short",a=i[0].cell.date.toLocaleDateString(t.locale,{day:"numeric"})+" "+i[0].cell.date.toLocaleDateString(t.locale,{weekday:e}),n=i[i.length-1].cell.date.toLocaleDateString(t.locale,{day:"numeric"})+" "+i[i.length-1].cell.date.toLocaleDateString(t.locale,{weekday:e});i.length>1?i[0].element.innerHTML=`<div>${a}-${n}</div>`:i[0].element.innerHTML=`<div>${a}</div>`,"numeric"===t.weekFormat&&(i[0].element.innerHTML=t._getWeekNumber(i[0].cell.date))}if(t.timelineHeaderFormatFunction){const e=t.timelineHeaderFormatFunction(new Date(i[0].cell.date),t.view,!0,i[0].element.innerHTML);i[0].element.innerHTML!==e&&(i[0].element.innerHTML=e)}for(let e=1;e<i.length;e++)i[e].element.classList.add("smart-visibility-hidden")}}_refreshHeaderDetailsDate(e){const t=this,i=t.view,a=t.scrollLeft,n=t.$.timelineViewDetails.children,s=t._timelineHeaderCells;let r;for(let e=0;e<s.length;e++){const t=s[e];if(a<=t.left+t.width){r=e;break}}for(let a=0;a<n.length;a++){const o=s[r],l=n[a];let d=new Date(o.date);if("week"===t.view)if(-1!==t.firstDayOfWeek){const e=d.getDay()-t.firstDayOfWeek;d.setDate(d.getDate()-d.getDay()+t.firstDayOfWeek-(e>=0?0:7))}else d.setDate(d.getDate()-d.getDay());r++,d=new Date(Math.max(o.date.getTime(),d.getTime())),l.innerHTML=`<div>${t._getDateString(d,i,!0)}</div>`,e||(l._date=d,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),a=Math.round((e.getTime()-i.getTime()-6e4*(e.getTimezoneOffset()-i.getTimezoneOffset()))/864e5)+1,n=i.getDay();return n=n>=0?n:n+7,n<4?(t=Math.floor((a+n-1)/7)+1,t>52&&(i=new Date(e.getFullYear()+1,0,1),n=i.getDay(),n=n>=0?n:n+7,t=n<4?1:53)):t="week"===this.view?function(e){var t=new Date(e.valueOf()),i=(e.getDay()+6)%7;t.setDate(t.getDate()-i+3);var a=t.valueOf();return t.setMonth(0,1),4!==t.getDay()&&t.setMonth(0,1+(4-t.getDay()+7)%7),1+Math.ceil((a-t)/6048e5)}(e):Math.round((a+n-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,a=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()])return void i._refresh();i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width="",i._createTimelineCellsObj(e,t),i._createTimelineHeaderCellsObj(e,t),i._createTimelineHeaderSubCellsObj(e,t),i.$.timelineViewDetails.innerHTML="",i.$.timelineViewDetails.appendChild(i._createCells(i._getHeaderVisibleCellsCount())),i.$.timelineViewSubDetails.innerHTML="",i.$.timelineViewCells.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.classList.add("smart-hidden");let n=2;"quarter"===i.view?(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(i._getTimelineVisibleCellsCount()))):"month"===i.view&&"day"===i.monthScale?(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(t.day))):"year"===i.view&&(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(t.month))),i.hideTimelineHeader&&(i.$.timelineViewCells.classList.add("smart-hidden"),n--),i.hideTimelineHeaderDetails&&(i.$.timelineViewDetails.classList.add("smart-hidden"),n--),i.hideTimelineSecondHeaderDetails&&("quarter"===i.view?i.$.timelineViewDetails.classList.add("smart-hidden"):i.$.timelineViewSubDetails.classList.add("smart-hidden"),("year"===i.view||"month"===i.view&&"day"===i.monthScale||"quarter"===i.view)&&n--),i.$.taskTable.style.setProperty("--smart-table-column-header-height","calc("+n+" * var(--smart-gantt-chart-task-default-height) - calc("+n+" * var(--smart-border-width) / "+n+"))"),i.$.timelineViewCells.innerHTML="",i.$.timelineViewCells.appendChild(i._createCells(i._getTimelineVisibleCellsCount()));let s=t[a];if("hour"===a&&("halfHour"===i.dayScale?s*=2:"quarterHour"===i.dayScale&&(s*=4)),i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width=Math.max(s*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,a=e._taskDefaultHeight,n=e.$.taskTimelineContainer,s=e.scrollLeft;if(i.style.height="",t.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e._createTimelineVCells(a),i.style.height=e._timelineVCells.length*a+"px",t.style.setProperty("--smart-gantt-chart-task-timeline-content-height",e.$.timeline.offsetHeight+"px"),s||s!==n.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);n.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=t)}e.scrollTop&&(n.scrollTop=e.scrollTop),e._recycleContentCells()}_createDateMarkers(){const e=this,t=e.dateMarkers;let i=[];delete e._markers;for(let a=0,n=t.length;a<n;a+=1){const n=t[a],s=e._dateValidator(void 0,n.date);if(s){const e={date:s},t=n.label,a=n.className;("string"==typeof t||"number"==typeof t&&!isNaN(t))&&(e.label=t),"string"==typeof a&&(e.className=a),i.push(e)}}i.length&&(e._markers=i),e._recycleDateMarkers()}_createTimelineRowCells(e,t){const i=this,a=e.children,n=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=n.length;e<t;e+=1)n[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],n=a[e];i.hasAttribute("weekend")?n.setAttribute("weekend",""):n.removeAttribute("weekend"),i.hasAttribute("nonworking")?n.setAttribute("nonworking",""):n.removeAttribute("nonworking"),n.style[o]=i.style[o],n.style[r]=i.style[r],n.style.width=i.style.width}for(let t=0,i=n.length;t<i;t+=1)e.appendChild(n[t])}_recycleTimelineRowCells(){const e=this,t=e.$.timelineViewCells.children,i=e.$.taskTimelineCellsContainer.children;for(let a=0,n=i.length;a<n;a+=1)e._createTimelineRowCells(i[a],t)}_createTimelineVCells(e){const t=this,i=t._tasks,a=t.$.taskTable.rows,n=t.groupByResources;let s=0,r={};t._timelineVCells=[];for(let o=0,l=a.length;o<l;o++){const l=a[o].data;let d=i[l.itemIndex];if(n)if(!d&&l.groupDataField){const e=l.$.id;d={$:{id:e,project:void 0},label:t._formatResourceGroupLabel(l.label),value:l.label,expanded:l.expanded,synchronized:!0,isGroup:!0,type:"project"},r[e]=d}else l.parent?(d.$.group=r[l.parent.$.id],t._synchronizeProjectDates(d.$.group,[d])):delete d.$.group;else delete d.$.group;!d.hidden&&t._isTaskExpanded(d)&&(t._timelineVCells.push({top:s,height:e,task:d}),s=parseFloat((s+e).toFixed(2)))}}_getCellsViewType(){const e=this;switch(e.view){case"quarter":case"year":return"month";case"month":return"day"===e.monthScale?"day":"week";case"week":return"day";case"day":return"hour"}}_dateAdd(e,t,i){if(e instanceof Date){var a=new Date(e),n=function(){a.getDate()!==e.getDate()&&a.setDate(0)};switch(String(t).toLowerCase()){case"year":a.setFullYear(a.getFullYear()+i),n();break;case"quarter":a.setMonth(a.getMonth()+3*i),n();break;case"month":a.setMonth(a.getMonth()+i),n();break;case"week":a.setDate(a.getDate()+7*i);break;case"day":a.setDate(a.getDate()+i);break;case"hour":a.setTime(a.getTime()+36e5*i);break;case"minute":a.setTime(a.getTime()+6e4*i);break;case"second":a.setTime(a.getTime()+1e3*i);break;default:a=void 0}return a}}_createTimelineCellsObj(e,t){const i=this,a=i._getCellsViewType();t=t[a],"hour"===a&&"halfHour"===i.dayScale?t*=2:"hour"===a&&"quarterHour"===i.dayScale&&(t*=4);const n=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<n&&(s=n/t),s=parseFloat(s.toFixed(2)),i._timelineCells=[];for(let e=0;e<t;e++){const t={left:r,width:s};if("year"===a||"quarter"===a)o.setMonth(0),t.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===a)o.setDate(1),t.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===a)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),t.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===a)i.nonworkingDays.indexOf(o.getDay())>-1&&(t.nonworking=!0),o.setHours(0,0,0,0),t.date=new Date(o),o.setDate(o.getDate()+1),t.weekend=0===t.date.getDay()||6===t.date.getDay();else if("hour"===a){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(t.nonworking=!0),"hour"!==i.dayScale&&0!==e||o.setHours(o.getHours(),0,0,0),t.date=new Date(o);const a=o.getTime();"hour"===i.dayScale?o.setHours(o.getHours()+1):"halfHour"===i.dayScale?o=i._dateAdd(o,"minute",30):"quarterHour"===i.dayScale&&(o=i._dateAdd(o,"minute",15)),a===o.getTime()&&o.setHours(o.getHours()+2),t.weekend=0===t.date.getDay()||6===t.date.getDay()}i._timelineCells.push(t),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderSubCellsObj(e,t){const i=this,a=i._getCellsViewType();t="month"===i.view&&"day"===i.monthScale?t.day:t[a],"hour"===a&&"halfHour"===i.dayScale?t*=2:"hour"===a&&"quarterHour"===i.dayScale&&(t*=4);const n=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<n&&(s=n/t),s=parseFloat(s.toFixed(2)),i._timelineHeaderSubCells=[];for(let e=0;e<t;e++){const t={left:r,width:s};if("year"===a||"quarter"===a)o.setMonth(0),t.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===a)o.setDate(1),t.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===a)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),t.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===a)i.nonworkingDays.indexOf(o.getDay())>-1&&(t.nonworking=!0),o.setHours(0,0,0,0),t.date=new Date(o),o.setDate(o.getDate()+1),t.weekend=0===t.date.getDay()||6===t.date.getDay();else if("hour"===a){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(t.nonworking=!0),"hour"!==i.dayScale&&0!==e||o.setHours(o.getHours(),0,0,0),t.date=new Date(o);const a=o.getTime();"hour"===i.dayScale?o.setHours(o.getHours()+1):"halfHour"===i.dayScale?o=i._dateAdd(o,"minute",30):"quarterHour"===i.dayScale&&(o=i._dateAdd(o,"minute",15)),a===o.getTime()&&o.setHours(o.getHours()+2),t.weekend=0===t.date.getDay()||6===t.date.getDay()}i._timelineHeaderSubCells.push(t),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderCellsObj(e,t){const i=this;let a=i.view,n=0,s=new Date(e);"quarter"===a&&(a="year"),t=t[a],i._timelineHeaderCells=[];for(let e=0;e<t;e++){const t={};switch(t.date=new Date(s),a){case"quarter":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)}n=i._refreshViewDetailCell(t,n,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 a;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 n=i.exec(t)[0].replace(/[,-.\/]/g,",").split(",");if(3===n.length){const[i,s]=parseInt(n[0])<parseInt(n[2])?[n[0],n[2]]:[n[2],n[0]];if(a=new Date(parseInt(s),parseInt(n[1])-1,parseInt(i)),e.test(t)){const i=e.exec(t)[0].split(":");a.setHours(i[0]||0,i[1]||0,i[2]||0)}t=a}}}else a=new Date(Date.parse(t)),e.test(t)||a.setHours(0,0,0,0),t=a}return i._minMaxDateValidator(new Date(t))}_currentTimeIndicatorIntervalValidator(e,t){return Math.max(1,t)}_getTaskBarPositionLimits(e,t){const i=this;function a(e){const t=i._getTimelineTaskCellByDate(e);if(t)return t.left+i._getTimelineTaskOffset(t,e)||0}return{min:a(e["min"+t]),max:a(e["max"+t])}}_getTimelineTaskOffset(e,t){if(!e)return;let i,a;switch(this.view){case"quarter":case"year":{const n=t.getHours()/24+t.getMinutes()/1440+t.getSeconds()/86400;i=new Date(e.date.getFullYear(),e.date.getMonth()+1,0),a=(t.getDate()-1+n)/i.getDate()*e.width;break}case"month":a=t.getDay()/7*e.width;break;case"week":a=parseFloat(t.getHours()+t.getMinutes()/60+t.getSeconds()/3600)/24*e.width;break;case"day":a=parseFloat(t.getMinutes()+t.getSeconds()/60)/60*e.width}return a}_getTaskBarSizeLimits(e,t){const i=this,a=i._getTaskBarDateRange(e);let n,s=0,r=i._convertDuration(e._cellObj.task.minDuration)||i._getMinDuration(e,t),o=i._convertDuration(e._cellObj.task.maxDuration);function l(n,s){if(!n)return;let r,o;"left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft?(n*=-1,o=a.dateEnd):o=a.dateStart,s&&Math.abs(r)===Math.abs(n)&&(r=0);let l=i._getTaskWorkingDateEnd({dateStart:o},n);const d=l.getTime()+60*(l.getTimezoneOffset()-o.getTimezoneOffset())*1e3,c=i._getTimelineTaskCellByDate(new Date(d));if(!c)return;const m=i._getTimelineTaskOffset(c,new Date(d));return i.rightToLeft?"left"===t?m-(i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth-c.left):i.$.timelineContent.offsetWidth-e.offsetLeft-c.left-m:"left"===t?e.offsetLeft+e.offsetWidth-c.left-m:c.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()-a.dateEnd.getTimezoneOffset())*1e3,n=Math.abs(i.getTime()-a.dateEnd.getTime())+s,o=o?Math.min(n,o):n),t&&(s=60*(t.getTimezoneOffset()-a.dateEnd.getTimezoneOffset())*1e3,n=Math.abs(t.getTime()-a.dateEnd.getTime())+s,r=r?Math.max(n,r):n)}else{const t=e._cellObj.task.maxDateEnd,i=e._cellObj.task.minDateEnd;i&&(s=60*(i.getTimezoneOffset()-a.dateStart.getTimezoneOffset())*1e3,n=Math.abs(i.getTime()-a.dateStart.getTime())+s,r=r?Math.max(n,r):n),t&&(s=60*(t.getTimezoneOffset()-a.dateStart.getTimezoneOffset())*1e3,n=Math.abs(t.getTime()-a.dateStart.getTime())+s,o=o?Math.min(n,o):n)}return o&&(r=Math.min(r,o)),{min:l(r,!0),max:l(o)}}_getMinDuration(e,t){const i=this,a=i._taskBarMinWidth;if(!a||!i._timelineCells||0===i._timelineCells.length)return;const n=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=n.dateEnd,r+=parseFloat(e.style.width)||e.offsetWidth,o=-1):s=n.dateStart;const l=r+o*a;let d;for(let e=0;e<i._timelineCells.length;e++){const t=i._timelineCells[e];if(l<t.left)break;d=t}const c=i._getDateFromCell(l,d);return c?Math.abs(s.getTime()-c.getTime()):void 0}_createDelimiter(e,t){const i=this,a=i._dragDetails,n=a.segment,s=e.slice(0,3),r=document.createElement("div");if(r.classList.add("smart-task-bar-limiter",e),e.indexOf("date")>-1){if(!a[s]||!a[s].left)return;const[e,t]=n?[n.element,n.originalPosition.x]:[a.timelineTask,0],o=i.$.taskTimelineCellsContainer.children[i._getTaskDOMIndex(a.task)];s.indexOf("max")>-1?r.style.width=o.offsetWidth-a[s].left-t-e.offsetWidth+"px":r.style.width=a[s].left+t+"px"}else{if(!a[s].width)return;r.style["left"===t?"right":"left"]=a[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 a=i.closest?i.closest(".smart-task-connection"):void 0;if(a)t._openPopupWindow(a);else if(a=i.closest(".smart-timeline-task")||i.closest(".smart-table tbody tr[row-id]"),a&&t.$.taskSplitter.contains(a))if(a.classList.contains("smart-timeline-task"))t._openPopupWindow(a._cellObj.task);else{const e=t._getVCellById("task",a.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,a=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target,n=a.closest?a.closest(".smart-timeline-row")||a.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(a)?"task":"resource";if((a.closest(".smart-timeline-content")||a.closest(`.smart-${s}-table`))&&requestAnimationFrame((()=>t.$[`${s}Table`].focus({preventScroll:!0}))),t._itemClickDetails={target:a},!t._isMobile&&0!==e.button)return;if(!n){if(a.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((a.closest(".smart-table tbody tr[row-id]")&&!a.classList.contains("smart-arrow")||a.closest(".smart-task-connection"))&&t._checkDoubleClick(i))}if(a.closest(".smart-resource-timeline-view-cell")||t.disabled)return;const r=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===n._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((a.closest(".smart-timeline-task-fill")||r.classList.contains("milestone")&&a.closest(".smart-task-container"))&&t._checkDoubleClick(i))return;const n=a.closest(".smart-timeline-task-progress-thumb"),s=e.pageX-window.pageXOffset,d=e.pageY-window.pageYOffset,c=t._dragDetails={},m=t.rightToLeft;let u,h=a.closest(".smart-task-segment");if(l&&!h){const e=r.querySelectorAll(".smart-task-segment");c.segments=e,h="left"===l&&!m||"right"===l&&m?e[0]:e[e.length-1]}if(c.target=(n||a).className,c.timelineTask=r,c.task=r._cellObj.task,c.taskDimensions={width:r.offsetWidth,height:r.offsetHeight,left:r.offsetLeft,top:r.offsetTop},c.coordinates={x:s,y:d},!e.ctrlKey&&h&&o.segments&&o.segments.length>1&&!t.disableSegmentDrag){const e=h.getBoundingClientRect(),t=h._segmentObj,i=c.task.segments,a=i.indexOf(t);c.segment={element:h,dimensions:{width:e.width,left:h.offsetLeft},offset:{x:s-e.left},originalSize:{width:e.width},isFirstSegment:0===a,isLastSegment:a===i.length-1,min:{},max:{}},u=c.segment.dimensions}const g=c.taskDimensions;t.rightToLeft?(g.right=t.$.timelineContent.offsetWidth-(g.left+g.width),c.originalPosition={x:g.right,y:g.top},c.segment&&(u.right=g.width-(u.left+u.width),c.segment.originalPosition={x:u.right})):(c.originalPosition={x:g.left,y:g.top},c.segment&&(c.segment.originalPosition={x:u.left}));const f=(n||r).getBoundingClientRect();if(c.offset={x:s-f.left,y:d-f.top},c.originalSize={width:g.width,height:g.height},n||!n&&"project"===o.type&&o.synchronized&&!o.dragProject)return void(a.closest(".smart-task-connection-point")&&(c.timelineTask=void 0,c.relatedConnections={}));("visible"===t.resizeHandlesVisibility||t._isMobile&&"auto"===t.resizeHandlesVisibility)&&(a.closest(".smart-timeline-task-fill")?t._checkTaskBarResizability(e):t.$.timeline.removeAttribute("task-bar-hovered")),c.min={},c.max={},t._setDragLimits(a)}}_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 a=i.closest&&i.closest(".smart-table tbody tr[row-id]");return a&&a.data?t._handleTableItemHover(a.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 a=i.target;if(t._upHandler(),!t._dragDetails)return void t._handleItemClick(i);if(t._scrollView.disableSwipeScroll=t._touchmoveInside=!1,t.shadowRoot&&a===t&&(a=i.composedPath()[0]),t.hasAttribute("connecting-task")){const i=t._connectTask(e),a=t._tasks;if(t._setConnectionFeedback(),i){const e=i.taskStart,n=i.taskEnd,[s,r,o]=[a.indexOf(i.taskStart),a.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 n.id||"number"==typeof n.id?n.id:n.$.id,type:o}),t._autoSchedule(i.taskStart)}return t._isMobile&&t._handleTimelineHover(e,!0),void delete t._dragDetails}const n=t._dragDetails.task;if(!n)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===n))),t.hasAttribute("dragged")){t._snapToNearest(s,r),r||t._checkWorkingDays(s,r),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),t._autoSchedule(n),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n)):(t.snapToNearest||t.nonworkingDays.length>0||t.nonworkingHours.length>0)&&t._refreshAssignedResources(n),t.removeAttribute("dragged");const e={id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:new Date(n.dateStart),dateEnd:new Date(n.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(n,["progress"])),t.removeAttribute("progress-change"),t.$.fireEvent("progressChangeEnd",{id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),progress:n.progress||0});else if(t.hasAttribute("resized")){t._snapToNearest(s,r),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n,["workload"])):t.snapToNearest&&t._refreshAssignedResources(n,["workload"]),t.removeAttribute("resized");const e={id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:n.dateStart,dateEnd:n.dateEnd};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("resizeEnd",e),t._autoSchedule(n)}else a.closest(".smart-timeline-task")===s&&(t._select("task",n.$.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 a,n,s;if(i.closest(".smart-timeline-task-fill"))n=i.closest(".smart-timeline-task")._cellObj.task,s="task";else if(a=i.closest(".smart-task-connection"),a)n=a.getAttribute("connection-id").split("-"),n={source:n[0],target:n[1],type:n[2]},s="connection";else if(i.closest(".milestone"))n=i.closest(".milestone")._cellObj.task,s="milestone";else if(a=i.closest(".smart-table tbody tr"),a){const e=t._getVCellById(s,a.getAttribute("row-id"));s=t.$.taskTable.contains(a)?"task":"resource",n=e?e[s]:void 0}if(!n)return;const r={originalEvent:e,type:s,item:t._cloneObject(n)};r.id="connection"===s?`${n.source}-${n.target}-${n.type}`:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.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,a=i._hoveredItem;let n,s;if(t&&([n,s]=i.$.taskSplitter.contains(t)?[i.$.taskTable,"task"]:[i.$.resourceTable,"resource"]),a&&"itemType"===a.type&&a.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(!n)return;i._setTableHoverState(n,e);const o=i.$["task"===s?"taskTimelineCellsContainer":"resourceTimelineCellsContainer"].children;for(let t=0,a=o.length;t<a;t+=1){const a=o[t];if(a._cellObj[s].$.id===e){i._handleTimelineHover({target:a});break}}}_setTableHoverState(e,t){const i=this;e||(e=i.$.taskTable);const a=e===i.$.taskTable?"task":"resource",n=e.querySelectorAll("table tbody tr");if(!i._isMobile&&i[a+"Columns"].length)for(let e=0;e<n.length;e++){let i=n[e];const a=i.data;a&&a.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 a=e._cellObj,n=a.task,s=t._getTaskWorkingDateEnd(n),r=n.segments;let o=new Date(t._timelineCells[t._timelineCells.length-1].date);if("year"===t.view||"quarter"===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&&(n.dateEnd=n.maxDateEnd?new Date(Math.min(s.getTime(),n.maxDateEnd.getTime())):s),n.dateEnd=new Date(Math.min(o.getTime(),n.dateEnd.getTime())),n.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(n.dateStart,n.dateEnd):n.dateEnd.getTime()-n.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(n),n.segments.length!==r.length&&t._recycleSegments(n,e),t._setTaskBarSegments(a,e,!0),t._setTaskBarProgress(n)}t._setTimelineTaskBar(a,void 0,!0),t._refreshTaskConnections(a.task),t._refreshTableColumnsData(n,["dateEnd","duration","overdue"])}_getTaskWorkingDateEnd(e,t){const i=this;if(!e||!e.dateStart)return;let a,n,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)n=new Date(s),n.setHours(0,0,0,0),n.setDate(s.getDate()+1*r),a=Math.min(e,n.getTime()-s.getTime()),s=new Date(s.getTime()+a);else if("day"===i.view&&l.indexOf(s.getHours())>-1){n=new Date(s);const t=n.getTime();n.setHours(s.getHours()+1*r,0,0,0),t===n.getTime()&&n.setHours(s.getHours()+2*r,0,0,0),a=Math.min(e,n.getTime()-s.getTime()),s=new Date(s.getTime()+a)}else t-=e,s=new Date(s.getTime()+r*e)}return s}_createConnectingElement(e,t,i,a,n){const s=this;if(!s._connectionDetails||!s._connectionDetails.start)return;const r=s._connectionDetails,o=r.type,l=s.$.timelineConnectionsContainer;let d=r.connections.shift();d||(d=document.createElement("div"),d.classList.add("smart-task-connection")),d.style.width=d.style.width="","horizontal"===a?(d.style.width=Math.abs(i)+"px",d.style.height=""):(d.style.width="",d.style.height=Math.abs(i)+"px"),d.style[s.rightToLeft?"left":"right"]="",d.style[s.rightToLeft?"right":"left"]=e+"px",d.style.top=t+"px",d.setAttribute("connection-id",r.id);const c=r.start.task.label,m=0===o||3===o?"start":"end",u=r.end.task.label,h=0===o||1===o?"start":"end";if(d.setAttribute("aria-label","Connection between "+c+" ("+m+") and "+u+" ("+h+")"),n){let e=0===o||1===o?"right":"left";s.rightToLeft&&(e="left"===e?"right":"left"),d.setAttribute("arrow-direction",e)}else d.removeAttribute("arrow-direction");d.parentElement||l.appendChild(d)}_getConnectionType(e,t){if(!e||!t)return;let i,a;return"string"==typeof e?i=!e.includes("end"):e instanceof HTMLElement&&(i=!e.classList.contains("end")),"string"==typeof t?a=t.includes("end"):t instanceof HTMLElement&&(a=t.classList.contains("end")),i&&!a?0:i||a?!i&&a?2:i&&a?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 a=i.task,n=i.taskDimensions;if(!a)return;if(!t.hasAttribute("connecting-task")){if(t.$.fireEvent("connectionStart",{startIndex:t._tasks.indexOf(a)}).defaultPrevented)return void delete t._dragDetails.target;t.setAttribute("connecting-task",""),t._isMobile&&(t._scrollView.disableSwipeScroll=t._touchmoveInside=!0)}const s="milestone"===a.type,r=t.rightToLeft;let o=s?-1*n.height/2:0;t._dragDetails.target.includes("end")&&(o=s?-1*o:n.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,d=t._dragDetails.coordinates.y,c=t._dragDetails.offset.x-(r?n.width:0),m=t._dragDetails.offset.y,u=e.pageX-window.pageXOffset+c,h=e.pageY-window.pageYOffset+m-n.height/2;r?(t._connectionFeedback.style.left="",t._connectionFeedback.style.right=n.right+o+"px"):(t._connectionFeedback.style.left=n.left+o+"px",t._connectionFeedback.style.right=""),t._connectionFeedback.style.top=n.top+n.height/2+"px",t._connectionFeedback.style.width=Math.sqrt(Math.pow(Math.abs(u-l),2)+Math.pow(Math.abs(h-d),2))+"px",t._connectionFeedback.style.transform=t.rightToLeft?"rotate("+180*(Math.atan2(d-h,l-u)||0)/Math.PI+"deg)":"rotate("+180*(Math.atan2(h-d,u-l)||0)/Math.PI+"deg)",t._connectionFeedback.parentElement||t.$.timelineContent.appendChild(t._connectionFeedback)}_connectTask(e){const t=this,i=t._tasks;let a,n,s,r,o,l,d,c,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]),a=t._dragDetails.target.includes("smart-task-connection-point")?t._dragDetails.target:void 0,n=o.classList.contains("smart-task-connection-point")?o:void 0,a&&(l=t._dragDetails.task),n)s=n.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;n=s.querySelector(".smart-task-connection-point."+(e>=s.offsetWidth/2?"end":"start"))}if(!l||!s)return;d=s._cellObj.task;for(let e=0,t=i.length;e<t;e+=1){const t=i[e];if(t!==l)if(t!==d){if(void 0!==c&&void 0!==m)break}else m=e;else c=e}}else{if(!e||e.length<3)return;const a=t._getValidConnectionId(e[0],e[1],e[2],"_connectTask");if(void 0===a)return;[c,m]=[parseInt(a[0]),parseInt(a[1])],[l,d]=[i[c],i[m]],r=parseInt(e[2]),o=e[4]||0}if(!l||!d||l===d||l.isGroup||d.isGroup||t._isAutoScheduled(l,d)||t.hasAttribute("dragged")||t.hasAttribute("resized"))return;void 0===r&&(r=t._getConnectionType(a,n));let u=t._connections;return u||(t._connections=u=[]),t._updateConnection([c,m,r,o])?(e.originalEvent&&t._recycleConnections([{startIndex:c,endIndex:m,type:r}]),e.originalEvent&&t.$.fireEvent("itemInsert",{type:"connection",item:{source:c,target:m,type:r}}),{taskStart:l,taskEnd:d,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 a=t.$.timelineTasksContainer.children,n=t.$.timelineConnectionsContainer;let s,r=[];if(a.length){const n=a[0],o=(()=>{let e=[];for(let t=0,n=a.length;t<n;t+=1)e.push(i.indexOf(a[t]._cellObj.task));return e})(),l=n.querySelector(".smart-task-connection-point."+(t.rightToLeft?"end":"start")),d=t._baselineProportion,c=t.showBaseline?t._taskDefaultHeight/d:0;s={top:l.offsetTop,width:l.offsetWidth},s.offset=Math.abs(l.offsetLeft)-s.width;for(let a=0,n=e.length;a<n;a+=1){const n=e[a],l=n.startIndex,d=n.endIndex;if(o.indexOf(l)<0&&o.indexOf(d)<0)continue;const m=i[l],u=i[d],{vCellStart:h,vCellEnd:g}=t._getTasksVCell(m,u);if(!h||!g)continue;const f=n.type,p={start:{width:s.width,top:s.top,index:l,task:m},end:{width:s.width,top:s.top,index:d,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-c),"milestone"===u.type&&(T.width=h.height-c),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-c,_.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(n.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 a,n;for(let s=0,r=i.length;s<r;s+=1){const r=i[s];if(r.task===e&&(a=r),r.task===t&&(n=r),a&&n)break}return{vCellStart:a,vCellEnd:n}}_isAutoScheduled(e,t,i){const a=this,n=a._tasks;let s={};if(a.autoSchedule)return e instanceof HTMLElement&&(e=e._cellObj.task),t instanceof HTMLElement&&(t=t._cellObj.task),function e(t,r){const o=a._getTaskConnections().taskConnections,l=n.indexOf(t);s[l]=!0;for(let t=0;t<o.length;t++){const d=o[t],c=d.endIndex;if(c===r)return i&&a._removeConnection(l+"-"+c+"-"+d.type,!0),!0;if(!s[c]&&e(n[c],r))return!0}}(t,n.indexOf(e))}_setConnectionDetails(e,t){const i=this;if(!i._connectionDetails)return;const a=i._connectionDetails,n=a.start,s=a.end,r=a.type;if(!n||!s)return;let o,l=e.width,d=t.width,c=e.left,m=t.left,u=e.top,h=t.top,g=n.left,f=s.left;const p=n.index,_=s.index;if("milestone"===e.type&&(l=e.height,c-=l/2),"milestone"===t.type&&(d=t.height,m-=d/2),a.id=p+"-"+_+"-"+r,!a.connectionStartOffset||!a.connectionEndOffset){switch(r){case 0:g=Math.abs(g)-n.width,f=Math.abs(f)-s.width;break;case 1:g-=l,f=Math.abs(f)-s.width;break;case 2:g-=l,f-=d;break;default:g=Math.abs(g)-n.width,f-=d}a.start.offset=g+=n.width/2,a.end.offset=f+=s.width/2}if(0===r&&c>m||1===r&&c+l+g>m-f&&h>u||2===r&&m+d>c+l||3===r&&(c-g<m+d+f&&h>u||c-g>m+d+f&&u>h)){o=!0;let i=e;e=t,t=i,i=g,g=f,f=i,i=l,l=d,d=i,i=c,c=m,m=i,i=u,u=h,h=i}let T=c,b=m;!o&&1===r||o&&3===r?T+=l:!o&&3===r||o&&1===r?b+=d:2===r&&(T+=l,b+=d);let k=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+p+"-"+_+'-"]');0===k.length&&(k=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+_+"-"+p+'"]')),a.connections=[].slice.call(k),a.start.x=T,a.start.y=u+n.top,a.end.x=b,a.end.y=h+s.top,a.type=r,a.inverted=o}_createTaskConnection(){const e=this,t=e._connectionDetails;if(!t)return;const i=2*e._taskConnectionWidth,a=t.start.x,n=t.start.y,s=t.start.offset,r=t.start.top,o=t.end.x,l=t.end.y,d=t.end.offset,c=t.type,m=t.inverted,u=!m&&3===c||m&&1===c,h=!m&&1===c||m&&3===c;let g,f,p,_=a,T=o;u?(_=a-d,T=o+d):h&&(_=a+s,T=o-d);const b=_<=T&&u,k=_>=T&&h,y=2===c||h;!function d(u){g!==o&&(u?"horizontal"===u?(p=g-o+(b?-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,d("vertical")):(p=Math.abs(f-l),f+=n<l?0:-1*p,g-=m&&1===c||!m&&3===c&&n>l?i:0,e._createConnectingElement(g,f,p,"vertical"),d()):(g?(p=Math.abs(g-o),g>=o&&(g+=-1*p,p+=i),e._createConnectingElement(g,f+(n<l?Math.abs(f-l):0),p,"horizontal",!t.inverted),g=o):(g=a,f=n,(0===c||!m&&3===c||m&&1===c)&&(g-=s),e._createConnectingElement(g,f,s,"horizontal",t.inverted),y&&(g+=s-i),b||k?(e._createConnectingElement(g,f-=n>l?r:0,r,"vertical"),f+=n<l?r:0):d("vertical")),d("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,a=t.length;i<a;i+=1)if(t[i].id===e)return i;return-1}_refreshTaskConnections(e){const t=this,i=e instanceof HTMLElement?e._cellObj.task:e,a=t._tasks.indexOf(i);if(void 0===a||e.classList&&e.classList.contains("smart-visibility-hidden"))return;let n;if(t._dragDetails&&(n=t._dragDetails.relatedConnections[a]),!n){n=[];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!==a&&i.endIndex!==a||n.push(i)}t._dragDetails&&(t._dragDetails.relatedConnections[a]=n)}t._recycleConnections(n)}_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 a,n;for(let t=0;t<e.length;t++){const s=e[t];if(s.left+s.width>i){a=s;break}n=s}return!a&&n&&(a=i>n.left?n:e[0]),a}_getFirstContentCellInView(e="task"){const t=this;let i,a,n,s;if("task"===e?(i=t._timelineVCells,a=t.scrollTop):(i=t._timelineResourceVCells,a=t.$.resourceVerticalScrollBar.value),!i)return 0;for(let e=0;e<i.length;e++){const t=i[e];if(t.top+t.height>a){n=t;break}s=t}return!n&&s&&(n=a>s.left?s:i[0]),n}_getProjectTasks(e,t){const i=this,a=i.groupByResources&&e.isGroup?"group":"project",n=i._tasks;if(!e||"project"!==e.type)return[];let s=[];for(let r=0,o=n.length;r<o;r+=1){const o=n[r];o.$[a]===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,a=t._getProjectTasks(i);let n,s;if(!a.length)return;let r=a[0],o=a[0];for(let e=0;e<a.length;e++){const t=a[e];a[e].dateEnd&&a[e].dateStart&&(r.dateStart||(r=t[e]),o.dateEnd||(o=t[e]),a[e].dateEnd.getTime()>o.dateEnd.getTime()&&(o=a[e]),a[e].dateStart.getTime()<r.dateStart.getTime()&&(r=a[e]))}const l=t.$.timelineContent.offsetWidth;let d,c,m;if(r&&(d=t._getTimelineSubTaskOffset(r),d&&(c=d.left,m=d.width,n=Math.max(0,t.rightToLeft?l-e.offsetLeft-e.offsetWidth-(l-c-m):e.offsetLeft-c))),o&&(d=t._getTimelineSubTaskOffset(o),d))if(c=d.left,m=d.width,t.rightToLeft){const t=l-e.offsetLeft-e.offsetWidth;s=Math.max(t,t+l-(l-c))}else s=Math.max(e.offsetLeft,e.offsetLeft+l-(c+m));return{min:n,max:s}}_getTimelineSubTaskOffset(e){const t=this,i=t.$.timelineTasksContainer.children[t._tasks.filter((e=>!e.hidden)).indexOf(e)];let a,n,s;if(i)a=i.offsetLeft,s=i.offsetWidth;else{const i=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);i&&(a=i.left+t._getTimelineTaskOffset(i,e.dateStart)||0),r&&(n=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0),s=n-a}return{left:a,width:s}}_getTaskDragLimits(e){const t=this,i=t._dragDetails,a=i.segment?i.segment.element:void 0,n=a&&a.previousElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateStart"),s=a&&a.nextElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateEnd"),r=t._dragDetails.taskDimensions;let o={};return(n.min||s.min)&&(o.min=Math.max(n.min||0,Math.max(0,(s.min||0)-r.width))),s.max&&(o.max=Math.max(0,s.max-r.width)),n.max&&(o.max=o.max?Math.min(n.max,o.max):n.max),o}_getTaskBarDateRange(e){if(!e)return;const t=this,i=e.classList.contains("milestone"),a=parseFloat(e.style.width)||e.offsetWidth,n=i?a/2:a,s=t.rightToLeft?parseFloat(e.style.right)||t.$.timelineContent.offsetWidth-e.offsetLeft-n:parseFloat(e.style.left)||e.offsetLeft,r=e._cellStart,o=e._cellEnd,l=e._cellObj.task,d=l.minDateStart,c=l.maxDateEnd;let m,u;return m=t._getDateFromCell(s,r),!d||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(m=new Date(Math.max(d.getTime(),m.getTime()))),u=i?new Date(m):t._getDateFromCell(s+n,o),!c||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(u=new Date(Math.min(c.getTime(),u.getTime()))),{dateStart:m,dateEnd:u}}_getTaskBarDetails(e,t,i){const a=this,n=e.task;if(!e)return;let s=new Date(n.dateStart);const r=new Date(n.dateEnd);if(!a._dragDetails&&a.snapToNearest){let s,r,o=n.dateStart,l=n.dateEnd;const d=new Date(t.date),c=a._getDateFromCell(t.left+t.width,t),m=new Date(i.date),u=a._getDateFromCell(i.left+i.width,i);return s=c.getTime()-o.getTime()>=c.getTime()-d.getTime()?t.left:t.left+t.width,"milestone"!==n.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,d,c,m,u;switch(a.view){case"quarter":case"year":{d=new Date(s.getFullYear(),s.getMonth()+1,0).getDate(),c=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();const e=s.getHours()/24+s.getMinutes()/1440+s.getSeconds()/86400,a=r.getHours()/24+r.getMinutes()/1440+r.getSeconds()/86400;o=t.left+(s.getDate()-1+e)/d*t.width,l=i.left+(r.getDate()-1+a)/c*i.width-o;break}case"month":"day"===a.monthScale?(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):(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"===n.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 a=e.dateStart,n=e.dateEnd;const{cellStart:s,cellEnd:r}={cellStart:i._getTimelineCellByDate(a),cellEnd:i._getTimelineCellByDate(n)},o=new Date(s.date),l=i._getDateFromCell(s.left+s.width,s),d=new Date(r.date),c=i._getDateFromCell(r.left+r.width,r);if(a=l.getTime()-a.getTime()>=l.getTime()-o.getTime()?o:l,"milestone"!==e.type&&(n=c.getTime()-n.getTime()>=c.getTime()-d.getTime()?d:c),e.dateEnd=n,n.getTime()<a.getTime()&&(a=new Date(n)),e.dateStart=a,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,a=t.length;e<a;e+=1)i._snapToNearestDates(t[e],!0);i._validateTaskSegments(e)}}_getTimelineTaskCellByDate(e){if(!e)return;let t=this,i=t.view,a=t._timelineCells;"month"===i&&"day"===t.monthScale&&(i="day");for(let n=0;n<a.length;n++){const s=a[n];if(t._isDateInCell(s.date,e,i))return s}}_isDateInCell(e,t,i){const a=this;switch(i){case"quarter":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("hour"!==a.dayScale){if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()&&e.getHours()===t.getHours()&&e.getMinutes()===t.getMinutes())return!0}else 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[a,n,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!==a.size?a.style[i._measurements.dimension]:t.treeSize;a.size="",i.removeChild(n),t.inverted&&!t.rightToLeft||!t.inverted&&t.rightToLeft?i.insertBefore(n,a):i.appendChild(n),a.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 a=e._timelineResourceVCells.length*i;e.$.resourceTimelineCellsContainer.style.height=a+"px",e.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",a+"px"),e._recycleResourceContent()}_recycleResourceContent(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e._timelineResourceVCells,i=e.$.resourceTimelineCellsContainer,a=e._getFirstContentCellInView("resource"),n=e.$.tooltip;if(n&&i.contains(n.selector)&&e._closeTooltip(),!a)return void(i.innerHTML="");const s=t.indexOf(a),r=a.height,o=1-(a.top+r-Math.abs(e.$.resourceVerticalScrollBar.value))/r,l=t?t.length:0,d=!e.$.resourceSplitter.offsetHeight,c=e.$.resourceTimelineContent.offsetHeight,m=!d&&c?Math.min(l,Math.ceil((parseFloat((c/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 a=t[s+i],n=f[i];if(!a){n&&n.remove();continue}const r=a.resource,o=r.$.id;p.indexOf(o)>-1?n.setAttribute("selected",""):n.removeAttribute("selected"),n._cellObj=a,n.setAttribute("row-id",o),n.style.top=a.top+"px",e._refreshResourceTimelineContent(r,n)}}_createResourceTimelineVCells(e){const t=this,i=t._resources,a=t.$.resourceTable.rows,n=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=a.length;t<r;t+=1){const r=i[a[t].data.itemIndex];r.hidden||(n.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)),a=e.$.mainSplitter,n=e.$.resourceSplitterItem,s=e.$.taskSplitterItem;if(!i||!i.length||e.hideResourcePanel)return n&&!n.size&&(n._size=n.style[a._measurements.dimension]),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView),s.size="",s.min="",e.$.resourceTable&&e.$.resourceTable.clearSelection(),a.contains(n)&&(a.removeChild(n),e._refresh()),e._highlightAssignedItem("resource"),void t.removeAttribute("show-resource-panel");a.contains(n)||(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 a=Smart.Utilities,n=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,d,c,m,u,h,g,f]=n;e.$.resourceSplitterItem=i,e.$resourceSplitterItem=a.Extend(i),e.$.resourceSplitterItemHeader=s,e.$resourceSplitterItemHeader=a.Extend(s),e.$.resourceSplitter=r,r.hasResizeObserver=!1,r.wait=!1,e.$resourceSplitter=a.Extend(r),e.$.resourceTableItem=o,e.$resourceTableItem=a.Extend(o),e.$.resourceTable=l,l.hasResizeObserver=!1,e.$resourceTable=a.Extend(l),e.$.resourceTimelineSplitterItem=d,e.$resourceTimelineSplitterItem=a.Extend(d),e.$.resourceTimelineViewCells=u,e.$resourceTimelineViewCells=a.Extend(u),e.$.resourceTimeline=c,e.$resourceTimeline=a.Extend(c),e.$.resourceTimelineContent=h,e.$resourceTimelineContent=a.Extend(h),e.$.resourceTimelineHeader=m,e.$resourceTimelineHeader=a.Extend(m),e.$.resourceTimelineCellsContainer=g,e.$resourceTimelineCellsContainer=a.Extend(g),e.$.resourceVerticalScrollBar=f,e.$resourceVerticalScrollBar=a.Extend(f)}}_setupResourcePanel(){const e=this,t=e.rightToLeft,i=e.$.resourceSplitterItem,a=e.$.resourceTableItem,n=e.$.resourceTable,s=e.$.resourceTimelineSplitterItem,r=e.$.resourceVerticalScrollBar;e.$.mainSplitter.contains(i)?([e.$.resourceSplitter,n,e.$.resourceVerticalScrollBar].forEach((e=>e.rightToLeft=t)),n.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,n.$.virtualizationContainer.verticalScrollBarVisibility="hidden",n.$.virtualizationContainer.disabled=!0,a.size=e.treeSize,a.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,a=e.dateEnd,n=t.dateStart,s=t.dateEnd,r=e.dateStart.getTime()<n.getTime()?n:i,o=a.getTime()>s.getTime()?s:a,l=Math.round(this._getWorkingTime(r,o)/36e5);return{value:Math.max(0,l),max:r.getTime()===n.getTime()&&o.getTime()===s.getTime()?l:Math.round(this._getWorkingTime(n,s)/36e5)}}_refreshResourceTimelineContent(e,t){const i=this,a=i._resources.indexOf(e),n=i._getResourceTasks(e);if(t||(t=(()=>{const t=i.$.resourceTimelineCellsContainer.children;for(let i=0,a=t.length;i<a;i+=1){const a=t[i];if(a._cellObj&&a._cellObj.resource===e)return a}})()),a<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 d,c=l.firstElementChild;n.length&&!e.hidden?(c?(c.classList.remove("hide-left-border","hide-right-border"),c.removeAttribute("load"),c.innerHTML=c.style.height=""):(c=document.createElement("div"),c.classList.add("smart-resource-timeline-view-cell"),d=!0),e.class&&c.classList.add(e.class),i._setResourceCellLoad({cell:c,cellIndex:t,resource:e,resourceCell:l,resourceIndex:a,resourceTasks:n,tasks:o,viewCells:r}),c.hasAttribute("load")?d&&l.appendChild(c):c.remove()):c&&c.remove()}}_setResourceCellLoad(e){const t=this,i=t.resourceTimelineFormatFunction,{cell:a,cellIndex:n,resource:s,resourceCell:r,resourceIndex:o,resourceTasks:l,tasks:d,viewCells:c}=e;let m={};for(let e=0,u=l.length;e<u;e+=1){const u=l[e];if(u.hidden)continue;const h=d.indexOf(u),g=t._getCellDateRange(c[n]),{dateStart:f,dateEnd:p}=g;if(!f||f.getTime()>=u.dateEnd.getTime()||p.getTime()<=u.dateStart.getTime())continue;if(m[n]&&m[n].indexOf(h)<0?m[n].push(h):m[a]||(m[n]=[h]),"custom"===t.resourceTimelineMode){i&&(a.innerHTML=i.call(t,m[n]||[],o,new Date(f))||"");continue}const _=t._getResourceCellCapacity({cell:a,cellDateRange:g,cellTaskIndexAssigned:m,index:o,resource:s,task:u,cellIndex:n});if(!_)continue;const{capacity:T,maxCapacity:b}=_,k=parseFloat(((parseFloat(a.getAttribute("load"))||0)+(T||0)).toFixed(1));k>b?a.classList.add("warning"):a.classList.remove("warning"),"histogram"!==t.resourceTimelineMode?k&&a.setAttribute("load",k):t._setCellHistogram({cell:a,load:k,maxCapacity:b,previousViewCell:r.previousElementSibling})}}_getResourceCellCapacity(e){const t=this,i=t.resourceTimelineView,{cell:a,cellDateRange:n,cellTaskIndexAssigned:s,index:r,resource:o,task:l,cellIndex:d}=e;let c,m;if("tasks"===i)c=1,m=o.maxCapacity;else if("hours"===i){const e=t._getResourceCellWorkTime(l,n),i=e.max/24;c=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[d]||[],r,new Date(n.dateStart));if(null!=i)if(i="object"!=typeof i?[i]:Object.values(i),2===i.length)c=parseFloat(i[0])||0,m=parseFloat(i[1])||0;else if(1===i.length)return void(a&&a.setAttribute("load",i[0]))}return{capacity:c,maxCapacity:m}}_setCellHistogram(e){const{load:t,cell:i,maxCapacity:a,previousViewCell:n}=e,s=Math.min(100,100*parseFloat((t/a).toFixed(2))),r=n?n.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+"/"+a)}_recycleResourceHeaderCells(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e.$.resourceTimelineViewCells,i=t.children,a=e.$.timelineViewCells.children;let n=document.createDocumentFragment();for(;i.length>a.length;)i[0].remove();for(let e=0;e<a.length;e++){const t=a[e];let s=i[e];s||(s=t.cloneNode(!0),n.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")}n.childElementCount&&t.appendChild(n),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 a=i[e].resources;Array.isArray(a)||(a=[a].reduce(((e,t)=>e.concat(t)),[]));for(let n=0;n<a.length;n++){let s=a[n];if("object"!=typeof s||!s||void 0===s.id||null===s.id){"number"==typeof s&&(a[n]=s+"");continue}let r=t._resources.find((e=>e.id&&e.id.toString()===s.id.toString()))||{};t._setResource(r,s,i[e]),a[n]=r.id,Object.values(r).length&&!t._resources.includes(r)&&t._resources.push(r)}}t._refreshItemIds("resource");const a=t._resources;for(let e=0,i=a.length;e<i;e+=1)t._refreshResource(a[e])}_refreshAssignedResources(e,t=[]){const i=this;if(!e.$.id||i._tasks.indexOf(e)<0)return;const a=i._getTaskResources(e);for(let e=0;e<a.length;e++){const n=a[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(n),t.includes("workload")?i._refreshResource(n,"workload"):t.includes("progress")&&i._refreshResource(n,"progress"),s.length&&i._refreshTableColumnsData(n,s,"resource")}}_refreshResource(e,t){const i=this;if(!i._resources.length)return;const a=i._getResourceTasks(e),n=864e5;switch(t){case"progress":e.progress=parseFloat((a.reduce(((e,t)=>e+t.progress),0)/a.length).toFixed(2));break;case"workload":e.workload=parseFloat((i._convertDuration(a.reduce(((e,t)=>e+t.duration),0))/n*e.maxCapacity).toFixed(2));break;default:e.progress=parseFloat((a.reduce(((e,t)=>e+t.progress),0)/a.length).toFixed(2)),e.workload=parseFloat((i._convertDuration(a.reduce(((e,t)=>e+t.duration),0))/n*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,a=Array.from(arguments).filter((e=>void 0!==e));let n,s=i._resources;if(1===a.length&&(t=a[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&&(n=[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!==n){Array.isArray(n)||(n=[n]);for(let e=0,a=n.length;e<a;e+=1){const a=i._getValidItemAndIndex(n[e],"task");if(a){const e=a.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 a=this,n=a.$.resourceTimelineCellsContainer,s=document.createElement("div");s.classList.add("smart-timeline-row"),s._resource=t,a._refreshResourceTimelineContent(t,s),a.$.resourceTimelineCellsContainer.insertBefore(s,e>-1?n.children[e]:void 0),a.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",n.offsetHeight+"px"),a._refreshResourceScrollBar(),a._insertNewTreeItem(e,t,i,"resource"),a.$.resourceTree.refresh(),a._highlightAssignedItem("task",a._getSelection("task",a.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 a=[];for(let t=0;t<i.length;t++)i[t].resources.includes(e.id)&&a.push(i[t]);return a}_getTaskResources(e){const t=this;if(!e)return[];const i=[e.resources].reduce(((e,t)=>e.concat(t)),[]);let a=[];for(let e=0;e<i.length;e++){const n=t._resources.find((t=>t.id&&t.id.toString()===i[e].toString()));n&&a.push(n)}return a}_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,a=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:n,width:s}=a.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(n+t._dragDetails.offset.x,Math.min(n+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,a),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,a=i.segment,n=a.element,s=n._segmentObj;if(!s||s.disableDrag)return;const r=i.task,o=t._dragDetails.timelineTask,l=a.isFirstSegment,d=a.isLastSegment,c=t.rightToLeft,m=c?"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||d){const e=t._createDelimiter("min-date"),i=t._createDelimiter("max-date");e&&u.appendChild(e),i&&u.appendChild(i)}}if(l){const a=i.size?i.size.width:i.originalSize.width;t._handleTaskResize(e,c?"right":"left"),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const n=i.size.width-a,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)+n+"px")}}else{if(!d)return void t._handleSegmentDrag(e);{const s=a.dimensions;t._handleTaskResize(e,c?"left":"right"),n.style[m]=i.size.width-s.width+"px"}}t._refreshTask(o,[n]),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,a=i.segment,n=a.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 d=i.timelineRow,{left:c}=d.getBoundingClientRect(),m=i.taskDimensions.left;a.position||(a.position={x:a.originalPosition.x});const u=r.offsetWidth,h=e.pageX-window.pageXOffset;let g=0,f=a.min.left||0,p=a.max.left;o&&(f=u-(f+a.dimensions.width),p=u-p),a.position.x=Math.max(f,Math.min(p,a.position.x+(o?-1:1)*(h-i.coordinates.x))),void 0!==p&&(g=o?m+a.min.left:m+a.max.left,a.position.x=Math.min(p,a.position.x)),f=m+(o?a.max.left-a.dimensions.width:f),i.coordinates.x=Math.max(c+a.offset.x+f,Math.min(c+a.offset.x+g,h)),n.style[l]=a.position.x+"px",t._refreshTaskSegments(r,[n])}_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 a=i.task,n=i.timelineTask;i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===a)));const s=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{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 delete i.timelineTask;t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0;const e=t._createDelimiter("min-date"),n=t._createDelimiter("max-date");e&&s.appendChild(e),n&&s.appendChild(n)}i.position||(i.position={x:i.originalPosition.x,y:i.originalPosition.y});const r=s.getBoundingClientRect().left,o=s.offsetWidth,l=n.offsetWidth,d=i.min.left||0,c=i.max.left,m=e.pageX-window.pageXOffset,u=t.rightToLeft;let h=0;i.position.x=Math.max(d,Math.min(o-l,i.position.x+(u?-1:1)*(m-i.coordinates.x))),void 0!==c&&(i.position.x=Math.min(c,i.position.x),h=o-l-c),i.coordinates.x=u?Math.max(r+i.offset.x+h,Math.min(r+o-(l-i.offset.x+d),m)):Math.max(r+i.offset.x+d,Math.min(r+o-(l-i.offset.x+h),m));const g=a.dateStart.getTime(),f=a.dateEnd.getTime();n.style[u?"right":"left"]=i.position.x+"px",t._refreshTask(n),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),"project"===a.type&&a.dragProject&&t._refreshProjectTasks(a,{startTime:a.dateStart.getTime()-g,endTime:a.dateEnd.getTime()-f}),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(n._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 a=i.timelineTask,n=i.task;if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{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 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(a),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(a._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_updateSegmentsOnTaskResize(){const e=this,t=e._dragDetails,i=t.task,a=t.timelineTask;if(!i||!i.segments)return;let n;t&&t.segments?n=t.segments:t.segments=n=a.querySelectorAll(".smart-task-segment");const s=n.length,r=t.size.width,o=e.rightToLeft?"right":"left";for(let t=0;t<s;t+=1){const i=n[t],a=i.style.width?parseFloat(i.style.width):i.offsetWidth,l=i.style[o]?parseFloat(i.style[o]):0;if(l+a>r){const t=r-(l+a),n=a+t;n<e._taskBarMinWidth&&(i.style[o]=l+t+"px"),i.style.width=n+"px"}else t===s-1&&(i.style.width=r-l+"px")}}_handleTaskSegmentResize(e){const t=this,i=t._dragDetails,a=i.segment,n=a.element,s=n._segmentObj;if(!s||s.disableResize)return;const r=i.task,o=t._dragDetails.timelineTask,l=a.isFirstSegment,d=a.isLastSegment,c=t.rightToLeft,m=c?"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&&!c||"right"===u&&c)){const s=i.size?i.size.width:i.originalSize.width;void 0===a.size&&(a.size={width:a.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")}n.style.width=(a.size.width+=r)+"px"}else{if(!d||!("right"===u&&!c||"left"===u&&c))return t._handleSegmentResize(e,u),void t._refreshTaskSegments(o,[n]);{const s=i.size?i.size.width:i.originalSize.width;void 0===a.size&&(a.size={width:a.originalSize.width}),t._handleTaskResize(e,u),n.style.width=(a.size.width+=i.size.width-s)+"px"}}t._refreshTask(o,[n]),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,a=i._dragDetails,n=a.task,s=a.segment,r=s.element,o=i.rightToLeft,l=a.taskDimensions.left;a.timelineRow||(a.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const d=a.timelineRow;s.position||(s.position={x:s.originalPosition.x}),s.size||(s.size={width:s.originalSize.width});const c=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:_}=d.getBoundingClientRect(),T="object"==typeof e?c-a.coordinates.x:e;if(_+=l,"left"===t&&!o||"right"===t&&o)if(o){const e=a.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)||d.offsetWidth-p-m)-T))+"px",a.coordinates.x=Math.max(_+e-p+u,Math.min(_+e-p,c))}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",a.coordinates.x=Math.max(_+g+u,Math.min(_+p+m-u,c));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,a.coordinates.x=Math.max(_+f,Math.min(_+f+h,c))):(T>0&&(T=Math.min(h-m,T)),m=Math.max(u,Math.min(h,m+T)),a.coordinates.x=Math.max(_+p+u,Math.min(_+p+h,c)));r.style.width=(s.size.width=m)+"px"}_handleTaskResize(e,t){const i=this,a=i._dragDetails,n=a.task;a.position||(a.position={x:a.originalPosition.x,y:a.originalPosition.y}),a.size||(a.size={width:a.originalSize.width}),a.timelineRow||(a.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const s=a.timelineRow,r=a.timelineTask,o=a.segment,l=e.pageX-window.pageXOffset;let d=a.size.width,c=a.min.width||0,m=a.max.width,u=s.getBoundingClientRect().left,h=i.rightToLeft,g="object"==typeof e?l-a.coordinates.x:e;if("left"===t&&!h||"right"===t&&h)if(o&&(h?(u-=o.dimensions.width-o.offset.x,c=Math.max(o.max.left+o.min.width,c)):(u+=o.offset.x,c=Math.max(a.taskDimensions.width-o.max.left+o.min.width,c))),h){g<0?g=-1*Math.min(Math.abs(g),d-(c||0)):void 0!==m&&(g=Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(s.offsetWidth-r.offsetLeft,d+g));const e=r.offsetLeft;r.style.left="",r.style.right=(a.position.x=Math.max(0,(parseFloat(r.style.right)||s.offsetWidth-r.offsetLeft-r.offsetWidth)-g))+"px",a.coordinates.x=Math.max(u+r.offsetLeft+c,Math.min(u+e+d,l))}else g>0?g=Math.min(g,d-(c||0)):void 0!==m&&(g=-1*Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(r.offsetLeft+d,d-g)),r.style.right="",r.style.left=(a.position.x=Math.max(0,(parseFloat(r.style.left)||r.offsetLeft)+g))+"px",a.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+d-c,l));else h?(o&&(u+=o.offset.x,c=Math.max(a.taskDimensions.width-o.min.left+o.min.width,c)),g<0&&void 0!==m&&(g=-1*Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(r.offsetLeft+r.offsetWidth,d-g)),r.style.width=a.size.width+"px",a.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+d-c,l))):(o&&(u-=o.dimensions.width-o.offset.x,c=Math.max(o.min.left+o.min.width,c)),g>0&&void 0!==m&&(g=Math.min(m-d,g)),d=a.size.width=Math.max(c,Math.min(s.offsetWidth-r.offsetLeft,d+g)),a.coordinates.x=Math.max(u+r.offsetLeft+c,Math.min(u+r.offsetLeft+(m||d),l)));r.style.width=a.size.width+"px"}_handleTimelineConnectionHover(e){const t=this;if(!(t.shadowRoot||t).contains(e))return;const i=t.$.timelineConnectionsContainer.children,a=e.closest(".smart-task-connection");if(a||!t.$.timelineConnectionsContainer.querySelector(".smart-task-connection[hover]")){if(a){const e=a.getAttribute("connection-id");for(let t=0;t<i.length;t++){const a=i[t];a.getAttribute("connection-id")===e?a.setAttribute("hover",""):a.removeAttribute("hover")}t._hoveredConnectionTasks=a.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,a=i._isMobile;if(!e||a)return void i._resetItemHover();const n=e.originalEvent||e;let s="task",r=n.pageX&&a?document.elementFromPoint(n.pageX-window.pageXOffset,n.pageY-window.pageYOffset):n.target;if(n.pageX&&i.shadowRoot&&r===i&&(r=n.pageX&&a?i.shadowRoot.elementFromPoint(n.pageX-window.pageXOffset,n.pageY-window.pageYOffset):n.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],d=l.$.id,c=i._hoveredItem;if(!(c&&c.type===s&&c.id===d||(i._resetItemHover(),l.isGroup||("task"===s&&o.classList.contains("smart-timeline-row")&&(o=i.$.timelineTasksContainer.querySelector(`.smart-timeline-task[row-id="${d}"]`)),!o||i._connectionFeedback&&o.contains(i._connectionFeedback)||(o.setAttribute("hover",""),i._hoveredItem={id:d,type:s},a))))){const e=("task"===s?i.$.taskTimelineCellsContainer:i.$.resourceTimelineCellsContainer).querySelector(`.smart-timeline-row[row-id="${d}"]`);e&&(e.setAttribute("hover",""),i._handleTableItemHover(d,r))}}_getScrollLeft(e){return this.rightToLeft?e*=-1:e}_synchronizeSplitters(e,t){if(this.$.mainSplitter.contains(this.$.resourceSplitter)){const i=e._measurements,a=e.items,n=t.items,[s,r,o]=[i.dimension,i.minDimension,i.maxDimension],[l,d]=[n[0],a[0]],[c,m]=[n[1],a[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,""),c.set(t,""),l[t]=d.style[e],c[t]=m.style[e]})),t.removeAttribute("orientation-change"),t.keepProportionsOnResize=!1}}_resizeEventHandler(e){const t=this,i=t.$.taskSplitter;function a(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 a(e.target);e.target===t.$.resourceSplitter&&t._synchronizeSplitters(t.$.resourceSplitter,i)}if(!t._timelineCells)return void t._refresh();t.$.mainSplitter.refresh(),a(i);const n=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=n,t.$.taskTable.scrollTop=t.$.taskTimelineContainer.scrollTop=t.scrollTop,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=n,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.$.timelineViewSubDetails.classList.contains("smart-hidden")||t._recycleHeaderSubCells(t.$.timelineViewSubDetails),t._recycleResourceContent()),i)return;if(t._recycleResourceContent(),t._recycleContentCells(),t._recycleTimelineTasks(),!e)return;const a=Math.round(e.detail.value);e.target!==t.$.resourceVerticalScrollBar?t._refreshTableScrollTop(t.$.taskTable,a):t._refreshTableScrollTop(t.$.resourceTable,a)}_recycleContentCells(){const e=this,t=e._getFirstContentCellInView(),i=e.$.taskTimelineCellsContainer,a=e.$.timelineTasksContainer;if(!t)return void(i.innerHTML=a.innerHTML="");const n=t.height,s=1-(t.top+n-Math.abs(e.scrollTop))/n,r=e._timelineVCells?e._timelineVCells.length:0,o=!e.$.taskSplitter.offsetHeight,l=e.$.taskTimelineContainer.offsetHeight,d=!o&&l?Math.min(r,Math.ceil((parseFloat((l/n).toFixed(2))+s).toFixed(2))):r,c=e.$.timelineViewCells.children,m=document.createDocumentFragment();for(;i.childElementCount>d;)i.lastElementChild.remove();for(;a.childElementCount>d;)a.lastElementChild.remove();for(let t=i.childElementCount;t<d;t+=1){const t=document.createElement("div");t.classList.add("smart-timeline-row"),e._createTimelineRowCells(t,c),m.appendChild(t)}m.childElementCount&&i.appendChild(m);for(let e=a.childElementCount;e<d;e+=1){const e=document.createElement("div");e.classList.add("smart-timeline-task"),m.appendChild(e)}m.childElementCount&&a.appendChild(m)}_getCellIndexByDate(e){const t=this._timelineCells;let i=[];if(e&&e.length&&t){Array.isArray(e)||(e=[e]);for(let t=0,a=e.length;t<a;t+=1){const a=e[t];e[t]=a.getTime?a.getTime():a,i[t]=-1}for(let a=0,n=t.length;a<n;a+=1){const n=t[a],s=e.indexOf(n.date.getTime());if(s>-1&&(i[s]=a,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 a=e.$.timelineViewCells.children,n=a[0]._date,s=a[a.length-1]._date,[r,o]=e._getCellIndexByDate([n,s]);if(!n||!s)return;const l=n.getTime(),d=e._getCellDateRange({_date:s}).dateEnd.getTime(),c=t.children,[m,u]=e.rightToLeft?["right","left"]:["left","right"],h=document.createDocumentFragment();let g=0;for(let t=0,a=i.length;t<a;t+=1){const a=i[t],n=i[t].date,s=n.getTime();if(s<l||s>d)continue;const f=e._getTimelineCellByDate(n,r,o);if(f){const t=f.left+e._getTimelineTaskOffset(f,n),i=a.label,s=a.className;let r=c[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);c.length>g;)c[c.length-1].remove()}_refreshTableScrollTop(e,t){this.$.mainSplitter.contains(e)&&void 0!==t&&(e.scrollTop=t)}_recycleHeaderCells(e){let t=this,i=e.children,a=t.scrollLeft,n=e===t.$.timelineViewCells,s=n?t._timelineCells:t._timelineHeaderCells;if(e===t.$.timelineViewSubDetails&&(n=!1,s=t._timelineHeaderSubCells),!s.length)return;let r=document.createDocumentFragment();for(;i.length;)r.appendChild(e.firstElementChild);let o=t._getFirstCellObjInView(s),l=1-(o.left+o.width-Math.abs(a))/s[0].width,d=r.children.length,c=n?Math.ceil((parseFloat((t.$.timeline.offsetWidth/o.width).toFixed(2))+l).toFixed(2)):t._getHeaderVisibleCellsCount();if(e===t.$.timelineViewSubDetails&&(c=t._getHeaderSubVisibleCellsCount()),d>c)for(;r.children.length&&r.children.length!==c;)r.removeChild(r.firstElementChild);else if(d<c){const e=t._createCells(c-d);for(;e.children.length;)r.appendChild(e.firstElementChild)}const m=[t.rightToLeft?"right":"left"],u=n?t._getCellsViewType():t.view;let h=s.indexOf(o);for(let e=0;e<r.children.length;e++){const i=r.children[e],a=s[h];if(!a)break;let o=new Date(a.date);n||"week"!==t.view||(o.setDate(o.getDate()-o.getDay()),o=new Date(Math.max(a.date.getTime(),o.getTime()))),i.style[m]=a.left+"px",i.style.width=a.width+"px",i._date=o,i.innerHTML=`<div>${t._getDateString(o,u,!n)}</div>`,a.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),a.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),h++}e.appendChild(r),n&&(t._recycleTimelineRowCells(),t._recycleResourceHeaderCells(),t._recycleDateMarkers(),t._setTodayCell())}_recycleHeaderSubCells(e){let t=this,i=e.children,a=t.scrollLeft,n=t._timelineHeaderSubCells;if(!n.length)return;let s=document.createDocumentFragment();for(;i.length;)s.appendChild(e.firstElementChild);let r=t._getFirstCellObjInView(n),o=(r.left,r.width,Math.abs(a),n[0].width,s.children.length),l=t._getHeaderSubVisibleCellsCount();if(o>l)for(;s.children.length&&s.children.length!==l;)s.removeChild(s.firstElementChild);else if(o<l){const e=t._createCells(l-o);for(;e.children.length;)s.appendChild(e.firstElementChild)}const d=[t.rightToLeft?"right":"left"],c=t.view;let m=n.indexOf(r);for(let e=0;e<s.children.length;e++){const i=s.children[e],a=n[m];if(!a)break;let r=new Date(a.date);"week"===t.view&&(r.setDate(r.getDate()-r.getDay()),r=new Date(Math.max(a.date.getTime(),r.getTime()))),i.style[d]=a.left+"px",i.style.width=a.width+"px",i._date=r,i.innerHTML=`<div>${t._getDateString(r,c,!0)}</div>`,a.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),a.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),m++}e.appendChild(s),t._refreshHeaderSubDetailsDate()}_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 a(){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 n=e.scrollWidth,s=e.scrollHeight;let r=i(),o=a();o&&s===o||(r=i()),r&&n===r||(o=a()),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,a=i._getProjectTasks(e);if(!a.length)return;const n=i.nonworkingDays,s=i.nonworkingHours,r=i._timelineVCells;for(let e=0,o=a.length;e<o;e++){const o=a[e];if(o){const e=i._getTaskDOMIndex(o),a=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(n.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)}a&&(i._recycleTaskBars(a,e),i._setTimelineTaskBar(a,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,a,n;if(e instanceof HTMLElement)i=e.offsetLeft,n=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,a=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0,n=a-i)}return[i,n]}if(!e)return;const a=t.groupByResources&&e.isGroup?"group":"project";if(e.synchronized)for(;e&&e.synchronized;){const n=t._getProjectTasks(e);let s=n[0],r=n[0];for(let e=0;e<n.length;e++)s.dateStart.getTime()>=n[e].dateStart.getTime()&&(s=n[e]),r.dateEnd.getTime()<=n[e].dateEnd.getTime()&&(r=n[e]);const o=t.$.timelineTasksContainer.children,l=t.$.timelineContent.offsetWidth;let d,c,m;for(let t=0,i=o.length;t<i;t+=1){const i=o[t],a=i._cellObj?i._cellObj.task:void 0;a&&(a===e?d=i:a===s?c=i:a===e&&(m=i))}if(!d){s&&(e.dateStart=s.dateStart),r&&(e.dateEnd=r.dateEnd),e=e.$[a];continue}s&&(e.dateStart=s.dateStart);let[u,h]=i(c||s);void 0!==u&&void 0!==h&&(t.rightToLeft?(d.style.width=d.offsetWidth-(l-u-h-(l-d.offsetLeft-d.offsetWidth))+"px",d.style.right=c?c.style.right:u+"px"):(d.style.width=d.offsetWidth-(u-d.offsetLeft)+"px",d.style.left=c?c.style.left:u+"px")),r&&(e.dateEnd=r.dateEnd),[u,h]=i(m||r),void 0!==u&&void 0!==h&&(t.rightToLeft?d.style.width=Math.max(0,d.offsetWidth-(l-d.offsetLeft-(l-u)))+"px":d.style.width=Math.max(0,d.offsetWidth-(d.offsetLeft+d.offsetWidth-(u+h)))+"px"),t._refreshTask(d),e=e.$[a]}else t._refreshProject(e.$[a])}_refreshTask(e,t){const i=this,a=i._getTaskBarCellRange(e),n=a.cellStart,s=a.cellEnd;if(!a||!n||!s)return;e._cellStart=n,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 a;e.classList.contains("task")?t&&t.segments?a=t.segments:t.segments=a=e.querySelectorAll(".smart-task-segment"):a=e.querySelectorAll(".smart-task-segment"),i._refreshTaskSegments(e,a)}i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"])}}_refreshTaskSegments(e,t){const i=this,a=e._cellObj.task;if(!a||!a.segments||!a.segments.length)return void i._setTaskBarDeadline(a,t?t[0]:void 0);const n=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 a=0,d=t.length;a<d;a+=1){const d=t[a],c=d._segmentObj,m=i._getSegmentCellRange(d),u=m.cellStart,h=m.cellEnd;if(!m||!u||!h)continue;const g=parseFloat(d.style.width)||d.offsetWidth,f=o+parseFloat(d.style[r])||(s?(parseFloat(e.style.width)||e.offsetWidth)-(d.offsetLeft+d.offsetWidth):d.offsetLeft);d._cellStart=u,d._cellEnd=h,l=d;let p=i._getDateFromCell(f,u),_=i._getDateFromCell(f+g,h);c.dateStart=p,c.dateEnd=_,c.duration=i._convertDuration(n?i._getWorkingTime(p,_):_.getTime()-p.getTime(),!0),e.setAttribute("aria-label",(c.label||"")+" Start date: "+i._toISODate(p)+", End date: "+i._toISODate(_))}i._setTaskBarProgress(a,e),i._setTaskBarDeadline(a,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 a=t[e];i._refreshResource(a),i._refreshTableColumnsData(a,void 0,"resource")}}_refreshTableColumnsData(e,t,i){const a=this;if(i||(i="task"),!e)return;const n=a[`${i}Columns`],s=a.$[`${i}Table`];if(!a.$.mainSplitter.contains(s))return;const r=e.$.id;t=t?t.map((e=>n.find((t=>t.value===e)))):n;for(let i=0;i<t.length;i++){const n=t[i];n&&s.setValue(r,n.value,a._formatColumnData(e,n))}a.$[`${i}Splitter`].refresh()}_removeConnection(e,t){const i=this,a=i.$.connectionPopupWindow,n=i.$.timelineConnectionsContainer;if(e.classList&&e.classList.contains("smart-task-connection")?e=e.getAttribute("connection-id"):e+="",void 0===e)return;const s=n.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++)n.removeChild(s[e]);let d;const c=parseInt(o[0]),m=parseInt(o[1]),u=parseInt(o[2]);if(a&&void 0!==a._target&&"number"==typeof a._target.type){const t=a._target;d=t.startIndex+"-"+t.endIndex+"-"+t.type===e}i._updateConnection([c,m,u],!0),!t&&i.autoSchedule&&(i._autoScheduleRestore(r[l],parseInt(o[2])),i._autoSchedule(r[l])),d&&i.$.fireEvent("itemRemove",{type:"connection",id:`${c}-${m}-${u}`,item:{source:c,target:m,type:u}})}_removeTaskConnections(e,t){const i=this,a=i._connections;if(a&&a.length){for(let t=0,i=a.length;t<i;t+=1)a[t].startTask===e&&(a.splice(t,1),i--);e.connections=[],t&&i._recycleConnections()}}_removeTask(e){const t=this,i=t._tasks;if(!e||!i||!i.length)return;const a=t._getSelection("task",t.selectedTaskIds),n=t.$.taskPopupWindow;let s;if(t._highlightAssignedItem("task",[e]),n&&n._target===e&&n.close(),"project"===e.type){const a=t._getProjectTasks(e);for(let e=0,t=a.length;e<t;e+=1)i.splice(i.indexOf(a[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)),a.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,a=i.indexOf(e);if(e&&!(a<0)){if(t._isUpdating)return i.splice(a,1),t._isUpdating.type.resource=!0,void(t._isUpdating.type.task=!0);if(i.splice(a,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 n();t._refreshResourceTimeline(),t._refreshTableDataSource("resource"),t.$.mainSplitter.contains(t.$.resourceSplitter)?(t._refreshResourceScrollBar(),t._resizeEventHandler(),n()):n()}function n(){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,a=i._tasks;if(!e||!a||!a.length)return;const n=i.$.taskPopupWindow,s=i._getSelection("task",i.selectedTaskIds);n&&n._target===e&&n.close();let r,o=i._getTaskResources(e);for(let n in t){let s=e[n],l=t[n];if("type"===n&&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)a.splice(a.indexOf(t[e]),1);delete e.tasks}if("project"!==e.type||!e.synchronized||!(n.toLowerCase().indexOf("date")>-1||n.toLowerCase().indexOf("duration")>-1))if("dateEnd"===n&&new Date(s).getTime()!==new Date(l).getTime()&&(r=!0),"tasks"!==n)"connections"===n&&(i._removeTaskConnections(e),i._handleTaskConnections(e)),e[n]=l,"resources"===n&&(i._handleResources(e),e.disableResources||(o=o.concat(i._getTaskResources(e)),o=o.filter(((e,t)=>o.indexOf(e)===t)))),"milestone"!==e.type||"dateStart"!==n&&"dateEnd"!==n||(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)a.splice(a.indexOf(t[e]),1);const n=i._createTasks(l,!0);for(let t=0,i=n.length;t<i;t+=1)n[t].$.project=e;i._insertTasks(n,e,a.indexOf(e))}}r&&delete e.duration;const l=e.$,d=e.$.project;if(i._validateTaskProperties(e,d),e.$=l,d&&i._synchronizeProjectDates(d),"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 c;i._selected&&i._selected.task&&i._setSelection("task",c=i._selected.task.map((e=>e.$.id))),i._refreshTableDataSource(),i._refreshTimeline(),i._ensureVisible(e),c&&s.toString()!==c.toString()&&(i.$.taskTable.selected=c.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 a=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(a!==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 a=0;a<t.length;a++){const n=t[a];n._resource===e&&i._refreshResourceTimelineContent(e,n)}}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 a,n;"task"===e?(a="selectedTaskIds",n=i._tasks):(a="selectedResourceIds",n=i._resources);const s=n.findIndex((e=>e.$.id===t)),r=i._getSelection(e,i[a]);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 a,n,s,r,o,l=i._selected;l||(l=i._selected={});const d=t[t.length-1],c=l[e]=[];"task"===e?(o=i._tasks,a="selectedTaskIds",n=i.$.taskTimelineCellsContainer.children,s=i.$.timelineTasksContainer.children):(o=i._resources,a="selectedResourceIds",n=i.$.resourceTimelineCellsContainer.children,s=[]);for(let e=0,i=o.length;e<i;e+=1){const i=o[e];t.indexOf(i.$.id)>-1&&c.push(i)}for(let i=0,a=n.length;i<a;i+=1){const a=n[i],o=s[i],l=a._cellObj[e].$.id;d===l&&(r=s[i]),t.indexOf(l)>-1?(a.setAttribute("selected",""),a.setAttribute("aria-selected","true"),o&&o.setAttribute("selected","")):(a.removeAttribute("selected"),a.setAttribute("aria-selected","false"),o&&o.removeAttribute("selected"))}const m=i[a].slice(0);if(i._setSelection(e,t),!i._tableChangeEventFired){const a=document.scrollingElement||document.documentElement,n=a.scrollLeft,s=a.scrollTop;i._highlightAssignedItem(e,t),i.$[`${e}Table`].focus({preventScroll:!0}),window.scrollTo(n,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[a].slice(0),oldValue:m})}_setSelection(e="task",t){const i=this;let[a,n]="task"===e?[i._tasks,"selectedTaskIds"]:[i._resources,"selectedResourceIds"],s=[];for(let e=0,i=t.length;e<i;e+=1){const i=t[e],n=a.find((e=>e.$.id===i));n&&s.push(void 0!==n.id?n.id:i)}i.set(n,s)}_getSelection(e="task",t){const i="task"===e?this._tasks:this._resources;let a=t.slice(0);if(!t||!t.length)return a;for(let e=0,n=i.length;e<n;e+=1){const n=i[e],s=t.indexOf(n.id);s>-1&&(a[s]=n.$.id)}return a}_highlightAssignedItem(e,t){const i=this,[a,n]="task"===e?["resource","_getTaskResources"]:["task","_getResourceTasks"],s=i.$[`${a}Table`],r=i[`_${a}s`];if(!s||!i.$.mainSplitter.contains(s)||!r.length)return;t&&Array.isArray(t)||(t=[]);let o=[];for(let a=0,s=t.length;a<s;a+=1){const s=i._getValidItemAndIndex(t[a],e);s&&(o=o.concat(i[n](s.item).filter((e=>!e.hidden))))}i._tableChangeEventFired=!0,s.selected=o.map((e=>e.$.id)),o.length&&i._ensureVisible(o[0],a),delete i._tableChangeEventFired}_selectResource(e){const t=this,i=t._resources.indexOf(e);if(i<0)return void t._unselectAll("resource");const a=t.$.resourceTimelineCellsContainer.children[i];a&&a.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 a=e._cellObj.task,n=a.segments;if(t&&t.classList.contains("smart-task-segment")){const a=n.indexOf(t._segmentObj),s=0===a,r=a===n.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(n&&n.length>1){for(let e=0,t=n.length;e<t;e+=1)i._snapToNearestDates(n[e],!0);i._validateTaskSegments(a),a.segments.length!==n.length&&i._recycleSegments(a,e),i._setTaskBarSegments(e._cellObj,e,!0),i._setTaskBarProgress(a)}if("project"!==a.type||!a.dragProject)return;const s=i._getProjectTasks(a);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 a=this,n=a.rightToLeft,s=n?"right":"left",r=parseFloat(e.style[s])||0,o=t,l=a._getSegmentCellRange(t),d=l.cellStart,c=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(a.hasAttribute("dragged")){const t=c.width-(f+h-c.left);let a;if(f-d.left<=t?(a=d.left-r,o.style[s]=Math.max(0,m?0:a)+"px"):(a=g+t,o.style[s]=Math.max(0,m?0:a)+"px"),i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&(e.style[s]=r+(a-g)+"px"),e.style.width=t+(m?-1:1)*(a-g)+"px"}}else if(a.hasAttribute("resized")){const t=d===c?a._taskBarMinWidth:0;let l;if("left"===a.$.timeline.getAttribute("task-bar-hovered")){if(l=f-d.left,l-=l>=d.width/2?d.width-t:0,f-=l,o.style[s]=Math.max(0,m?0:f-r)+"px",l=f+h>c.left+c.width/2?c.left+c.width-(f+h):c.left-(f+h),o.style.width=Math.max(t,h+l)+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&!n&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&n&&(e.style.width=t+l+"px")}}else if(f>d.left+d.width/2?(f=d.left+d.width,o.style[s]=Math.max(0,m?0:f-r)+"px"):(f=d.left,o.style[s]=Math.max(0,m?0:f-r)+"px"),l=f+h-c.left,l=-1*(l-(l>=d.width/2?c.width:t)),o.style.width=h+l+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&n&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&!n&&(e.style.width=t+l+"px")}}}_handleSnapToNearest(e,t){const i=this;if(!e)return;const a=i.rightToLeft?"right":"left",n=e.cellStart,s=e.cellEnd;let r=parseFloat(t.style.width)||t.offsetWidth,o=parseFloat(t.style[a])||0;if(i.hasAttribute("dragged")){const e=s.width-(o+r-s.left);o-n.left<=e?t.style[a]=n.left+"px":t.style[a]=o+e+"px"}else if(i.hasAttribute("resized")){const e=n===s?i._taskBarMinWidth:0;let l;"left"===i.$.timeline.getAttribute("task-bar-hovered")?(l=o-n.left,l-=l>=n.width/2?n.width-e:0,t.style[a]=(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>n.left+n.width/2?t.style[a]=n.left+n.width+"px":t.style[a]=n.left+"px",o=parseFloat(t.style[a])||0,l=o+r-s.left,l=-1*(l-(l>=n.width/2?s.width:e)),t.style.width=r+l+"px")}}_setDragLimits(e){const t=this,i=t._dragDetails;if(!i)return;const a=i.timelineTask;if(!a||!e)return;const n=t.$.timeline.getAttribute("task-bar-hovered"),s=a._cellObj.task;if(n){if(s.disableResize)return void delete t._dragDetails;const e=t._getTaskBarSizeLimits(a,n);i.min.width=e.min,i.max.width=e.max,t._setSegmentLimits(n);const r=t._createDelimiter("min",n),o=t._createDelimiter("max",n);r&&a.appendChild(r),o&&a.appendChild(o)}else if(e.closest(".smart-task-connection-point"))i.timelineTask=void 0;else if(e.closest(".smart-timeline-task")===a){let e;if(t._connections){const i=t._tasks.indexOf(a._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),a.classList.contains("milestone")&&(i.target="smart-timeline-task-fill");const n=t._getTaskDragLimits(a),r=t.rightToLeft?t.$.timelineContent.offsetWidth-a.offsetLeft-a.offsetWidth:a.offsetLeft;if(void 0!==n.min&&(i.min.left=n.min,"project"===a._cellObj.task.type&&n.min>r&&(i.min.left=r)),void 0!==n.max&&(i.max.left=n.max,"project"===a._cellObj.task.type&&n.max<r&&(i.max.left=r)),"project"===s.type&&s.dragProject&&!t.synchronized){const e=t._getSubTaskLimits(a);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 a=i.segment;if(a){const n=a.element,s=a.dimensions,r=n.previousElementSibling,o=n.nextElementSibling;if(a.min.width=e?t._taskBarMinWidth:0,t.rightToLeft){if(r)a.min.left="left"===e?s.left+s.width:r.offsetLeft-(e?0:s.width),"right"===e&&(a.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)a.max.left="right"===e?a.dimensions.left:o.offsetLeft+o.offsetWidth+s.width,e&&"left"!==e||(a.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)a.min.left="right"===e?s.left:r.offsetLeft+r.offsetWidth+(e||o?0:s.width),"left"===e&&(a.max.width=s.left+s.width-a.min.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}if(o)a.max.left="left"===e?s.left+s.width:o.offsetLeft-s.width,e&&"right"!==e||(a.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 a=i.nonworkingHours,n=i.nonworkingDays;function s(e,t){let s,r,o=t.getTime()-e.getTime(),l=new Date(e),d=0;for(;o>0;){const e=Math.min(o,36e5-(60*l.getMinutes()*1e3+1e3*l.getSeconds()+l.getMilliseconds()));if(n.indexOf(l.getDay())>-1)r=new Date(l),r.setHours(0,0,0,0),r.setDate(l.getDate()+1),s=Math.min(e,r.getTime()-l.getTime()),l=new Date(l.getTime()+s),o-=s;else if("day"===i.view&&a.indexOf(l.getHours())>-1){r=new Date(l);const t=r.getTime();r.setHours(l.getHours()+1,0,0,0),t===r.getTime()&&r.setHours(l.getHours()+2,0,0,0),s=Math.min(e,r.getTime()-l.getTime()),l=new Date(l.getTime()+s),o-=s}else d+=e,o-=e,l=new Date(l.getTime()+e)}return d}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(),a=(i%100==0?i%400==0:i%4==0)?366:365;let n=new Date(e),s=0;for(let e=0;e<a;e++)t.nonworkingDays.indexOf(n.getDay())<0&&s++,n.setDate(n.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 a=i.$.timelineTasksContainer.children[t];if(!a)return;const n=a.querySelector(".smart-task-segments").children;let s=e.segments;Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);for(let r=0,o=s.length;r<o;r+=1){const o=s[r],l=n[r],d=l?l.getElementsByClassName("smart-timeline-task-label")[0]:void 0;if(!d)continue;d.firstElementChild||(d.innerHTML="<div></div>");let c=d.firstElementChild;"string"==typeof o.label||"number"==typeof o.label?c.textContent=o.formatFunction?o.formatFunction(o.label||"",t)||"":o.label||"":c.textContent=e.formatFunction?o.formatFunction(e.label||"",t)||"":e.label||"",i.onTaskRender&&i.onTaskRender(e,o,a,l,c),e.onRender&&e.onRender(e,o,a,l,c)}}_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 a=e.progress;const n=t.querySelector(".smart-timeline-task-progress-thumb");if(!n)return;a=Math.min(100,Math.max(0,a))||0;const s=e.dateStart.getTime(),r=e.dateEnd.getTime(),o=t.querySelector(".smart-task-segments").children;let l,d,c=e.segments,m=0;c&&c.length||(c=[e]);for(let e=0,t=c.length;e<t;e+=1){const t=c[e],i=o[e],n=i?i.querySelector(".smart-timeline-task-progress"):void 0;if(!n)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,(a-u)/(h-u)*100));n.style.width=g+"%",n.removeAttribute("value"),i.removeAttribute("show-progress-label"),a>=u?(m=Math.max(u,Math.min(a,h)),l=n,d=i):l||(l=n,d=i)}if(n.style[i.rightToLeft?"left":"right"]="",n.style[i.rightToLeft?"right":"left"]=m+"%",!l||!i.showProgressLabel)return;const u=i.progressLabelFormatFunction;d.setAttribute("show-progress-label",""),l.setAttribute("value",u?u(a)+"":parseFloat(a.toFixed(2))+"%")}_setTaskDeadline(e,t,i){const a=this,n=e.task,{timelineStart:s,timelineEnd:r}=i,o=n.deadline,l=a.$.timelineDeadlines,d=l.children,c=o&&o.getTime&&!isNaN(o.getTime())?o.getTime():void 0;let m;for(let e=0,i=d.length;e<i;e+=1){const i=d[e];if(parseInt(i.getAttribute("task-index"))===t){m=i;break}}if(!c||c<s||c>r)return void(m&&m.remove());const u=a._getTimelineCellByDate(o),[h,g]=a.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",a._formatDate(o)),m.style.top=e.top+"px",m.style[g]="",m.style[h]=u.left+(a._getTimelineTaskOffset(u,o)||0)+"px"}_setTaskBarDeadline(e,t){const i=this,a=e.deadline;if(!a||!a.getTime||isNaN(a)||!t)return;const n=e.deadline.getTime()-e.dateEnd.getTime();if(!e.deadline||n>0)return t.removeAttribute("deadline"),void(e.overdue=!1);e.overdue=!0,t.setAttribute("deadline",`${i.localize("overdue")}: ${Math.round(i._convertDuration(Math.abs(n),!0))} ${i.durationUnit+"s"}`)}_setTaskIndicators(e,t,i){const a=this,n=e.task,{timelineStart:s,timelineEnd:r}=i,[o,l]=a.rightToLeft?["right","left"]:["left","right"],d=a.$.taskIndicatorsContainer,c=d.children,m=n.indicators;let u;for(let e=0,i=c.length;e<i;e+=1){const i=c[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 n=m[t],d=n.date;if(!d||!d.getTime){i&&i.remove();continue}const c=d.getTime();if(c<s||c>r){i&&i.remove();continue}const u=a._getTimelineCellByDate(d),h=n.label,p=n.className,_=n.icon;i||(i=document.createElement("div"),g.appendChild(i)),i.className="smart-gantt-chart-task-indicator",i._indicatorObj=n;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+(a._getTimelineTaskOffset(u,d)||0)+"px"}g.childElementCount&&u.appendChild(g),h.childElementCount&&d.appendChild(h)}_setTimelineTaskBar(e,t,i){const a=this,n=e.task,s=void 0===t?a._getTaskDOMIndex(n):t,r=a.$.timelineTasksContainer.children,o=r[s];let l,d;if(0===r.length||!o||!o.classList||!o.classList.contains("smart-timeline-task"))return;const c=n.dateStart instanceof Date?n.dateStart:new Date(n.dateStart),m=n.dateEnd instanceof Date?n.dateEnd:new Date(n.dateEnd);if(l=!i&&o._cellStart||a._getTimelineCellByDate(c),d=!i&&o._cellEnd||a._getTimelineCellByDate(m),!l||!d)return void o.classList.add("smart-visibility-hidden");o._cellStart=l,o._cellEnd=d,o.classList.remove("smart-visibility-hidden");const u=a._getTaskBarDetails(e,l,d);u&&(o.style[a.rightToLeft?"left":"right"]="",o.style[a.rightToLeft?"right":"left"]=u.left+"px",o.style.width=u.width?u.width+"px":"",o.style.top=u.top+"px"),a._setTaskBarSegments(e,o,i)}_setTimelineTaskBaseline(e,t){const i=this,a=e.task,n=i.$.timelineBaselinesContainer;if(!i.showBaseline)return void(n.innerHTML&&(n.innerHTML=""));const s=a.planned,r=n.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"===a.type||!s.dateStart||!s.dateEnd)return void(o&&o.remove());const l=s.dateStart,d=s.dateEnd,c=i._getTimelineCellByDate(l),m=i._getTimelineCellByDate(d);if(!c||!m)return;o||(o=document.createElement("div"),o.classList.add("smart-gantt-chart-task-baseline"),o.setAttribute("task-index",t),n.appendChild(o));const[u,h]=i.rightToLeft?["right","left"]:["left","right"];(e=JSON.parse(JSON.stringify(e))).dateStart=l,e.dateEnd=d,e.task.dateStart=l,e.task.dateEnd=d;const g=i._getTaskBarDetails(e,c,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",a.label+" Start date: "+i._toISODate(l)+", End date: "+i._toISODate(d))}_setTaskBarSegments(e,t,i){const a=this,n=e.task,s=t.querySelector(".smart-task-segments").children;let r,o,l=n.segments;if(Array.isArray(l)&&l&&l.length&&"task"===n.type||(l=[n]),1===l.length){const e=s[0].style;return void(e.right=e.left=e.width="")}const d=a.rightToLeft,c=parseFloat(t.style[d?"right":"left"]);let m;for(let e=0,t=l.length;e<t;e+=1){const t=l[e],n=s[e];if(!n)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&&n._cellStart||a._getTimelineCellByDate(u),o=!i&&n._cellEnd||a._getTimelineCellByDate(h),n._cellStart=r,n._cellEnd=o;const g=a._getTaskBarDetails({task:t},r,o);g&&(n.style[d?"left":"right"]="",n.style[d?"right":"left"]=Math.max(0,g.left-c)+"px",n.style.width=g.width+"px"),m=n}a._setTaskBarDeadline(n,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=e.currentTime,i=e.view,a=e._getTodayCellObj(t);let n=e.$.timelineIndicatorsContainer;if(!a)return n&&n.remove(),clearInterval(e._currentTimeIndicatorInterval),void delete e._currentTimeIndicatorInterval;n||(e.$.timelineIndicatorsContainer=n=document.createElement("div"),n.classList.add("smart-gantt-chart-time-indicators-container"),n.setAttribute("role","presentation")),new Date(a.date);let s,r,o=t.getMinutes();switch(i){case"quarter":case"year":{const e=new Date(t.getFullYear(),t.getMonth()+1,1,0,0,0,0);e.setDate(0),o+=24*t.getDate()*60,s=24*e.getDate()*60;break}case"month":o+=24*(t.getDay()+1)*60,s=10080;break;case"week":o+=60*t.getHours(),s=1440;break;case"day":s=60}r={cellObj:a,minutes:o,max:s,today:t},e._refreshCurrentTimeShader(r),e._refreshCurrentTimeIndicator(r),n.childElementCount||(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval),n.parentElement||e.$.timelineContent.appendChild(n)}_refreshCurrentTimeIndicator(e){const t=this,i=t.$.timelineIndicatorsContainer;let a=i.querySelector(".smart-gantt-chart-current-time-indicator");if(!t.currentTimeIndicator||!e)return void(a&&a.remove());const{cellObj:n,minutes:s,max:r}=e;a||(a=document.createElement("div"),a.classList.add("smart-gantt-chart-current-time-indicator")),t.rightToLeft?a.style.right=n.left+n.width*(s/r)+"px":a.style.left=n.left+n.width*(s/r)+"px",a.setAttribute("aria-label","Current Time Indicator"),a.parentElement||i.appendChild(a),t._setTodayCell(n.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:a,minutes:n,max:s}=e;i||(i=document.createElement("div"),i.classList.add("smart-gantt-chart-current-time-shader")),i.style.width=a.left+a.width*(n/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=t.currentTime,"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 a=i[t],n=new Date(a._date);n&&(n.getTime()===e?a.setAttribute("current",""):a.removeAttribute("current"))}}_getTodayCellObj(e){const t=this,i=t.view,a=t._timelineCells;e&&e.getTime||(e=t.currentTime);for(let t=0,n=a.length;t<n;t+=1){const n=a[t],s=n.date;switch(i){case"quarter":case"year":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth())return n;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 n;break}case"week":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate())return n;break;case"day":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate()&&s.getHours()===e.getHours())return n}}}_getTaskDOMIndex(e){const t=this.$.timelineTasksContainer.children;if(!e||void 0===e.$.id)return-1;for(let i=0,a=t.length;i<a;i+=1)if(t[i]._cellObj.task===e)return i;return-1}_getTimelineCellByDate(e,t,i){const a=this,n=a._timelineCells;if(!n||0===n.length)return;const s=n.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=n[s];if(!t)continue;const i=t.date;switch(a.view){case"quarter":case"year":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth())return t;break;case"month":if("day"===a.monthScale){if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate())return t}else{const a=new Date(i);let n=new Date(i);if(n.setDate(n.getDate()+(6-n.getDay())+1),n.setMilliseconds(n.getMilliseconds()-1),e.getTime()>=a.getTime()&&e.getTime()<=n.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("hour"!==a.dayScale){if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours()&&i.getMinutes()<=e.getMinutes())return t}else if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours())return t}}const r=n[0],o=n[n.length-1];return e.getTime()<r.date.getTime()?r:e.getTime()>o.date.getTime()?o:void 0}_refreshViewDetailCell(e,t,i){const a=this,n=a._timelineCells,s=e.date;let r=0,o=0===i?0:void 0;for(void 0===t&&(t=0);t<n.length;t++){const e=n[t],i=a._getCellWidth(e,s);if(i){if("month"===a.view&&"day"===a.monthScale&&s.getMonth()!==e.date.getMonth())break;void 0===o&&(o=e.left+e.width-i),r+=i}else if(e.date.getTime()>s.getTime())break}return a._isLastWeekCellNotFull&&(delete a._isLastWeekCellNotFull,t--),e.width=r,e.left=o,t}_getCellWidth(e,t){const i=this,a=e.date,n=(e,t)=>e.getFullYear()===t.getFullYear(),s=(e,t)=>e.getMonth()===t.getMonth(),r=e.width;switch(i.view){case"month":{if("day"===i.monthScale)return r;let e=new Date(a),o=new Date(e),l=0;for(o.setDate(o.getDate()+(6-e.getDay())+1),o.setMilliseconds(o.getMilliseconds()-1);e.getTime()<=o.getTime();)n(e,t)&&s(e,t)&&l++,e.setDate(e.getDate()+1);if(0===l)return;"day"!==i.monthScale&&(i._isLastWeekCellNotFull=l/7!=1);let d=r*l/7;return d<70?70:d}case"quarter":case"year":if(n(a,t))return r;break;case"week":{const e=new Date(t),n=new Date(t);if(-1!==i.firstDayOfWeek){const t=e.getDay()-i.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+i.firstDayOfWeek-(t>=0?0:7)),n.setDate(e.getDate()+6)}else e.setDate(t.getDate()-t.getDay()),n.setDate(t.getDate()+(6-t.getDay()));if(a.getTime()>=e.getTime()&&a.getTime()<=n.getTime())return r;break}case"day":if(n(a,t)&&s(a,t)&&a.getDate()===t.getDate())return r}}_getCellByOffsetLeft(e){const t=this._timelineCells;if(!e)return;let i;for(let a=0;a<t.length&&!(t[a].left>=e);a++)i=t[a];return i}_unselectAll(e,t){const i=this,a=i.$[`${e}TimelineCellsContainer`];let n;delete i._selected;const s=a.querySelectorAll(".smart-timeline-row[selected]");for(let e=0;e<s.length;e++)s[e].removeAttribute("selected");if("task"===e){n="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 n="selectedResourceIds";if(i[`_${e}TreeChangeEventFired`]||i.$[e+"Table"].clearSelection(),i._highlightAssignedItem(e),t)return;const r=i[n].slice(0);r.length&&(i[n]=[],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 a,n,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,d=t._timelineCells;let c=parseFloat(i.style[o?"right":"left"]);c&&!isNaN(c)||(c=i.offsetLeft,o&&(c=t.$.timelineContent.offsetWidth-c));const m=c+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=d.indexOf(s),t=d.indexOf(r);e<=t;e++){const t=d[e],i=t.left,s=t.width,r=parseFloat((i+s).toFixed(2));if(m>=i&&m<=r&&(a=t),!n&&u>i&&u<=r&&(n=t),a&&n)break}return a||(a=n||d[0]),n||(n=d[d.length-1]),{cellStart:a,cellEnd:n}}_getTaskBarCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-timeline-task"))return;let i=parseFloat(e.style.width)||e.offsetWidth;const a=t._timelineCells,n=t.$.timelineContent,s=parseFloat(e.style[t.rightToLeft?"right":"left"])||(t.rightToLeft?(parseFloat(n.style.width)||n.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<a.length;e++){const t=a[e],i=t.left,n=t.width,d=parseFloat((i+n).toFixed(2));if(s>=i&&s<=d&&(r=t),!o&&l>i&&l<=d&&(o=t),r&&o)break}return r||(r=e.classList.contains("milestone")&&o?o:a[0]),o||(o=a[a.length-1]),{cellStart:r,cellEnd:o}}_getDateFromCell(e,t,i){if(!t)return new Date;const a=this,n=new Date(t.date);let s,r=0,o=0,l=new Date(n);switch(l.setHours(0,0,0,0),i||(i=a.view),i){case"quarter":case"year":s=new Date(n.getFullYear(),n.getMonth()+1,0).getDate(),r=1,l.setDate(s);break;case"month":"day"===a.monthScale?(r=n.getDate(),s=1):(r=n.getDate(),s=7,l.setDate(l.getDate()+6));break;case"week":s=1,r=n.getDate();break;case"day":s=1/24,r=n.getDate(),o=n.getHours()}l.setHours(23,59,59,999);const d=parseFloat(((e-t.left)/t.width*s).toFixed(12)),c=Math.min(s,Math.floor(d)),m=d%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(_),b=new Date(n.getFullYear(),n.getMonth(),r+c,o+u,g,p,T);return b.getTime()>l?l:b}_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"quarter":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,a){if(!i)return;let n=[];for(let s=0;s<i.length;s++){const r=i[s];let o;if(!r.$.project&&!a||r.$.project===a){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.$,n.push(o)}}return n}(t)}_cloneObject(e,t){let i={};for(let a in e){let n=e[a];"tasks"!==a&&("connections"!==a?n instanceof Date?i[a]=t?n.toISOString():new Date(n):i[a]=n:i[a]=JSON.parse(JSON.stringify(n)))}return t||delete i.$,i}_setTable(e){const t=this;e||(e=t.$.taskTable);const[i,a]=e===t.$.taskTable?[t.taskColumns,"task"]:[t.resourceColumns,"resource"];if(!t.contains(e))return;if(!i.length)return void(t.$[a+"Table"].dataSource=[]);const n=t._getTableColumns(a);"task"===a&&(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=n,e.dataSource=t._getTableDataSource(a,n),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[`${a}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.selectionMode=t.selectionMode,e.onKeyboardScroll=(i,a)=>{const n=e===t.$.taskTable?t:t._resourceScrollView;a!==n.scrollTop&&(n.scrollTop=a)},e.wait=!1),e.$.virtualizationContainer.scrollTop="task"===a?t.scrollTop:t.$.resourceVerticalScrollBar.value,t._refresh()}_formatResourceGroups(e){const t=this,i=t._resources,a=e.data.data.resources.split(",");let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";a.indexOf(s)>-1&&n.push(t.label||t.value||t.id)}t.resourceGroupFormatFunction?e.template=t.resourceGroupFormatFunction(a):e.template="<strong>"+(n.length?n.join(", "):t.localize("unassigned"))+"</strong>"}_formatResourceGroupLabel(e){const t=this,i=t._resources,a=e.split(",");if(!e)return t.localize("unassigned");let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";a.indexOf(s)>-1&&n.push(t.label||t.value||t.id)}return n.length?n.join(", "):t.localize("unassigned")}_getTableColumns(e="task"){const t=this,i=["dateStart","dateEnd","minDateStart","maxDateStart","minDateEnd","maxDateEnd"],a=["progress","capacity","workload","maxCapacity","minCapacity"];let n="task"===e?t.taskColumns:t.resourceColumns,s=[];"task"===e&&t.groupByResources&&!n.find((e=>"resources"===e.value))&&(n=n.slice(0),n.push({label:"",value:"resources",hidden:!0}));for(let r=0,o=n.length;r<o;r++){const o=n[r],l=o.value,d={};d.label=t.localize(o.label)||o.label,d.dataField=l,l.startsWith("date")||i.indexOf(l)>-1?d.dataType="date":d.dataType="overdue"===l?"boolean":l.startsWith("duration")||a.indexOf(l)>-1?"number":"string",o.hidden&&(d.visible=!1),"function"==typeof o.formatFunction?d.formatFunction=i=>{const a=t._getValidItemAndIndex(i.data.itemId,e).item,n=i.column.toLowerCase();let s=i.value;n.indexOf("date")>-1?s=new Date(s):"resources"===n&&(s=s?s.split(","):[]),i.template=o.formatFunction.call(t,s,a?t._cloneObject(a):void 0)}:["date","number"].indexOf(d.dataType)>-1?d.formatFunction=i=>{const a=t._getValidItemAndIndex(i.data.itemId,e).item,n=t._formatColumnData(t._cloneObject(a),o);i.template=n}:"overdue"===l&&(d.formatFunction=e=>{const t=e.cell;e.value+""=="true"?t.setAttribute("overdue",""):t.removeAttribute("overdue"),e.value=""},d.width=t._taskDefaultHeight),o.size&&(d.width=o.size),s.push(d)}return s}_getTableDataSource(e="task",t){const i=this,a="task"===e?i._getTableData(i._tasks,i.taskColumns,e):i._getTableData(i._resources,i.resourceColumns,e),n=i.groupByResources,s=(()=>{let e=[];e.push("itemId: string"),e.push("projectId: string"),e.push("itemIndex: number"),n&&e.push("resources: string");for(let i=0,a=t.length;i<a;i+=1){const a=t[i];e.push(`${a.dataField}: ${a.dataType}`)}return e})();return i.groupByResources?new window.Smart.DataAdapter({dataFields:s,dataSource:a,groupBy:["resources"],id:"itemId"}):new window.Smart.DataAdapter({dataFields:s,dataSource:a,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,a=t[`${e}Columns`];for(let e=0,n=i.length;e<n;e++)i[e].label=t.localize(a[e].label)||a[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 a=[];if(Array.isArray(t))for(let e=0,n=t.length;e<n;e+=1){const n=t[e].id||t[e];i.indexOf(n)>-1&&a.push(n)}return a.sort()}_getTableData(e,t,i){const a=this,n=a.groupByResources;i||(i="task");const s=t.map((e=>e.value));let r=[],o=[];for(let l=0,d=e.length;l<d;l+=1){const d=e[l];if(d.hidden||n&&d.disableResources)continue;const c={},m=d.$.project,u=a._getTaskResourceIds(d);for(let e=0,n=s.length;e<n;e+=1)c[s[e]]=a._formatColumnData(d,t[e],i);c.expanded=n||d.expanded,c.itemId=d.$.id||d.id||"",c.itemIndex=l,u&&u.length?c.resources=u.toString():delete c.resources,d.$&&m&&(m.$.id?c.projectId=d.$.project.$.id:o.push(((e,t)=>{e.projectId=t.$.id}).bind(null,d,m))),r.push(c)}for(let e=0,t=o.length;e<t;e+=1)o[e]();return r}_formatColumnData(e,t){const i=this,a=t.value;let n=e[a];if(a){const e=(a+"").toLowerCase();if(e.indexOf("date")>-1||t.dateFormat)return i._formatDate(n,t);if(e.indexOf("duration")>-1||t.numberFormat){const e=parseFloat(n.toFixed(1));return t.numberFormat?i._formatNumber(e,t.numberFormat):e}}return null!=n?n.toString():i.localize("unassigned")}_formatDate(e,t){const i=this;if(e=Date.parse(e),!isNaN(e)){let a=t?t.dateFormat:void 0;if("string"==typeof a)return new Smart.Utilities.DateTime(new Date(e)).toString(a);if("object"==typeof a)a=t.dateFormat;else{const e=i.view;a={year:"numeric",month:"2-digit",day:"numeric"},["day","week"].indexOf(e)>-1&&(a.hour="numeric",a.minute="numeric",a.second="numeric")}return new Intl.DateTimeFormat(i.locale,a).format(new Date(e))}}_formatNumber(e,t,i){const a=this;if("object"==typeof t)return new Intl.NumberFormat(a.locale,t).format(""+e);i||(i={percentSymbol:"%",currencySymbol:"$",currencySymbolPosition:"before",decimalSeparator:".",thousandsSeparator:","});const n=e=>"number"==typeof e&&isFinite(e);if(""===t||null===t)return e;let s;n(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(n(e)){const t=e<0;let i=e+"";const a=r.decimalSeparator?r.decimalSeparator:".";let s;if(n(r.decimalPlaces)){var l=r.decimalPlaces,d=Math.pow(10,l);if(i=(e*d).toFixed(0)/d+"",s=i.lastIndexOf("."),l>0)for(s<0?(i+=a,s=i.length-1):"."!==a&&(i=i.replace(".",a));i.length-1-s<l;)i+="0"}else{let t=e+"";s=t.lastIndexOf("."),s>0&&void 0===l&&"."!==a&&(t=t.replace(".",a))}if(r.thousandsSeparator){const e=r.thousandsSeparator;s=i.lastIndexOf(a),s=s>-1?s:i.length;let n=i.substring(s),o=-1;for(var c=s;c>0;c--)o++,o%3==0&&c!==s&&(!t||c>1)&&(n=e+n),n=i.charAt(c-1)+n;i=n}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 a=e.connections;if(a instanceof Array){for(let e=0;e<a.length;e++){const t=a[e],i=t.target="string"==typeof t.target?t.target:parseInt(t.target),n=t.type=parseInt(t.type);null==i||"number"==typeof i&&isNaN(i)||isNaN(n)?(a.splice(a.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 a=[];for(let e=0,n=i.length;e<n;e+=1){const n=i[e];if("object"!=typeof n)continue;const s=t._validateDate(n,"date");s&&s.getTime&&!isNaN(s.getTime())&&a.push(n)}e.indicators=a}_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 a=t.nonworkingDays.length>0||t.nonworkingHours.length>0;let n,s=[],r=[];for(let e=0,a=i.length;e<a;e+=1){const a=i[e];if("object"!=typeof a)continue;let n=parseFloat(a.duration);isNaN(n)&&delete a.duration,t._validateTaskDates(a),a.dateStart&&a.dateEnd&&s.push(a)}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,d=o.dateEnd;o.dateStart=l=new Date(Math.max(e.dateStart.getTime(),l.getTime())),o.dateEnd=d=new Date(Math.min(e.dateEnd.getTime(),d.getTime())),n&&n.dateEnd.getTime()>l.getTime()&&(o.dateStart=l=new Date(n.dateEnd.getTime()+1e3),l.getTime()>=d.getTime())||l.getTime()>d.getTime()||(o.duration=t._convertDuration(a?t._getWorkingTime(l,d):d.getTime()-l.getTime(),!0),n=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,a=t._convertDuration(parseFloat(e.minDuration))||0,n=t._convertDuration(parseFloat(e.maxDuration))||0;a&&n&&(n=Math.max(a,n)),i&&(a?i=Math.max(a,i):n&&(i=Math.min(i,n))),e.duration=t._convertDuration(i,!0),e.minDuration=t._convertDuration(a,!0),e.maxDuration=t._convertDuration(n,!0)}_validateTaskDates(e,t){const i=this,a=i._convertDuration(e.minDuration),n=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)),a&&e.dateStart)if(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)){const t=i._getTaskWorkingDateEnd(e,a);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()+a));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||n){let t;t=i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?i._getTaskWorkingDateEnd(e,Math.max(s,n)):new Date(e.dateStart.getTime()+Math.max(s,n)),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,a=e.planned;if("milestone"===i||!a)return;const n=t._validateDate(a,"dateStart"),s=t._validateDate(a,"dateEnd");n&&s&&(a.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(n,s):s.getTime()-n.getTime(),!0))}_synchronizeProjectDates(e,t){const i=this;if(e){void 0===t&&(t=i._getProjectTasks(e));for(let n=0,s=t.length;n<s;n+=1){const s=t[n];e.synchronized&&(s.dateStart&&(e.dateStart=a(s,"dateStart","min")),s.dateEnd&&(e.dateEnd=a(s,"dateEnd","max")),s.minDateStart&&(e.minDateStart=a(s,"minDateStart","max")),s.maxDateStart&&(e.maxDateStart=a(s,"maxDateStart","min")),s.minDateEnd&&(e.minDateEnd=a(s,"minDateEnd","max")),s.maxDateEnd&&(e.maxDateEnd=a(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 a(t,i,a){const n=e[i];let s=t[i];return void 0===n?new Date(s):s instanceof Date?new Date(Math[a](n.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 a=t.$.resourceSplitterItem;t.$.mainSplitter.contains(a)&&a.contains(e.target)?t._handleVerticalScroll(e,!0):t.$.taskSplitterItem.contains(e.target)&&t._handleVerticalScroll(e)}_handleVerticalScroll(e,t){const i=this;let a,n,s,r;if(t){if(a=i.$.resourceVerticalScrollBar,a.classList.contains("smart-hidden")||a.disabled)return!0;n=a.value,s=a.max,r=i._resourceScrollView}else{if(!i.computedVerticalScrollBarVisibility||i.$.verticalScrollBar.disabled)return!0;n=i.scrollTop,s=i.scrollHeight,r=i}if(0===n&&e.deltaY<0||n===s&&e.deltaY>0)return void e.stopPropagation();const o=i.$[t?"resourceTable":"taskTable"];if(e.stopPropagation(),e.preventDefault(),n+=i._getScrollCoefficient(e,i.offsetHeight),r){const e=o.$.virtualizationContainer;e.scrollHeight!==r.scrollHeight&&(e.scrollHeight=r.scrollHeight),r.scrollTo(n,void 0)}o.scrollTop=n,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`],a=t.$[`${e}SplitterItem`],n="task"===e?"headerTemplate":"resourcePanelHeaderTemplate";let s=t[n];if(a.removeAttribute("show-header"),i.innerHTML="",!s)return;if("function"==typeof s)return s(i,{}),void(i.innerHTML?a.setAttribute("show-header",""):a.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:n}));let r=document.importNode(s.content,!0);if(a.setAttribute("show-header",""),t.shadowRoot)return i.innerHTML="<slot></slot>",void t.appendChild(r);i.appendChild(r)}_handleCollapseExpandMethods(e,t){const i=this,a=i._tasks;if(null==e||!a||!a.length)return;const n=i._getValidItemAndIndex(e);if(!n||!n.item)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"collapse",argumentName:"task"}));let s=n.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,a="task"===t?i._tasks:i._resources;let n;if(null==e||!a||!a.length)return{};if("string"==typeof e||"number"==typeof e){const t=e.toString();let i,s;for(let n=0,r=a.length;n<r;n+=1){const r=a[n];if(!i){const a=r.id;if(null!=a&&a.toString&&a.toString()===t){i=r,e=n;break}}r.$.id===t&&(s=r,e=n)}n=i||s}else"object"==typeof e&&(n=a[i._getItemIndex(e,t)],e=a.indexOf(n));return{item:n,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,a=Math.round(e.detail.value);e.stopPropagation&&e.stopPropagation(),t._refreshing||(i&&i===t.$.resourceVerticalScrollBar?t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=a:(t.$.taskTimelineContainer.scrollTop=a,t.$.taskTable.scrollTop=a),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,a=t[t.length-1].date;switch(e.view){case"quarter":case"year":a.setMonth(a.getMonth()+i);break;case"month":a.setDate(a.getDate()+7*i);break;case"week":a.setDate(a.getDate()+i);break;case"day":a.setHours(a.getHours()+i)}e.set("dateEnd",a),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 a=this,[n,s,r]=i?[0,23,24]:[0,6,7];let o=[];function l(e){let t=Math.max(n,Math.min(s,parseInt(e[0]))),i=Math.max(n,Math.min(s,parseInt(e[1])));if(!isNaN(t)&&!isNaN(i)){for(;t!==i;)o.push(t),t=t===s?n:++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(n,Math.min(s,parseInt(i))))}return o.length===r&&(o.pop(),a.warn(a.localize("invalidNonworkingRange",{elementType:a.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"},currentTime:{value:new Date,type:"any",validator:"_dateValidator"},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"},dayScale:{value:"hour",allowedValues:["hour","halfHour","quarterHour"],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"},firstDayOfWeek:{value:-1,type:"number"},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"},hideTimelineSecondHeaderDetails:{value:!0,type:"boolean"},hideTimelineHeader:{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",quarter:"Quarter",quarterShort:"Q"}},type:"object"},monthFormat:{value:"short",allowedValues:["2-digit","numeric","long","short","narrow"],type:"string"},monthScale:{value:"week",allowedValues:["day","week"],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"},onTaskRender:{value:null,reflectToAttribute:!1,type:"function?"},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"},quarterFormat:{value:"short",allowedValues:["long","short","numeric"],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"},selectionMode:{value:"many",type:"string",allowedValues:["one","many","extended"]},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","quarter","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-details smart-hidden" id="timelineViewSubDetails" 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 a=t[i];if(e.$[a]&&e.$[a].opened){const t=e["$"+a];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.$[a])}}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 a=t[i],n=e["$"+a];e.$[a]&&e.$[a].remove(),n&&(n.unlisten("open"),n.unlisten("close"),n.unlisten("closing"),n.unlisten("click"),n.unlisten("change"),n.unlisten("transitionend"))}e._handleTooltipEvents(),clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval}propertyChangedHandler(e,t,i){const a=this;switch(e){case"adjustToNonworkingTime":for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i),a._refreshTableColumnsData(t,["dateEnd","duration"])}a._refreshTimeline();break;case"animation":break;case"autoSchedule":i?a._autoSchedule():a._autoScheduleRestore();break;case"autoScheduleStrictMode":i&&(a._autoSchedule(),a._refreshTimeline());break;case"columnMinWidth":case"columnResizeFeedback":case"columnResize":{const t=a.$.taskTable,n=a.$.resourceTable;t[e]=i,n&&(n[e]=i);break}case"currentTimeIndicator":case"shadeUntilCurrentTime":a._setCurrentTimeIndicators();break;case"dataSource":if(a.scrollLeft=a.scrollTop=0,a._createTasks(),a._refreshTableDataSource(),a._createTimeline(),a._createResourceTimeline(),a._setAriaControls(),a.snapToNearest){for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i),a._refreshTableColumnsData(t,["dateEnd","duration"])}a._refreshTimeline()}break;case"dateMarkers":a._createDateMarkers();break;case"hideDateMarkers":a._recycleDateMarkers();break;case"selectionMode":{const e=a.$.taskTable,t=a.$.resourceTable;e&&(e.selectionMode=a.selectionMode),t&&(t.selectionMode=a.selectionMode);break}case"disableSelection":{const e=a.$.taskTable,t=a.$.resourceTable;e&&(e.selection=!a.disableSelection),t&&(t.selection=!a.disableSelection);break}case"durationUnit":for(let e=0;e<a._tasks.length;e++){const t=a._tasks[e],i=t.$.project;a._validateTaskDuration(t),a._validateTaskDates(t,i),a._validateTaskSegments(t),a._synchronizeProjectDates(t,i)}a._createTimelineCells(),a._insertTimelineTasks(),a.taskColumns.some((e=>(e.value+"").toLowerCase().indexOf("duration")>-1))&&a._refreshTableDataSource();break;case"filterRow":a.$.taskTable[e]=i;break;case"groupByResources":a._setTable(a.$.taskTable),a._createTimelineContent(),a._recycleTimelineTasks(),a._refresh();break;case"infiniteTimeline":i?a._scrollView.hScrollBar.value===a._scrollView.hScrollBar.max&&a._handleInfiniteTimeline():a.set("dateEnd","");break;case"keyboardNavigation":a.$.taskTable[e]=i,a.$.resourceTable&&(a.$.resourceTable[e]=i);break;case"popupWindowTabs":case"popupWindowCustomizationFunction":{const e=a.$.taskPopupWindow;e&&(e.opened&&(e.close(),delete e._target),e.clear());break}case"taskFiltering":a.$.taskTable.filtering=i,a._refresh();break;case"resourceFiltering":{const e=a.$.resourceTable;e&&(e.filtering=i,a._refresh());break}case"tooltip_enabled":{const e=a.$.tooltip;e&&(i||e.remove(),a._handleTooltipEvents(i));break}case"tooltip_arrow":case"tooltip_delay":case"tooltip_offset":{const t=a.$.tooltip;t&&(t[e.replace("tooltip_","")]=i);break}case"headerTemplate":a._handleHeaderTemplate();break;case"inverted":if(a._handleInverted(),a.scrollLeft){const e=a._getScrollLeft(a.scrollLeft);a.$.timelineHeader.scrollLeft=a.$.taskTimelineContainer.scrollLeft=e,a.$.mainSplitter.contains(a.$.resourceTimelineHeader)&&(a.$.resourceTimelineHeader.scrollLeft=a.$.resourceTimelineContent.scrollLeft=e)}break;case"rightToLeft":Array.from(a.querySelectorAll("smart-splitter, smart-table, smart-scroll-bar")).forEach((t=>t[e]=i)),a.closeWindow(),a._handleInverted(),a._refreshTimeline();break;case"firstDayOfWeek":case"dateStart":case"dateEnd":a._refreshTimeline();break;case"messages":case"locale":case"dayFormat":case"hourFormat":case"timelineHeaderFormatFunction":case"monthFormat":case"yearFormat":a._refreshHeaderDate(!0),a._refreshColumnsHeaders(),a._recycleResourceHeaderCells();break;case"hideResourcePanel":a._createResourceTimeline(),a._refreshTimeline();break;case"nonworkingDays":case"nonworkingHours":a._refreshAfterWorkingTimeChange();break;case"selectedTaskIds":a.$.taskTable.selected=a._getSelection("task",i);break;case"selectedResourceIds":a.$.resourceTable&&(a.$.resourceTable.selected=a._getSelection("resource",i));break;case"resourceColumns":a._setTable(a.$.resourceTable),a._highlightAssignedItem("task",a._getSelection("task",a.selectedTaskIds));break;case"resourcePanelHeaderTemplate":a._handleHeaderTemplate("resource");break;case"resourceTimelineView":case"resourceTimelineMode":case"resourceTimelineFormatFunction":a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._resources.forEach((e=>a._refreshResourceTimelineContent(e)));break;case"showProgressLabel":case"progressLabelFormatFunction":a._tasks.forEach((e=>a._setTaskBarProgress(e)));break;case"sortFunction":a.$.taskTable.sort=i,a.$.resourceTable&&(a.$.resourceTable.sort=i);break;case"showSelectionColumn":a.$.taskTable.hideSelectionColumn=!i,a.$.resourceTable&&(a.$.resourceTable.hideSelectionColumn=!i);break;case"columnMenu":case"hideSelectionColumn":case"sortMode":a.$.taskTable[e]=i,a.$.resourceTable&&(a.$.resourceTable[e]=i);break;case"taskColumns":a._setTable(a.$.taskTable);break;case"timelineMin":a.$.timelineSplitterItem.min=i,a.$.taskSplitter.refresh(),a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._synchronizeSplitters(a.$.taskSplitter,a.$.resourceSplitter);break;case"treeMin":case"treeSize":{const t=e.toLowerCase().indexOf("size")>-1?"size":"min";a.$.tableSplitterItem[t]=i,a.$.taskSplitter.refresh(),a.$.mainSplitter.contains(a.$.resourceSplitter)&&a._synchronizeSplitters(a.$.taskSplitter,a.$.resourceSplitter);break}case"taskPanelMin":case"taskPanelSize":case"resourcePanelSize":case"resourcePanelMin":{const t=e.indexOf("Min")>-1?"min":"size",n=e.indexOf("resource")>-1?"resource":"task";a.$.mainSplitter.contains(a.$.resourceSplitter)&&(a.$[`${n}SplitterItem`][t]=i,a.$.taskSplitterItem._setSize("size",a.taskPanelSize),a.refresh());break}case"unfocusable":a._setFocusable();break;case"monthScale":case"dayScale":case"view":a._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 a=0;a<e.length;a++){const n=e[a];let s=t._getProjectTasks(n);s&&Array.isArray(s)&&(s=i(s.filter((e=>e.$&&e.$.project===n)))),e[a]=t._cloneObject(n),s&&s.length?e[a].tasks=s:delete e[a].tasks}return e},a=t.properties[e].value;return a instanceof Smart.DataAdapter?a:i(a.slice(0))}case"dateStart":case"dateEnd":{const i=t._timelineCells;if(i.length){const a=t._getCellDateRange({_date:i["dateStart"===e?0:i.length-1].date});return new Date(a[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 a=i.taskColumns,n=i.resourceColumns,s=i.$.taskTable,r=i.$.resourceTable;for(let i=0;i<e.length;i++){const o=e[i],l=o.type,[d,c]="resource"===l||n.includes(o)?[r,n]:[s,a],m=c.find((e=>o.value&&e.value===o.value));m&&d.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,a=i._getValidItemAndIndex(e,t);(e=a?a.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 a=i._getValidItemAndIndex(e),n=i._getValidItemAndIndex(t);e=a?a.index:void 0,t=n?n.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 a=1===Object.keys(e._isUpdating.type).length?Object.keys(e._isUpdating.type)[0]:void 0;let n,s;switch(e._selected&&({task:n,resource:s}=e._selected),delete e._isUpdating,a){case"task":t();break;case"resource":i();break;default:t(),i()}n&&(e._refreshSelectedItems("task",n),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,a=Array.from(arguments).filter((e=>void 0!==e));if(!e.isCompleted||0===t.length)return;if(i=1===a.length?(a[0]+"").split("-"):a,!e._getValidConnectionId(i[0],i[1],i[2],"createConnection"))return;const n=parseInt(i[3]);e._connectTask([i[0],i[1],i[2],isNaN(n)?0:n]),e._recycleConnections(),e.$.fireEvent("itemInsert",{type:"connection",item:{source:i[0],target:i[1],type:i[2],lag:n}})}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 a="task"===i.dataExport.itemType?i.$.taskTable:i.$.resourceTable;return a?a.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"),a=window.open("","","width=800,height=500"),n=a.document.open(),s='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+t+"</title></head><body>"+i+"</body></html>";try{n.write(s),n.close(),setTimeout((function(){a.print(),a.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 a=i.startTask,n=i.endTask,s={startTask:t._cloneObject(i.startTask),endTask:t._cloneObject(i.endTask),startTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.id,endTaskId:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.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,a=t.endTask;return{id:t.startIndex+"-"+t.endIndex+"-"+t.type,startTask:e._cloneObject(i),endTask:e._cloneObject(a),startIndex:t.startIndex,startTaskId:"string"==typeof i.id||"number"==typeof i.id?i.id:i.$.id,endTaskId:"string"==typeof a.id||"number"==typeof a.id?a.id:a.$.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,a=23;i<a;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),a=JSON.stringify(e.selectedTaskIds),n=JSON.stringify(e.resources);if(i&&(i=JSON.parse(i)),a&&(a=JSON.parse(a)),n&&(n=JSON.parse(n)),t._noChangeEvent=!0,Array.isArray(i)&&(t._createTasks(i),t.set("dataSource",i)),Array.isArray(n)){let e=n;for(let i=0;i<e.length;i++){const e=n[i];let a=t._resources.find((t=>t.id&&t.id.toString()===e.id.toString()))||{};t._setResource(a,e),Object.values(a).length&&!t._resources.includes(a)&&t._resources.push(a)}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(a)&&(t.$.taskTable.selected=t._getSelection("task",a)),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 a=this;if("object"!=typeof e)return void a.error(a.localize("incorrectArgument",{elementType:a.nodeName.toLowerCase(),methodName:"insertTask",argumentName:"newTask"}));const n=a._tasks;if(n.indexOf(e)>-1)return void a.error(a.localize("alreadyExists",{elementType:a.nodeName.toLowerCase(),methodName:"insertTask"}));const s=a._createTasks([e],!0);if(!n)return;let r,o,l;const d=a._getSelection("task",a.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=n.find((e=>e.id&&e.id.toString()===t)),r||(r=a._getItemByTableId("task",t))):"number"==typeof t&&(r=n[t]),r){if("project"!==r.type)return void a.error(a.localize("notAProject",{elementType:a.nodeName.toLowerCase(),argumentName:"project",methodName:"insertTask"}));s[0].$.project=r}return a._synchronizeProjectVisibility(s[0].$.project,s[0]),a._insertTasks(s,r,i),a._refreshItemIds(),a._refreshConnectionIds(),a._isUpdating?(a._isUpdating.type.task=!0,void(a._isUpdating.type.resource=!0)):(a._selected&&a._selected.task&&a._setSelection("task",l=a._selected.task.map((e=>e.$.id))),a._refreshTableDataSource(),a._refreshTimeline(),l&&d.toString()!==l.toString()&&(a.$.taskTable.selected=l.slice(0)),a._refreshTaskResources(o),a._ensureVisible(o),a.$.fireEvent("itemInsert",{type:"task",item:a._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),a=i?i.task:void 0;return void(a&&t._openPopupWindow(a))}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 a=e.$[t[i]+"PopupWindow"];a&&(a.close(),delete a._target)}}updateTask(e,t){const i=this,a=i._getValidItemAndIndex(e),n=a?a.item:void 0;"object"==typeof n?"object"==typeof t?i._updateTask(n,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,a=t._getValidItemAndIndex(e),n=a?a.item:void 0;i&&i.length&&("object"==typeof n?t._removeTask(n):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,a=e.length;i<a;i+=1){const a=parseInt(e[i]),n=t.indexOf(a);n>-1&&t.splice(n,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,a=t.resourceColumns,n=t.$.taskTable,s=t.$.resourceTable;for(let t=0;t<e.length;t++){const r=e[t],o="desc"===r.sortOrder?"desc":"asc",[l,d]="resource"===r.type||a.includes(r)?[s,a]:[n,i],c=d.find((e=>r.value&&e.value===r.value));c&&l.sortBy(c.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,a=e.length;i<a;i+=1){const a=parseInt(e[i]);t.indexOf(a)<0&&t.push(a)}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`],a=t._getSelection(e,"task"===e?t.selectedTaskIds:t.selectedResourceIds);if(!a.length)return[];let n=[];for(let e=0,s=i.length;e<s;e+=1){const s=i[e];a.indexOf(s.$.id)>-1&&n.push(t._cloneObject(s))}return n}_getTasksAssigned(e){const t=this,i=t._tasks||[];let a=[];for(let n=0;n<i.length;n++){const s=i[n];!s.disableResources&&s.resources.find((t=>t===e.id))&&a.push(t._cloneObject(s))}return a}_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 a="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(a.every((a=>Array.isArray(e[a])?JSON.stringify(e[a])===JSON.stringify(i[t][a]):a.indexOf("date")>-1?new Date(e[a]).getTime()===new Date(i[t][a]).getTime():e[a]===i[t][a])))return i.indexOf(i[t]);return-1}_handleItemSelection(e,t="task",i){const a=this,n=a._getValidItemAndIndex(e,t);if(n.item){const s=n.item,r=a._getSelection(t,"task"===t?a.selectedTaskIds:a.selectedResourceIds);if(e=s.$.id,i){const i=r.indexOf(e);i>-1&&(r.splice(i,1),a.$[`${t}Table`].selected=r)}else r.indexOf(e)<0&&(r.push(e),a.$[`${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],a=i.$.project;e._validateTaskDates(i,a),e._synchronizeProjectDates(i,a),e._refreshTableColumnsData(i,["dateEnd","duration"])}e._refreshTimeline()}_refreshItemIds(e="task"){const t=this[`_${e}s`];if(!t)return;let i={},a=0;for(let e=0,n=t.length;e<n;e+=1){const n=t[e],s=n.$.project;if(void 0!==s){const e=s.$.id;i[e]||(i[e]=0),n.$.id=e+"."+i[e],i[e]++}else n.$.id=a+"",a++}}_refreshConnectionIds(){const e=this._tasks,t=this._connections;if(t&&t.length)for(let i=0,a=t.length;i<a;i+=1){const n=t[i],s=e.indexOf(n.startTask),r=e.indexOf(n.endTask);(s<0||r<0)&&(t.splice(i,1),a--),n.startIndex=s,n.endIndex=r}}_refreshSelectedItems(e="task",t){const i=this,a=i[`_${e}s`];if(a&&(!t&&i._selected&&i._selected[e]&&(t=i._selected[e]),t)){for(let e=0,i=t.length;e<i;e+=1){const n=t[e];(a.indexOf(n)<0||n.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 a(){i.$.taskTable[t](),i._createTimelineContent(),i._recycleTimelineTasks()}function n(){const e=i.$.resourceTable;e&&(e[t](),i._createResourceTimelineVCells(),i._recycleResourceContent())}"resource"===e?n():"task"===e?a():(a(),n())}_setWorkTime(e,t,i){const a=this;if("object"!=typeof e)return;let n,s=e.days,r=e.hours;null!=s&&(Array.isArray(s)||(s=[s]),s=a._nonworkingDayValidator(void 0,s),n=t(s,i?a.nonworkingDays:[0,1,2,3,4,5,6]),a.set("nonworkingDays",7===n.length?[]:n),a._refreshAfterWorkingTimeChange()),null!=r&&(Array.isArray(r)||(r=[r]),r=a._nonworkingTimeValidator(void 0,r),n=t(r,i?a.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]),a.set("nonworkingHours",24===n.length?[]:n),a._refreshAfterWorkingTimeChange())}_getValidConnectionId(e,t,i,a){const n=this,s=n._tasks,r=0===a.indexOf("_");let o;if("string"==typeof e&&(o=n._getTaskIndexById(e),o>=0&&(e=o)),"string"==typeof t&&(o=n._getTaskIndexById(t),o>=0&&(t=o)),e=parseInt(e),t=parseInt(t),i=parseInt(i),isNaN(e)||isNaN(t)||e===t)r||n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"taskIndex"}));else if(e>=s.length||e<0||t>=s.length||t<0)r||n.error(n.localize("outOfBounds",{elementType:n.nodeName.toLowerCase(),methodName:a,argumentName:"taskIndex"}));else{if(!(isNaN(i)||i<0||i>3))return r?[e,t,i]:e+"-"+t+"-"+i;r||n.error(n.localize("incorrectArgument",{elementType:n.nodeName.toLowerCase(),methodName:a,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 a=e[i];"project"===a.type&&a.synchronized||(a.minDateStart=a.minDateEnd=void 0,t._autoScheduleTasks(a))}t._isUpdateRequired&&(t._createTimelineCells(),t._recycleTimelineTasks(!0),delete t._isUpdateRequired)}}_getTaskConnections(e){const t=this._tasks,i=this._connections;let a=[],n=[];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?a.push(t):t.endIndex===s&&n.push(t)}}return{taskConnections:a,connectedTasks:n}}_autoScheduleTasks(e){const t=this,i=t._tasks,a=t._getTaskConnections(e),n=a.taskConnections,s=a.connectedTasks;let r,o,l;for(let a=0;a<n.length;a++)t._isAutoScheduled(e,i[n[a].endIndex],!0);for(let a=0;a<s.length;a++){const n=s[a],d=i[n.startIndex],c=n.type,m=n.lag,u=e.$.project;d&&"project"===d.type&&d.synchronized||(0===c||1===c?(l=new Date((0===c?d.dateStart:d.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===c?d.dateEnd:d.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<n.length;e++){const a=i[n[e].endIndex];!a||"project"===a.type&&a.synchronized||(a.minDateStart=a.minDateEnd=void 0,t._autoScheduleTasks(a))}}_autoScheduleRestore(e,t){const i=this._tasks;e||(e=i),Array.isArray(e)||(e=[e]);for(let a=0;a<e.length;a++){const n=e[a];i.indexOf(e[a])>-1&&(t?0===t||1===t?n.minDateStart=void 0:n.minDateEnd=void 0:n.minDateStart=n.minDateEnd=void 0)}}_autoScroll(e){const t=this,i=t.hasAttribute("dragged"),a=t.hasAttribute("resized");function n(n,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*n,t._dragDetails.coordinates.y+=t.autoScrollStep*n):(t.scrollLeft-=(t.rightToLeft?-1:1)*t.autoScrollStep*n,t._dragDetails.coordinates.x+=t.autoScrollStep*n),i?t._handleTaskBarDrag(e):a&&t._handleTaskBarResize(e)}if(t.disableAutoScroll||!e||!i&&!a&&!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?n(1):t.scrollLeft!==(t.rightToLeft?0:t.scrollWidth)&&e.clientX>=s.left+s.width-20?n(-1):t.scrollTop&&e.clientY<=s.top+20?n(1,!0):t.scrollTop!==t.scrollHeight&&e.clientY>=s.top+s.height-20?n(-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 a=t.$.timeline;if(!i.closest)return void a.removeAttribute("task-bar-hovered");let n,s=i.closest(".smart-timeline-row")||i.closest(".smart-timeline-task");if(t.disabled||t.disableTaskResize||!s||!a.contains(s))return void a.removeAttribute("task-bar-hovered");const r=s._cellObj.task,o=t._getTaskDOMIndex(r);if(s.classList.contains("smart-timeline-row")?n=t.$.timelineTasksContainer.children[o]:s.classList.contains("smart-timeline-task")&&(n=s,s=t.$.taskTimelineCellsContainer.children[o]),!n||n.classList.contains("milestone")||r.synchronized||r.disableResize)return;const l=i.closest(".smart-task-segment"),d=r.segments?r.segments.length:1;if(i.classList&&i.classList.contains("smart-task-connection-point")||l&&(d>1&&t.disableSegmentResize||l._segmentObj&&l._segmentObj.disableResize))return void a.removeAttribute("task-bar-hovered");const c=e.pageX-window.pageXOffset,m="visible"===t.resizeHandlesVisibility||t._isMobile?20:5,u=(l||n).getBoundingClientRect(),h=s.getBoundingClientRect(),g=Math.min(m,c-h.left),f=Math.min(m,h.left+h.width-c);Math.round(u.left)+g>=c&&Math.round(u.left)-g<=c?a.setAttribute("task-bar-hovered","left"):Math.round(u.left+u.width)+f>=c&&Math.round(u.left+u.width)-f<=c?a.setAttribute("task-bar-hovered","right"):a.removeAttribute("task-bar-hovered")}_onShadowDomLoaded(e,t,i){requestAnimationFrame((function a(){const n=(e.shadowRoot||e.getRootNode()).querySelectorAll("link");for(let e=0;e<n.length;e++)if(-1!==n[e].href.indexOf(t))return void i();requestAnimationFrame(a)}))}_getConnectionObjById(e){const t=this._connections;if(!e||!t||!t.length)return;const i=e.split("-"),a=parseInt(i[0]),n=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===a&&i.endIndex===n&&i.type===s)return i}}_positionWindow(){const e=this,t=e.getShadowRootOrBody(),i=[e.$.taskPopupWindow,e.$.connectionPopupWindow,e.$.confirmPopupWindow];for(let a=0;a<i.length;a++){const n=i[a];if(!n||!t.contains(n))continue;const s=e.getBoundingClientRect();n.opened||(n.style.left=n.style.top=""),e._isMobile?(n.setAttribute("mobile",""),n.style.left=s.left+window.pageXOffset+"px",n.style.top=s.top+window.pageYOffset+"px",n.style.width=s.width+"px",n.style.height=s.height+"px"):(n.style.left=Math.max(s.left+window.pageXOffset,s.left+window.pageXOffset+s.width/2-n.offsetWidth/2)+"px",n.style.top=Math.max(s.top+window.pageYOffset,s.top+window.pageYOffset+s.height/2-n.offsetHeight/2)+"px")}}_openPopupWindow(e,t){const i=this;function a(){function t(){i._positionWindow(),s.opened?(s.bringToFront(),s._onOpenCallback?s._onOpenCallback():s._handleActiveState()):s.open()}if(i.popupWindowCustomizationFunction?i.popupWindowCustomizationFunction(s,n,"connection"===n?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",n,e),i._setPopupWindowTemplate("footer",n,e),i._setPopupWindowTemplate("content",n,e),!i._popupWindow[n+"PopupWindow"]){const e=i["$"+n+"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 a=(i.getAttribute("aria-owns")||"")+" "+s.id;i.setAttribute("aria-owns",a.trim()),i._popupWindow[n+"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",a=i._getVCellById(t,e.getAttribute("row-id"));e=a?a[t]:void 0}else e=e._cellObj.task;if(!e||e.isGroup)return;const n=t?"confirm":"string"==typeof e.type?"task":"connection",s=i._createPopupWindow(n);!t&&i.$.fireEvent("opening",{target:s,type:n}).defaultPrevented||(i._closeTooltip(),s._target=e,i._popupWindow||(i._popupWindow={}),s.parentElement||i.getShadowRootOrBody().appendChild(s),s.isCompleted?a():s.whenReady((()=>a())))}_createPopupWindow(e){const t=this,i=e+"PopupWindow";if(t.$[i])return t.$[i];const a=document.createElement("smart-window");return a.classList.add("smart-"+e+"-popup-window"),a.classList.add("smart-gantt-chart-popup-window"),a.setAttribute("smart-id",i),t.$[i]=a,t["$"+i]=Smart.Utilities.Extend(a),a.rightToLeft=t.rightToLeft,a.theme=t.theme,a.animation=t.animation,a.disableSnap=!0,a.headerButtons=["close"],a}_popupWindowOpenHandler(e){const t=this,i=t["$"+e.target.getAttribute("smart-id")];if(i){const a=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:a,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"),a=t["$"+i];if(a){const n=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:n,target:e.target},e.detail)),a.unlisten("close"),a.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,a=i.length;t<a;t+=1){const a=i[t];if(a.getAttribute("value")===e)return a}}_createTaskEditor(e,t,i){const a=this,n=e.value,s=t[e.value];let r,o,l=i.find((e=>e._label===n));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"===n){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",n||""),l._label=n,e.customEditor)return l.appendChild(e.customEditor(n,s)),l;if("number"==typeof s||"string"==typeof s)o=document.createElement("input"),o.classList.add("smart-input");else if(s instanceof Date||"deadline"===n)Smart.DateTimePicker?(o=document.createElement("smart-date-time-picker"),o.locale=a.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;a._setPopupWindowEditors(e,t,l)}_setAriaControls(){this.setAttribute("role","treegrid")}_setPopupWindowEditors(e,t,i){const a=this,n=i.querySelector("label"),s=i.querySelector(".smart-popup-window-editor-toggle"),r=i.lastElementChild,o=e.value+"",l=o.split(/(?=[A-Z])/).join(" "),d=t[o];if(e.customEditor)e.setCustomEditorValue&&e.setCustomEditorValue(i,l,d);else{if(n.innerHTML=a.localize(e.value)||l.charAt(0).toUpperCase()+l.slice(1),s)if("deadline"===o){const e=null==d?"add":"remove";r.classList[e]("smart-hidden"),s.textContent=a.localize(e)}else s.remove();if("number"==typeof d)r.value=parseFloat(d);else if("string"==typeof d)r.value=d;else if(d instanceof Date)r.value=new Date(d);else if(Array.isArray(d)){const e=a._resources;if(r.placeholder=a.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 a=i.querySelector("datalist"),n=document.createDocumentFragment();a.innerHTML="";for(let t=0;t<e.length;t++){const i=e[t],a=document.createElement("option");a.value=i.id,a.innerHTML=i.label,n.appendChild(a)}r.value=t.resources.toString(),a.appendChild(n)}}"project"===t.type&&t.synchronized&&["duration","date"].indexOf(l.toLowerCase())>-1||"resources"===l&&t.disableResources?r.disabled=!0:r.disabled=!!e.disableEdit,r.rightToLeft=a.rightToLeft,r.animation=a.animation,r.theme=a.theme}}_setupPopupWindowTabs(e,t){const i=this,a=i.popupWindowTabs,n="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];a.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=n&&"segments"===i)}return r}_setPopupWindowContent(e,t){const i=this,a=i.$[e+"PopupWindow"],n=[].slice.call(a.querySelectorAll(".smart-gantt-chart-popup-window-editor"));if(a.content&&(!a.content.innerHTML||n.length))if("task"===e&&t){const e=i.taskColumns;let s=[];const r=i._setupPopupWindowTabs(a,t);0!==r.selectedIndex&&(r.selectedIndex=0);const o=r.getTabs()[0];if("general"!==o.getAttribute("value"))return void i._handleTabsContent(o,a);"string"==typeof o.content?o.content="":o.content.innerHTML="";for(let a=0;a<e.length;a++){const r=e[a],l=r.value;if(void 0===t[l]&&"deadline"!==l||"overdue"===l)continue;let d=i._findTaskEditor(l,o);d||(d=i._createTaskEditor(r,t,n),d&&o.appendChild(d)),d&&(i._setPopupWindowEditors(r,t,d),s.push(d))}for(let e=0,t=n.length;e<t;e+=1){const t=n[e];s.indexOf(t)<0&&t.remove()}t.id&&a.setAttribute("aria-controls",t.id)}else if("confirm"===e){if(a.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&&a.setAttribute("aria-controls",i._popupWindow[e[e.length-1]].id)}}else{const e=t.startTask,n=t.endTask;a.innerHTML='<div class="smart-gantt-chart-popup-window-editor">'+i.localize("deleteLink")+"<b> "+e.label+" - "+n.label+"?</b></div>"}}_setPopupWindowTemplate(e,t,i){const a=this,n=a.$[t+"PopupWindow"];if("content"!==e){if(n[e+"Template"]||(n[e+"Template"]=a._createPopupWindowTemplate(e,t)),"header"===e&&i&&"string"==typeof i.type){const e=(n.shadowRoot||n).querySelector(".smart-popup-window-label");e&&(e.innerHTML=i.label)}else if("footer"===e){const e=(n.shadowRoot||n).querySelectorAll(".smart-popup-window-button");for(let i=0;i<e.length;i++){const n=e[i];n.innerHTML="task"===t?'<span class="smart-icon"></span>':"",n.theme=a.theme,n.rightToLeft=a.rightToLeft,n.animation=a.animation,n.disabled=!1,n.classList.contains("ok")?(n.innerHTML+=a.localize("ok"),n.setAttribute("aria-label","ok")):n.classList.contains("cancel")?(n.innerHTML+=a.localize("cancel"),n.setAttribute("aria-label","cancel")):n.classList.contains("delete")&&(n.innerHTML+=a.localize("delete"),n.setAttribute("aria-label","delete"));const s=n.querySelector(".smart-ripple");s&&s.parentElement.removeChild(s)}}}else a._setPopupWindowContent(t,i)}_createPopupWindowTemplate(e,t){const i=this,a=document.createElement("template");if("footer"===e)switch(t){case"task":a.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":a.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||(a.innerHTML='<span class="smart-popup-window-label"></span>');return a}_handleTabsContent(e,t){const i=this,a=t._target;if(!e|!a)return;const n=e.getAttribute("value");if("general"===n)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(n){case"dependency":{const e=i._tasks,t=o.name,n=e.indexOf(a),r=e.findIndex((e=>e.$.id===t));r>-1&&s.updateRow(o.$.id,{id:`${r}-${n}-${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(n,a);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 a=this,n=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 d="";if("segments"===n)if(l<2)d=a.localize("segmentsCountValidation");else{const e=i._target,t=e.dateStart.getTime(),n=e.dateEnd.getTime();let s={};for(let e=0;e<l;e+=1){const i=o[e],r=i.label,l=i.dateStart.getTime(),c=i.dateEnd.getTime();for(let e in s){const t=s[e],n=t.timeStart,r=t.timeEnd,o=l<=n&&c>=n,m=l<=r&&c>=r;(o||m)&&(d+=a.localize("segmentConflictError",{dateConflict:o?"dateStart":"dateEnd",label:i.label,conflictLabel:t.label})+"\r\n")}l>c?d+=a.localize("segmentStartError",{label:i.label})+"\r\n":l===c&&(d+=a.localize("segmentEndError",{label:i.label})+"\r\n"),(l<t||c>n)&&(d+=a.localize("segmentRangeError",{label:i.label})+"\r\n"),void 0===s[e]&&(s[e]={label:r,timeStart:l,timeEnd:c})}}else if("dependency"===n)for(let e=0;e<l;e+=1){const t=o[e].id.split("-");t[0]===t[1]&&(d+=a.localize("dependencyValidation")+"\r\n")}s.textContent=d,r&&(r.disabled=d.length>0)}_getTabsTableData(e,t){const i=this;if("dependency"===e){const e=i._getTaskConnections(t).connectedTasks,a={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 a=[];for(let i=0,n=e.length;i<n;i+=1){const n=e[i];n!==t&&a.push({value:n.$.id,label:n.label})}return a})()};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",a),formatFunction:e=>{const t=a.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",a),formatFunction:e=>{const t=a.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,a,n,s)=>{const r=t.task;s||(s=new Date(r.dateStart)),n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.min=r.dateStart,n.max=r.dateEnd,n.locale=i.locale,n.calendarButton=!0,n.dropDownDisplayMode="auto",n.enableMouseWheelAction=!0,n.formatString="yyyy-MMM-dd HH:mm:ss",n.value=new Date(Math.max(r.dateStart.getTime(),Math.min(r.dateEnd.getTime(),s.getTime()))),n.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,a,n,s)=>{n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.dataSource=t.tasks,n.selectedValues=[s],n.removeAttribute("wait")},getValue:e=>e.selectedValues[0]};case"type":return{template:"<smart-input wait></smart-input>",onInit:(e,a,n,s)=>{const r=t.connectionTypes,o=r.find((e=>e.value===s));n.readonly=!0,n.rightToLeft=i.rightToLeft,n.animation=i.animation,n.theme=i.theme,n.dropDownButtonPosition="right",n.dataSource=r,n.value=(o||r[0]).label+"",n.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,a=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0);if(a._target)if(i.classList.contains("smart-gantt-chart-popup-window-tabs")){const n=a.querySelector(".smart-popup-window-button.ok");n&&(n.disabled=!1),t._handleTabsContent(i.getTabs()[e.detail.index],a)}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 a=i.closest("smart-window")||(i.getRootNode()&&i.getRootNode().host?i.getRootNode().host:void 0),n=a._target;if(i.closest(".smart-popup-window-button.cancel"))return t._popupWindow&&t._popupWindow.confirmPopupWindow&&a!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),a.close(),void delete a._target;if(i.closest(".smart-popup-window-button.ok")){if(a===t.$.connectionPopupWindow&&"number"==typeof n.type)t._removeConnection(n.startIndex+"-"+n.endIndex+"-"+n.type);else if(a===t.$.confirmPopupWindow){const e=n;void 0!==e.$._resourceId?t._removeResource(e):t._removeTask(e),a.close(),t.$.taskPopupWindow&&t.$.taskPopupWindow.close(),delete a._target}else{const e=a.shadowRoot||a,i=e.querySelectorAll(".smart-gantt-chart-popup-window-editor"),s=n;let r={};for(let e=0;e<i.length;e++){const a=i[e]._label,n=t.taskColumns.find((e=>e.value===a));if(n.customEditor&&n.getCustomEditorValue)r[a]=n.getCustomEditorValue(i[e]);else{const t=i[e].lastElementChild;let n;if(!t)continue;if(t.classList.contains("smart-hidden")){r[a]=void 0;continue}n=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,n instanceof Date&&isNaN(n.getTime())&&(n=void 0),null!=n&&(r[a]=n)}}if(void 0!==s.$._resourceId)t._updateResource(s,r);else{const i=r.dateStart?r.dateStart:void 0,a=r.dateEnd?r.dateEnd:void 0;if((i&&i.getTime&&i.getTime()!==s.dateStart.getTime()||a&&a.getTime&&a.getTime()!==s.dateEnd.getTime())&&(r.duration=void 0),t._isPopupWindowTableModified){const i=e.querySelectorAll(".smart-gantt-popup-window-table");for(let e=0,a=i.length;e<a;e+=1){const a=i[e];a.closest('.smart-tab-item[value="dependency"]')?t._updateTaskDependencies(a,s):a.closest('.smart-tab-item[value="segments"]')&&t._updateTaskSegments(a,s)}}t._updateTask(s,r)}}return t._popupWindow&&t._popupWindow.confirmPopupWindow&&a!==t._popupWindow.confirmPopupWindow&&t._popupWindow.confirmPopupWindow.close(),a.close(),void delete a._target}if(i.closest(".smart-popup-window-button.delete"))return void t._openPopupWindow(a._target,!0);if(i.closest(".smart-popup-window-editor-toggle")){const e=i.closest('.smart-gantt-chart-popup-window-editor[value="deadline"]'),a=e?e.lastElementChild:void 0;if(a){const e=a.classList.contains("smart-hidden")?"remove":"add";a.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"),d=n;switch(o){case"add":{let e;e="segments"===l?{label:`${t.localize("segment")} ${r.dataSource.length+1}`,dateStart:new Date(d.dateStart),dateEnd:new Date(d.dateEnd),duration:parseFloat((d.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,a)}}_updateTaskDependencies(e,t){const i=this,a=i._tasks.indexOf(t),n=i._getTaskConnections(t).connectedTasks,s=e.rows;for(let e=0,t=n.length;e<t;e+=1){const t=n[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,n=t.name,r=t.type;if(!i._getValidConnectionId(n,a,r,"_"))continue;const o=parseInt(t.lag);i._connectTask([n,a,r,isNaN(o)?0:o])}i._recycleConnections()}_updateTaskSegments(e,t){const i=e.rows;let a=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e].data,n=t.label,s=new Date(t.dateStart),r=new Date(t.dateEnd);isNaN(s)||isNaN(r)||a.push({label:"string"==typeof n?n:"",dateStart:s,dateEnd:r})}t.segments=a,this._validateTaskSegments(t)}_createTasks(e,t){const i=this,a={},n=[];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 d=0;d<r.length;d++){let c,m=r[d];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+"."+d:d+"","string"!=typeof h&&"number"!=typeof h||(a[h]?n.push(h):a[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",c=e(u,m),c.length&&(m.hidden=!c.some((e=>!e.hidden)),m.hidden?c.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&&c&&c.length>0?(l.push(m),l=l.concat(c)):(o||((t&&"project"===m.type&&m.synchronized||m.dateStart&&m.dateEnd&&!isNaN(m.dateStart.getTime())&&!isNaN(m.dateEnd.getTime()))&&s.push(m),c&&(s=s.concat(c))),l.push(m))}return o&&i._synchronizeProjectDates(o,l),l}(e),t)return s.slice(0);n.length&&console.warn(i.localize("duplicateIds",{elementType:i.nodeName.toLowerCase(),duplicates:n.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,a=t.length;i<a;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 a=t.$tooltip;e?(a=t.$tooltip=Smart.Utilities.Extend(i),a.listen("close",t._tooltipVisibilityHandler.bind(t)),a.listen("closing",t._tooltipVisibilityHandler.bind(t)),a.listen("open",t._tooltipVisibilityHandler.bind(t)),a.listen("opening",t._tooltipVisibilityHandler.bind(t))):a&&(a.unlisten("close"),a.unlisten("closing"),a.unlisten("open"),a.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(),a={"smart-task-segment":null,"smart-timeline-task":null,"smart-gantt-chart-task-indicator":null,"smart-resource-timeline-view-cell":null,"smart-task-connection":null},n=(i.host?i.host.shadowRoot:i).elementsFromPoint(e.clientX,e.clientY);let s;for(let e=0,t=n.length;e<t;e+=1){const t=n[e],i=t.classList;if(i.contains("smart-task-container"))a["smart-timeline-task"]=t.closest(".smart-timeline-task");else for(let e in a)i.contains(e)&&(a[e]=t)}if(a["smart-task-segment"]){const e=a["smart-timeline-task"],t=e?e._cellObj.task:void 0;s=t&&t.segments&&t.segments.length?a["smart-task-segment"]:e}else if(a["smart-gantt-chart-task-indicator"])s=a["smart-gantt-chart-task-indicator"];else for(let e in a)if(a[e]){s=a[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,a=t.length;i<a;i+=1){const a=t[i];if(Array.isArray(a.segments)&&a.segments.indexOf(e)>-1)return a}}_getTooltipContent(e){const t=this;if(!e)return;const i=e.classList;let a,n;if(i.contains("smart-task-segment")){if(n=e._segmentObj,n){let e=n.label;if(void 0===e){const i=t._getSegmentTask(n);i&&(e=i.label)}a=`<label><b>${t.localize("segment")}</b>: ${e||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(n.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(n.dateEnd)||""}</label>`}}else if(i.contains("smart-timeline-task"))n=e._cellObj.task,n&&!n.segments&&(a=`<label><b>${t.localize("task")}</b>: ${n.label||""}</label>\n <label><b>${t.localize("dateStart")}</b>: ${t._formatDate(n.dateStart)||""}</label>\n <label><b>${t.localize("dateEnd")}</b>: ${t._formatDate(n.dateEnd)||""}</label>`);else if(i.contains("smart-gantt-chart-task-indicator"))n=e._indicatorObj,n&&(a=n.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&&(n=e._cellObj.resource),n){const s=t._getResourceTasks(n),r="hours"===t.resourceTimelineView?"h":"",o=t._tasks,l=t.$.resourceTimelineViewCells.children,d=Array.from(e.children).findIndex((e=>e===i));a=`<label><b>${t.localize("resource")}</b>: ${n.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],c=o.indexOf(i),m=t._getResourceCellCapacity({cellDateRange:t._getCellDateRange(l[d]),cellTaskIndexAssigned:[c],index:d,resource:n,task:i,cellIndex:d});void 0!==m&&(a+=`<label>${t.localize("task")} #${c}: (${parseFloat(m.capacity.toFixed(1))}${r}) ${i.label||""}</label>`)}}}else i.contains("smart-task-connection")&&(n=t.getConnectionDetails(e.getAttribute("connection-id")),void 0!==n&&(a=`<label><b>${t.localize("startTask")}</b>: ${n.startTask.label||""}</label>\n <label><b>${t.localize("endTask")}</b>: ${n.endTask.label||""}</label>\n <label><b>${t.localize("type")}</b>: ${t._getConnectionTypeName(n.type)||""}</label>`,n.lag&&(a+=`<label><b>${t.localize("lag")}</b>: ${parseFloat(n.lag.toFixed(1))}</label>`)));return n?n.tooltip?n.tooltip+"":a||"":void 0}_openTooltip(e,t,i){const a=this,n=a.tooltip;if(i="string"==typeof i?i:a._getTooltipContent(e),!(n.enabled&&i&&e&&e.nodeName))return void a._closeTooltip();const s=a.$.tooltip||a._createTooltip();let r,o;if(i&&s.value!==i&&(s.value=i),s.selector=e,t&&t.pageX){const i=document.body.getBoundingClientRect(),a=e.getBoundingClientRect(),l=n,d=l.offset[0]||0,c=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-d),r=a.top-u-c,r<i.top&&(r=a.bottom+c,h="top"),o<i.left&&(o=i.left+d,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=n.offset);s.visible||(a.getShadowRootOrBody().appendChild(s),s.open())}_closeTooltip(){const e=this.$.tooltip;e&&e.visible&&e.close()}_tooltipVisibilityHandler(e){const t=this,i=e.type,a=t.$.tooltip;e.target===a&&(e.stopPropagation(),t._fireTooltipVisibilityEvent(e)?e.preventDefault():"opening"===i?a.classList.remove("smart-visibility-hidden"):"closing"===i&&(a.hasAnimation?a.addEventListener("transitionend",(()=>{a.visible||(a.classList.add("smart-visibility-hidden"),a.style.top=a.style.left=0,t.$.container.appendChild(a))}),{once:!0}):t.$.container.appendChild(a)))}_fireTooltipVisibilityEvent(e){const t=this,i=e.type,a=t.$.tooltip,n=e.detail.owner;let s={target:a,owner:n};if(n)if(n.classList.contains("smart-task-connection")){s.type="connection";const e=t.getConnectionDetails(n.getAttribute("connection-id"));e&&(s.item=e)}else if(n.classList.contains("smart-gantt-chart-task-indicator"))s.type="indicator",n._indicatorObj&&(s.item=t._cloneObject(n._indicatorObj));else if(n.classList.contains("smart-task-segment"))s.type="segment",n._segmentObj&&(s.item=t._cloneObject(n._segmentObj));else if(n.classList.contains("smart-timeline-task"))s.type="task",n._cellObj&&n._cellObj.task&&(s.item=t._cloneObject(n._cellObj.task));else if(n.classList.contains("smart-resource-timeline-view-cell")){s.type="resource";const e=n.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+" "+a.id).trim()),t.$.fireEvent(i,s);break;case"close":r=r.replace(a.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,a=e.length;i<a;i+=1){const a=e[i],n=Object.assign({},a),s=a.parent,r=a.$.id;if(s&&s!==a){const e=s.$.id;t[e]||(t[e]=Object.assign({},s));const i=t[e];i.tasks||(i.tasks=[]),i.tasks.push(n)}else t[r]=n;delete n.parent,delete n.children,delete n.$}return Object.values(t)}_handleTaskConnections(e){const t=this,i=t._tasks;let a;if("number"==typeof e&&(a=e,e=i[e]),!e)return;void 0===a&&(a=i.indexOf(e));const n=e.connections,s=i.length;for(let e=0;e<n.length;e++){const i=n[e],r=t._getTaskIndexById(i.target);null==r||isNaN(r)||r<0||r>=s||r===a||t._connectTask([a,r,i.type,i.lag])}delete e.connections}_insertTasks(e,t,i){const a=this,n=a._tasks;if(t){const s=a._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=a._getProjectTasks(r);i=o&&l.length?n.indexOf(l[l.length-1]):n.indexOf(r),n.splice.apply(n,[i+(o?1:0),0].concat(e))}else n.splice.apply(n,[n.indexOf(t)+1,0].concat(e))}else"number"==typeof i?(i+="",(i=n.findIndex((e=>e.$.id===i)))<0&&(i=n.length)):i=n.length,n.splice.apply(n,[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,a=i.children,n=t.$.taskTimelineCellsContainer.childElementCount,s=t._timelineVCells;for(;i.childElementCount>n;)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,d=n;i<d;i++){const n=a[i],d=s[r+i];if(!d){n&&n.remove();continue}const c=d.task;t._snapToNearestDates(c),t._recycleTaskBars(d,i,o),t._setTimelineTaskBar(d,i),t._setTimelineTaskBaseline(d,i),t._setTaskBarProgress(c,i),t._setTaskBarLabel(c,i),t._setTaskIndicators(d,i,l),t._setTaskDeadline(d,i,l),e&&t._refreshTableColumnsData(c)}t._recycleConnections()}_ensureVisible(e,t="task"){const i=this;if(null==e)return;let a,n="task"===t?i._timelineVCells:i._timelineResourceVCells;a||(a=i.$[`${t}Table`]);const s=n.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,a=i.$.taskTimelineContainer.offsetWidth;t.left+t.width>e+a?i.scrollLeft=Math.max(0,t.left+t.width-a):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,a=e.$[this.groupByResources?"group":"project"];if(!a)return!0;for(;a;){if(i=a.expanded,!i)return!1;if(a=a.$.project,a===t)break}return i}_getItemByTreeIndex(e,t,i){if(!t)return;const a=t.split(".");let n=this[`_${e}s`].filter((e=>!e.$.project))[t.split(".")[0]];if(n){if(!n[`${e}s`]||!n[`${e}s`].length)return i?null:n;for(let t=1;t<a.length;t++){const s=n[`${e}s`].filter((e=>!e.hidden&&e.$.project===n))[a[t]];if(!s||i&&"project"!==s.type)break;if(n=s,"project"!==n.type)break}return i?n&&"project"===n.type?n:void 0:n}}_getItemByTableId(e,t,i){if(null==t)return;const a=this[`_${e}s`];let n;for(let e=0,i=a.length;e<i;e+=1){const i=a[e];if(i.$.id===t){n=i;break}}return n?i?"project"===n.type?n:void 0:n: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,a=t.classList.contains("smart-task-table");if(!a&&!t.classList.contains("smart-resource-table"))return;e.stopPropagation();const n=i.dataField,s=this[(a?"task":"resource")+"Columns"].find((e=>e.value===n));s&&(s.size=i.width),this.$.fireEvent("columnResize",i)}_tableSortFilterHandler(e){const t=this,i=e.target;let a;i.classList.contains("smart-task-table")?(a="task",t._createTimelineContent(),t._recycleTimelineTasks()):i.classList.contains("smart-resource-table")&&(a="resource",t._createResourceTimelineContent(),t._recycleResourceContent()),a&&(t._refresh(),e.stopPropagation(),t.$.fireEvent(e.type,Object.assign({type:a},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 a=i===t.$.taskTable?"task":"resource";if(e.stopPropagation(),!t[`${a}s`]||!t[`${a}s`].length)return;const n=e.detail.record.itemId,s=t._getItemByTableId(a,n,!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 a=e.closest("tbody tr");if(!a)return;const n=t._getVCellById("task",a.getAttribute("row-id"));n&&t._openPopupWindow(n.task,"Delete"===i);break}}}_getVCellById(e="task",t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let a=0,n=i.length;a<n;a+=1){const n=i[a][e];if(n.$&&n.$.id===t)return i[a]}}_getGroupVCellByPath(e,t){const i="task"===e?this._timelineVCells:this._timelineResourceVCells;if(i&&i.length)for(let a=0,n=i.length;a<n;a+=1){const n=i[a][e];if(n.$&&n.$.id===t)return i[a]}}_taskTableGroupEventHandler(e){const t=this,i=e.detail.action,a=e.target;if(["collapse","expand"].indexOf(i)<0||!a.classList.contains("smart-task-table")&&!a.classList.contains("smart-resource-table"))return;const n=a===t.$.taskTable?"task":"resource",s=t.$.taskTable._getGroupByIndex(e.detail.path),r=t._getGroupVCellByPath(n,s.$.id);if(!r||!r[n].isGroup)return;const o=r[n];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),a=t.scrollTop;t._refreshing=!0,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._refreshing=!1,t._scrollTo(i),t.scrollTop=a}_scrollTo(e,t){const i=this,a=i._timelineCells;let n;if(void 0!==e&&!isNaN(new Date(e).getTime()))for(let s=0;s<a.length;s++){const r=a[s],o=r.date;switch(i.view){case"quarter":case"year":if(o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()){if(t){n=r.left;break}let i=new Date(e);i.setMonth(e.getMonth()+1),i.setDate(0),i=i.getDate(),n=r.left+(e.getDate()-1)/i*r.width}break;case"month":{let i=new Date(o),a=new Date(o);i.setDate(i.getDate()-i.getDay()),a.setDate(a.getDate()+(6-a.getDay())+1),a.setMilliseconds(a.getMilliseconds()-1),e.getTime()>=i.getTime()&&e.getTime()<=a.getTime()&&(n=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()&&(n=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()&&(n=r.left+(t?0:parseFloat(e.getMinutes()+e.getSeconds())/60*r.width))}if(void 0!==n)return i.scrollLeft=n,void(i.$.mainSplitter.contains(i.$.resourceTimelineHeader)&&(i.$.resourceTimelineHeader.scrollLeft=i.$.resourceTimelineContent.scrollLeft=n,i._refreshResourceTimeline()))}}_updateConnection(e,t){const i=this,a=i._tasks,[n,s,r,o]=e,l=a[n],d=a[s];if(!l||!d||"number"!=typeof r)return;let c=i._connections,m=-1;c||(c=i._connections=[]);for(let e=0,t=c.length;e<t;e+=1){const t=c[e],i=t.startIndex,a=t.endIndex;if(i===n&&a===s||i===s&&a===n){m=e;break}}if(!t){if(m<0)c.push({startTask:a[n],endTask:a[s],startIndex:n,endIndex:s,type:r,lag:o});else{const e=c[m];if(!e)return;if(e.startIndex=n,e.startTask=a[n],e.endIndex=s,e.endTask=a[s],e.type=r,o!==e.lag){const t=parseInt(o);isNaN(t)||(e.lag=t)}}return!0}m>-1&&c.splice(m,1)}_createTimelineCells(){const e=this,t=e._tasks,i=new Date(e.properties.dateStart.value),a=new Date(e.properties.dateEnd.value);let n,s;if(isNaN(i.getTime())||(n=i),isNaN(a.getTime())||(s=a),t.length>0){let e=t[0].dateStart,i=t[0].dateEnd;for(let a=0;a<t.length;a++)t[a].dateStart&&t[a].dateEnd&&(e||(e=t[a].dateStart),i||(i=t[a].dateEnd),e.getTime()>t[a].dateStart.getTime()&&(e=t[a].dateStart),i.getTime()<t[a].dateEnd.getTime()&&(i=t[a].dateEnd));(!n||n.getTime()>e.getTime())&&(n=e),(!s||s.getTime()<i.getTime())&&(s=i)}if(n&&s){if(n=e._minMaxDateValidator(n),s=e._minMaxDateValidator(s),-1!==e.firstDayOfWeek){const t=n.getDay()-e.firstDayOfWeek,i=new Date(n.getTime());i.setDate(n.getDate()-n.getDay()+e.firstDayOfWeek-(t>=0?0:7)),n=i}e._createTimelineHeader(n,e._getCellsCount(n,s)),e._createTimelineContent(),e._createDateMarkers(),e._refresh()}}_getCellsCount(e,t,i){let a,n,s,r,o,l,d=new Date(e),c=new Date(t);const m=this,u=t.getFullYear()-e.getFullYear();if(n=a=Math.round(u)+1,"year"===i)return{year:n};if(d.setHours(d.getHours(),0,0,0),c.setHours(c.getHours(),0,0,0),l=Math.floor((t.getTime()-e.getTime())/36e5),l>0){let e=new Date(d);if(l=1,d.getFullYear()!==c.getFullYear()){let t=new Date(d.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=c.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()<c.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(d.setHours(0,0,0,0),c.setHours(23,59,59,999),o=a=Math.round((c.getTime()-d.getTime())/864e5),"day"===i)return{day:o};if(d.setDate(d.getDate()-d.getDay()),c.setDate(c.getDate()+6-c.getDay()),r=a=Math.round((c.getTime()-d.getTime())/6048e5),"week"===i){if(-1!==m.firstDayOfWeek){const t=e.getDay()-m.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+m.firstDayOfWeek-(t>=0?0:7))}return{week:r}}if("month"===this.view&&"day"!==m.monthScale&&(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()))),-1!==m.firstDayOfWeek)){const t=e.getDay()-m.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+m.firstDayOfWeek-(t>=0?0:7))}if(e.getFullYear()!==t.getFullYear()){a=12-e.getMonth();const i=t.getFullYear();for(let n=e.getFullYear()+1;n<=i;n++)a+=n===t.getFullYear()?t.getMonth()+1:12}else a=t.getMonth()-e.getMonth()+1;return s=Math.ceil(a),"months"===i?{month:s}:("day"===this.view&&0===l&&(l=1),{year:n,month:s,week:r,day:o,hour:l})}_recycleTaskBars(e,t,i){const a=this,n=e.task,s=a.$.timelineTasksContainer,r=a.$.taskTimelineCellsContainer,o="project"===n.type&&n.synchronized,l=n.type,d=n.$.id,c=s.children[t],m=r.children[t];m._cellObj=e,m.setAttribute("row-id",d),m.style.top=e.top+"px",m.removeAttribute("hover"),c.removeAttribute("hover"),c.classList.contains(l)||(c.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.connectionType&&(n.connectionType.includes("start")||c.querySelector(".start").classList.add("smart-hidden"),n.connectionType.includes("end")||c.querySelector(".end").classList.add("smart-hidden")),a._recycleSegments(n,c),delete c._cellStart,delete c._cellEnd,n.disableDrag||o&&!n.dragProject?c.setAttribute("disable-drag",""):c.removeAttribute("disable-drag"),n.disableResize||o?c.setAttribute("disable-resize",""):c.removeAttribute("disable-resize"),n.isGroup?c.setAttribute("resource-group",""):c.removeAttribute("resource-group"),i&&(i.indexOf(d)>-1?(c.setAttribute("selected",""),m.setAttribute("selected","")):(c.removeAttribute("selected"),m.removeAttribute("selected"))),n.id?c.id=n.id:c.id="ganttTask"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),c._cellObj=e,c.className="smart-timeline-task "+l,c.setAttribute("row-id",d),n.class&&c.classList.add(n.class),c.setAttribute("aria-label",n.label+" Start date: "+a._toISODate(n.dateStart)+", End date: "+a._toISODate(n.dateEnd)),c.setAttribute("aria-selected","false")}_toISODate(e){const t=e.getFullYear(),i=e.getMonth()+1,a=e.getDate();return t+"-"+(i<10?"0"+i:i)+"-"+(a<10?"0"+a:a)}_recycleSegments(e,t){const i=this,a=t.querySelector(".smart-task-segments");let n,s=e.segments;if(!a)return;for(Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);a.childElementCount>s.length;)a.children[0].remove();const r=document.createDocumentFragment(),o=a.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,a=s.length;t<a;t+=1){const a=s[t];let d=o[t];a.dateStart=new Date(Math.max(e.dateStart.getTime(),a.dateStart.getTime())),a.dateEnd=new Date(Math.min(e.dateEnd.getTime(),a.dateEnd.getTime())),d?(delete d._cellStart,delete d._cellEnd):(d=document.createElement("div"),d.classList.add("smart-task-segment"),d.innerHTML=l,r.appendChild(d)),a.disableDrag?d.setAttribute("disable-drag",""):d.removeAttribute("disable-drag"),a.disableResize?d.setAttribute("disable-resize",""):d.removeAttribute("disable-resize"),d._segmentObj=a,d.setAttribute("aria-label",(a.label||"")+" Start date: "+i._toISODate(a.dateStart)+", End date: "+i._toISODate(a.dateEnd)),n=d}r.childElementCount&&a.appendChild(r),i._setTaskBarDeadline(e,n)}_createCells(e){let t,i=document.createDocumentFragment();for(let a=0;a<e;a++)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 a=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))+a))}_getHeaderVisibleCellsCount(){const e=this;if(!e._timelineHeaderCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,a=e._timelineHeaderCells;let n=0;for(let e=0;e<a.length;e++){const s=a[e];s.left+s.width>t&&s.left<i+t&&n++}return n}_getHeaderSubVisibleCellsCount(){const e=this;if(!e._timelineHeaderSubCells)return;const t=Math.abs(e.scrollLeft),i=e.$.timeline.offsetWidth,a=e._timelineHeaderSubCells;let n=0;for(let e=0;e<a.length;e++){const s=a[e];s.left+s.width>t&&s.left<i+t&&n++}return n}_refreshHeaderDate(e){const t=this,i=t._getCellsViewType(),a=t.$.timelineHeader.scrollLeft,n=t.$.timelineViewCells.children,s=t._timelineCells;let r;t._refreshHeaderSubDetailsDate(e),t._refreshHeaderDetailsDate(e);for(let e=0;e<s.length;e++){const t=s[e];if(a<=t.left+t.width){r=e;break}}for(let a=0;a<n.length;a++){const o=n[a],l=s[r];if(!l)break;r++;const d=l.date;o.innerHTML=`<div>${t._getDateString(new Date(d),i)}</div>`,e||(o._date=new Date(d),o.setAttribute("date",d.toLocaleDateString()),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 a=this,n=["2-digit","numeric"][a.dayFormat]||"numeric";let s;if("year"===t||"quarter"===t)s=e.toLocaleDateString(a.locale,{year:a.yearFormat});else if("month"===t)s=e.toLocaleDateString(a.locale,{month:a.monthFormat}),"month"===a.view&&(s+=" "+e.toLocaleDateString(a.locale,{year:a.yearFormat}));else if("week"===t)s="numeric"!==a.weekFormat&&i?e.toLocaleDateString(a.locale,{day:n,month:a.monthFormat,year:a.yearFormat}):a._getWeekNumber(e);else if("day"===t)s="month"===a.view?"numeric"!==a.dayFormat&&"2-digit"!==a.dayFormat?e.toLocaleDateString(a.locale,{day:"numeric"})+" "+e.toLocaleDateString(a.locale,{weekday:a.dayFormat}):e.toLocaleDateString(a.locale,{day:"numeric"})+" "+e.toLocaleDateString(a.locale,{weekday:"short"}):e.toLocaleDateString(a.locale,"day"===a.view?{day:n,month:a.monthFormat,year:a.yearFormat}:["long","short","narrow"].indexOf(a.dayFormat)>-1?{weekday:a.dayFormat}:{day:a.dayFormat});else if("hour"===t)if(s="default"===a.hourFormat?e.toLocaleTimeString(a.locale,{hour12:!1}):e.toLocaleDateString(a.locale,{hour:a.hourFormat}),"default"!==a.hourFormat)s.indexOf(",")>=0&&(s=s.substring(s.indexOf(",")+1).trim());else if(s.indexOf(":")!==s.lastIndexOf(":")&&s.indexOf(":")>=0){let e=s.toLowerCase().indexOf("am")>=0?" AM":"";e=s.toLowerCase().indexOf("pm")>=0?" PM":e,s=s.substring(0,s.lastIndexOf(":"))+e}return a.timelineHeaderFormatFunction?a.timelineHeaderFormatFunction(new Date(e),t,i,s):s}_refreshHeaderSubDetailsDate(e){const t=this,i=(t.view,t.scrollLeft),a=t.$.timelineViewSubDetails.children,n=t._timelineHeaderSubCells;let s;if(t.$.timelineViewSubDetails.classList.contains("smart-hidden"))return;for(let e=0;e<n.length;e++){const t=n[e];if(i<=t.left+t.width){s=e;break}}let r=[],o=0;for(let i=0;i<a.length;i++){const l=n[s],d=a[i];if(!l)continue;let c=new Date(l.date);"week"===t.view&&c.setDate(c.getDate()-c.getDay()),s++,c=new Date(Math.max(l.date.getTime(),c.getTime()));const m=e=>{var i,a=e.getMonth();return i=a>=9?4:a>=6?3:a>=3?2:1,"long"===t.quarterFormat?t.localize("quarter")+" "+i:"numeric"===t.quarterFormat?i:t.localize("quarterShort")+i};let u="";"quarter"===t.view||"year"===t.view?(u=m(c),"quarter"===t.view&&t.hideTimelineSecondHeaderDetails&&(u+=" "+c.getFullYear())):"month"===t.view&&(-1===t.firstDayOfWeek?u=t._getWeekNumber(c):((c.getDay()-t.firstDayOfWeek)%7==0&&i>0&&o++,u=o));const h=u+"_"+c.getFullYear();r[h]||(r[h]=[]),d.classList.remove("smart-visibility-hidden"),r[h].push({element:d,cell:l}),d.innerHTML=`<div>${u}</div>`,d.classList.add("middle"),e||(d._date=c,d.style[t.rightToLeft?"right":"left"]=l.left+"px",d.style.width=l.width+"px")}for(let e in r){const i=r[e];let a=0;for(let e=0;e<i.length;e++)a+=i[e].cell.width;if(i[0].element.style.width=a+"px","year"===t.view){const e=i[0].cell.date.toLocaleDateString(t.locale,{month:t.monthFormat}),a=i[i.length-1].cell.date.toLocaleDateString(t.locale,{month:t.monthFormat});i.length>1?i[0].element.innerHTML=`<div>${e}-${a}</div>`:i[0].element.innerHTML=`<div>${e}</div>`}else if("month"===t.view){const e="numeric"!==t.dayFormat&&"2-digit"!==t.dayFormat?t.dayFormat:"short",a=i[0].cell.date.toLocaleDateString(t.locale,{day:"numeric"})+" "+i[0].cell.date.toLocaleDateString(t.locale,{weekday:e}),n=i[i.length-1].cell.date.toLocaleDateString(t.locale,{day:"numeric"})+" "+i[i.length-1].cell.date.toLocaleDateString(t.locale,{weekday:e});i.length>1?i[0].element.innerHTML=`<div>${a}-${n}</div>`:i[0].element.innerHTML=`<div>${a}</div>`,"numeric"===t.weekFormat&&(i[0].element.innerHTML=t._getWeekNumber(i[0].cell.date))}if(t.timelineHeaderFormatFunction){const e=t.timelineHeaderFormatFunction(new Date(i[0].cell.date),t.view,!0,i[0].element.innerHTML);i[0].element.innerHTML!==e&&(i[0].element.innerHTML=e)}for(let e=1;e<i.length;e++)i[e].element.classList.add("smart-visibility-hidden")}}_refreshHeaderDetailsDate(e){const t=this,i=t.view,a=t.scrollLeft,n=t.$.timelineViewDetails.children,s=t._timelineHeaderCells;let r;for(let e=0;e<s.length;e++){const t=s[e];if(a<=t.left+t.width){r=e;break}}for(let a=0;a<n.length;a++){const o=s[r],l=n[a];let d=new Date(o.date);if("week"===t.view)if(-1!==t.firstDayOfWeek){const e=d.getDay()-t.firstDayOfWeek;d.setDate(d.getDate()-d.getDay()+t.firstDayOfWeek-(e>=0?0:7))}else d.setDate(d.getDate()-d.getDay());r++,d=new Date(Math.max(o.date.getTime(),d.getTime())),l.innerHTML=`<div>${t._getDateString(d,i,!0)}</div>`,e||(l._date=d,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),a=Math.round((e.getTime()-i.getTime()-6e4*(e.getTimezoneOffset()-i.getTimezoneOffset()))/864e5)+1,n=i.getDay();return n=n>=0?n:n+7,n<4?(t=Math.floor((a+n-1)/7)+1,t>52&&(i=new Date(e.getFullYear()+1,0,1),n=i.getDay(),n=n>=0?n:n+7,t=n<4?1:53)):t="week"===this.view?function(e){var t=new Date(e.valueOf()),i=(e.getDay()+6)%7;t.setDate(t.getDate()-i+3);var a=t.valueOf();return t.setMonth(0,1),4!==t.getDay()&&t.setMonth(0,1+(4-t.getDay()+7)%7),1+Math.ceil((a-t)/6048e5)}(e):Math.round((a+n-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,a=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()])return void i._refresh();i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width="",i._createTimelineCellsObj(e,t),i._createTimelineHeaderCellsObj(e,t),i._createTimelineHeaderSubCellsObj(e,t),i.$.timelineViewDetails.innerHTML="",i.$.timelineViewDetails.appendChild(i._createCells(i._getHeaderVisibleCellsCount())),i.$.timelineViewSubDetails.innerHTML="",i.$.timelineViewCells.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.classList.add("smart-hidden");let n=2;"quarter"===i.view?(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(i._getTimelineVisibleCellsCount()))):"month"===i.view&&"day"===i.monthScale?(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(t.day))):"year"===i.view&&(n=3,i.$.timelineViewSubDetails.classList.remove("smart-hidden"),i.$.timelineViewSubDetails.appendChild(i._createCells(t.month))),i.hideTimelineHeader&&(i.$.timelineViewCells.classList.add("smart-hidden"),n--),i.hideTimelineHeaderDetails&&(i.$.timelineViewDetails.classList.add("smart-hidden"),n--),i.hideTimelineSecondHeaderDetails&&("quarter"===i.view?i.$.timelineViewDetails.classList.add("smart-hidden"):i.$.timelineViewSubDetails.classList.add("smart-hidden"),("year"===i.view||"month"===i.view&&"day"===i.monthScale||"quarter"===i.view)&&n--),i.$.taskTable.style.setProperty("--smart-table-column-header-height","calc("+n+" * var(--smart-gantt-chart-task-default-height) - calc("+n+" * var(--smart-border-width) / "+n+"))"),i.$.timelineViewCells.innerHTML="",i.$.timelineViewCells.appendChild(i._createCells(i._getTimelineVisibleCellsCount()));let s=t[a];if("hour"===a&&("halfHour"===i.dayScale?s*=2:"quarterHour"===i.dayScale&&(s*=4)),i.$.timelineContent.style.width=i.$.timelineHeaderContent.style.width=Math.max(s*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,a=e._taskDefaultHeight,n=e.$.taskTimelineContainer,s=e.scrollLeft;if(i.style.height="",t.style.removeProperty("--smart-gantt-chart-task-timeline-content-height"),e._createTimelineVCells(a),i.style.height=e._timelineVCells.length*a+"px",t.style.setProperty("--smart-gantt-chart-task-timeline-content-height",e.$.timeline.offsetHeight+"px"),s||s!==n.scrollLeft){const t=e._getScrollLeft(e.scrollLeft);n.scrollLeft=t,e.$.mainSplitter.contains(e.$.resourceTimelineHeader)&&(e.$.resourceTimelineContent.scrollLeft=t)}e.scrollTop&&(n.scrollTop=e.scrollTop),e._recycleContentCells()}_createDateMarkers(){const e=this,t=e.dateMarkers;let i=[];delete e._markers;for(let a=0,n=t.length;a<n;a+=1){const n=t[a],s=e._dateValidator(void 0,n.date);if(s){const e={date:s},t=n.label,a=n.className;("string"==typeof t||"number"==typeof t&&!isNaN(t))&&(e.label=t),"string"==typeof a&&(e.className=a),i.push(e)}}i.length&&(e._markers=i),e._recycleDateMarkers()}_createTimelineRowCells(e,t){const i=this,a=e.children,n=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=n.length;e<t;e+=1)n[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],n=a[e];i.hasAttribute("weekend")?n.setAttribute("weekend",""):n.removeAttribute("weekend"),i.hasAttribute("nonworking")?n.setAttribute("nonworking",""):n.removeAttribute("nonworking"),n.style[o]=i.style[o],n.style[r]=i.style[r],n.style.width=i.style.width}for(let t=0,i=n.length;t<i;t+=1)e.appendChild(n[t])}_recycleTimelineRowCells(){const e=this,t=e.$.timelineViewCells.children,i=e.$.taskTimelineCellsContainer.children;for(let a=0,n=i.length;a<n;a+=1)e._createTimelineRowCells(i[a],t)}_createTimelineVCells(e){const t=this,i=t._tasks,a=t.$.taskTable.rows,n=t.groupByResources;let s=0,r={};t._timelineVCells=[];for(let o=0,l=a.length;o<l;o++){const l=a[o].data;let d=i[l.itemIndex];if(n)if(!d&&l.groupDataField){const e=l.$.id;d={$:{id:e,project:void 0},label:t._formatResourceGroupLabel(l.label),value:l.label,expanded:l.expanded,synchronized:!0,isGroup:!0,type:"project"},r[e]=d}else l.parent?(d.$.group=r[l.parent.$.id],t._synchronizeProjectDates(d.$.group,[d])):delete d.$.group;else delete d.$.group;!d.hidden&&t._isTaskExpanded(d)&&(t._timelineVCells.push({top:s,height:e,task:d}),s=parseFloat((s+e).toFixed(2)))}}_getCellsViewType(){const e=this;switch(e.view){case"quarter":case"year":return"month";case"month":return"day"===e.monthScale?"day":"week";case"week":return"day";case"day":return"hour"}}_dateAdd(e,t,i){if(e instanceof Date){var a=new Date(e),n=function(){a.getDate()!==e.getDate()&&a.setDate(0)};switch(String(t).toLowerCase()){case"year":a.setFullYear(a.getFullYear()+i),n();break;case"quarter":a.setMonth(a.getMonth()+3*i),n();break;case"month":a.setMonth(a.getMonth()+i),n();break;case"week":a.setDate(a.getDate()+7*i);break;case"day":a.setDate(a.getDate()+i);break;case"hour":a.setTime(a.getTime()+36e5*i);break;case"minute":a.setTime(a.getTime()+6e4*i);break;case"second":a.setTime(a.getTime()+1e3*i);break;default:a=void 0}return a}}_createTimelineCellsObj(e,t){const i=this,a=i._getCellsViewType();t=t[a],"hour"===a&&"halfHour"===i.dayScale?t*=2:"hour"===a&&"quarterHour"===i.dayScale&&(t*=4);const n=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<n&&(s=n/t),s=parseFloat(s.toFixed(2)),i._timelineCells=[];for(let e=0;e<t;e++){const t={left:r,width:s};if("year"===a||"quarter"===a)o.setMonth(0),t.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===a)o.setDate(1),t.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===a)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),t.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===a)i.nonworkingDays.indexOf(o.getDay())>-1&&(t.nonworking=!0),o.setHours(0,0,0,0),t.date=new Date(o),o.setDate(o.getDate()+1),t.weekend=0===t.date.getDay()||6===t.date.getDay();else if("hour"===a){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(t.nonworking=!0),"hour"!==i.dayScale&&0!==e||o.setHours(o.getHours(),0,0,0),t.date=new Date(o);const a=o.getTime();"hour"===i.dayScale?o.setHours(o.getHours()+1):"halfHour"===i.dayScale?o=i._dateAdd(o,"minute",30):"quarterHour"===i.dayScale&&(o=i._dateAdd(o,"minute",15)),a===o.getTime()&&o.setHours(o.getHours()+2),t.weekend=0===t.date.getDay()||6===t.date.getDay()}i._timelineCells.push(t),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderSubCellsObj(e,t){const i=this,a=i._getCellsViewType();t="month"===i.view&&"day"===i.monthScale?t.day:t[a],"hour"===a&&"halfHour"===i.dayScale?t*=2:"hour"===a&&"quarterHour"===i.dayScale&&(t*=4);const n=i.$.timeline.parentElement.offsetWidth;let s=Math.max(i._timelineCellSize,i._timelineCellMinSize),r=0,o=new Date(e);t*s<n&&(s=n/t),s=parseFloat(s.toFixed(2)),i._timelineHeaderSubCells=[];for(let e=0;e<t;e++){const t={left:r,width:s};if("year"===a||"quarter"===a)o.setMonth(0),t.date=new Date(o),o.setFullYear(o.getFullYear()+1);else if("month"===a)o.setDate(1),t.date=new Date(o),o.setMonth(o.getMonth()+1);else if("week"===a)o.setHours(0,0,0,0),o.setDate(o.getDate()-o.getDay()),t.date=new Date(o),o.setDate(o.getDate()+7);else if("day"===a)i.nonworkingDays.indexOf(o.getDay())>-1&&(t.nonworking=!0),o.setHours(0,0,0,0),t.date=new Date(o),o.setDate(o.getDate()+1),t.weekend=0===t.date.getDay()||6===t.date.getDay();else if("hour"===a){(i.nonworkingHours.indexOf(o.getHours())>-1||i.nonworkingDays.indexOf(o.getDay())>-1)&&(t.nonworking=!0),"hour"!==i.dayScale&&0!==e||o.setHours(o.getHours(),0,0,0),t.date=new Date(o);const a=o.getTime();"hour"===i.dayScale?o.setHours(o.getHours()+1):"halfHour"===i.dayScale?o=i._dateAdd(o,"minute",30):"quarterHour"===i.dayScale&&(o=i._dateAdd(o,"minute",15)),a===o.getTime()&&o.setHours(o.getHours()+2),t.weekend=0===t.date.getDay()||6===t.date.getDay()}i._timelineHeaderSubCells.push(t),r=parseFloat((r+s).toFixed(2))}}_createTimelineHeaderCellsObj(e,t){const i=this;let a=i.view,n=0,s=new Date(e);"quarter"===a&&(a="year"),t=t[a],i._timelineHeaderCells=[];for(let e=0;e<t;e++){const t={};switch(t.date=new Date(s),a){case"quarter":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)}n=i._refreshViewDetailCell(t,n,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 a;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 n=i.exec(t)[0].replace(/[,-.\/]/g,",").split(",");if(3===n.length){const[i,s]=parseInt(n[0])<parseInt(n[2])?[n[0],n[2]]:[n[2],n[0]];if(a=new Date(parseInt(s),parseInt(n[1])-1,parseInt(i)),e.test(t)){const i=e.exec(t)[0].split(":");a.setHours(i[0]||0,i[1]||0,i[2]||0)}t=a}}}else a=new Date(Date.parse(t)),e.test(t)||a.setHours(0,0,0,0),t=a}return i._minMaxDateValidator(new Date(t))}_currentTimeIndicatorIntervalValidator(e,t){return Math.max(1,t)}_getTaskBarPositionLimits(e,t){const i=this;function a(e){const t=i._getTimelineTaskCellByDate(e);if(t)return t.left+i._getTimelineTaskOffset(t,e)||0}return{min:a(e["min"+t]),max:a(e["max"+t])}}_getTimelineTaskOffset(e,t){if(!e)return;let i,a;switch(this.view){case"quarter":case"year":{const n=t.getHours()/24+t.getMinutes()/1440+t.getSeconds()/86400;i=new Date(e.date.getFullYear(),e.date.getMonth()+1,0),a=(t.getDate()-1+n)/i.getDate()*e.width;break}case"month":a=t.getDay()/7*e.width;break;case"week":a=parseFloat(t.getHours()+t.getMinutes()/60+t.getSeconds()/3600)/24*e.width;break;case"day":a=parseFloat(t.getMinutes()+t.getSeconds()/60)/60*e.width}return a}_getTaskBarSizeLimits(e,t){const i=this,a=i._getTaskBarDateRange(e);let n,s=0,r=i._convertDuration(e._cellObj.task.minDuration)||i._getMinDuration(e,t),o=i._convertDuration(e._cellObj.task.maxDuration);function l(n,s){if(!n)return;let r,o;"left"===t&&!i.rightToLeft||"right"===t&&i.rightToLeft?(n*=-1,o=a.dateEnd):o=a.dateStart,s&&Math.abs(r)===Math.abs(n)&&(r=0);let l=i._getTaskWorkingDateEnd({dateStart:o},n);const d=l.getTime()+60*(l.getTimezoneOffset()-o.getTimezoneOffset())*1e3,c=i._getTimelineTaskCellByDate(new Date(d));if(!c)return;const m=i._getTimelineTaskOffset(c,new Date(d));return i.rightToLeft?"left"===t?m-(i.$.timelineContent.offsetWidth-e.offsetLeft-e.offsetWidth-c.left):i.$.timelineContent.offsetWidth-e.offsetLeft-c.left-m:"left"===t?e.offsetLeft+e.offsetWidth-c.left-m:c.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()-a.dateEnd.getTimezoneOffset())*1e3,n=Math.abs(i.getTime()-a.dateEnd.getTime())+s,o=o?Math.min(n,o):n),t&&(s=60*(t.getTimezoneOffset()-a.dateEnd.getTimezoneOffset())*1e3,n=Math.abs(t.getTime()-a.dateEnd.getTime())+s,r=r?Math.max(n,r):n)}else{const t=e._cellObj.task.maxDateEnd,i=e._cellObj.task.minDateEnd;i&&(s=60*(i.getTimezoneOffset()-a.dateStart.getTimezoneOffset())*1e3,n=Math.abs(i.getTime()-a.dateStart.getTime())+s,r=r?Math.max(n,r):n),t&&(s=60*(t.getTimezoneOffset()-a.dateStart.getTimezoneOffset())*1e3,n=Math.abs(t.getTime()-a.dateStart.getTime())+s,o=o?Math.min(n,o):n)}return o&&(r=Math.min(r,o)),{min:l(r,!0),max:l(o)}}_getMinDuration(e,t){const i=this,a=i._taskBarMinWidth;if(!a||!i._timelineCells||0===i._timelineCells.length)return;const n=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=n.dateEnd,r+=parseFloat(e.style.width)||e.offsetWidth,o=-1):s=n.dateStart;const l=r+o*a;let d;for(let e=0;e<i._timelineCells.length;e++){const t=i._timelineCells[e];if(l<t.left)break;d=t}const c=i._getDateFromCell(l,d);return c?Math.abs(s.getTime()-c.getTime()):void 0}_createDelimiter(e,t){const i=this,a=i._dragDetails,n=a.segment,s=e.slice(0,3),r=document.createElement("div");if(r.classList.add("smart-task-bar-limiter",e),e.indexOf("date")>-1){if(!a[s]||!a[s].left)return;const[e,t]=n?[n.element,n.originalPosition.x]:[a.timelineTask,0],o=i.$.taskTimelineCellsContainer.children[i._getTaskDOMIndex(a.task)];s.indexOf("max")>-1?r.style.width=o.offsetWidth-a[s].left-t-e.offsetWidth+"px":r.style.width=a[s].left+t+"px"}else{if(!a[s].width)return;r.style["left"===t?"right":"left"]=a[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 a=i.closest?i.closest(".smart-task-connection"):void 0;if(a)t._openPopupWindow(a);else if(a=i.closest(".smart-timeline-task")||i.closest(".smart-table tbody tr[row-id]"),a&&t.$.taskSplitter.contains(a))if(a.classList.contains("smart-timeline-task"))t._openPopupWindow(a._cellObj.task);else{const e=t._getVCellById("task",a.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,a=t.shadowRoot||t.isInShadowDOM?i.composedPath()[0]:i.target,n=a.closest?a.closest(".smart-timeline-row")||a.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(a)?"task":"resource";if((a.closest(".smart-timeline-content")||a.closest(`.smart-${s}-table`))&&requestAnimationFrame((()=>t.$[`${s}Table`].focus({preventScroll:!0}))),t._itemClickDetails={target:a},!t._isMobile&&0!==e.button)return;if(!n){if(a.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((a.closest(".smart-table tbody tr[row-id]")&&!a.classList.contains("smart-arrow")||a.closest(".smart-task-connection"))&&t._checkDoubleClick(i))}if(a.closest(".smart-resource-timeline-view-cell")||t.disabled)return;const r=Array.from(t.$.timelineTasksContainer.children).find((e=>e._cellObj.task===n._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((a.closest(".smart-timeline-task-fill")||r.classList.contains("milestone")&&a.closest(".smart-task-container"))&&t._checkDoubleClick(i))return;const n=a.closest(".smart-timeline-task-progress-thumb"),s=e.pageX-window.pageXOffset,d=e.pageY-window.pageYOffset,c=t._dragDetails={},m=t.rightToLeft;let u,h=a.closest(".smart-task-segment");if(l&&!h){const e=r.querySelectorAll(".smart-task-segment");c.segments=e,h="left"===l&&!m||"right"===l&&m?e[0]:e[e.length-1]}if(c.target=(n||a).className,c.timelineTask=r,c.task=r._cellObj.task,c.taskDimensions={width:r.offsetWidth,height:r.offsetHeight,left:r.offsetLeft,top:r.offsetTop},c.coordinates={x:s,y:d},!e.ctrlKey&&h&&o.segments&&o.segments.length>1&&!t.disableSegmentDrag){const e=h.getBoundingClientRect(),t=h._segmentObj,i=c.task.segments,a=i.indexOf(t);c.segment={element:h,dimensions:{width:e.width,left:h.offsetLeft},offset:{x:s-e.left},originalSize:{width:e.width},isFirstSegment:0===a,isLastSegment:a===i.length-1,min:{},max:{}},u=c.segment.dimensions}const g=c.taskDimensions;t.rightToLeft?(g.right=t.$.timelineContent.offsetWidth-(g.left+g.width),c.originalPosition={x:g.right,y:g.top},c.segment&&(u.right=g.width-(u.left+u.width),c.segment.originalPosition={x:u.right})):(c.originalPosition={x:g.left,y:g.top},c.segment&&(c.segment.originalPosition={x:u.left}));const f=(n||r).getBoundingClientRect();if(c.offset={x:s-f.left,y:d-f.top},c.originalSize={width:g.width,height:g.height},n||!n&&"project"===o.type&&o.synchronized&&!o.dragProject)return void(a.closest(".smart-task-connection-point")&&(c.timelineTask=void 0,c.relatedConnections={}));("visible"===t.resizeHandlesVisibility||t._isMobile&&"auto"===t.resizeHandlesVisibility)&&(a.closest(".smart-timeline-task-fill")?t._checkTaskBarResizability(e):t.$.timeline.removeAttribute("task-bar-hovered")),c.min={},c.max={},t._setDragLimits(a)}}_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 a=i.closest&&i.closest(".smart-table tbody tr[row-id]");return a&&a.data?t._handleTableItemHover(a.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 a=i.target;if(t._upHandler(),!t._dragDetails)return void t._handleItemClick(i);if(t._scrollView.disableSwipeScroll=t._touchmoveInside=!1,t.shadowRoot&&a===t&&(a=i.composedPath()[0]),t.hasAttribute("connecting-task")){const i=t._connectTask(e),a=t._tasks;if(t._setConnectionFeedback(),i){const e=i.taskStart,n=i.taskEnd,[s,r,o]=[a.indexOf(i.taskStart),a.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 n.id||"number"==typeof n.id?n.id:n.$.id,type:o}),t._autoSchedule(i.taskStart)}return t._isMobile&&t._handleTimelineHover(e,!0),void delete t._dragDetails}const n=t._dragDetails.task;if(!n)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===n))),t.hasAttribute("dragged")){t._snapToNearest(s,r),r||t._checkWorkingDays(s,r),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),t._autoSchedule(n),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n)):(t.snapToNearest||t.nonworkingDays.length>0||t.nonworkingHours.length>0)&&t._refreshAssignedResources(n),t.removeAttribute("dragged");const e={id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:new Date(n.dateStart),dateEnd:new Date(n.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(n,["progress"])),t.removeAttribute("progress-change"),t.$.fireEvent("progressChangeEnd",{id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),progress:n.progress||0});else if(t.hasAttribute("resized")){t._snapToNearest(s,r),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),t._resourceTreeRefreshTimeout?(clearTimeout(t._resourceTreeRefreshTimeout),delete t._resourceTreeRefreshTimeout,t._refreshAssignedResources(n,["workload"])):t.snapToNearest&&t._refreshAssignedResources(n,["workload"]),t.removeAttribute("resized");const e={id:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.id,item:t._cloneObject(n),dateStart:n.dateStart,dateEnd:n.dateEnd};r&&(e.segment=t._cloneObject(r._segmentObj)),t.$.fireEvent("resizeEnd",e),t._autoSchedule(n)}else a.closest(".smart-timeline-task")===s&&(t._select("task",n.$.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 a,n,s;if(i.closest(".smart-timeline-task-fill"))n=i.closest(".smart-timeline-task")._cellObj.task,s="task";else if(a=i.closest(".smart-task-connection"),a)n=a.getAttribute("connection-id").split("-"),n={source:n[0],target:n[1],type:n[2]},s="connection";else if(i.closest(".milestone"))n=i.closest(".milestone")._cellObj.task,s="milestone";else if(a=i.closest(".smart-table tbody tr"),a){const e=t._getVCellById(s,a.getAttribute("row-id"));s=t.$.taskTable.contains(a)?"task":"resource",n=e?e[s]:void 0}if(!n)return;const r={originalEvent:e,type:s,item:t._cloneObject(n)};r.id="connection"===s?`${n.source}-${n.target}-${n.type}`:"string"==typeof n.id||"number"==typeof n.id?n.id:n.$.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,a=i._hoveredItem;let n,s;if(t&&([n,s]=i.$.taskSplitter.contains(t)?[i.$.taskTable,"task"]:[i.$.resourceTable,"resource"]),a&&"itemType"===a.type&&a.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(!n)return;i._setTableHoverState(n,e);const o=i.$["task"===s?"taskTimelineCellsContainer":"resourceTimelineCellsContainer"].children;for(let t=0,a=o.length;t<a;t+=1){const a=o[t];if(a._cellObj[s].$.id===e){i._handleTimelineHover({target:a});break}}}_setTableHoverState(e,t){const i=this;e||(e=i.$.taskTable);const a=e===i.$.taskTable?"task":"resource",n=e.querySelectorAll("table tbody tr");if(!i._isMobile&&i[a+"Columns"].length)for(let e=0;e<n.length;e++){let i=n[e];const a=i.data;a&&a.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 a=e._cellObj,n=a.task,s=t._getTaskWorkingDateEnd(n),r=n.segments;let o=new Date(t._timelineCells[t._timelineCells.length-1].date);if("year"===t.view||"quarter"===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&&(n.dateEnd=n.maxDateEnd?new Date(Math.min(s.getTime(),n.maxDateEnd.getTime())):s),n.dateEnd=new Date(Math.min(o.getTime(),n.dateEnd.getTime())),n.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(n.dateStart,n.dateEnd):n.dateEnd.getTime()-n.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(n),n.segments.length!==r.length&&t._recycleSegments(n,e),t._setTaskBarSegments(a,e,!0),t._setTaskBarProgress(n)}t._setTimelineTaskBar(a,void 0,!0),t._refreshTaskConnections(a.task),t._refreshTableColumnsData(n,["dateEnd","duration","overdue"])}_getTaskWorkingDateEnd(e,t){const i=this;if(!e||!e.dateStart)return;let a,n,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)n=new Date(s),n.setHours(0,0,0,0),n.setDate(s.getDate()+1*r),a=Math.min(e,n.getTime()-s.getTime()),s=new Date(s.getTime()+a);else if("day"===i.view&&l.indexOf(s.getHours())>-1){n=new Date(s);const t=n.getTime();n.setHours(s.getHours()+1*r,0,0,0),t===n.getTime()&&n.setHours(s.getHours()+2*r,0,0,0),a=Math.min(e,n.getTime()-s.getTime()),s=new Date(s.getTime()+a)}else t-=e,s=new Date(s.getTime()+r*e)}return s}_createConnectingElement(e,t,i,a,n){const s=this;if(!s._connectionDetails||!s._connectionDetails.start)return;const r=s._connectionDetails,o=r.type,l=s.$.timelineConnectionsContainer;let d=r.connections.shift();d||(d=document.createElement("div"),d.classList.add("smart-task-connection")),d.style.width=d.style.width="","horizontal"===a?(d.style.width=Math.abs(i)+"px",d.style.height=""):(d.style.width="",d.style.height=Math.abs(i)+"px"),d.style[s.rightToLeft?"left":"right"]="",d.style[s.rightToLeft?"right":"left"]=e+"px",d.style.top=t+"px",d.setAttribute("connection-id",r.id);const c=r.start.task.label,m=0===o||3===o?"start":"end",u=r.end.task.label,h=0===o||1===o?"start":"end";if(d.setAttribute("aria-label","Connection between "+c+" ("+m+") and "+u+" ("+h+")"),n){let e=0===o||1===o?"right":"left";s.rightToLeft&&(e="left"===e?"right":"left"),d.setAttribute("arrow-direction",e)}else d.removeAttribute("arrow-direction");d.parentElement||l.appendChild(d)}_getConnectionType(e,t){if(!e||!t)return;let i,a;return"string"==typeof e?i=!e.includes("end"):e instanceof HTMLElement&&(i=!e.classList.contains("end")),"string"==typeof t?a=t.includes("end"):t instanceof HTMLElement&&(a=t.classList.contains("end")),i&&!a?0:i||a?!i&&a?2:i&&a?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 a=i.task,n=i.taskDimensions;if(!a)return;if(!t.hasAttribute("connecting-task")){if(t.$.fireEvent("connectionStart",{startIndex:t._tasks.indexOf(a)}).defaultPrevented)return void delete t._dragDetails.target;t.setAttribute("connecting-task",""),t._isMobile&&(t._scrollView.disableSwipeScroll=t._touchmoveInside=!0)}const s="milestone"===a.type,r=t.rightToLeft;let o=s?-1*n.height/2:0;t._dragDetails.target.includes("end")&&(o=s?-1*o:n.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,d=t._dragDetails.coordinates.y,c=t._dragDetails.offset.x-(r?n.width:0),m=t._dragDetails.offset.y,u=e.pageX-window.pageXOffset+c,h=e.pageY-window.pageYOffset+m-n.height/2;r?(t._connectionFeedback.style.left="",t._connectionFeedback.style.right=n.right+o+"px"):(t._connectionFeedback.style.left=n.left+o+"px",t._connectionFeedback.style.right=""),t._connectionFeedback.style.top=n.top+n.height/2+"px",t._connectionFeedback.style.width=Math.sqrt(Math.pow(Math.abs(u-l),2)+Math.pow(Math.abs(h-d),2))+"px",t._connectionFeedback.style.transform=t.rightToLeft?"rotate("+180*(Math.atan2(d-h,l-u)||0)/Math.PI+"deg)":"rotate("+180*(Math.atan2(h-d,u-l)||0)/Math.PI+"deg)",t._connectionFeedback.parentElement||t.$.timelineContent.appendChild(t._connectionFeedback)}_connectTask(e){const t=this,i=t._tasks;let a,n,s,r,o,l,d,c,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]),a=t._dragDetails.target.includes("smart-task-connection-point")?t._dragDetails.target:void 0,n=o.classList.contains("smart-task-connection-point")?o:void 0,a&&(l=t._dragDetails.task),n)s=n.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;n=s.querySelector(".smart-task-connection-point."+(e>=s.offsetWidth/2?"end":"start"))}if(!l||!s)return;d=s._cellObj.task;for(let e=0,t=i.length;e<t;e+=1){const t=i[e];if(t!==l)if(t!==d){if(void 0!==c&&void 0!==m)break}else m=e;else c=e}}else{if(!e||e.length<3)return;const a=t._getValidConnectionId(e[0],e[1],e[2],"_connectTask");if(void 0===a)return;[c,m]=[parseInt(a[0]),parseInt(a[1])],[l,d]=[i[c],i[m]],r=parseInt(e[2]),o=e[4]||0}if(!l||!d||l===d||l.isGroup||d.isGroup||t._isAutoScheduled(l,d)||t.hasAttribute("dragged")||t.hasAttribute("resized"))return;void 0===r&&(r=t._getConnectionType(a,n));let u=t._connections;return u||(t._connections=u=[]),t._updateConnection([c,m,r,o])?(e.originalEvent&&t._recycleConnections([{startIndex:c,endIndex:m,type:r}]),e.originalEvent&&t.$.fireEvent("itemInsert",{type:"connection",item:{source:c,target:m,type:r}}),{taskStart:l,taskEnd:d,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 a=t.$.timelineTasksContainer.children,n=t.$.timelineConnectionsContainer;let s,r=[];if(a.length){const n=a[0],o=(()=>{let e=[];for(let t=0,n=a.length;t<n;t+=1)e.push(i.indexOf(a[t]._cellObj.task));return e})(),l=n.querySelector(".smart-task-connection-point."+(t.rightToLeft?"end":"start")),d=t._baselineProportion,c=t.showBaseline?t._taskDefaultHeight/d:0;s={top:l.offsetTop,width:l.offsetWidth},s.offset=Math.abs(l.offsetLeft)-s.width;for(let a=0,n=e.length;a<n;a+=1){const n=e[a],l=n.startIndex,d=n.endIndex;if(o.indexOf(l)<0&&o.indexOf(d)<0)continue;const m=i[l],u=i[d],{vCellStart:h,vCellEnd:g}=t._getTasksVCell(m,u);if(!h||!g)continue;const f=n.type,p={start:{width:s.width,top:s.top,index:l,task:m},end:{width:s.width,top:s.top,index:d,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-c),"milestone"===u.type&&(T.width=h.height-c),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-c,_.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(n.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 a,n;for(let s=0,r=i.length;s<r;s+=1){const r=i[s];if(r.task===e&&(a=r),r.task===t&&(n=r),a&&n)break}return{vCellStart:a,vCellEnd:n}}_isAutoScheduled(e,t,i){const a=this,n=a._tasks;let s={};if(a.autoSchedule)return e instanceof HTMLElement&&(e=e._cellObj.task),t instanceof HTMLElement&&(t=t._cellObj.task),function e(t,r){const o=a._getTaskConnections().taskConnections,l=n.indexOf(t);s[l]=!0;for(let t=0;t<o.length;t++){const d=o[t],c=d.endIndex;if(c===r)return i&&a._removeConnection(l+"-"+c+"-"+d.type,!0),!0;if(!s[c]&&e(n[c],r))return!0}}(t,n.indexOf(e))}_setConnectionDetails(e,t){const i=this;if(!i._connectionDetails)return;const a=i._connectionDetails,n=a.start,s=a.end,r=a.type;if(!n||!s)return;let o,l=e.width,d=t.width,c=e.left,m=t.left,u=e.top,h=t.top,g=n.left,f=s.left;const p=n.index,_=s.index;if("milestone"===e.type&&(l=e.height,c-=l/2),"milestone"===t.type&&(d=t.height,m-=d/2),a.id=p+"-"+_+"-"+r,!a.connectionStartOffset||!a.connectionEndOffset){switch(r){case 0:g=Math.abs(g)-n.width,f=Math.abs(f)-s.width;break;case 1:g-=l,f=Math.abs(f)-s.width;break;case 2:g-=l,f-=d;break;default:g=Math.abs(g)-n.width,f-=d}a.start.offset=g+=n.width/2,a.end.offset=f+=s.width/2}if(0===r&&c>m||1===r&&c+l+g>m-f&&h>u||2===r&&m+d>c+l||3===r&&(c-g<m+d+f&&h>u||c-g>m+d+f&&u>h)){o=!0;let i=e;e=t,t=i,i=g,g=f,f=i,i=l,l=d,d=i,i=c,c=m,m=i,i=u,u=h,h=i}let T=c,b=m;!o&&1===r||o&&3===r?T+=l:!o&&3===r||o&&1===r?b+=d:2===r&&(T+=l,b+=d);let k=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+p+"-"+_+'-"]');0===k.length&&(k=i.$.timelineConnectionsContainer.querySelectorAll('.smart-task-connection[connection-id^="'+_+"-"+p+'"]')),a.connections=[].slice.call(k),a.start.x=T,a.start.y=u+n.top,a.end.x=b,a.end.y=h+s.top,a.type=r,a.inverted=o}_createTaskConnection(){const e=this,t=e._connectionDetails;if(!t)return;const i=2*e._taskConnectionWidth,a=t.start.x,n=t.start.y,s=t.start.offset,r=t.start.top,o=t.end.x,l=t.end.y,d=t.end.offset,c=t.type,m=t.inverted,u=!m&&3===c||m&&1===c,h=!m&&1===c||m&&3===c;let g,f,p,_=a,T=o;u?(_=a-d,T=o+d):h&&(_=a+s,T=o-d);const b=_<=T&&u,k=_>=T&&h,y=2===c||h;!function d(u){g!==o&&(u?"horizontal"===u?(p=g-o+(b?-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,d("vertical")):(p=Math.abs(f-l),f+=n<l?0:-1*p,g-=m&&1===c||!m&&3===c&&n>l?i:0,e._createConnectingElement(g,f,p,"vertical"),d()):(g?(p=Math.abs(g-o),g>=o&&(g+=-1*p,p+=i),e._createConnectingElement(g,f+(n<l?Math.abs(f-l):0),p,"horizontal",!t.inverted),g=o):(g=a,f=n,(0===c||!m&&3===c||m&&1===c)&&(g-=s),e._createConnectingElement(g,f,s,"horizontal",t.inverted),y&&(g+=s-i),b||k?(e._createConnectingElement(g,f-=n>l?r:0,r,"vertical"),f+=n<l?r:0):d("vertical")),d("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,a=t.length;i<a;i+=1)if(t[i].id===e)return i;return-1}_refreshTaskConnections(e){const t=this,i=e instanceof HTMLElement?e._cellObj.task:e,a=t._tasks.indexOf(i);if(void 0===a||e.classList&&e.classList.contains("smart-visibility-hidden"))return;let n;if(t._dragDetails&&(n=t._dragDetails.relatedConnections[a]),!n){n=[];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!==a&&i.endIndex!==a||n.push(i)}t._dragDetails&&(t._dragDetails.relatedConnections[a]=n)}t._recycleConnections(n)}_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 a,n;for(let t=0;t<e.length;t++){const s=e[t];if(s.left+s.width>i){a=s;break}n=s}return!a&&n&&(a=i>n.left?n:e[0]),a}_getFirstContentCellInView(e="task"){const t=this;let i,a,n,s;if("task"===e?(i=t._timelineVCells,a=t.scrollTop):(i=t._timelineResourceVCells,a=t.$.resourceVerticalScrollBar.value),!i)return 0;for(let e=0;e<i.length;e++){const t=i[e];if(t.top+t.height>a){n=t;break}s=t}return!n&&s&&(n=a>s.left?s:i[0]),n}_getProjectTasks(e,t){const i=this,a=i.groupByResources&&e.isGroup?"group":"project",n=i._tasks;if(!e||"project"!==e.type)return[];let s=[];for(let r=0,o=n.length;r<o;r+=1){const o=n[r];o.$[a]===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,a=t._getProjectTasks(i);let n,s;if(!a.length)return;let r=a[0],o=a[0];for(let e=0;e<a.length;e++){const t=a[e];a[e].dateEnd&&a[e].dateStart&&(r.dateStart||(r=t[e]),o.dateEnd||(o=t[e]),a[e].dateEnd.getTime()>o.dateEnd.getTime()&&(o=a[e]),a[e].dateStart.getTime()<r.dateStart.getTime()&&(r=a[e]))}const l=t.$.timelineContent.offsetWidth;let d,c,m;if(r&&(d=t._getTimelineSubTaskOffset(r),d&&(c=d.left,m=d.width,n=Math.max(0,t.rightToLeft?l-e.offsetLeft-e.offsetWidth-(l-c-m):e.offsetLeft-c))),o&&(d=t._getTimelineSubTaskOffset(o),d))if(c=d.left,m=d.width,t.rightToLeft){const t=l-e.offsetLeft-e.offsetWidth;s=Math.max(t,t+l-(l-c))}else s=Math.max(e.offsetLeft,e.offsetLeft+l-(c+m));return{min:n,max:s}}_getTimelineSubTaskOffset(e){const t=this,i=t.$.timelineTasksContainer.children[t._tasks.filter((e=>!e.hidden)).indexOf(e)];let a,n,s;if(i)a=i.offsetLeft,s=i.offsetWidth;else{const i=t._getTimelineTaskCellByDate(e.dateStart),r=t._getTimelineTaskCellByDate(e.dateEnd);i&&(a=i.left+t._getTimelineTaskOffset(i,e.dateStart)||0),r&&(n=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0),s=n-a}return{left:a,width:s}}_getTaskDragLimits(e){const t=this,i=t._dragDetails,a=i.segment?i.segment.element:void 0,n=a&&a.previousElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateStart"),s=a&&a.nextElementSibling?{}:t._getTaskBarPositionLimits(e._cellObj.task,"DateEnd"),r=t._dragDetails.taskDimensions;let o={};return(n.min||s.min)&&(o.min=Math.max(n.min||0,Math.max(0,(s.min||0)-r.width))),s.max&&(o.max=Math.max(0,s.max-r.width)),n.max&&(o.max=o.max?Math.min(n.max,o.max):n.max),o}_getTaskBarDateRange(e){if(!e)return;const t=this,i=e.classList.contains("milestone"),a=parseFloat(e.style.width)||e.offsetWidth,n=i?a/2:a,s=t.rightToLeft?parseFloat(e.style.right)||t.$.timelineContent.offsetWidth-e.offsetLeft-n:parseFloat(e.style.left)||e.offsetLeft,r=e._cellStart,o=e._cellEnd,l=e._cellObj.task,d=l.minDateStart,c=l.maxDateEnd;let m,u;return m=t._getDateFromCell(s,r),!d||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(m=new Date(Math.max(d.getTime(),m.getTime()))),u=i?new Date(m):t._getDateFromCell(s+n,o),!c||"project"===e._cellObj.task.type&&e._cellObj.task.synchronized||(u=new Date(Math.min(c.getTime(),u.getTime()))),{dateStart:m,dateEnd:u}}_getTaskBarDetails(e,t,i){const a=this,n=e.task;if(!e)return;let s=new Date(n.dateStart);const r=new Date(n.dateEnd);if(!a._dragDetails&&a.snapToNearest){let s,r,o=n.dateStart,l=n.dateEnd;const d=new Date(t.date),c=a._getDateFromCell(t.left+t.width,t),m=new Date(i.date),u=a._getDateFromCell(i.left+i.width,i);return s=c.getTime()-o.getTime()>=c.getTime()-d.getTime()?t.left:t.left+t.width,"milestone"!==n.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,d,c,m,u;switch(a.view){case"quarter":case"year":{d=new Date(s.getFullYear(),s.getMonth()+1,0).getDate(),c=new Date(r.getFullYear(),r.getMonth()+1,0).getDate();const e=s.getHours()/24+s.getMinutes()/1440+s.getSeconds()/86400,a=r.getHours()/24+r.getMinutes()/1440+r.getSeconds()/86400;o=t.left+(s.getDate()-1+e)/d*t.width,l=i.left+(r.getDate()-1+a)/c*i.width-o;break}case"month":"day"===a.monthScale?(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):(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"===n.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 a=e.dateStart,n=e.dateEnd;const{cellStart:s,cellEnd:r}={cellStart:i._getTimelineCellByDate(a),cellEnd:i._getTimelineCellByDate(n)},o=new Date(s.date),l=i._getDateFromCell(s.left+s.width,s),d=new Date(r.date),c=i._getDateFromCell(r.left+r.width,r);if(a=l.getTime()-a.getTime()>=l.getTime()-o.getTime()?o:l,"milestone"!==e.type&&(n=c.getTime()-n.getTime()>=c.getTime()-d.getTime()?d:c),e.dateEnd=n,n.getTime()<a.getTime()&&(a=new Date(n)),e.dateStart=a,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,a=t.length;e<a;e+=1)i._snapToNearestDates(t[e],!0);i._validateTaskSegments(e)}}_getTimelineTaskCellByDate(e){if(!e)return;let t=this,i=t.view,a=t._timelineCells;"month"===i&&"day"===t.monthScale&&(i="day");for(let n=0;n<a.length;n++){const s=a[n];if(t._isDateInCell(s.date,e,i))return s}}_isDateInCell(e,t,i){const a=this;switch(i){case"quarter":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("hour"!==a.dayScale){if(e.getYear()===t.getYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()&&e.getHours()===t.getHours()&&e.getMinutes()===t.getMinutes())return!0}else 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[a,n,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!==a.size?a.style[i._measurements.dimension]:t.treeSize;a.size="",i.removeChild(n),t.inverted&&!t.rightToLeft||!t.inverted&&t.rightToLeft?i.insertBefore(n,a):i.appendChild(n),a.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 a=e._timelineResourceVCells.length*i;e.$.resourceTimelineCellsContainer.style.height=a+"px",e.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",a+"px"),e._recycleResourceContent()}_recycleResourceContent(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e._timelineResourceVCells,i=e.$.resourceTimelineCellsContainer,a=e._getFirstContentCellInView("resource"),n=e.$.tooltip;if(n&&i.contains(n.selector)&&e._closeTooltip(),!a)return void(i.innerHTML="");const s=t.indexOf(a),r=a.height,o=1-(a.top+r-Math.abs(e.$.resourceVerticalScrollBar.value))/r,l=t?t.length:0,d=!e.$.resourceSplitter.offsetHeight,c=e.$.resourceTimelineContent.offsetHeight,m=!d&&c?Math.min(l,Math.ceil((parseFloat((c/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 a=t[s+i],n=f[i];if(!a){n&&n.remove();continue}const r=a.resource,o=r.$.id;p.indexOf(o)>-1?n.setAttribute("selected",""):n.removeAttribute("selected"),n._cellObj=a,n.setAttribute("row-id",o),n.style.top=a.top+"px",e._refreshResourceTimelineContent(r,n)}}_createResourceTimelineVCells(e){const t=this,i=t._resources,a=t.$.resourceTable.rows,n=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=a.length;t<r;t+=1){const r=i[a[t].data.itemIndex];r.hidden||(n.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)),a=e.$.mainSplitter,n=e.$.resourceSplitterItem,s=e.$.taskSplitterItem;if(!i||!i.length||e.hideResourcePanel)return n&&!n.size&&(n._size=n.style[a._measurements.dimension]),e._resourceScrollView&&(e._resourceScrollView.unlisten(),delete e._resourceScrollView),s.size="",s.min="",e.$.resourceTable&&e.$.resourceTable.clearSelection(),a.contains(n)&&(a.removeChild(n),e._refresh()),e._highlightAssignedItem("resource"),void t.removeAttribute("show-resource-panel");a.contains(n)||(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 a=Smart.Utilities,n=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,d,c,m,u,h,g,f]=n;e.$.resourceSplitterItem=i,e.$resourceSplitterItem=a.Extend(i),e.$.resourceSplitterItemHeader=s,e.$resourceSplitterItemHeader=a.Extend(s),e.$.resourceSplitter=r,r.hasResizeObserver=!1,r.wait=!1,e.$resourceSplitter=a.Extend(r),e.$.resourceTableItem=o,e.$resourceTableItem=a.Extend(o),e.$.resourceTable=l,l.hasResizeObserver=!1,e.$resourceTable=a.Extend(l),e.$.resourceTimelineSplitterItem=d,e.$resourceTimelineSplitterItem=a.Extend(d),e.$.resourceTimelineViewCells=u,e.$resourceTimelineViewCells=a.Extend(u),e.$.resourceTimeline=c,e.$resourceTimeline=a.Extend(c),e.$.resourceTimelineContent=h,e.$resourceTimelineContent=a.Extend(h),e.$.resourceTimelineHeader=m,e.$resourceTimelineHeader=a.Extend(m),e.$.resourceTimelineCellsContainer=g,e.$resourceTimelineCellsContainer=a.Extend(g),e.$.resourceVerticalScrollBar=f,e.$resourceVerticalScrollBar=a.Extend(f)}}_setupResourcePanel(){const e=this,t=e.rightToLeft,i=e.$.resourceSplitterItem,a=e.$.resourceTableItem,n=e.$.resourceTable,s=e.$.resourceTimelineSplitterItem,r=e.$.resourceVerticalScrollBar;e.$.mainSplitter.contains(i)?([e.$.resourceSplitter,n,e.$.resourceVerticalScrollBar].forEach((e=>e.rightToLeft=t)),n.$.virtualizationContainer._scrollView.disableSwipeScroll=!0,n.$.virtualizationContainer.verticalScrollBarVisibility="hidden",n.$.virtualizationContainer.disabled=!0,a.size=e.treeSize,a.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,a=e.dateEnd,n=t.dateStart,s=t.dateEnd,r=e.dateStart.getTime()<n.getTime()?n:i,o=a.getTime()>s.getTime()?s:a,l=Math.round(this._getWorkingTime(r,o)/36e5);return{value:Math.max(0,l),max:r.getTime()===n.getTime()&&o.getTime()===s.getTime()?l:Math.round(this._getWorkingTime(n,s)/36e5)}}_refreshResourceTimelineContent(e,t){const i=this,a=i._resources.indexOf(e),n=i._getResourceTasks(e);if(t||(t=(()=>{const t=i.$.resourceTimelineCellsContainer.children;for(let i=0,a=t.length;i<a;i+=1){const a=t[i];if(a._cellObj&&a._cellObj.resource===e)return a}})()),a<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 d,c=l.firstElementChild;n.length&&!e.hidden?(c?(c.classList.remove("hide-left-border","hide-right-border"),c.removeAttribute("load"),c.innerHTML=c.style.height=""):(c=document.createElement("div"),c.classList.add("smart-resource-timeline-view-cell"),d=!0),e.class&&c.classList.add(e.class),i._setResourceCellLoad({cell:c,cellIndex:t,resource:e,resourceCell:l,resourceIndex:a,resourceTasks:n,tasks:o,viewCells:r}),c.hasAttribute("load")?d&&l.appendChild(c):c.remove()):c&&c.remove()}}_setResourceCellLoad(e){const t=this,i=t.resourceTimelineFormatFunction,{cell:a,cellIndex:n,resource:s,resourceCell:r,resourceIndex:o,resourceTasks:l,tasks:d,viewCells:c}=e;let m={};for(let e=0,u=l.length;e<u;e+=1){const u=l[e];if(u.hidden)continue;const h=d.indexOf(u),g=t._getCellDateRange(c[n]),{dateStart:f,dateEnd:p}=g;if(!f||f.getTime()>=u.dateEnd.getTime()||p.getTime()<=u.dateStart.getTime())continue;if(m[n]&&m[n].indexOf(h)<0?m[n].push(h):m[a]||(m[n]=[h]),"custom"===t.resourceTimelineMode){i&&(a.innerHTML=i.call(t,m[n]||[],o,new Date(f))||"");continue}const _=t._getResourceCellCapacity({cell:a,cellDateRange:g,cellTaskIndexAssigned:m,index:o,resource:s,task:u,cellIndex:n});if(!_)continue;const{capacity:T,maxCapacity:b}=_,k=parseFloat(((parseFloat(a.getAttribute("load"))||0)+(T||0)).toFixed(1));k>b?a.classList.add("warning"):a.classList.remove("warning"),"histogram"!==t.resourceTimelineMode?k&&a.setAttribute("load",k):t._setCellHistogram({cell:a,load:k,maxCapacity:b,previousViewCell:r.previousElementSibling})}}_getResourceCellCapacity(e){const t=this,i=t.resourceTimelineView,{cell:a,cellDateRange:n,cellTaskIndexAssigned:s,index:r,resource:o,task:l,cellIndex:d}=e;let c,m;if("tasks"===i)c=1,m=o.maxCapacity;else if("hours"===i){const e=t._getResourceCellWorkTime(l,n),i=e.max/24;c=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[d]||[],r,new Date(n.dateStart));if(null!=i)if(i="object"!=typeof i?[i]:Object.values(i),2===i.length)c=parseFloat(i[0])||0,m=parseFloat(i[1])||0;else if(1===i.length)return void(a&&a.setAttribute("load",i[0]))}return{capacity:c,maxCapacity:m}}_setCellHistogram(e){const{load:t,cell:i,maxCapacity:a,previousViewCell:n}=e,s=Math.min(100,100*parseFloat((t/a).toFixed(2))),r=n?n.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+"/"+a)}_recycleResourceHeaderCells(){const e=this;if(!e.$.mainSplitter.contains(e.$.resourceSplitterItem))return;const t=e.$.resourceTimelineViewCells,i=t.children,a=e.$.timelineViewCells.children;let n=document.createDocumentFragment();for(;i.length>a.length;)i[0].remove();for(let e=0;e<a.length;e++){const t=a[e];let s=i[e];s||(s=t.cloneNode(!0),n.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")}n.childElementCount&&t.appendChild(n),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 a=i[e].resources;Array.isArray(a)||(a=[a].reduce(((e,t)=>e.concat(t)),[]));for(let n=0;n<a.length;n++){let s=a[n];if("object"!=typeof s||!s||void 0===s.id||null===s.id){"number"==typeof s&&(a[n]=s+"");continue}let r=t._resources.find((e=>e.id&&e.id.toString()===s.id.toString()))||{};t._setResource(r,s,i[e]),a[n]=r.id,Object.values(r).length&&!t._resources.includes(r)&&t._resources.push(r)}}t._refreshItemIds("resource");const a=t._resources;for(let e=0,i=a.length;e<i;e+=1)t._refreshResource(a[e])}_refreshAssignedResources(e,t=[]){const i=this;if(!e.$.id||i._tasks.indexOf(e)<0)return;const a=i._getTaskResources(e);for(let e=0;e<a.length;e++){const n=a[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(n),t.includes("workload")?i._refreshResource(n,"workload"):t.includes("progress")&&i._refreshResource(n,"progress"),s.length&&i._refreshTableColumnsData(n,s,"resource")}}_refreshResource(e,t){const i=this;if(!i._resources.length)return;const a=i._getResourceTasks(e),n=864e5;switch(t){case"progress":e.progress=parseFloat((a.reduce(((e,t)=>e+t.progress),0)/a.length).toFixed(2));break;case"workload":e.workload=parseFloat((i._convertDuration(a.reduce(((e,t)=>e+t.duration),0))/n*e.maxCapacity).toFixed(2));break;default:e.progress=parseFloat((a.reduce(((e,t)=>e+t.progress),0)/a.length).toFixed(2)),e.workload=parseFloat((i._convertDuration(a.reduce(((e,t)=>e+t.duration),0))/n*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,a=Array.from(arguments).filter((e=>void 0!==e));let n,s=i._resources;if(1===a.length&&(t=a[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&&(n=[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!==n){Array.isArray(n)||(n=[n]);for(let e=0,a=n.length;e<a;e+=1){const a=i._getValidItemAndIndex(n[e],"task");if(a){const e=a.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 a=this,n=a.$.resourceTimelineCellsContainer,s=document.createElement("div");s.classList.add("smart-timeline-row"),s._resource=t,a._refreshResourceTimelineContent(t,s),a.$.resourceTimelineCellsContainer.insertBefore(s,e>-1?n.children[e]:void 0),a.$.container.style.setProperty("--smart-gantt-chart-resource-timeline-content-height",n.offsetHeight+"px"),a._refreshResourceScrollBar(),a._insertNewTreeItem(e,t,i,"resource"),a.$.resourceTree.refresh(),a._highlightAssignedItem("task",a._getSelection("task",a.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 a=[];for(let t=0;t<i.length;t++)i[t].resources.includes(e.id)&&a.push(i[t]);return a}_getTaskResources(e){const t=this;if(!e)return[];const i=[e.resources].reduce(((e,t)=>e.concat(t)),[]);let a=[];for(let e=0;e<i.length;e++){const n=t._resources.find((t=>t.id&&t.id.toString()===i[e].toString()));n&&a.push(n)}return a}_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,a=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:n,width:s}=a.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(n+t._dragDetails.offset.x,Math.min(n+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,a),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,a=i.segment,n=a.element,s=n._segmentObj;if(!s||s.disableDrag)return;const r=i.task,o=t._dragDetails.timelineTask,l=a.isFirstSegment,d=a.isLastSegment,c=t.rightToLeft,m=c?"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||d){const e=t._createDelimiter("min-date"),i=t._createDelimiter("max-date");e&&u.appendChild(e),i&&u.appendChild(i)}}if(l){const a=i.size?i.size.width:i.originalSize.width;t._handleTaskResize(e,c?"right":"left"),i.segments||(i.segments=o.querySelectorAll(".smart-task-segment"));const n=i.size.width-a,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)+n+"px")}}else{if(!d)return void t._handleSegmentDrag(e);{const s=a.dimensions;t._handleTaskResize(e,c?"left":"right"),n.style[m]=i.size.width-s.width+"px"}}t._refreshTask(o,[n]),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,a=i.segment,n=a.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 d=i.timelineRow,{left:c}=d.getBoundingClientRect(),m=i.taskDimensions.left;a.position||(a.position={x:a.originalPosition.x});const u=r.offsetWidth,h=e.pageX-window.pageXOffset;let g=0,f=a.min.left||0,p=a.max.left;o&&(f=u-(f+a.dimensions.width),p=u-p),a.position.x=Math.max(f,Math.min(p,a.position.x+(o?-1:1)*(h-i.coordinates.x))),void 0!==p&&(g=o?m+a.min.left:m+a.max.left,a.position.x=Math.min(p,a.position.x)),f=m+(o?a.max.left-a.dimensions.width:f),i.coordinates.x=Math.max(c+a.offset.x+f,Math.min(c+a.offset.x+g,h)),n.style[l]=a.position.x+"px",t._refreshTaskSegments(r,[n])}_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 a=i.task,n=i.timelineTask;i.timelineRow||(i.timelineRow=Array.from(t.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===a)));const s=i.timelineRow;if(!t.hasAttribute("dragged")){if(t.$.fireEvent("dragStart",{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 delete i.timelineTask;t.setAttribute("dragged",""),t._closeTooltip(),t._touchmoveInside=!0;const e=t._createDelimiter("min-date"),n=t._createDelimiter("max-date");e&&s.appendChild(e),n&&s.appendChild(n)}i.position||(i.position={x:i.originalPosition.x,y:i.originalPosition.y});const r=s.getBoundingClientRect().left,o=s.offsetWidth,l=n.offsetWidth,d=i.min.left||0,c=i.max.left,m=e.pageX-window.pageXOffset,u=t.rightToLeft;let h=0;i.position.x=Math.max(d,Math.min(o-l,i.position.x+(u?-1:1)*(m-i.coordinates.x))),void 0!==c&&(i.position.x=Math.min(c,i.position.x),h=o-l-c),i.coordinates.x=u?Math.max(r+i.offset.x+h,Math.min(r+o-(l-i.offset.x+d),m)):Math.max(r+i.offset.x+d,Math.min(r+o-(l-i.offset.x+h),m));const g=a.dateStart.getTime(),f=a.dateEnd.getTime();n.style[u?"right":"left"]=i.position.x+"px",t._refreshTask(n),t._refreshProject(a.$.project),t.groupByResources&&t._refreshProject(a.$.group),"project"===a.type&&a.dragProject&&t._refreshProjectTasks(a,{startTime:a.dateStart.getTime()-g,endTime:a.dateEnd.getTime()-f}),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(n._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 a=i.timelineTask,n=i.task;if(!t.hasAttribute("resized")){if(t.$.fireEvent("resizeStart",{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 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(a),t._refreshProject(n.$.project),t.groupByResources&&t._refreshProject(n.$.group),clearTimeout(t._resourceTreeRefreshTimeout),t.$.mainSplitter.contains(t.$.resourceSplitter)&&(t._resourceTreeRefreshTimeout=setTimeout((function(){t._refreshAssignedResources(a._cellObj.task,["workload"]),delete t._resourceTreeRefreshTimeout}),t.resourcePanelRefreshRate))}_updateSegmentsOnTaskResize(){const e=this,t=e._dragDetails,i=t.task,a=t.timelineTask;if(!i||!i.segments)return;let n;t&&t.segments?n=t.segments:t.segments=n=a.querySelectorAll(".smart-task-segment");const s=n.length,r=t.size.width,o=e.rightToLeft?"right":"left";for(let t=0;t<s;t+=1){const i=n[t],a=i.style.width?parseFloat(i.style.width):i.offsetWidth,l=i.style[o]?parseFloat(i.style[o]):0;if(l+a>r){const t=r-(l+a),n=a+t;n<e._taskBarMinWidth&&(i.style[o]=l+t+"px"),i.style.width=n+"px"}else t===s-1&&(i.style.width=r-l+"px")}}_handleTaskSegmentResize(e){const t=this,i=t._dragDetails,a=i.segment,n=a.element,s=n._segmentObj;if(!s||s.disableResize)return;const r=i.task,o=t._dragDetails.timelineTask,l=a.isFirstSegment,d=a.isLastSegment,c=t.rightToLeft,m=c?"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&&!c||"right"===u&&c)){const s=i.size?i.size.width:i.originalSize.width;void 0===a.size&&(a.size={width:a.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")}n.style.width=(a.size.width+=r)+"px"}else{if(!d||!("right"===u&&!c||"left"===u&&c))return t._handleSegmentResize(e,u),void t._refreshTaskSegments(o,[n]);{const s=i.size?i.size.width:i.originalSize.width;void 0===a.size&&(a.size={width:a.originalSize.width}),t._handleTaskResize(e,u),n.style.width=(a.size.width+=i.size.width-s)+"px"}}t._refreshTask(o,[n]),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,a=i._dragDetails,n=a.task,s=a.segment,r=s.element,o=i.rightToLeft,l=a.taskDimensions.left;a.timelineRow||(a.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const d=a.timelineRow;s.position||(s.position={x:s.originalPosition.x}),s.size||(s.size={width:s.originalSize.width});const c=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:_}=d.getBoundingClientRect(),T="object"==typeof e?c-a.coordinates.x:e;if(_+=l,"left"===t&&!o||"right"===t&&o)if(o){const e=a.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)||d.offsetWidth-p-m)-T))+"px",a.coordinates.x=Math.max(_+e-p+u,Math.min(_+e-p,c))}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",a.coordinates.x=Math.max(_+g+u,Math.min(_+p+m-u,c));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,a.coordinates.x=Math.max(_+f,Math.min(_+f+h,c))):(T>0&&(T=Math.min(h-m,T)),m=Math.max(u,Math.min(h,m+T)),a.coordinates.x=Math.max(_+p+u,Math.min(_+p+h,c)));r.style.width=(s.size.width=m)+"px"}_handleTaskResize(e,t){const i=this,a=i._dragDetails,n=a.task;a.position||(a.position={x:a.originalPosition.x,y:a.originalPosition.y}),a.size||(a.size={width:a.originalSize.width}),a.timelineRow||(a.timelineRow=Array.from(i.$.taskTimelineCellsContainer.children).find((e=>e._cellObj.task===n)));const s=a.timelineRow,r=a.timelineTask,o=a.segment,l=e.pageX-window.pageXOffset;let d=a.size.width,c=a.min.width||0,m=a.max.width,u=s.getBoundingClientRect().left,h=i.rightToLeft,g="object"==typeof e?l-a.coordinates.x:e;if("left"===t&&!h||"right"===t&&h)if(o&&(h?(u-=o.dimensions.width-o.offset.x,c=Math.max(o.max.left+o.min.width,c)):(u+=o.offset.x,c=Math.max(a.taskDimensions.width-o.max.left+o.min.width,c))),h){g<0?g=-1*Math.min(Math.abs(g),d-(c||0)):void 0!==m&&(g=Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(s.offsetWidth-r.offsetLeft,d+g));const e=r.offsetLeft;r.style.left="",r.style.right=(a.position.x=Math.max(0,(parseFloat(r.style.right)||s.offsetWidth-r.offsetLeft-r.offsetWidth)-g))+"px",a.coordinates.x=Math.max(u+r.offsetLeft+c,Math.min(u+e+d,l))}else g>0?g=Math.min(g,d-(c||0)):void 0!==m&&(g=-1*Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(r.offsetLeft+d,d-g)),r.style.right="",r.style.left=(a.position.x=Math.max(0,(parseFloat(r.style.left)||r.offsetLeft)+g))+"px",a.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+d-c,l));else h?(o&&(u+=o.offset.x,c=Math.max(a.taskDimensions.width-o.min.left+o.min.width,c)),g<0&&void 0!==m&&(g=-1*Math.min(m-d,Math.abs(g))),d=a.size.width=Math.max(c,Math.min(r.offsetLeft+r.offsetWidth,d-g)),r.style.width=a.size.width+"px",a.coordinates.x=Math.max(u+r.offsetLeft,Math.min(u+r.offsetLeft+d-c,l))):(o&&(u-=o.dimensions.width-o.offset.x,c=Math.max(o.min.left+o.min.width,c)),g>0&&void 0!==m&&(g=Math.min(m-d,g)),d=a.size.width=Math.max(c,Math.min(s.offsetWidth-r.offsetLeft,d+g)),a.coordinates.x=Math.max(u+r.offsetLeft+c,Math.min(u+r.offsetLeft+(m||d),l)));r.style.width=a.size.width+"px"}_handleTimelineConnectionHover(e){const t=this;if(!(t.shadowRoot||t).contains(e))return;const i=t.$.timelineConnectionsContainer.children,a=e.closest(".smart-task-connection");if(a||!t.$.timelineConnectionsContainer.querySelector(".smart-task-connection[hover]")){if(a){const e=a.getAttribute("connection-id");for(let t=0;t<i.length;t++){const a=i[t];a.getAttribute("connection-id")===e?a.setAttribute("hover",""):a.removeAttribute("hover")}t._hoveredConnectionTasks=a.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,a=i._isMobile;if(!e||a)return void i._resetItemHover();const n=e.originalEvent||e;let s="task",r=n.pageX&&a?document.elementFromPoint(n.pageX-window.pageXOffset,n.pageY-window.pageYOffset):n.target;if(n.pageX&&i.shadowRoot&&r===i&&(r=n.pageX&&a?i.shadowRoot.elementFromPoint(n.pageX-window.pageXOffset,n.pageY-window.pageYOffset):n.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],d=l.$.id,c=i._hoveredItem;if(!(c&&c.type===s&&c.id===d||(i._resetItemHover(),l.isGroup||("task"===s&&o.classList.contains("smart-timeline-row")&&(o=i.$.timelineTasksContainer.querySelector(`.smart-timeline-task[row-id="${d}"]`)),!o||i._connectionFeedback&&o.contains(i._connectionFeedback)||(o.setAttribute("hover",""),i._hoveredItem={id:d,type:s},a))))){const e=("task"===s?i.$.taskTimelineCellsContainer:i.$.resourceTimelineCellsContainer).querySelector(`.smart-timeline-row[row-id="${d}"]`);e&&(e.setAttribute("hover",""),i._handleTableItemHover(d,r))}}_getScrollLeft(e){return this.rightToLeft?e*=-1:e}_synchronizeSplitters(e,t){if(this.$.mainSplitter.contains(this.$.resourceSplitter)){const i=e._measurements,a=e.items,n=t.items,[s,r,o]=[i.dimension,i.minDimension,i.maxDimension],[l,d]=[n[0],a[0]],[c,m]=[n[1],a[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,""),c.set(t,""),l[t]=d.style[e],c[t]=m.style[e]})),t.removeAttribute("orientation-change"),t.keepProportionsOnResize=!1}}_resizeEventHandler(e){const t=this,i=t.$.taskSplitter;function a(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 a(e.target);e.target===t.$.resourceSplitter&&t._synchronizeSplitters(t.$.resourceSplitter,i)}if(!t._timelineCells)return void t._refresh();t.$.mainSplitter.refresh(),a(i);const n=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=n,t.$.taskTable.scrollTop=t.$.taskTimelineContainer.scrollTop=t.scrollTop,t.$.mainSplitter.contains(t.$.resourceTimelineHeader)&&(t.$.resourceTimelineHeader.scrollLeft=t.$.resourceTimelineContent.scrollLeft=n,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.$.timelineViewSubDetails.classList.contains("smart-hidden")||t._recycleHeaderSubCells(t.$.timelineViewSubDetails),t._recycleResourceContent()),i)return;if(t._recycleResourceContent(),t._recycleContentCells(),t._recycleTimelineTasks(),!e)return;const a=Math.round(e.detail.value);e.target!==t.$.resourceVerticalScrollBar?t._refreshTableScrollTop(t.$.taskTable,a):t._refreshTableScrollTop(t.$.resourceTable,a)}_recycleContentCells(){const e=this,t=e._getFirstContentCellInView(),i=e.$.taskTimelineCellsContainer,a=e.$.timelineTasksContainer;if(!t)return void(i.innerHTML=a.innerHTML="");const n=t.height,s=1-(t.top+n-Math.abs(e.scrollTop))/n,r=e._timelineVCells?e._timelineVCells.length:0,o=!e.$.taskSplitter.offsetHeight,l=e.$.taskTimelineContainer.offsetHeight,d=!o&&l?Math.min(r,Math.ceil((parseFloat((l/n).toFixed(2))+s).toFixed(2))):r,c=e.$.timelineViewCells.children,m=document.createDocumentFragment();for(;i.childElementCount>d;)i.lastElementChild.remove();for(;a.childElementCount>d;)a.lastElementChild.remove();for(let t=i.childElementCount;t<d;t+=1){const t=document.createElement("div");t.classList.add("smart-timeline-row"),e._createTimelineRowCells(t,c),m.appendChild(t)}m.childElementCount&&i.appendChild(m);for(let e=a.childElementCount;e<d;e+=1){const e=document.createElement("div");e.classList.add("smart-timeline-task"),m.appendChild(e)}m.childElementCount&&a.appendChild(m)}_getCellIndexByDate(e){const t=this._timelineCells;let i=[];if(e&&e.length&&t){Array.isArray(e)||(e=[e]);for(let t=0,a=e.length;t<a;t+=1){const a=e[t];e[t]=a.getTime?a.getTime():a,i[t]=-1}for(let a=0,n=t.length;a<n;a+=1){const n=t[a],s=e.indexOf(n.date.getTime());if(s>-1&&(i[s]=a,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 a=e.$.timelineViewCells.children,n=a[0]._date,s=a[a.length-1]._date,[r,o]=e._getCellIndexByDate([n,s]);if(!n||!s)return;const l=n.getTime(),d=e._getCellDateRange({_date:s}).dateEnd.getTime(),c=t.children,[m,u]=e.rightToLeft?["right","left"]:["left","right"],h=document.createDocumentFragment();let g=0;for(let t=0,a=i.length;t<a;t+=1){const a=i[t],n=i[t].date,s=n.getTime();if(s<l||s>d)continue;const f=e._getTimelineCellByDate(n,r,o);if(f){const t=f.left+e._getTimelineTaskOffset(f,n),i=a.label,s=a.className;let r=c[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);c.length>g;)c[c.length-1].remove()}_refreshTableScrollTop(e,t){this.$.mainSplitter.contains(e)&&void 0!==t&&(e.scrollTop=t)}_recycleHeaderCells(e){let t=this,i=e.children,a=t.scrollLeft,n=e===t.$.timelineViewCells,s=n?t._timelineCells:t._timelineHeaderCells;if(e===t.$.timelineViewSubDetails&&(n=!1,s=t._timelineHeaderSubCells),!s.length)return;let r=document.createDocumentFragment();for(;i.length;)r.appendChild(e.firstElementChild);let o=t._getFirstCellObjInView(s),l=1-(o.left+o.width-Math.abs(a))/s[0].width,d=r.children.length,c=n?Math.ceil((parseFloat((t.$.timeline.offsetWidth/o.width).toFixed(2))+l).toFixed(2)):t._getHeaderVisibleCellsCount();if(e===t.$.timelineViewSubDetails&&(c=t._getHeaderSubVisibleCellsCount()),d>c)for(;r.children.length&&r.children.length!==c;)r.removeChild(r.firstElementChild);else if(d<c){const e=t._createCells(c-d);for(;e.children.length;)r.appendChild(e.firstElementChild)}const m=[t.rightToLeft?"right":"left"],u=n?t._getCellsViewType():t.view;let h=s.indexOf(o);for(let e=0;e<r.children.length;e++){const i=r.children[e],a=s[h];if(!a)break;let o=new Date(a.date);n||"week"!==t.view||(o.setDate(o.getDate()-o.getDay()),o=new Date(Math.max(a.date.getTime(),o.getTime()))),i.style[m]=a.left+"px",i.style.width=a.width+"px",i._date=o,i.innerHTML=`<div>${t._getDateString(o,u,!n)}</div>`,a.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),a.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),h++}e.appendChild(r),n&&(t._recycleTimelineRowCells(),t._recycleResourceHeaderCells(),t._recycleDateMarkers(),t._setTodayCell())}_recycleHeaderSubCells(e){let t=this,i=e.children,a=t.scrollLeft,n=t._timelineHeaderSubCells;if(!n.length)return;let s=document.createDocumentFragment();for(;i.length;)s.appendChild(e.firstElementChild);let r=t._getFirstCellObjInView(n),o=(r.left,r.width,Math.abs(a),n[0].width,s.children.length),l=t._getHeaderSubVisibleCellsCount();if(o>l)for(;s.children.length&&s.children.length!==l;)s.removeChild(s.firstElementChild);else if(o<l){const e=t._createCells(l-o);for(;e.children.length;)s.appendChild(e.firstElementChild)}const d=[t.rightToLeft?"right":"left"],c=t.view;let m=n.indexOf(r);for(let e=0;e<s.children.length;e++){const i=s.children[e],a=n[m];if(!a)break;let r=new Date(a.date);"week"===t.view&&(r.setDate(r.getDate()-r.getDay()),r=new Date(Math.max(a.date.getTime(),r.getTime()))),i.style[d]=a.left+"px",i.style.width=a.width+"px",i._date=r,i.innerHTML=`<div>${t._getDateString(r,c,!0)}</div>`,a.weekend?i.setAttribute("weekend",""):i.removeAttribute("weekend"),a.nonworking?i.setAttribute("nonworking",""):i.removeAttribute("nonworking"),m++}e.appendChild(s),t._refreshHeaderSubDetailsDate()}_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 a(){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 n=e.scrollWidth,s=e.scrollHeight;let r=i(),o=a();o&&s===o||(r=i()),r&&n===r||(o=a()),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,a=i._getProjectTasks(e);if(!a.length)return;const n=i.nonworkingDays,s=i.nonworkingHours,r=i._timelineVCells;for(let e=0,o=a.length;e<o;e++){const o=a[e];if(o){const e=i._getTaskDOMIndex(o),a=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(n.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)}a&&(i._recycleTaskBars(a,e),i._setTimelineTaskBar(a,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,a,n;if(e instanceof HTMLElement)i=e.offsetLeft,n=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,a=r.left+t._getTimelineTaskOffset(r,e.dateEnd)||0,n=a-i)}return[i,n]}if(!e)return;const a=t.groupByResources&&e.isGroup?"group":"project";if(e.synchronized)for(;e&&e.synchronized;){const n=t._getProjectTasks(e);let s=n[0],r=n[0];for(let e=0;e<n.length;e++)s.dateStart.getTime()>=n[e].dateStart.getTime()&&(s=n[e]),r.dateEnd.getTime()<=n[e].dateEnd.getTime()&&(r=n[e]);const o=t.$.timelineTasksContainer.children,l=t.$.timelineContent.offsetWidth;let d,c,m;for(let t=0,i=o.length;t<i;t+=1){const i=o[t],a=i._cellObj?i._cellObj.task:void 0;a&&(a===e?d=i:a===s?c=i:a===e&&(m=i))}if(!d){s&&(e.dateStart=s.dateStart),r&&(e.dateEnd=r.dateEnd),e=e.$[a];continue}s&&(e.dateStart=s.dateStart);let[u,h]=i(c||s);void 0!==u&&void 0!==h&&(t.rightToLeft?(d.style.width=d.offsetWidth-(l-u-h-(l-d.offsetLeft-d.offsetWidth))+"px",d.style.right=c?c.style.right:u+"px"):(d.style.width=d.offsetWidth-(u-d.offsetLeft)+"px",d.style.left=c?c.style.left:u+"px")),r&&(e.dateEnd=r.dateEnd),[u,h]=i(m||r),void 0!==u&&void 0!==h&&(t.rightToLeft?d.style.width=Math.max(0,d.offsetWidth-(l-d.offsetLeft-(l-u)))+"px":d.style.width=Math.max(0,d.offsetWidth-(d.offsetLeft+d.offsetWidth-(u+h)))+"px"),t._refreshTask(d),e=e.$[a]}else t._refreshProject(e.$[a])}_refreshTask(e,t){const i=this,a=i._getTaskBarCellRange(e),n=a.cellStart,s=a.cellEnd;if(!a||!n||!s)return;e._cellStart=n,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 a;e.classList.contains("task")?t&&t.segments?a=t.segments:t.segments=a=e.querySelectorAll(".smart-task-segment"):a=e.querySelectorAll(".smart-task-segment"),i._refreshTaskSegments(e,a)}i._refreshTableColumnsData(o,["dateStart","dateEnd","duration","overdue"])}}_refreshTaskSegments(e,t){const i=this,a=e._cellObj.task;if(!a||!a.segments||!a.segments.length)return void i._setTaskBarDeadline(a,t?t[0]:void 0);const n=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 a=0,d=t.length;a<d;a+=1){const d=t[a],c=d._segmentObj,m=i._getSegmentCellRange(d),u=m.cellStart,h=m.cellEnd;if(!m||!u||!h)continue;const g=parseFloat(d.style.width)||d.offsetWidth,f=o+parseFloat(d.style[r])||(s?(parseFloat(e.style.width)||e.offsetWidth)-(d.offsetLeft+d.offsetWidth):d.offsetLeft);d._cellStart=u,d._cellEnd=h,l=d;let p=i._getDateFromCell(f,u),_=i._getDateFromCell(f+g,h);c.dateStart=p,c.dateEnd=_,c.duration=i._convertDuration(n?i._getWorkingTime(p,_):_.getTime()-p.getTime(),!0),e.setAttribute("aria-label",(c.label||"")+" Start date: "+i._toISODate(p)+", End date: "+i._toISODate(_))}i._setTaskBarProgress(a,e),i._setTaskBarDeadline(a,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 a=t[e];i._refreshResource(a),i._refreshTableColumnsData(a,void 0,"resource")}}_refreshTableColumnsData(e,t,i){const a=this;if(i||(i="task"),!e)return;const n=a[`${i}Columns`],s=a.$[`${i}Table`];if(!a.$.mainSplitter.contains(s))return;const r=e.$.id;t=t?t.map((e=>n.find((t=>t.value===e)))):n;for(let i=0;i<t.length;i++){const n=t[i];n&&s.setValue(r,n.value,a._formatColumnData(e,n))}a.$[`${i}Splitter`].refresh()}_removeConnection(e,t){const i=this,a=i.$.connectionPopupWindow,n=i.$.timelineConnectionsContainer;if(e.classList&&e.classList.contains("smart-task-connection")?e=e.getAttribute("connection-id"):e+="",void 0===e)return;const s=n.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++)n.removeChild(s[e]);let d;const c=parseInt(o[0]),m=parseInt(o[1]),u=parseInt(o[2]);if(a&&void 0!==a._target&&"number"==typeof a._target.type){const t=a._target;d=t.startIndex+"-"+t.endIndex+"-"+t.type===e}i._updateConnection([c,m,u],!0),!t&&i.autoSchedule&&(i._autoScheduleRestore(r[l],parseInt(o[2])),i._autoSchedule(r[l])),d&&i.$.fireEvent("itemRemove",{type:"connection",id:`${c}-${m}-${u}`,item:{source:c,target:m,type:u}})}_removeTaskConnections(e,t){const i=this,a=i._connections;if(a&&a.length){for(let t=0,i=a.length;t<i;t+=1)a[t].startTask===e&&(a.splice(t,1),i--);e.connections=[],t&&i._recycleConnections()}}_removeTask(e){const t=this,i=t._tasks;if(!e||!i||!i.length)return;const a=t._getSelection("task",t.selectedTaskIds),n=t.$.taskPopupWindow;let s;if(t._highlightAssignedItem("task",[e]),n&&n._target===e&&n.close(),"project"===e.type){const a=t._getProjectTasks(e);for(let e=0,t=a.length;e<t;e+=1)i.splice(i.indexOf(a[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)),a.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,a=i.indexOf(e);if(e&&!(a<0)){if(t._isUpdating)return i.splice(a,1),t._isUpdating.type.resource=!0,void(t._isUpdating.type.task=!0);if(i.splice(a,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 n();t._refreshResourceTimeline(),t._refreshTableDataSource("resource"),t.$.mainSplitter.contains(t.$.resourceSplitter)?(t._refreshResourceScrollBar(),t._resizeEventHandler(),n()):n()}function n(){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,a=i._tasks;if(!e||!a||!a.length)return;const n=i.$.taskPopupWindow,s=i._getSelection("task",i.selectedTaskIds);n&&n._target===e&&n.close();let r,o=i._getTaskResources(e);for(let n in t){let s=e[n],l=t[n];if("type"===n&&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)a.splice(a.indexOf(t[e]),1);delete e.tasks}if("project"!==e.type||!e.synchronized||!(n.toLowerCase().indexOf("date")>-1||n.toLowerCase().indexOf("duration")>-1))if("dateEnd"===n&&new Date(s).getTime()!==new Date(l).getTime()&&(r=!0),"tasks"!==n)"connections"===n&&(i._removeTaskConnections(e),i._handleTaskConnections(e)),e[n]=l,"resources"===n&&(i._handleResources(e),e.disableResources||(o=o.concat(i._getTaskResources(e)),o=o.filter(((e,t)=>o.indexOf(e)===t)))),"milestone"!==e.type||"dateStart"!==n&&"dateEnd"!==n||(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)a.splice(a.indexOf(t[e]),1);const n=i._createTasks(l,!0);for(let t=0,i=n.length;t<i;t+=1)n[t].$.project=e;i._insertTasks(n,e,a.indexOf(e))}}r&&delete e.duration;const l=e.$,d=e.$.project;if(i._validateTaskProperties(e,d),e.$=l,d&&i._synchronizeProjectDates(d),"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 c;i._selected&&i._selected.task&&i._setSelection("task",c=i._selected.task.map((e=>e.$.id))),i._refreshTableDataSource(),i._refreshTimeline(),i._ensureVisible(e),c&&s.toString()!==c.toString()&&(i.$.taskTable.selected=c.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 a=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(a!==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 a=0;a<t.length;a++){const n=t[a];n._resource===e&&i._refreshResourceTimelineContent(e,n)}}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 a,n;"task"===e?(a="selectedTaskIds",n=i._tasks):(a="selectedResourceIds",n=i._resources);const s=n.findIndex((e=>e.$.id===t)),r=i._getSelection(e,i[a]);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 a,n,s,r,o,l=i._selected;l||(l=i._selected={});const d=t[t.length-1],c=l[e]=[];"task"===e?(o=i._tasks,a="selectedTaskIds",n=i.$.taskTimelineCellsContainer.children,s=i.$.timelineTasksContainer.children):(o=i._resources,a="selectedResourceIds",n=i.$.resourceTimelineCellsContainer.children,s=[]);for(let e=0,i=o.length;e<i;e+=1){const i=o[e];t.indexOf(i.$.id)>-1&&c.push(i)}for(let i=0,a=n.length;i<a;i+=1){const a=n[i],o=s[i],l=a._cellObj[e].$.id;d===l&&(r=s[i]),t.indexOf(l)>-1?(a.setAttribute("selected",""),a.setAttribute("aria-selected","true"),o&&o.setAttribute("selected","")):(a.removeAttribute("selected"),a.setAttribute("aria-selected","false"),o&&o.removeAttribute("selected"))}const m=i[a].slice(0);if(i._setSelection(e,t),!i._tableChangeEventFired){const a=document.scrollingElement||document.documentElement,n=a.scrollLeft,s=a.scrollTop;i._highlightAssignedItem(e,t),i.$[`${e}Table`].focus({preventScroll:!0}),window.scrollTo(n,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[a].slice(0),oldValue:m})}_setSelection(e="task",t){const i=this;let[a,n]="task"===e?[i._tasks,"selectedTaskIds"]:[i._resources,"selectedResourceIds"],s=[];for(let e=0,i=t.length;e<i;e+=1){const i=t[e],n=a.find((e=>e.$.id===i));n&&s.push(void 0!==n.id?n.id:i)}i.set(n,s)}_getSelection(e="task",t){const i="task"===e?this._tasks:this._resources;let a=t.slice(0);if(!t||!t.length)return a;for(let e=0,n=i.length;e<n;e+=1){const n=i[e],s=t.indexOf(n.id);s>-1&&(a[s]=n.$.id)}return a}_highlightAssignedItem(e,t){const i=this,[a,n]="task"===e?["resource","_getTaskResources"]:["task","_getResourceTasks"],s=i.$[`${a}Table`],r=i[`_${a}s`];if(!s||!i.$.mainSplitter.contains(s)||!r.length)return;t&&Array.isArray(t)||(t=[]);let o=[];for(let a=0,s=t.length;a<s;a+=1){const s=i._getValidItemAndIndex(t[a],e);s&&(o=o.concat(i[n](s.item).filter((e=>!e.hidden))))}i._tableChangeEventFired=!0,s.selected=o.map((e=>e.$.id)),o.length&&i._ensureVisible(o[0],a),delete i._tableChangeEventFired}_selectResource(e){const t=this,i=t._resources.indexOf(e);if(i<0)return void t._unselectAll("resource");const a=t.$.resourceTimelineCellsContainer.children[i];a&&a.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 a=e._cellObj.task,n=a.segments;if(t&&t.classList.contains("smart-task-segment")){const a=n.indexOf(t._segmentObj),s=0===a,r=a===n.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(n&&n.length>1){for(let e=0,t=n.length;e<t;e+=1)i._snapToNearestDates(n[e],!0);i._validateTaskSegments(a),a.segments.length!==n.length&&i._recycleSegments(a,e),i._setTaskBarSegments(e._cellObj,e,!0),i._setTaskBarProgress(a)}if("project"!==a.type||!a.dragProject)return;const s=i._getProjectTasks(a);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 a=this,n=a.rightToLeft,s=n?"right":"left",r=parseFloat(e.style[s])||0,o=t,l=a._getSegmentCellRange(t),d=l.cellStart,c=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(a.hasAttribute("dragged")){const t=c.width-(f+h-c.left);let a;if(f-d.left<=t?(a=d.left-r,o.style[s]=Math.max(0,m?0:a)+"px"):(a=g+t,o.style[s]=Math.max(0,m?0:a)+"px"),i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&(e.style[s]=r+(a-g)+"px"),e.style.width=t+(m?-1:1)*(a-g)+"px"}}else if(a.hasAttribute("resized")){const t=d===c?a._taskBarMinWidth:0;let l;if("left"===a.$.timeline.getAttribute("task-bar-hovered")){if(l=f-d.left,l-=l>=d.width/2?d.width-t:0,f-=l,o.style[s]=Math.max(0,m?0:f-r)+"px",l=f+h>c.left+c.width/2?c.left+c.width-(f+h):c.left-(f+h),o.style.width=Math.max(t,h+l)+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&!n&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&n&&(e.style.width=t+l+"px")}}else if(f>d.left+d.width/2?(f=d.left+d.width,o.style[s]=Math.max(0,m?0:f-r)+"px"):(f=d.left,o.style[s]=Math.max(0,m?0:f-r)+"px"),l=f+h-c.left,l=-1*(l-(l>=d.width/2?c.width:t)),o.style.width=h+l+"px",i){const t=parseFloat(e.style.width)||e.offsetWidth;m&&n&&(e.style[s]=f+"px",e.style.width=t+l+"px"),u&&!n&&(e.style.width=t+l+"px")}}}_handleSnapToNearest(e,t){const i=this;if(!e)return;const a=i.rightToLeft?"right":"left",n=e.cellStart,s=e.cellEnd;let r=parseFloat(t.style.width)||t.offsetWidth,o=parseFloat(t.style[a])||0;if(i.hasAttribute("dragged")){const e=s.width-(o+r-s.left);o-n.left<=e?t.style[a]=n.left+"px":t.style[a]=o+e+"px"}else if(i.hasAttribute("resized")){const e=n===s?i._taskBarMinWidth:0;let l;"left"===i.$.timeline.getAttribute("task-bar-hovered")?(l=o-n.left,l-=l>=n.width/2?n.width-e:0,t.style[a]=(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>n.left+n.width/2?t.style[a]=n.left+n.width+"px":t.style[a]=n.left+"px",o=parseFloat(t.style[a])||0,l=o+r-s.left,l=-1*(l-(l>=n.width/2?s.width:e)),t.style.width=r+l+"px")}}_setDragLimits(e){const t=this,i=t._dragDetails;if(!i)return;const a=i.timelineTask;if(!a||!e)return;const n=t.$.timeline.getAttribute("task-bar-hovered"),s=a._cellObj.task;if(n){if(s.disableResize)return void delete t._dragDetails;const e=t._getTaskBarSizeLimits(a,n);i.min.width=e.min,i.max.width=e.max,t._setSegmentLimits(n);const r=t._createDelimiter("min",n),o=t._createDelimiter("max",n);r&&a.appendChild(r),o&&a.appendChild(o)}else if(e.closest(".smart-task-connection-point"))i.timelineTask=void 0;else if(e.closest(".smart-timeline-task")===a){let e;if(t._connections){const i=t._tasks.indexOf(a._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),a.classList.contains("milestone")&&(i.target="smart-timeline-task-fill");const n=t._getTaskDragLimits(a),r=t.rightToLeft?t.$.timelineContent.offsetWidth-a.offsetLeft-a.offsetWidth:a.offsetLeft;if(void 0!==n.min&&(i.min.left=n.min,"project"===a._cellObj.task.type&&n.min>r&&(i.min.left=r)),void 0!==n.max&&(i.max.left=n.max,"project"===a._cellObj.task.type&&n.max<r&&(i.max.left=r)),"project"===s.type&&s.dragProject&&!t.synchronized){const e=t._getSubTaskLimits(a);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 a=i.segment;if(a){const n=a.element,s=a.dimensions,r=n.previousElementSibling,o=n.nextElementSibling;if(a.min.width=e?t._taskBarMinWidth:0,t.rightToLeft){if(r)a.min.left="left"===e?s.left+s.width:r.offsetLeft-(e?0:s.width),"right"===e&&(a.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)a.max.left="right"===e?a.dimensions.left:o.offsetLeft+o.offsetWidth+s.width,e&&"left"!==e||(a.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)a.min.left="right"===e?s.left:r.offsetLeft+r.offsetWidth+(e||o?0:s.width),"left"===e&&(a.max.width=s.left+s.width-a.min.left);else if(!e){const e=t._getTaskBarSizeLimits(i.timelineTask,"left");i.min.width=e.min,i.max.width=e.max}if(o)a.max.left="left"===e?s.left+s.width:o.offsetLeft-s.width,e&&"right"!==e||(a.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 a=i.nonworkingHours,n=i.nonworkingDays;function s(e,t){let s,r,o=t.getTime()-e.getTime(),l=new Date(e),d=0;for(;o>0;){const e=Math.min(o,36e5-(60*l.getMinutes()*1e3+1e3*l.getSeconds()+l.getMilliseconds()));if(n.indexOf(l.getDay())>-1)r=new Date(l),r.setHours(0,0,0,0),r.setDate(l.getDate()+1),s=Math.min(e,r.getTime()-l.getTime()),l=new Date(l.getTime()+s),o-=s;else if("day"===i.view&&a.indexOf(l.getHours())>-1){r=new Date(l);const t=r.getTime();r.setHours(l.getHours()+1,0,0,0),t===r.getTime()&&r.setHours(l.getHours()+2,0,0,0),s=Math.min(e,r.getTime()-l.getTime()),l=new Date(l.getTime()+s),o-=s}else d+=e,o-=e,l=new Date(l.getTime()+e)}return d}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(),a=(i%100==0?i%400==0:i%4==0)?366:365;let n=new Date(e),s=0;for(let e=0;e<a;e++)t.nonworkingDays.indexOf(n.getDay())<0&&s++,n.setDate(n.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 a=i.$.timelineTasksContainer.children[t];if(!a)return;const n=a.querySelector(".smart-task-segments").children;let s=e.segments;Array.isArray(s)&&s&&s.length&&"task"===e.type||(s=[e]);for(let r=0,o=s.length;r<o;r+=1){const o=s[r],l=n[r],d=l?l.getElementsByClassName("smart-timeline-task-label")[0]:void 0;if(!d)continue;d.firstElementChild||(d.innerHTML="<div></div>");let c=d.firstElementChild;"string"==typeof o.label||"number"==typeof o.label?c.textContent=o.formatFunction?o.formatFunction(o.label||"",t)||"":o.label||"":c.textContent=e.formatFunction?o.formatFunction(e.label||"",t)||"":e.label||"",i.onTaskRender&&i.onTaskRender(e,o,a,l,c),e.onRender&&e.onRender(e,o,a,l,c)}}_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 a=e.progress;const n=t.querySelector(".smart-timeline-task-progress-thumb");if(!n)return;a=Math.min(100,Math.max(0,a))||0;const s=e.dateStart.getTime(),r=e.dateEnd.getTime(),o=t.querySelector(".smart-task-segments").children;let l,d,c=e.segments,m=0;c&&c.length||(c=[e]);for(let e=0,t=c.length;e<t;e+=1){const t=c[e],i=o[e],n=i?i.querySelector(".smart-timeline-task-progress"):void 0;if(!n)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,(a-u)/(h-u)*100));n.style.width=g+"%",n.removeAttribute("value"),i.removeAttribute("show-progress-label"),a>=u?(m=Math.max(u,Math.min(a,h)),l=n,d=i):l||(l=n,d=i)}if(n.style[i.rightToLeft?"left":"right"]="",n.style[i.rightToLeft?"right":"left"]=m+"%",!l||!i.showProgressLabel)return;const u=i.progressLabelFormatFunction;d.setAttribute("show-progress-label",""),l.setAttribute("value",u?u(a)+"":parseFloat(a.toFixed(2))+"%")}_setTaskDeadline(e,t,i){const a=this,n=e.task,{timelineStart:s,timelineEnd:r}=i,o=n.deadline,l=a.$.timelineDeadlines,d=l.children,c=o&&o.getTime&&!isNaN(o.getTime())?o.getTime():void 0;let m;for(let e=0,i=d.length;e<i;e+=1){const i=d[e];if(parseInt(i.getAttribute("task-index"))===t){m=i;break}}if(!c||c<s||c>r)return void(m&&m.remove());const u=a._getTimelineCellByDate(o),[h,g]=a.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",a._formatDate(o)),m.style.top=e.top+"px",m.style[g]="",m.style[h]=u.left+(a._getTimelineTaskOffset(u,o)||0)+"px"}_setTaskBarDeadline(e,t){const i=this,a=e.deadline;if(!a||!a.getTime||isNaN(a)||!t)return;const n=e.deadline.getTime()-e.dateEnd.getTime();if(!e.deadline||n>0)return t.removeAttribute("deadline"),void(e.overdue=!1);e.overdue=!0,t.setAttribute("deadline",`${i.localize("overdue")}: ${Math.round(i._convertDuration(Math.abs(n),!0))} ${i.durationUnit+"s"}`)}_setTaskIndicators(e,t,i){const a=this,n=e.task,{timelineStart:s,timelineEnd:r}=i,[o,l]=a.rightToLeft?["right","left"]:["left","right"],d=a.$.taskIndicatorsContainer,c=d.children,m=n.indicators;let u;for(let e=0,i=c.length;e<i;e+=1){const i=c[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 n=m[t],d=n.date;if(!d||!d.getTime){i&&i.remove();continue}const c=d.getTime();if(c<s||c>r){i&&i.remove();continue}const u=a._getTimelineCellByDate(d),h=n.label,p=n.className,_=n.icon;i||(i=document.createElement("div"),g.appendChild(i)),i.className="smart-gantt-chart-task-indicator",i._indicatorObj=n;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+(a._getTimelineTaskOffset(u,d)||0)+"px"}g.childElementCount&&u.appendChild(g),h.childElementCount&&d.appendChild(h)}_setTimelineTaskBar(e,t,i){const a=this,n=e.task,s=void 0===t?a._getTaskDOMIndex(n):t,r=a.$.timelineTasksContainer.children,o=r[s];let l,d;if(0===r.length||!o||!o.classList||!o.classList.contains("smart-timeline-task"))return;const c=n.dateStart instanceof Date?n.dateStart:new Date(n.dateStart),m=n.dateEnd instanceof Date?n.dateEnd:new Date(n.dateEnd);if(l=!i&&o._cellStart||a._getTimelineCellByDate(c),d=!i&&o._cellEnd||a._getTimelineCellByDate(m),!l||!d)return void o.classList.add("smart-visibility-hidden");o._cellStart=l,o._cellEnd=d,o.classList.remove("smart-visibility-hidden");const u=a._getTaskBarDetails(e,l,d);u&&(o.style[a.rightToLeft?"left":"right"]="",o.style[a.rightToLeft?"right":"left"]=u.left+"px",o.style.width=u.width?u.width+"px":"",o.style.top=u.top+"px"),a._setTaskBarSegments(e,o,i)}_setTimelineTaskBaseline(e,t){const i=this,a=e.task,n=i.$.timelineBaselinesContainer;if(!i.showBaseline)return void(n.innerHTML&&(n.innerHTML=""));const s=a.planned,r=n.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"===a.type||!s.dateStart||!s.dateEnd)return void(o&&o.remove());const l=s.dateStart,d=s.dateEnd,c=i._getTimelineCellByDate(l),m=i._getTimelineCellByDate(d);if(!c||!m)return;o||(o=document.createElement("div"),o.classList.add("smart-gantt-chart-task-baseline"),o.setAttribute("task-index",t),n.appendChild(o));const[u,h]=i.rightToLeft?["right","left"]:["left","right"];(e=JSON.parse(JSON.stringify(e))).dateStart=l,e.dateEnd=d,e.task.dateStart=l,e.task.dateEnd=d;const g=i._getTaskBarDetails(e,c,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",a.label+" Start date: "+i._toISODate(l)+", End date: "+i._toISODate(d))}_setTaskBarSegments(e,t,i){const a=this,n=e.task,s=t.querySelector(".smart-task-segments").children;let r,o,l=n.segments;if(Array.isArray(l)&&l&&l.length&&"task"===n.type||(l=[n]),1===l.length){const e=s[0].style;return void(e.right=e.left=e.width="")}const d=a.rightToLeft,c=parseFloat(t.style[d?"right":"left"]);let m;for(let e=0,t=l.length;e<t;e+=1){const t=l[e],n=s[e];if(!n)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&&n._cellStart||a._getTimelineCellByDate(u),o=!i&&n._cellEnd||a._getTimelineCellByDate(h),n._cellStart=r,n._cellEnd=o;const g=a._getTaskBarDetails({task:t},r,o);g&&(n.style[d?"left":"right"]="",n.style[d?"right":"left"]=Math.max(0,g.left-c)+"px",n.style.width=g.width+"px"),m=n}a._setTaskBarDeadline(n,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=e.currentTime,i=e.view,a=e._getTodayCellObj(t);let n=e.$.timelineIndicatorsContainer;if(!a)return n&&n.remove(),clearInterval(e._currentTimeIndicatorInterval),void delete e._currentTimeIndicatorInterval;n||(e.$.timelineIndicatorsContainer=n=document.createElement("div"),n.classList.add("smart-gantt-chart-time-indicators-container"),n.setAttribute("role","presentation")),new Date(a.date);let s,r,o=t.getMinutes();switch(i){case"quarter":case"year":{const e=new Date(t.getFullYear(),t.getMonth()+1,1,0,0,0,0);e.setDate(0),o+=24*t.getDate()*60,s=24*e.getDate()*60;break}case"month":o+=24*(t.getDay()+1)*60,s=10080;break;case"week":o+=60*t.getHours(),s=1440;break;case"day":s=60}r={cellObj:a,minutes:o,max:s,today:t},e._refreshCurrentTimeShader(r),e._refreshCurrentTimeIndicator(r),n.childElementCount||(clearInterval(e._currentTimeIndicatorInterval),delete e._currentTimeIndicatorInterval),n.parentElement||e.$.timelineContent.appendChild(n)}_refreshCurrentTimeIndicator(e){const t=this,i=t.$.timelineIndicatorsContainer;let a=i.querySelector(".smart-gantt-chart-current-time-indicator");if(!t.currentTimeIndicator||!e)return void(a&&a.remove());const{cellObj:n,minutes:s,max:r}=e;a||(a=document.createElement("div"),a.classList.add("smart-gantt-chart-current-time-indicator")),t.rightToLeft?a.style.right=n.left+n.width*(s/r)+"px":a.style.left=n.left+n.width*(s/r)+"px",a.setAttribute("aria-label","Current Time Indicator"),a.parentElement||i.appendChild(a),t._setTodayCell(n.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:a,minutes:n,max:s}=e;i||(i=document.createElement("div"),i.classList.add("smart-gantt-chart-current-time-shader")),i.style.width=a.left+a.width*(n/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=t.currentTime,"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 a=i[t],n=new Date(a._date);n&&(n.getTime()===e?a.setAttribute("current",""):a.removeAttribute("current"))}}_getTodayCellObj(e){const t=this,i=t.view,a=t._timelineCells;e&&e.getTime||(e=t.currentTime);for(let t=0,n=a.length;t<n;t+=1){const n=a[t],s=n.date;switch(i){case"quarter":case"year":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth())return n;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 n;break}case"week":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate())return n;break;case"day":if(e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate()&&s.getHours()===e.getHours())return n}}}_getTaskDOMIndex(e){const t=this.$.timelineTasksContainer.children;if(!e||void 0===e.$.id)return-1;for(let i=0,a=t.length;i<a;i+=1)if(t[i]._cellObj.task===e)return i;return-1}_getTimelineCellByDate(e,t,i){const a=this,n=a._timelineCells;if(!n||0===n.length)return;const s=n.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=n[s];if(!t)continue;const i=t.date;switch(a.view){case"quarter":case"year":if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth())return t;break;case"month":if("day"===a.monthScale){if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate())return t}else{const a=new Date(i);let n=new Date(i);if(n.setDate(n.getDate()+(6-n.getDay())+1),n.setMilliseconds(n.getMilliseconds()-1),e.getTime()>=a.getTime()&&e.getTime()<=n.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("hour"!==a.dayScale){if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours()&&i.getMinutes()<=e.getMinutes())return t}else if(i.getFullYear()===e.getFullYear()&&i.getMonth()===e.getMonth()&&i.getDate()===e.getDate()&&i.getHours()===e.getHours())return t}}const r=n[0],o=n[n.length-1];return e.getTime()<r.date.getTime()?r:e.getTime()>o.date.getTime()?o:void 0}_refreshViewDetailCell(e,t,i){const a=this,n=a._timelineCells,s=e.date;let r=0,o=0===i?0:void 0;for(void 0===t&&(t=0);t<n.length;t++){const e=n[t],i=a._getCellWidth(e,s);if(i){if("month"===a.view&&"day"===a.monthScale&&s.getMonth()!==e.date.getMonth())break;void 0===o&&(o=e.left+e.width-i),r+=i}else if(e.date.getTime()>s.getTime())break}return a._isLastWeekCellNotFull&&(delete a._isLastWeekCellNotFull,t--),e.width=r,e.left=o,t}_getCellWidth(e,t){const i=this,a=e.date,n=(e,t)=>e.getFullYear()===t.getFullYear(),s=(e,t)=>e.getMonth()===t.getMonth(),r=e.width;switch(i.view){case"month":{if("day"===i.monthScale)return r;let e=new Date(a),o=new Date(e),l=0;for(o.setDate(o.getDate()+(6-e.getDay())+1),o.setMilliseconds(o.getMilliseconds()-1);e.getTime()<=o.getTime();)n(e,t)&&s(e,t)&&l++,e.setDate(e.getDate()+1);if(0===l)return;"day"!==i.monthScale&&(i._isLastWeekCellNotFull=l/7!=1);let d=r*l/7;return d<70?70:d}case"quarter":case"year":if(n(a,t))return r;break;case"week":{const e=new Date(t),n=new Date(t);if(-1!==i.firstDayOfWeek){const t=e.getDay()-i.firstDayOfWeek;e.setDate(e.getDate()-e.getDay()+i.firstDayOfWeek-(t>=0?0:7)),n.setDate(e.getDate()+6)}else e.setDate(t.getDate()-t.getDay()),n.setDate(t.getDate()+(6-t.getDay()));if(a.getTime()>=e.getTime()&&a.getTime()<=n.getTime())return r;break}case"day":if(n(a,t)&&s(a,t)&&a.getDate()===t.getDate())return r}}_getCellByOffsetLeft(e){const t=this._timelineCells;if(!e)return;let i;for(let a=0;a<t.length&&!(t[a].left>=e);a++)i=t[a];return i}_unselectAll(e,t){const i=this,a=i.$[`${e}TimelineCellsContainer`];let n;delete i._selected;const s=a.querySelectorAll(".smart-timeline-row[selected]");for(let e=0;e<s.length;e++)s[e].removeAttribute("selected");if("task"===e){n="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 n="selectedResourceIds";if(i[`_${e}TreeChangeEventFired`]||i.$[e+"Table"].clearSelection(),i._highlightAssignedItem(e),t)return;const r=i[n].slice(0);r.length&&(i[n]=[],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 a,n,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,d=t._timelineCells;let c=parseFloat(i.style[o?"right":"left"]);c&&!isNaN(c)||(c=i.offsetLeft,o&&(c=t.$.timelineContent.offsetWidth-c));const m=c+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=d.indexOf(s),t=d.indexOf(r);e<=t;e++){const t=d[e],i=t.left,s=t.width,r=parseFloat((i+s).toFixed(2));if(m>=i&&m<=r&&(a=t),!n&&u>i&&u<=r&&(n=t),a&&n)break}return a||(a=n||d[0]),n||(n=d[d.length-1]),{cellStart:a,cellEnd:n}}_getTaskBarCellRange(e){const t=this;if(!e.classList||!e.classList.contains("smart-timeline-task"))return;let i=parseFloat(e.style.width)||e.offsetWidth;const a=t._timelineCells,n=t.$.timelineContent,s=parseFloat(e.style[t.rightToLeft?"right":"left"])||(t.rightToLeft?(parseFloat(n.style.width)||n.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<a.length;e++){const t=a[e],i=t.left,n=t.width,d=parseFloat((i+n).toFixed(2));if(s>=i&&s<=d&&(r=t),!o&&l>i&&l<=d&&(o=t),r&&o)break}return r||(r=e.classList.contains("milestone")&&o?o:a[0]),o||(o=a[a.length-1]),{cellStart:r,cellEnd:o}}_getDateFromCell(e,t,i){if(!t)return new Date;const a=this,n=new Date(t.date);let s,r=0,o=0,l=new Date(n);switch(l.setHours(0,0,0,0),i||(i=a.view),i){case"quarter":case"year":s=new Date(n.getFullYear(),n.getMonth()+1,0).getDate(),r=1,l.setDate(s);break;case"month":"day"===a.monthScale?(r=n.getDate(),s=1):(r=n.getDate(),s=7,l.setDate(l.getDate()+6));break;case"week":s=1,r=n.getDate();break;case"day":s=1/24,r=n.getDate(),o=n.getHours()}l.setHours(23,59,59,999);const d=parseFloat(((e-t.left)/t.width*s).toFixed(12)),c=Math.min(s,Math.floor(d)),m=d%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(_),b=new Date(n.getFullYear(),n.getMonth(),r+c,o+u,g,p,T);return b.getTime()>l?l:b}_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"quarter":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,a){if(!i)return;let n=[];for(let s=0;s<i.length;s++){const r=i[s];let o;if(!r.$.project&&!a||r.$.project===a){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.$,n.push(o)}}return n}(t)}_cloneObject(e,t){let i={};for(let a in e){let n=e[a];"tasks"!==a&&("connections"!==a?n instanceof Date?i[a]=t?n.toISOString():new Date(n):i[a]=n:i[a]=JSON.parse(JSON.stringify(n)))}return t||delete i.$,i}_setTable(e){const t=this;e||(e=t.$.taskTable);const[i,a]=e===t.$.taskTable?[t.taskColumns,"task"]:[t.resourceColumns,"resource"];if(!t.contains(e))return;if(!i.length)return void(t.$[a+"Table"].dataSource=[]);const n=t._getTableColumns(a);"task"===a&&(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=n,e.dataSource=t._getTableDataSource(a,n),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[`${a}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.selectionMode=t.selectionMode,e.onKeyboardScroll=(i,a)=>{const n=e===t.$.taskTable?t:t._resourceScrollView;a!==n.scrollTop&&(n.scrollTop=a)},e.wait=!1),e.$.virtualizationContainer.scrollTop="task"===a?t.scrollTop:t.$.resourceVerticalScrollBar.value,t._refresh()}_formatResourceGroups(e){const t=this,i=t._resources,a=e.data.data.resources.split(",");let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";a.indexOf(s)>-1&&n.push(t.label||t.value||t.id)}t.resourceGroupFormatFunction?e.template=t.resourceGroupFormatFunction(a):e.template="<strong>"+(n.length?n.join(", "):t.localize("unassigned"))+"</strong>"}_formatResourceGroupLabel(e){const t=this,i=t._resources,a=e.split(",");if(!e)return t.localize("unassigned");let n=[];for(let e=0,t=i.length;e<t;e+=1){const t=i[e],s=t.id+"";a.indexOf(s)>-1&&n.push(t.label||t.value||t.id)}return n.length?n.join(", "):t.localize("unassigned")}_getTableColumns(e="task"){const t=this,i=["dateStart","dateEnd","minDateStart","maxDateStart","minDateEnd","maxDateEnd"],a=["progress","capacity","workload","maxCapacity","minCapacity"];let n="task"===e?t.taskColumns:t.resourceColumns,s=[];"task"===e&&t.groupByResources&&!n.find((e=>"resources"===e.value))&&(n=n.slice(0),n.push({label:"",value:"resources",hidden:!0}));for(let r=0,o=n.length;r<o;r++){const o=n[r],l=o.value,d={};d.label=t.localize(o.label)||o.label,d.dataField=l,l.startsWith("date")||i.indexOf(l)>-1?d.dataType="date":d.dataType="overdue"===l?"boolean":l.startsWith("duration")||a.indexOf(l)>-1?"number":"string",o.hidden&&(d.visible=!1),"function"==typeof o.formatFunction?d.formatFunction=i=>{const a=t._getValidItemAndIndex(i.data.itemId,e).item,n=i.column.toLowerCase();let s=i.value;n.indexOf("date")>-1?s=new Date(s):"resources"===n&&(s=s?s.split(","):[]),i.template=o.formatFunction.call(t,s,a?t._cloneObject(a):void 0)}:["date","number"].indexOf(d.dataType)>-1?d.formatFunction=i=>{const a=t._getValidItemAndIndex(i.data.itemId,e).item,n=t._formatColumnData(t._cloneObject(a),o);i.template=n}:"overdue"===l&&(d.formatFunction=e=>{const t=e.cell;e.value+""=="true"?t.setAttribute("overdue",""):t.removeAttribute("overdue"),e.value=""},d.width=t._taskDefaultHeight),o.size&&(d.width=o.size),s.push(d)}return s}_getTableDataSource(e="task",t){const i=this,a="task"===e?i._getTableData(i._tasks,i.taskColumns,e):i._getTableData(i._resources,i.resourceColumns,e),n=i.groupByResources,s=(()=>{let e=[];e.push("itemId: string"),e.push("projectId: string"),e.push("itemIndex: number"),n&&e.push("resources: string");for(let i=0,a=t.length;i<a;i+=1){const a=t[i];e.push(`${a.dataField}: ${a.dataType}`)}return e})();return i.groupByResources?new window.Smart.DataAdapter({dataFields:s,dataSource:a,groupBy:["resources"],id:"itemId"}):new window.Smart.DataAdapter({dataFields:s,dataSource:a,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,a=t[`${e}Columns`];for(let e=0,n=i.length;e<n;e++)void 0!==a[e]&&(i[e].label=t.localize(a[e].label)||a[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 a=[];if(Array.isArray(t))for(let e=0,n=t.length;e<n;e+=1){const n=t[e].id||t[e];i.indexOf(n)>-1&&a.push(n)}return a.sort()}_getTableData(e,t,i){const a=this,n=a.groupByResources;i||(i="task");const s=t.map((e=>e.value));let r=[],o=[];for(let l=0,d=e.length;l<d;l+=1){const d=e[l];if(d.hidden||n&&d.disableResources)continue;const c={},m=d.$.project,u=a._getTaskResourceIds(d);for(let e=0,n=s.length;e<n;e+=1)c[s[e]]=a._formatColumnData(d,t[e],i);c.expanded=n||d.expanded,c.itemId=d.$.id||d.id||"",c.itemIndex=l,u&&u.length?c.resources=u.toString():delete c.resources,d.$&&m&&(m.$.id?c.projectId=d.$.project.$.id:o.push(((e,t)=>{e.projectId=t.$.id}).bind(null,d,m))),r.push(c)}for(let e=0,t=o.length;e<t;e+=1)o[e]();return r}_formatColumnData(e,t){const i=this,a=t.value;let n=e[a];if(a){const e=(a+"").toLowerCase();if(e.indexOf("date")>-1||t.dateFormat)return i._formatDate(n,t);if(e.indexOf("duration")>-1||t.numberFormat){const e=parseFloat(n.toFixed(1));return t.numberFormat?i._formatNumber(e,t.numberFormat):e}}return null!=n?n.toString():i.localize("unassigned")}_formatDate(e,t){const i=this;if(e=Date.parse(e),!isNaN(e)){let a=t?t.dateFormat:void 0;if("string"==typeof a)return new Smart.Utilities.DateTime(new Date(e)).toString(a);if("object"==typeof a)a=t.dateFormat;else{const e=i.view;a={year:"numeric",month:"2-digit",day:"numeric"},["day","week"].indexOf(e)>-1&&(a.hour="numeric",a.minute="numeric",a.second="numeric")}return new Intl.DateTimeFormat(i.locale,a).format(new Date(e))}}_formatNumber(e,t,i){const a=this;if("object"==typeof t)return new Intl.NumberFormat(a.locale,t).format(""+e);i||(i={percentSymbol:"%",currencySymbol:"$",currencySymbolPosition:"before",decimalSeparator:".",thousandsSeparator:","});const n=e=>"number"==typeof e&&isFinite(e);if(""===t||null===t)return e;let s;n(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(n(e)){const t=e<0;let i=e+"";const a=r.decimalSeparator?r.decimalSeparator:".";let s;if(n(r.decimalPlaces)){var l=r.decimalPlaces,d=Math.pow(10,l);if(i=(e*d).toFixed(0)/d+"",s=i.lastIndexOf("."),l>0)for(s<0?(i+=a,s=i.length-1):"."!==a&&(i=i.replace(".",a));i.length-1-s<l;)i+="0"}else{let t=e+"";s=t.lastIndexOf("."),s>0&&void 0===l&&"."!==a&&(t=t.replace(".",a))}if(r.thousandsSeparator){const e=r.thousandsSeparator;s=i.lastIndexOf(a),s=s>-1?s:i.length;let n=i.substring(s),o=-1;for(var c=s;c>0;c--)o++,o%3==0&&c!==s&&(!t||c>1)&&(n=e+n),n=i.charAt(c-1)+n;i=n}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 a=e.connections;if(a instanceof Array){for(let e=0;e<a.length;e++){const t=a[e],i=t.target="string"==typeof t.target?t.target:parseInt(t.target),n=t.type=parseInt(t.type);null==i||"number"==typeof i&&isNaN(i)||isNaN(n)?(a.splice(a.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 a=[];for(let e=0,n=i.length;e<n;e+=1){const n=i[e];if("object"!=typeof n)continue;const s=t._validateDate(n,"date");s&&s.getTime&&!isNaN(s.getTime())&&a.push(n)}e.indicators=a}_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 a=t.nonworkingDays.length>0||t.nonworkingHours.length>0;let n,s=[],r=[];for(let e=0,a=i.length;e<a;e+=1){const a=i[e];if("object"!=typeof a)continue;let n=parseFloat(a.duration);isNaN(n)&&delete a.duration,t._validateTaskDates(a),a.dateStart&&a.dateEnd&&s.push(a)}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,d=o.dateEnd;o.dateStart=l=new Date(Math.max(e.dateStart.getTime(),l.getTime())),o.dateEnd=d=new Date(Math.min(e.dateEnd.getTime(),d.getTime())),n&&n.dateEnd.getTime()>l.getTime()&&(o.dateStart=l=new Date(n.dateEnd.getTime()+1e3),l.getTime()>=d.getTime())||l.getTime()>d.getTime()||(o.duration=t._convertDuration(a?t._getWorkingTime(l,d):d.getTime()-l.getTime(),!0),n=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,a=t._convertDuration(parseFloat(e.minDuration))||0,n=t._convertDuration(parseFloat(e.maxDuration))||0;a&&n&&(n=Math.max(a,n)),i&&(a?i=Math.max(a,i):n&&(i=Math.min(i,n))),e.duration=t._convertDuration(i,!0),e.minDuration=t._convertDuration(a,!0),e.maxDuration=t._convertDuration(n,!0)}_validateTaskDates(e,t){const i=this,a=i._convertDuration(e.minDuration),n=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)),a&&e.dateStart)if(i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)){const t=i._getTaskWorkingDateEnd(e,a);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()+a));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||n){let t;t=i.adjustToNonworkingTime&&(i.nonworkingDays.length>0||i.nonworkingHours.length>0)?i._getTaskWorkingDateEnd(e,Math.max(s,n)):new Date(e.dateStart.getTime()+Math.max(s,n)),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,a=e.planned;if("milestone"===i||!a)return;const n=t._validateDate(a,"dateStart"),s=t._validateDate(a,"dateEnd");n&&s&&(a.duration=t._convertDuration(t.nonworkingDays.length>0||t.nonworkingHours.length>0?t._getWorkingTime(n,s):s.getTime()-n.getTime(),!0))}_synchronizeProjectDates(e,t){const i=this;if(e){void 0===t&&(t=i._getProjectTasks(e));for(let n=0,s=t.length;n<s;n+=1){const s=t[n];e.synchronized&&(s.dateStart&&(e.dateStart=a(s,"dateStart","min")),s.dateEnd&&(e.dateEnd=a(s,"dateEnd","max")),s.minDateStart&&(e.minDateStart=a(s,"minDateStart","max")),s.maxDateStart&&(e.maxDateStart=a(s,"maxDateStart","min")),s.minDateEnd&&(e.minDateEnd=a(s,"minDateEnd","max")),s.maxDateEnd&&(e.maxDateEnd=a(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 a(t,i,a){const n=e[i];let s=t[i];return void 0===n?new Date(s):s instanceof Date?new Date(Math[a](n.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 a=t.$.resourceSplitterItem;t.$.mainSplitter.contains(a)&&a.contains(e.target)?t._handleVerticalScroll(e,!0):t.$.taskSplitterItem.contains(e.target)&&t._handleVerticalScroll(e)}_handleVerticalScroll(e,t){const i=this;let a,n,s,r;if(t){if(a=i.$.resourceVerticalScrollBar,a.classList.contains("smart-hidden")||a.disabled)return!0;n=a.value,s=a.max,r=i._resourceScrollView}else{if(!i.computedVerticalScrollBarVisibility||i.$.verticalScrollBar.disabled)return!0;n=i.scrollTop,s=i.scrollHeight,r=i}if(0===n&&e.deltaY<0||n===s&&e.deltaY>0)return void e.stopPropagation();const o=i.$[t?"resourceTable":"taskTable"];if(e.stopPropagation(),e.preventDefault(),n+=i._getScrollCoefficient(e,i.offsetHeight),r){const e=o.$.virtualizationContainer;e.scrollHeight!==r.scrollHeight&&(e.scrollHeight=r.scrollHeight),r.scrollTo(n,void 0)}o.scrollTop=n,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`],a=t.$[`${e}SplitterItem`],n="task"===e?"headerTemplate":"resourcePanelHeaderTemplate";let s=t[n];if(a.removeAttribute("show-header"),i.innerHTML="",!s)return;if("function"==typeof s)return s(i,{}),void(i.innerHTML?a.setAttribute("show-header",""):a.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:n}));let r=document.importNode(s.content,!0);if(a.setAttribute("show-header",""),t.shadowRoot)return i.innerHTML="<slot></slot>",void t.appendChild(r);i.appendChild(r)}_handleCollapseExpandMethods(e,t){const i=this,a=i._tasks;if(null==e||!a||!a.length)return;const n=i._getValidItemAndIndex(e);if(!n||!n.item)return void i.error(i.localize("incorrectArgument",{elementType:i.nodeName.toLowerCase(),methodName:"collapse",argumentName:"task"}));let s=n.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,a="task"===t?i._tasks:i._resources;let n;if(null==e||!a||!a.length)return{};if("string"==typeof e||"number"==typeof e){const t=e.toString();let i,s;for(let n=0,r=a.length;n<r;n+=1){const r=a[n];if(!i){const a=r.id;if(null!=a&&a.toString&&a.toString()===t){i=r,e=n;break}}r.$.id===t&&(s=r,e=n)}n=i||s}else"object"==typeof e&&(n=a[i._getItemIndex(e,t)],e=a.indexOf(n));return{item:n,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,a=Math.round(e.detail.value);e.stopPropagation&&e.stopPropagation(),t._refreshing||(i&&i===t.$.resourceVerticalScrollBar?t.$.resourceTable.scrollTop=t.$.resourceTimelineContent.scrollTop=a:(t.$.taskTimelineContainer.scrollTop=a,t.$.taskTable.scrollTop=a),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,a=t[t.length-1].date;switch(e.view){case"quarter":case"year":a.setMonth(a.getMonth()+i);break;case"month":a.setDate(a.getDate()+7*i);break;case"week":a.setDate(a.getDate()+i);break;case"day":a.setHours(a.getHours()+i)}e.set("dateEnd",a),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 a=this,[n,s,r]=i?[0,23,24]:[0,6,7];let o=[];function l(e){let t=Math.max(n,Math.min(s,parseInt(e[0]))),i=Math.max(n,Math.min(s,parseInt(e[1])));if(!isNaN(t)&&!isNaN(i)){for(;t!==i;)o.push(t),t=t===s?n:++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(n,Math.min(s,parseInt(i))))}return o.length===r&&(o.pop(),a.warn(a.localize("invalidNonworkingRange",{elementType:a.nodeName.toLowerCase(),property:i?"nonworkingHours":"nonworkingDays"}))),o}});
|
|
91
91
|
|
|
92
92
|
/***/ }),
|
|
93
93
|
|
|
@@ -101,7 +101,7 @@ Smart("smart-grid-panel",class extends Smart.BaseElement{static get properties()
|
|
|
101
101
|
/***/ 8588:
|
|
102
102
|
/***/ (() => {
|
|
103
103
|
|
|
104
|
-
Smart("smart-input",class extends Smart.BaseElement{static get properties(){return{autoCompleteDelay:{value:100,type:"number"},dataSource:{type:"any",value:[],reflectToAttribute:!1},dropDownClassList:{value:[],type:"array",reflectToAttribute:!1},dropDownDataSource:{type:"any",reflectToAttribute:!1,value:[]},dropDownHeight:{type:"any",value:200},dropDownOpenMode:{allowedValues:["default","manual"],value:"default",type:"string"},dropDownAppendTo:{value:null,type:"any"},dropDownWidth:{type:"any",value:null},dropDownButtonPosition:{allowedValues:["none","left","right"],value:"none",type:"string"},dropDownOpenPosition:{allowedValues:["bottom","top","auto"],value:"bottom",type:"string"},dropDownPlaceholder:{type:"string",value:""},hint:{type:"string",value:""},inputPurpose:{type:"string",value:"off"},items:{type:"number",value:8},minLength:{type:"number",value:1},maxLength:{type:"number",value:99999999},name:{value:"",type:"string"},prefix:{value:"",type:"string",reflectToAttribute:!1},suffix:{value:"",type:"string",reflectToAttribute:!1},onAffixClick:{value:null,type:"any",reflectToAttribute:!1},opened:{value:!1,type:"boolean"},query:{type:"string",value:""},queryMode:{allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase"],type:"string",value:"containsIgnoreCase"},placeholder:{value:"",type:"string"},readonly:{type:"boolean",value:!1},sorted:{value:!1,type:"boolean"},sortDirection:{value:"asc",type:"string"},selectedIndex:{type:"number",value:-1},selectedValue:{type:"any",value:""},selectedValues:{value:[],type:"array"},type:{type:"string"},value:{type:"string",value:""},innerHTML:{type:"string",reflectToAttribute:!1}}}static get styleUrls(){return["smart.textbox.css"]}template(){return'<div id="inputContainer" role="presentation"><div id="optionsContainer" inner-h-t-m-l=\'{{innerHTML}}\' class="smart-hidden"></div><span class="smart-input-prefix" id="prefix" inner-h-t-m-l=\'{{prefix}}\'></span><input maxlength=\'[[maxLength]]\' class="smart-input" id=\'input\' readonly=\'[[readonly]]\' placeholder=\'[[placeholder]]\' type=\'[[type]]\' name=\'[[name]]\' value=\'{{value::keyup}}\' disabled=\'[[disabled]]\' aria-label="[[placeholder]]" /><span class="smart-hidden smart-hint" id="span">[[hint]]</span><span id="suffix" class="smart-input-suffix" inner-h-t-m-l=\'{{suffix}}\'></span><div id="dropDownButton" tabindex=-1 class="smart-drop-down-button" role="button" aria-label="Toggle popup"><div id="arrow" class="arrow" aria-hidden="true"></div></div></div>'}static get listeners(){return{"input.focus":"_focusHandler","input.blur":"_blurHandler","input.keydown":"_keyDownHandler","input.keyup":"_keyUpHandler","input.keypress":"_keyPressHandler","input.paste":"_pasteHandler","prefix.click":"_prefixClick","suffix.click":"_suffixClick","dropDownButton.down":"_dropDownButtonDownHandler","inputContainer.down":"_downHandler","document.up":"_documentUpHandler"}}_prefixClick(e){const t=this;if(t.onAffixClick)if("string"==typeof t.onAffixClick){const o=t.onAffixClick.replace("()","");window[o]&&window[o].apply(t,e)}else t.onAffixClick(e)}_suffixClick(e){const t=this;if("string"==typeof t.onAffixClick){const o=t.onAffixClick.replace("()","");window[o]&&window[o].apply(t,e)}else t.onAffixClick(e)}get selectedIndexes(){return this.isCompleted?[this.selectedIndex]:[]}set selectedIndexes(e){if(!this.isCompleted)return;const t=this;if(e&&void 0!==e[0]){if(this.selectedIndex=e[0],null===this.dataSource)return;const o=this.dataSource[this.selectedIndex];if(!o)return;const a=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="string"==typeof o?o:o.value,this.setAttribute("data-value",this.$.input.dataValue);let l=t.dataSource;"string"==typeof l&&(l=t.$.deserialize(l,"array"));for(let e=0;e<l.length;e++){let o=l[e];"string"!=typeof o&&"number"!=typeof o&&(o.value===t.$.input.dataValue?o.selected=!0:o.selected=!1)}this.context=a}else{const e=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="",this.setAttribute("data-value",this.$.input.dataValue),this.selectedIndex=-1;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),o&&Array.isArray(o))for(let e=0;e<o.length;e++){let a=o[e];"string"!=typeof a&&(a.value===t.$.input.dataValue?a.selected=!0:a.selected=!1)}this.context=e}}focus(){this.$.input.focus()}select(){const e=this;e.readonly?e.$.input.focus():e.$.input.select()}_documentUpHandler(e){const t=this,o=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;o!==t&&o!==t.$.dropDownButton&&o!==t.$.input&&o!==t.$.arrow?t.$.scrollView.contains(o.shadowParent||o)?t._isPointerDown&&(t._isPointerDown=!1,t.opened&&(t._preventLookup=!0),t.$.input.focus()):(t.opened&&(t._preventLookup=!0),"manual"===t.dropDownOpenMode||t._isPointerDown||t.close(),t._isPointerDown=!1):t._isPointerDown=!1}_focusHandler(){const e=this;e.setAttribute("focus",""),e.readonly||0!==e.minLength||0!==e.$.input.value.length||e._preventLookup?(e.$.fireEvent("focus"),delete e._preventLookup):e._lookup()}_blurHandler(){const e=this;e.opened||e.removeAttribute("focus"),e.opened||e.$.fireEvent("blur"),e._refreshSelectedIndex(),delete e._preventLookup}_pasteHandler(e){const t=this,o=t.$.input,a=o.value,l=o.selectionStart,r=o.selectionEnd;if(!e.clipboardData&&!window.clipboardData)return;if(t.disabled)return;const i=(e.clipboardData||window.clipboardData).getData("text");let n=a.slice(0,l)+i;n.length,n+=a.slice(r),t.setAttribute("data-value",n),t._refreshSelectedIndex()}_refreshSelectedIndex(){const e=this;let t=e.dataSource;if(t){let o=-1,a=null;if(e.dataSource instanceof Promise)return;if("function"==typeof e.dataSource)return;"string"==typeof t&&(t=e.$.deserialize(t,"array"));for(let l=0;l<t.length;l++){let r=t[l];if("number"!=typeof r&&"boolean"!=typeof r||(r=""+r),"string"==typeof r){if(r===e.value){o=l,a=e.value;break}}else r&&(delete r.selected,r.label===e.value&&(o=l,a=r.value,r.selected=!0))}e.set("selectedIndex",o,!1),e.set("selectedValue",a,!1),-1===e.selectedIndex&&(e.$.input.dataValue=null)}}selectItem(e){const t=this;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),o)for(let a=0;a<o.length;a++){const l=o[a];if(t.set("selectedIndex",-1),t.set("value",""),t.$.input.dataValue=null,"string"==typeof l){if(l===e)return t.set("selectedIndex",a,!1),t.set("value",t.$.input.dataValue=e),void t.setAttribute("data-value",t.$.input.dataValue)}else if(l.value===e)return t.set("selectedIndex",a,!1),t.set("value",l.label),t.$.input.dataValue=e,void t.setAttribute("data-value",t.$.input.dataValue)}else t.set("value",t.$.input.dataValue=e),t.setAttribute("data-value",t.$.input.dataValue),t.set("selectedIndex",-1,!1)}getItem(e){const t=this;if(t.dataSource)for(let o=0;o<t.dataSource.length;o++){const a=t.dataSource[o];if(a.value===e)return a}return null}getPrevItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let o=0;o<e.dataSource.length;o++)if(e.dataSource[o].value===t.value)return e.dataSource[o-1];return null}getNextItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let o=0;o<e.dataSource.length;o++)if(e.dataSource[o].value===t.value)return e.dataSource[o+1];return null}getSelectedItem(){const e=this;return e.dataSource&&0===e.dataSource.length?{label:e.value,value:e.$.input.dataValue?e.$.input.dataValue:e.value}:{label:e.value,value:void 0!==e.$.input.dataValue?e.$.input.dataValue:e.value}}_refreshMenu(){const e=this;e.$.menu.classList.remove("scroll"),e.$.scrollView.computedVerticalScrollBarVisibility&&e.$.menu.classList.add("scroll")}_fromHTMLEntities(e){const t=this,o=t._textArea?t._textArea:document.createElement("textarea");return o.innerHTML=e,t._textArea=o,o.value}_performSelect(){const e=this,t=e.$.menu.querySelector(".active");let o="",a="";t&&(o=t.getAttribute("data-label"),o=e._fromHTMLEntities(o),a=t.dataValue);let l=e.value,r=e.$.input.dataValue;e.set("value",o),e.$.input.dataValue=a,e.setAttribute("data-value",a),t&&e.set("selectedIndex",t.index),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue);let i=e.dataSource;if("string"==typeof i&&(i=e.$.deserialize(i,"array")),i&&Array.isArray(i))for(let t=0;t<i.length;t++){let o=i[t];"string"!=typeof o&&"number"!=typeof o&&(o.value===e.$.input.dataValue?o.selected=!0:o.selected=!1)}e.close(),o===l&&a===r||(e.$.fireEvent("change",{value:a,label:o,oldValue:r,oldLabel:l}),e._updateTargetValue())}_open(){const e=this;if(e.opened)return;const t=window.scrollX,o=window.scrollY;let a=e.getBoundingClientRect(),l=0,r=0;if(e.timer&&clearTimeout(e.timer),e.getRootNode()&&e.getRootNode().host)e.getRootNode().host.shadowRoot.appendChild(e.$.scrollView);else if(e.dropDownAppendTo){if("body"===e.dropDownAppendTo||e.dropDownAppendTo===document.body)document.body.appendChild(e.$.scrollView);else if(e.dropDownAppendTo instanceof HTMLElement)e.dropDownAppendTo.appendChild(e.$.scrollView);else if("string"==typeof dropDownAppendTo){let t=document.getElementById(e.dropDownAppendTo);t instanceof HTMLElement?t.appendChild(e.$.scrollView):document.body.appendChild(e.$.scrollView)}}else document.body.appendChild(e.$.scrollView);if(e.setAttribute("aria-owns",e.$.scrollView.id),e.readonly||e.$.input.setAttribute("aria-controls",e.$.scrollView.id),e.$.scrollView.enableShadowDOM&&!e._importedStyle&&(e.$.scrollView.importStyle(e._getStyleUrl("smart.textbox.css")),e._importedStyle=!0),"static"!==getComputedStyle(document.body).position){const e=document.body.getBoundingClientRect();l=e.left,r=e.top}if(e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.style.left=-3+a.left+t-l+"px",e.$.scrollView.classList.remove("open"),e.$.scrollView.removeAttribute("top"),"bottom"===e.dropDownOpenPosition)e.$.scrollView.style.top=a.bottom+o-r+1+"px";else if("top"===e.dropDownOpenPosition)e.$.scrollView.style.top=a.top-e.$.scrollView.offsetHeight+o-r-2+"px",e.$.scrollView.setAttribute("top","");else if("auto"===e.dropDownOpenPosition){e.$.scrollView.style.top=a.bottom+o-r+1+"px";const t=a.top-e.$.scrollView.offsetHeight+o-r-2;window.innerHeight<parseInt(e.$.scrollView.style.top)+e.$.scrollView.offsetHeight-o?t>=0&&(e.$.scrollView.style.top=t+"px",e.$.scrollView.setAttribute("top","")):e.$.scrollView.style.top=a.bottom+o-r+1+"px"}if(e.dropDownAppendTo&&"body"!==e.dropDownAppendTo){e.$.scrollView.style.position="absolute",e.$.scrollView.style.width="auto",e.$.scrollView.style.height="auto";const t=e.$.scrollView.parentNode.getBoundingClientRect();e.$.scrollView.style.top=a.bottom-t.top+"px","top"===e.dropDownOpenPosition&&(e.$.scrollView.style.top=a.top-t.top-e.$.scrollView.offsetHeight+"px"),e.$.scrollView.style.left=-3+a.left-t.left+"px",e.dropDownHeight&&(e.$.scrollView.style.height=e.dropDownHeight),e.dropDownWidth&&(e.$.scrollView.style.width=e.dropDownWidth)}e.opening=!0,e._positionTimer&&clearInterval(e._positionTimer),e.dropDownAppendTo||(e._positionTimer=setInterval((()=>{const t=e.getBoundingClientRect();if(e.opening)e.opening=!1,a=t;else if(Math.abs(parseInt(t.top)-parseInt(a.top))>=10||Math.abs(parseInt(t.left)-parseInt(a.left))>=10){const o=window.scrollX,a=window.scrollY;return e.$.scrollView.style.left=-3+t.left+o-l+"px",void("bottom"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.bottom+a-r+1+"px":"top"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+a-r+1+"px":"auto"===e.dropDownOpenPosition&&(e.$.scrollView.removeAttribute("top"),e.$.scrollView.style.top=t.bottom+a-r+1+"px",window.innerHeight<parseInt(e.$.scrollView.style.top)+e.$.scrollView.offsetHeight-a?(e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+a-r+1+"px",e.$.scrollView.setAttribute("top","")):e.$.scrollView.style.top=t.bottom+a-r+1+"px"))}}),50)),e.$.scrollView.onpointerdown=function(t){e._isPointerDown=!0,t.stopPropagation(),t.preventDefault()},requestAnimationFrame((function(){const t=e.dropDownWidth;if(e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._refreshMenu(),e.$.scrollView.setAttribute("open",""),e.setAttribute("open",""),e.$.dropDownButton.setAttribute("open",""),e.$.input.setAttribute("open",""),t&&"string"==typeof t&&-1!==t.indexOf("%")){const o=parseFloat(t)/100;e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",e.offsetWidth*o+"px")}else if("auto"!==t&&t)e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",parseFloat(t)+"px");else if("auto"===t){if(e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.$.scrollViewerContainer.classList.contains("vscroll")){const t=e.$.scrollView.offsetWidth+parseFloat(getComputedStyle(e.$.scrollView).getPropertyValue("--smart-scroll-bar-size"));e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",t+"px")}}else{e.$.menu.style.width="auto";let t=e.$.menu.offsetWidth;const o=e.$.menu.querySelectorAll("li");for(let t=0;t<o.length;t++)e._maxDropDownWidth=Math.max((o[t].firstElementChild||o[t]).offsetWidth,e._maxDropDownWidth);e.$.scrollView.computedVerticalScrollBarVisibility&&(t+=e.$.scrollView.$&&e.$.scrollView.$.verticalScrollBar?e.$.scrollView.$.verticalScrollBar.offsetWidth:30),e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",Math.max(t,e.offsetWidth-8)+"px"),e.$.menu.style.width=""}(e.shadowRoot||e.isInShadowDOM)&&e.$.scrollView._scrollView&&Smart.ScrollBar&&requestAnimationFrame((()=>{e.$.scrollView._scrollView&&e.$.scrollView._scrollView.vScrollBar.refresh()}))})),e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._refreshMenu(),e.set("opened",!0),e.setAttribute("aria-expanded",!0),e.$.fireEvent("open")}close(){const e=this;return!!e.opened&&(e.timer&&clearTimeout(e.timer),e.timer=setTimeout((function(){e.$.scrollView.parentNode&&!e.opened&&(e.$.scrollView.remove(),e.removeAttribute("aria-owns"),e.readonly||e.$.input.removeAttribute("aria-controls"))}),1e3),e._positionTimer&&clearInterval(e._positionTimer),e.$.scrollView.removeAttribute("open"),e.$.dropDownButton.removeAttribute("open"),e.$.input.removeAttribute("open"),e.removeAttribute("open"),e.set("opened",!1),e.setAttribute("aria-expanded",!1),e.$.input.focus(),e.$.fireEvent("close"),!0)}refresh(){const e=this;e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._getDataSourceFromOption(),e.close()}_lookup(e){const t=this;t.query=t.$.input.value;const o=t.context;if(t.context=t,t.selectedIndex=-1,t.selectedValue=null,t.context=o,t.$.input.readonly&&(t._incrementalSearchQuery||(t._incrementalSearchQuery=""),t._incrementalSearchQuery+=e.key,t._incrementalSearchTimer&&clearTimeout(t._incrementalSearchTimer),t.query=t._incrementalSearchQuery,t._incrementalSearchTimer=setTimeout((function(){t._incrementalSearchQuery=""}),700)),t.query.length<t.minLength)return void t.close();const a=function(e){clearTimeout(t._autoCompleteTimeout),t._autoCompleteTimeout=setTimeout((()=>{const o=t.context;t.context=t,t._process(e),t.context=o}),t.autoCompleteDelay)};"function"==typeof t.dataSource?t.dataSource(t.query,a):a(t.dataSource)}_downHandler(e){const t=this;t.readonly&&t._dropDownButtonDownHandler(e)}_dropDownButtonDownHandler(e){const t=this;return"manual"!==t.dropDownOpenMode&&(t._toggle(),t.focus()),e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),t._isPointerDown=!0,!1}_toggle(){const e=this;e.opened?e.close():e.open()}open(){const e=this;function t(t){e._process(t);const o=e.$.menu.querySelector(".active");if(o){const t=e.$.input.dataValue;for(let a=0;a<e.$.menu.children.length;a++){const l=e.$.menu.children[a],r=l.getAttribute("data-label"),i=l.dataValue;if(void 0!==t&&i===t||void 0===t&&r===e.$.input.value){o.classList.remove("active"),l.classList.add("active"),e._setActiveDescendant(l),e.$.input.dataValue=i,e.setAttribute("data-value",i);break}}}e.ensureVisible(),e.$.input.focus(),setTimeout((function(){e.$.input.focus()}),25)}e.dropDownDataSource&&(Array.isArray(e.dropDownDataSource)&&e.dropDownDataSource.length>0||"function"==typeof e.dropDownDataSource)?(e.query="","function"==typeof e.dropDownDataSource?e.dropDownDataSource(e.query,t):t(e.dropDownDataSource)):(e.query="","function"==typeof e.dataSource?e.dataSource(e.query,t):t(e.dataSource))}_process(e){const t=this;"string"==typeof e&&(e=t.$.deserialize(e,"array")),e=t.readonly?e.filter((function(){return!0})):e.filter((function(e){return""===e||(t.matcher?t.matcher(e):t._matcher(e))})),e=t._sorter(e),t.sorted&&(e.sort(((e,t)=>void 0!==e.label?e.label.localeCompare(t.label):e.localeCompare(t))),"desc"===t.sortDirection&&e.reverse()),!e.length&&t.opened&&t.close(),0===e.length&&!0!==t.allowItemsAdd&&""===t.dropDownPlaceholder||(t.query.length>0?t._render(e.slice(0,t.items)):t._render(e),t._open(),t.$.scrollView.refresh&&t.$.scrollView.refresh(),t._refreshMenu(),t.ensureVisible())}_matcher(e){const t=this.query;switch(null===e&&(e="null"),e=""+(e=e.label||e),this.queryMode){case"startsWith":return e.startsWith(t);case"startsWithIgnoreCase":return e.toLowerCase().startsWith(t.toLowerCase());case"doesNotContain":return e.indexOf(t)<0;case"doesNotContainIgnoreCase":return e.toLowerCase().indexOf(t.toLowerCase())<0;case"contains":return e.indexOf(t)>-1;default:case"containsIgnoreCase":return~e.toLowerCase().indexOf(t.toLowerCase());case"equals":return 0===e.localeCompare(t);case"equalsIgnoreCase":return 0===e.toLowerCase().localeCompare(t.toLowerCase());case"endsWith":return e.endsWith(t);case"endsWithIgnoreCase":return e.toLowerCase().endsWith(t.toLowerCase())}}_sorter(e){const t=this;let o,a=[],l=[],r=[];if(e&&""===e[0])return e;for(;o=e.shift();){let e=o.label||o;e=""+e,e.toLowerCase().indexOf(t.query.toLowerCase())?~e.indexOf(t.query)?l.push(o):r.push(o):a.push(o)}return a.concat(l,r)}_highlighter(e){const t=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return this.query?e.replace(new RegExp("("+t+")","ig"),(function(e,t){return"<strong>"+t+"</strong>"})):e}_render(e){const t=this;let o=0,a=-1,l=null;const r=e.map((function(e){let r=e,i=e;"object"==typeof e&&(r=e.label,i=void 0!==e.value?e.value:r),r=""+r,r=r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""");const n=document.createElement("li"),s=document.createElement("a");if(s.href="javascript:void(0)",n.id=t.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),n.setAttribute("data-label",r),n.index=o++,n.dataValue=i,"string"==typeof i?n.setAttribute("value",i):n.setAttribute("value",JSON.stringify(i)),n.setAttribute("role","option"),n.setAttribute("aria-label",r),void 0!==e.menuLabel?(r=e.menuLabel,s.innerHTML=r):s.innerHTML=t.highlighter?t.highlighter(r):t._highlighter(r),s.setAttribute("aria-hidden",!0),e.disabled&&n.classList.add("smart-disabled"),e.icon&&(s.classList.add("icon"),s.classList.add(e.icon)),e.prefix){const t=document.createElement("span");t.innerHTML=e.prefix,s.classList.add("has-prefix"),s.innerHTML=t.innerHTML+s.innerHTML}if(e.suffix){const t=document.createElement("span");t.innerHTML=e.suffix,s.classList.add("has-suffix"),s.innerHTML=s.innerHTML+t.innerHTML}if(e.dataset)for(let t in e.dataset)n.setAttribute("data-"+t,e.dataset[t]);if(e.className){const t=e.className.split(" ");for(let e=0;e<t.length;e++)n.classList.add(t[e].trim())}return void 0!==t.selectedValue&&void 0!==e.value&&""!==t.selectedValue&&t.selectedValue===e.value&&(e.selected=!0,l=e,a=n.index,n.classList.add("active")),n.appendChild(s),n}));function i(){const e=t.$.menu.getElementsByClassName("active");e[0]&&e[0].classList.remove("active"),this.classList.add("active"),t._setActiveDescendant(this)}-1===a&&r.length>0&&(r[0].classList.add("active"),t._setActiveDescendant(r[0])),l&&(t.$.input.value=l.label,t.$.input.dataValue=l.value,t.setAttribute("data-value",t.$.input.dataValue)),t.$.menu.innerHTML="",0===r.length&&t.dropDownPlaceholder&&(t.$.menu.innerHTML='<div class="smart-flex smart-truncate smart-quiet" style="padding:10px; align-items: center;">'+t.dropDownPlaceholder+"</div>");for(let e=0;e<r.length;e++){const o=r[e];t.$.menu.appendChild(o),o.onmouseenter=i,o.onmouseleave=function(){this.classList.remove("active"),t._setActiveDescendant(null)},o.onclick=i}}ensureVisible(){const e=this,t=e.$.menu.querySelector(".active");t&&(t.offsetTop+t.offsetHeight>=e.$.scrollView.scrollTop+e.$.scrollView.offsetHeight&&(e.$.scrollView.scrollTop=t.offsetTop+t.offsetHeight),(t.offsetTop<=e.$.scrollView.scrollTop||t.offsetTop>=e.$.scrollView.scrollTop+e.$.scrollView.offsetHeight)&&(e.$.scrollView.scrollTop=t.offsetTop),0===[...e.$.menu.children].indexOf(t)?e.$.scrollView.scrollTop=0:[...e.$.menu.children].indexOf(t)===e.$.menu.children.length-1&&(e.$.scrollView.scrollTop=e.$.scrollView.scrollHeight))}_next(){const e=this,t=e.$.menu.querySelector(".active");if(!t){const t=e.$.menu.firstElementChild;return t.classList.add("active"),void e._setActiveDescendant(t)}t.classList.remove("active");let o=t.nextElementSibling;o||(o=e.$.menu.firstElementChild),o.classList.add("active"),e._setActiveDescendant(o),e.ensureVisible()}_prev(){const e=this,t=e.$.menu.querySelector(".active");if(!t){const t=e.$.menu.firstElementChild;return t.classList.add("active"),void e._setActiveDescendant(t)}t.classList.remove("active");let o=t.previousElementSibling;o||(o=e.$.menu.lastElementChild),o.classList.add("active"),e._setActiveDescendant(o),e.ensureVisible()}_move(e){const t=this;if(t.readonly&&!t.opened){if("ArrowUp"===e.key){const o=t.getPrevItem();o&&t.selectItem(o.value),e.preventDefault()}if("ArrowDown"===e.key){const o=t.getNextItem();o&&t.selectItem(o.value),e.preventDefault()}}if(t.opened){switch(e.keyCode){case 9:case 13:case 27:e.preventDefault();break;case 38:e.preventDefault(),t._prev();break;case 40:e.preventDefault(),t._next()}e.stopPropagation()}}_keyDownHandler(e){const t=this;if(t._suppressKeyPressRepeat=![40,38,9,13,27,16,17,18].includes(e.keyCode),t._oldValue=t.$.input.value,!(e.shiftKey||e.altKey||e.ctrlKey))return t.opened&&"Escape"===e.key?(t.close(),e.stopPropagation(),void e.preventDefault()):void t._move(e)}_keyPressHandler(e){this._suppressKeyPressRepeat||e.shiftKey||e.altKey||e.ctrlKey||this._move(e)}_keyUpHandler(e){const t=this;if(!(e.shiftKey||"F2"===e.key||"a"===e.key&&e.ctrlKey))switch(e.keyCode){case 40:case 38:case 16:case 17:case 18:40===e.keyCode&&e.altKey&&t.open(),38===e.keyCode&&e.altKey&&t.close();break;case 9:case 13:if(!t.opened)return;t._performSelect(),e.stopPropagation(),e.preventDefault();break;case 27:if(!t.opened)return;t.close(),e.stopPropagation(),e.preventDefault();break;default:if(t._lookup(e),!t.opened||e.ctrlKey||e.shiftKey||(e.stopPropagation(),e.preventDefault()),t.$.fireEvent("changing",{value:t.$.input.value,oldValue:t._oldValue}),t.dataSource&&t.dataSource.length)for(let e=0;e<t.dataSource.length;e++){const o=t.dataSource[e];if("string"==typeof o){if(o===t.$.input.value){t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue);break}}else if(void 0!==o.label&&o.label===t.$.input.value){t.$.input.dataValue=o.value,t.setAttribute("data-value",o.value);break}}else t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue);t._updateTargetValue()}}clearValue(){const e=this;e.$.input.value="",e.$.input.dataValue="",e.removeAttribute("data-value"),e.set("value",""),e.set("selectedIndex",-1),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue)}propertyChangedHandler(e,t,o){super.propertyChangedHandler(e,t,o);const a=this;if("innerHTML"===e&&(a._getDataSourceFromOption(),a._setSelection(!1)),"selectedValue"===e){let e=-1;if(a.dataSource&&Array.isArray(a.dataSource)&&a.dataSource.forEach(((t,a)=>{"string"==typeof t?t===o&&(e=a):t&&t.value===o&&(e=a)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}a._setSelection()}if("selectedIndex"===e){let e=a.dataSource;if(a.selectedValue=null,e&&Array.isArray(e))for(let t=0;t<e.length;t++){let o=e[t];"string"!=typeof o&&"number"!=typeof o&&(o.selected=!1)}a._setSelection()}else if("dataSource"===e){if(a.dataSource&&Array.isArray(a.dataSource)){let e=-1;if(a.dataSource.forEach(((t,o)=>{t.selected&&(e=o)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}}a._setSelection(!1)}else if("dropDownClassList"===e){const e=a.$.scrollView;for(let o=0,a=t.length;o<a;o+=1)e.classList.remove(t[o]);for(let t=0,a=o.length;t<a;t+=1)e.classList.add(o[t])}else if("dropDownHeight"===e)"auto"!==a.dropDownHeight?a.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height",a.dropDownHeight+"px"):a.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height","auto");else if("opened"===e)a.opened=t,o?a.open():a.close();else if("placeholder"===e){if(a.readonly){const e=a.getAttribute("aria-label");if(e&&e!==t)return;o?a.setAttribute("aria-label",o):a.removeAttribute("aria-label")}}else if("selectedValues"===e)if(null===o)a.$.input.value="",a.$.input.dataValue=o,a.setAttribute("data-value",o),a._refreshSelectedIndex();else{const e=o.join(","),t=a.value;if(a.$.input.dataValue=e,e&&-1===e.indexOf(",")){let e=-1,t=o[0];if(a.dataSource&&Array.isArray(a.dataSource)&&a.dataSource.forEach(((a,l)=>{"string"==typeof a?a!==o&&a!==t||(e=l):a&&a.value===t&&(e=l)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}}a._setSelection(),a.propertyChangedHandler("value",t,a.value)}else"value"===e?(a.displayMember!==a.valueMember&&"string"!=typeof o?(a.set("value",o[a.displayMember]),a.$.input.dataValue=o[a.valueMember],a.setAttribute("data-value",a.$.input.dataValue)):(a.$.input.value=a.$.input.dataValue=o,a.setAttribute("data-value",o)),a._refreshSelectedIndex()):"readonly"===e?(a._setAriaRelations(),a._setInputPurpose()):"theme"===e||"rightToLeft"===e?a.$.scrollView[e]=o:"inputPurpose"===e?a._setInputPurpose():"inverted"===e?o?a.$.scrollView.setAttribute("inverted",""):a.$.scrollView.removeAttribute("inverted"):"disabled"!==e&&"unfocusable"!==e||a._setFocusable()}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const o=e.dataset.property,a=e.value;o&&void 0!==t[o]&&(t[o]=a)}}}detached(){super.detached(),this.close(),this.removeAttribute("focus")}_getDataSourceFromOption(){const e=this;if(e.innerHTML.indexOf("<option")>=0){e.$.optionsContainer.innerHTML=e.innerHTML.trim();const t=e.querySelectorAll("option");let o=[];for(let e=0;e<t.length;e++){const a=t[e],l=a.hasAttribute("selected")||a.hasAttribute("is-selected")&&"false"!==a.getAttribute("is-selected");let r=(""+a.textContent).trim();const i=(""+a.innerHTML).trim(),n=a.hasAttribute("value")?a.getAttribute("value"):r,s=a.hasAttribute("disabled"),u=a.hasAttribute("label")?a.getAttribute("label"):null;u&&(r=u),o.push({label:r,menuLabel:i,value:n,disabled:s,selected:l,className:a.className,dataset:a.dataset}),a.classList.add("smart-hidden")}e.dataSource=o}}render(){const e=this,t=e.dropDownClassList;if(e._getDataSourceFromOption(),e.selectedValues&&e.selectedValues.length){const t=e.selectedValues.join(",");e.value=t}e._createElement&&e._createElement();const o=e.$.scrollView;for(let e=0,a=t.length;e<a;e+=1)o.classList.add(t[e]);e.opened&&(e.opened=!1,e.open());const a=e.$.menu;a&&(a.setAttribute("role","presentation"),o.appendChild(a)),"auto"!==e.dropDownHeight?o.style.setProperty("--smart-input-drop-down-menu-height",e.dropDownHeight+"px"):o.style.setProperty("--smart-input-drop-down-menu-height","auto"),o.classList.add("smart-input-drop-down-menu");for(let t=0;t<e.classList.length;t++){const a=e.classList[t];"smart-element"!==a&&"smart-input"!==a&&o.classList.add(a+"-drop-down-menu")}o.id=e.id+"_"+e.tagName.toLowerCase()+"_menu_"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),o.ownerElement=e;let l=e.dataSource;if("string"==typeof l&&(l=e.$.deserialize(l,"array")),l&&l.length&&Array.isArray(l)){let t=-1;if(l.forEach(((e,o)=>{e.selected&&(t=o)})),t>=0){e.selectedIndex=t;const o=l[t];e.selectedValue="string"==typeof o?l[t]:l[t].value}}e._setAriaRelations(),e._setInputPurpose(),e._setSelection(),e.isInitialized=!0,e.hasAttribute("tabindex")&&(e.readonly||(e.$.input.setAttribute("tabindex",e.getAttribute("tabindex")),e.removeAttribute("tabindex"))),super.render()}_setSelection(e){const t=this;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),t.selectedIndex>=0&&o&&o.length>0){let a=o[t.selectedIndex];if("number"!=typeof a&&"boolean"!=typeof a||(a=""+a),"string"==typeof a){let o=t.$.input.dataValue,l=t.value;t.set("value",a),t.$.input.dataValue=a,t.$.input.setAttribute("data-value",a),t.selectedValues=[t.$.input.dataValue],t.isInitialized&&!1!==e&&(t.$.fireEvent("change",{value:t.value,label:t.label,oldValue:o,oldLabel:l}),t._updateTargetValue())}else{let o=t.$.input.dataValue,l=t.value;a&&(void 0!==a.value?(t.set("value",void 0!==a.value?a.value+"":""),t.$.input.dataValue=a.value,t.$.input.setAttribute("data-value",a.value),t.selectedValues=[t.$.input.dataValue]):a.label&&(t.selectedValues=[a.value]),a.label&&t.set("value",a.label)),t.isInitialized&&!1!==e&&(t.$.fireEvent("change",{value:t.$.input.dataValue,label:a.value,oldValue:o,oldLabel:l}),t._updateTargetValue())}}}_createElement(){const e=this,t=document.createElement("ul"),o=document.createElement("smart-scroll-viewer");o.rightToLeft=e.rightToLeft,o.theme=e.theme,o.horizontalScrollBarVisibility="hidden",e.inverted?o.setAttribute("inverted",""):o.removeAttribute("inverted"),e.$.scrollView=o,e.$.menu=t,e._setFocusable();const a=e.$.input;e.$.menu.onpointerdown=function(t){const o=t.target.closest("li"),l=e.$.menu.querySelector(".active");l&&o&&(l.classList.remove("active"),o.classList.add("active")),t.stopPropagation(),t.preventDefault(),setTimeout((()=>{e._performSelect(),o&&o.parentNode&&e.$.fireEvent("itemClick",{index:[...o.parentNode.children].indexOf(o),item:o,label:o.getAttribute("aria-label"),value:o.dataValue}),a.focus()}),50)},e.$.menu.onpointerup=function(t){t.stopPropagation(),t.preventDefault(),e.$.scrollView.$.verticalScrollBar.thumbCapture&&(e.$.scrollView.$.verticalScrollBar.thumbCapture=!1)}}_setAriaRelations(){const e=this,t=e.getAttribute("aria-label");e.readonly?(e.setAttribute("role","button"),!t&&e.placeholder&&e.setAttribute("aria-label",e.placeholder),e.removeAttribute("aria-readonly"),e.$.input.setAttribute("aria-hidden",!0),e.$.input.removeAttribute("aria-activedescendant"),e.$.input.removeAttribute("aria-controls"),e.$.dropDownButton.setAttribute("aria-hidden",!0)):(e.setAttribute("role","combobox"),t&&t===e.placeholder&&e.removeAttribute("aria-label"),e.$.input.setAttribute("role","searchbox"),e.$.input.removeAttribute("aria-hidden",!0),e.$.dropDownButton.removeAttribute("aria-hidden")),e.setAttribute("aria-expanded",e.opened),e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-owns",e.$.scrollView.id),e.$.scrollView.setAttribute("role","listbox")}_setActiveDescendant(e){const t=this;t.readonly||(e?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant"))}_setInputPurpose(){const e=this;e.readonly?e.$.input.removeAttribute("autocomplete"):e.$.input.setAttribute("autocomplete",e.inputPurpose)}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.$.input.setAttribute("tabindex",-1):e.$.input.removeAttribute("tabindex")}});
|
|
104
|
+
Smart("smart-input",class extends Smart.BaseElement{static get properties(){return{autoCompleteDelay:{value:100,type:"number"},dataSource:{type:"any",value:[],reflectToAttribute:!1},dropDownClassList:{value:[],type:"array",reflectToAttribute:!1},dropDownDataSource:{type:"any",reflectToAttribute:!1,value:[]},dropDownHeight:{type:"any",value:200},dropDownOpenMode:{allowedValues:["default","manual"],value:"default",type:"string"},dropDownAppendTo:{value:null,type:"any"},dropDownWidth:{type:"any",value:null},dropDownButtonPosition:{allowedValues:["none","left","right"],value:"none",type:"string"},dropDownOpenPosition:{allowedValues:["bottom","top","auto"],value:"bottom",type:"string"},dropDownPlaceholder:{type:"string",value:""},hint:{type:"string",value:""},inputPurpose:{type:"string",value:"off"},items:{type:"number",value:8},minLength:{type:"number",value:1},maxLength:{type:"number",value:99999999},name:{value:"",type:"string"},prefix:{value:"",type:"string",reflectToAttribute:!1},suffix:{value:"",type:"string",reflectToAttribute:!1},onAffixClick:{value:null,type:"any",reflectToAttribute:!1},opened:{value:!1,type:"boolean"},query:{type:"string",value:""},queryMode:{allowedValues:["contains","containsIgnoreCase","doesNotContain","doesNotContainIgnoreCase","equals","equalsIgnoreCase","startsWith","startsWithIgnoreCase","endsWith","endsWithIgnoreCase"],type:"string",value:"containsIgnoreCase"},placeholder:{value:"",type:"string"},readonly:{type:"boolean",value:!1},sorted:{value:!1,type:"boolean"},sortDirection:{value:"asc",type:"string"},selectedIndex:{type:"number",value:-1},selectedValue:{type:"any",value:""},selectedValues:{value:[],type:"array"},type:{type:"string"},value:{type:"string",value:""},innerHTML:{type:"string",reflectToAttribute:!1}}}static get styleUrls(){return["smart.textbox.css"]}template(){return'<div id="inputContainer" role="presentation"><div id="optionsContainer" inner-h-t-m-l=\'{{innerHTML}}\' class="smart-hidden"></div><span class="smart-input-prefix" id="prefix" inner-h-t-m-l=\'{{prefix}}\'></span><input maxlength=\'[[maxLength]]\' class="smart-input" id=\'input\' readonly=\'[[readonly]]\' placeholder=\'[[placeholder]]\' type=\'[[type]]\' name=\'[[name]]\' value=\'{{value::keyup}}\' disabled=\'[[disabled]]\' aria-label="[[placeholder]]" /><span class="smart-hidden smart-hint" id="span">[[hint]]</span><span id="suffix" class="smart-input-suffix" inner-h-t-m-l=\'{{suffix}}\'></span><div id="dropDownButton" tabindex=-1 class="smart-drop-down-button" role="button" aria-label="Toggle popup"><div id="arrow" class="arrow" aria-hidden="true"></div></div></div>'}static get listeners(){return{"input.focus":"_focusHandler","input.blur":"_blurHandler","input.keydown":"_keyDownHandler","input.keyup":"_keyUpHandler","input.keypress":"_keyPressHandler","input.paste":"_pasteHandler","prefix.click":"_prefixClick","suffix.click":"_suffixClick","dropDownButton.down":"_dropDownButtonDownHandler","inputContainer.down":"_downHandler","document.up":"_documentUpHandler"}}_prefixClick(e){const t=this;if(t.onAffixClick)if("string"==typeof t.onAffixClick){const o=t.onAffixClick.replace("()","");window[o]&&window[o].apply(t,e)}else t.onAffixClick(e)}_suffixClick(e){const t=this;if("string"==typeof t.onAffixClick){const o=t.onAffixClick.replace("()","");window[o]&&window[o].apply(t,e)}else t.onAffixClick(e)}get selectedIndexes(){return this.isCompleted?[this.selectedIndex]:[]}set selectedIndexes(e){if(!this.isCompleted)return;const t=this;if(e&&void 0!==e[0]){if(this.selectedIndex=e[0],null===this.dataSource)return;const o=this.dataSource[this.selectedIndex];if(!o)return;const a=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="string"==typeof o?o:o.value,this.setAttribute("data-value",this.$.input.dataValue);let l=t.dataSource;"string"==typeof l&&(l=t.$.deserialize(l,"array"));for(let e=0;e<l.length;e++){let o=l[e];"string"!=typeof o&&"number"!=typeof o&&(o.value===t.$.input.dataValue?o.selected=!0:o.selected=!1)}this.context=a}else{const e=this.context;this.context=this,this.$.input.dataValue=this.selectedValue="",this.setAttribute("data-value",this.$.input.dataValue),this.selectedIndex=-1;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),o&&Array.isArray(o))for(let e=0;e<o.length;e++){let a=o[e];"string"!=typeof a&&(a.value===t.$.input.dataValue?a.selected=!0:a.selected=!1)}this.context=e}}focus(){this.$.input.focus()}select(){const e=this;e.readonly?e.$.input.focus():e.$.input.select()}_documentUpHandler(e){const t=this,o=t.shadowRoot||t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;o!==t&&o!==t.$.dropDownButton&&o!==t.$.input&&o!==t.$.arrow?t.$.scrollView.contains(o.shadowParent||o)?t._isPointerDown&&(t._isPointerDown=!1,t.opened&&(t._preventLookup=!0),t.$.input.focus()):(t.opened&&(t._preventLookup=!0),"manual"===t.dropDownOpenMode||t._isPointerDown||t.close(),t._isPointerDown=!1):t._isPointerDown=!1}_focusHandler(){const e=this;e.setAttribute("focus",""),e.readonly||0!==e.minLength||0!==e.$.input.value.length||e._preventLookup?(e.$.fireEvent("focus"),delete e._preventLookup):e._lookup()}_blurHandler(){const e=this;e.opened||e.removeAttribute("focus"),e.opened||e.$.fireEvent("blur"),e._refreshSelectedIndex(),delete e._preventLookup}_pasteHandler(e){const t=this,o=t.$.input,a=o.value,l=o.selectionStart,r=o.selectionEnd;if(!e.clipboardData&&!window.clipboardData)return;if(t.disabled)return;const i=(e.clipboardData||window.clipboardData).getData("text");let n=a.slice(0,l)+i;n.length,n+=a.slice(r),t.setAttribute("data-value",n),t._refreshSelectedIndex()}_refreshSelectedIndex(){const e=this;let t=e.dataSource;if(t){let o=-1,a=null;if(e.dataSource instanceof Promise)return;if("function"==typeof e.dataSource)return;"string"==typeof t&&(t=e.$.deserialize(t,"array"));for(let l=0;l<t.length;l++){let r=t[l];if("number"!=typeof r&&"boolean"!=typeof r||(r=""+r),"string"==typeof r){if(r===e.value){o=l,a=e.value;break}}else r&&(delete r.selected,r.label===e.value&&(o=l,a=r.value,r.selected=!0))}e.set("selectedIndex",o,!1),e.set("selectedValue",a,!1),-1===e.selectedIndex&&(e.$.input.dataValue=null)}}selectItem(e){const t=this;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),o)for(let a=0;a<o.length;a++){const l=o[a];if(t.set("selectedIndex",-1),t.set("value",""),t.$.input.dataValue=null,"string"==typeof l){if(l===e)return t.set("selectedIndex",a,!1),t.set("value",t.$.input.dataValue=e),void t.setAttribute("data-value",t.$.input.dataValue)}else if(l.value===e)return t.set("selectedIndex",a,!1),t.set("value",l.label),t.$.input.dataValue=e,void t.setAttribute("data-value",t.$.input.dataValue)}else t.set("value",t.$.input.dataValue=e),t.setAttribute("data-value",t.$.input.dataValue),t.set("selectedIndex",-1,!1)}getItem(e){const t=this;if(t.dataSource)for(let o=0;o<t.dataSource.length;o++){const a=t.dataSource[o];if(a.value===e)return a}return null}getPrevItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let o=0;o<e.dataSource.length;o++)if(e.dataSource[o].value===t.value)return e.dataSource[o-1];return null}getNextItem(){const e=this,t=e.getSelectedItem();if(e.dataSource&&t)for(let o=0;o<e.dataSource.length;o++)if(e.dataSource[o].value===t.value)return e.dataSource[o+1];return null}getSelectedItem(){const e=this;return e.dataSource&&0===e.dataSource.length?{label:e.value,value:e.$.input.dataValue?e.$.input.dataValue:e.value}:{label:e.value,value:void 0!==e.$.input.dataValue?e.$.input.dataValue:e.value}}_refreshMenu(){const e=this;e.$.menu.classList.remove("scroll"),e.$.scrollView.computedVerticalScrollBarVisibility&&e.$.menu.classList.add("scroll")}_fromHTMLEntities(e){const t=this,o=t._textArea?t._textArea:document.createElement("textarea");return o.innerHTML=e,t._textArea=o,o.value}_performSelect(){const e=this,t=e.$.menu.querySelector(".active");let o="",a="";t&&(o=t.getAttribute("data-label"),o=e._fromHTMLEntities(o),a=t.dataValue);let l=e.value,r=e.$.input.dataValue;e.set("value",o),e.$.input.dataValue=a,e.setAttribute("data-value",a),t&&e.set("selectedIndex",t.index),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue);let i=e.dataSource;if("string"==typeof i&&(i=e.$.deserialize(i,"array")),i&&Array.isArray(i))for(let t=0;t<i.length;t++){let o=i[t];"string"!=typeof o&&"number"!=typeof o&&(o.value===e.$.input.dataValue?o.selected=!0:o.selected=!1)}e.close(),o===l&&a===r||(e.$.fireEvent("change",{value:a,label:o,oldValue:r,oldLabel:l}),e._updateTargetValue())}_open(){const e=this;if(e.opened)return;const t=window.scrollX,o=window.scrollY;let a=e.getBoundingClientRect(),l=0,r=0;if(e.timer&&clearTimeout(e.timer),e.getRootNode()&&e.getRootNode().host)e.getRootNode().host.shadowRoot.appendChild(e.$.scrollView);else if(e.dropDownAppendTo){if("body"===e.dropDownAppendTo||e.dropDownAppendTo===document.body)document.body.appendChild(e.$.scrollView);else if(e.dropDownAppendTo instanceof HTMLElement)e.dropDownAppendTo.appendChild(e.$.scrollView);else if("string"==typeof dropDownAppendTo){let t=document.getElementById(e.dropDownAppendTo);t instanceof HTMLElement?t.appendChild(e.$.scrollView):document.body.appendChild(e.$.scrollView)}}else document.body.appendChild(e.$.scrollView);if(e.setAttribute("aria-owns",e.$.scrollView.id),e.readonly||e.$.input.setAttribute("aria-controls",e.$.scrollView.id),e.$.scrollView.enableShadowDOM&&!e._importedStyle&&(e.$.scrollView.importStyle(e._getStyleUrl("smart.textbox.css")),e._importedStyle=!0),"static"!==getComputedStyle(document.body).position){const e=document.body.getBoundingClientRect();l=e.left,r=e.top}if(e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.style.left=-3+a.left+t-l+"px",e.$.scrollView.classList.remove("open"),e.$.scrollView.removeAttribute("top"),"bottom"===e.dropDownOpenPosition)e.$.scrollView.style.top=a.bottom+o-r+1+"px";else if("top"===e.dropDownOpenPosition)e.$.scrollView.style.top=a.top-e.$.scrollView.offsetHeight+o-r-2+"px",e.$.scrollView.setAttribute("top","");else if("auto"===e.dropDownOpenPosition){e.$.scrollView.style.top=a.bottom+o-r+1+"px";const t=a.top-e.$.scrollView.offsetHeight+o-r-2;window.innerHeight<parseInt(e.$.scrollView.style.top)+e.$.scrollView.offsetHeight-o?t>=0&&(e.$.scrollView.style.top=t+"px",e.$.scrollView.setAttribute("top","")):e.$.scrollView.style.top=a.bottom+o-r+1+"px"}if(e.dropDownAppendTo&&"body"!==e.dropDownAppendTo){e.$.scrollView.style.position="absolute",e.$.scrollView.style.width="auto",e.$.scrollView.style.height="auto";const t=e.$.scrollView.parentNode.getBoundingClientRect();e.$.scrollView.style.top=a.bottom-t.top+"px","top"===e.dropDownOpenPosition&&(e.$.scrollView.style.top=a.top-t.top-e.$.scrollView.offsetHeight+"px"),e.$.scrollView.style.left=-3+a.left-t.left+"px",e.dropDownHeight&&(e.$.scrollView.style.height=e.dropDownHeight),e.dropDownWidth&&(e.$.scrollView.style.width=e.dropDownWidth)}e.opening=!0,e._positionTimer&&clearInterval(e._positionTimer),e.dropDownAppendTo||(e._positionTimer=setInterval((()=>{const t=e.getBoundingClientRect();if(e.opening)e.opening=!1,a=t;else if(Math.abs(parseInt(t.top)-parseInt(a.top))>=10||Math.abs(parseInt(t.left)-parseInt(a.left))>=10){const o=window.scrollX,a=window.scrollY;return e.$.scrollView.style.left=-3+t.left+o-l+"px",void("bottom"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.bottom+a-r+1+"px":"top"===e.dropDownOpenPosition?e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+a-r+1+"px":"auto"===e.dropDownOpenPosition&&(e.$.scrollView.removeAttribute("top"),e.$.scrollView.style.top=t.bottom+a-r+1+"px",window.innerHeight<parseInt(e.$.scrollView.style.top)+e.$.scrollView.offsetHeight-a?(e.$.scrollView.style.top=t.top-e.$.scrollView.offsetHeight+a-r+1+"px",e.$.scrollView.setAttribute("top","")):e.$.scrollView.style.top=t.bottom+a-r+1+"px"))}}),50)),e.$.scrollView.onpointerdown=function(t){e._isPointerDown=!0,t.stopPropagation(),t.preventDefault()},requestAnimationFrame((function(){const t=e.dropDownWidth;if(e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._refreshMenu(),e.$.scrollView.setAttribute("open",""),e.setAttribute("open",""),e.$.dropDownButton.setAttribute("open",""),e.$.input.setAttribute("open",""),t&&"string"==typeof t&&-1!==t.indexOf("%")){const o=parseFloat(t)/100;e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",e.offsetWidth*o+"px")}else if("auto"!==t&&t)e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",parseFloat(t)+"px");else if("auto"===t){if(e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",""),e.$.scrollView.$.scrollViewerContainer.classList.contains("vscroll")){const t=e.$.scrollView.offsetWidth+parseFloat(getComputedStyle(e.$.scrollView).getPropertyValue("--smart-scroll-bar-size"));e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",t+"px")}}else{e.$.menu.style.width="auto";let t=e.$.menu.offsetWidth;const o=e.$.menu.querySelectorAll("li");for(let t=0;t<o.length;t++)e._maxDropDownWidth=Math.max((o[t].firstElementChild||o[t]).offsetWidth,e._maxDropDownWidth);e.$.scrollView.computedVerticalScrollBarVisibility&&(t+=e.$.scrollView.$&&e.$.scrollView.$.verticalScrollBar?e.$.scrollView.$.verticalScrollBar.offsetWidth:30),e.$.scrollView.style.setProperty("--smart-input-drop-down-menu-width",Math.max(t,e.offsetWidth-8)+"px"),e.$.menu.style.width=""}(e.shadowRoot||e.isInShadowDOM)&&e.$.scrollView._scrollView&&Smart.ScrollBar&&requestAnimationFrame((()=>{e.$.scrollView._scrollView&&e.$.scrollView._scrollView.vScrollBar.refresh()}))})),e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._refreshMenu(),e.set("opened",!0),e.setAttribute("aria-expanded",!0),e.$.fireEvent("open")}close(){const e=this;return!!e.opened&&(e.timer&&clearTimeout(e.timer),e.timer=setTimeout((function(){e.$.scrollView.parentNode&&!e.opened&&(e.$.scrollView.remove(),e.removeAttribute("aria-owns"),e.readonly||e.$.input.removeAttribute("aria-controls"))}),1e3),e._positionTimer&&clearInterval(e._positionTimer),e.$.scrollView.removeAttribute("open"),e.$.dropDownButton.removeAttribute("open"),e.$.input.removeAttribute("open"),e.removeAttribute("open"),e.set("opened",!1),e.setAttribute("aria-expanded",!1),e.$.input.focus(),e.$.fireEvent("close"),!0)}refresh(){const e=this;e.$.scrollView.refresh&&e.$.scrollView.refresh(),e._getDataSourceFromOption(),e.close()}_lookup(e){const t=this;t.query=t.$.input.value;const o=t.context;if(t.context=t,t.selectedIndex=-1,t.selectedValue=null,t.context=o,t.$.input.readonly&&(t._incrementalSearchQuery||(t._incrementalSearchQuery=""),t._incrementalSearchQuery+=e.key,t._incrementalSearchTimer&&clearTimeout(t._incrementalSearchTimer),t.query=t._incrementalSearchQuery,t._incrementalSearchTimer=setTimeout((function(){t._incrementalSearchQuery=""}),700)),t.query.length<t.minLength)return void t.close();const a=function(e){clearTimeout(t._autoCompleteTimeout),t._autoCompleteTimeout=setTimeout((()=>{const o=t.context;t.context=t,t._process(e),t.context=o}),t.autoCompleteDelay)};"function"==typeof t.dataSource?t.dataSource(t.query,a):a(t.dataSource)}_downHandler(e){const t=this;t.readonly&&t._dropDownButtonDownHandler(e)}_dropDownButtonDownHandler(e){const t=this;return"manual"!==t.dropDownOpenMode&&(t._toggle(),t.focus()),e.preventDefault(),e.stopPropagation(),e.originalEvent.preventDefault(),e.originalEvent.stopPropagation(),t._isPointerDown=!0,!1}_toggle(){const e=this;e.opened?e.close():e.open()}open(){const e=this;function t(t){e._process(t);const o=e.$.menu.querySelector(".active");if(o){const t=e.$.input.dataValue;for(let a=0;a<e.$.menu.children.length;a++){const l=e.$.menu.children[a],r=l.getAttribute("data-label"),i=l.dataValue;if(void 0!==t&&i===t||void 0===t&&r===e.$.input.value){o.classList.remove("active"),l.classList.add("active"),e._setActiveDescendant(l),e.$.input.dataValue=i,e.setAttribute("data-value",i);break}}}e.ensureVisible(),e.$.input.focus(),setTimeout((function(){e.$.input.focus()}),25)}e.dropDownDataSource&&(Array.isArray(e.dropDownDataSource)&&e.dropDownDataSource.length>0||"function"==typeof e.dropDownDataSource)?(e.query="","function"==typeof e.dropDownDataSource?e.dropDownDataSource(e.query,t):t(e.dropDownDataSource)):(e.query="","function"==typeof e.dataSource?e.dataSource(e.query,t):t(e.dataSource))}_process(e){const t=this;"string"==typeof e&&(e=t.$.deserialize(e,"array")),e=t.readonly?e.filter((function(){return!0})):e.filter((function(e){return""===e||(t.matcher?t.matcher(e):t._matcher(e))})),e=t._sorter(e),t.sorted&&(e.sort(((e,t)=>void 0!==e.label?e.label.localeCompare(t.label):e.localeCompare(t))),"desc"===t.sortDirection&&e.reverse()),!e.length&&t.opened&&""===t.dropDownPlaceholder&&t.close(),0===e.length&&!0!==t.allowItemsAdd&&""===t.dropDownPlaceholder||(t.query.length>0?t._render(e.slice(0,t.items)):t._render(e),t._open(),t.$.scrollView.refresh&&t.$.scrollView.refresh(),t._refreshMenu(),t.ensureVisible())}_matcher(e){const t=this.query;switch(null===e&&(e="null"),e=""+(e=e.label||e),this.queryMode){case"startsWith":return e.startsWith(t);case"startsWithIgnoreCase":return e.toLowerCase().startsWith(t.toLowerCase());case"doesNotContain":return e.indexOf(t)<0;case"doesNotContainIgnoreCase":return e.toLowerCase().indexOf(t.toLowerCase())<0;case"contains":return e.indexOf(t)>-1;default:case"containsIgnoreCase":return~e.toLowerCase().indexOf(t.toLowerCase());case"equals":return 0===e.localeCompare(t);case"equalsIgnoreCase":return 0===e.toLowerCase().localeCompare(t.toLowerCase());case"endsWith":return e.endsWith(t);case"endsWithIgnoreCase":return e.toLowerCase().endsWith(t.toLowerCase())}}_sorter(e){const t=this;let o,a=[],l=[],r=[];if(e&&""===e[0])return e;for(;o=e.shift();){let e=o.label||o;e=""+e,e.toLowerCase().indexOf(t.query.toLowerCase())?~e.indexOf(t.query)?l.push(o):r.push(o):a.push(o)}return a.concat(l,r)}_highlighter(e){const t=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return this.query?e.replace(new RegExp("("+t+")","ig"),(function(e,t){return"<strong>"+t+"</strong>"})):e}_render(e){const t=this;let o=0,a=-1,l=null;const r=e.map((function(e){let r=e,i=e;"object"==typeof e&&(r=e.label,i=void 0!==e.value?e.value:r),r=""+r,r=r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""");const n=document.createElement("li"),s=document.createElement("a");if(s.href="javascript:void(0)",n.id=t.id+"Item"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),n.setAttribute("data-label",r),n.index=o++,n.dataValue=i,"string"==typeof i?n.setAttribute("value",i):n.setAttribute("value",JSON.stringify(i)),n.setAttribute("role","option"),n.setAttribute("aria-label",r),void 0!==e.menuLabel?(r=e.menuLabel,s.innerHTML=r):s.innerHTML=t.highlighter?t.highlighter(r):t._highlighter(r),s.setAttribute("aria-hidden",!0),e.disabled&&n.classList.add("smart-disabled"),e.icon&&(s.classList.add("icon"),s.classList.add(e.icon)),e.prefix){const t=document.createElement("span");t.innerHTML=e.prefix,s.classList.add("has-prefix"),s.innerHTML=t.innerHTML+s.innerHTML}if(e.suffix){const t=document.createElement("span");t.innerHTML=e.suffix,s.classList.add("has-suffix"),s.innerHTML=s.innerHTML+t.innerHTML}if(e.dataset)for(let t in e.dataset)n.setAttribute("data-"+t,e.dataset[t]);if(e.className){const t=e.className.split(" ");for(let e=0;e<t.length;e++)n.classList.add(t[e].trim())}return void 0!==t.selectedValue&&void 0!==e.value&&""!==t.selectedValue&&t.selectedValue===e.value&&(e.selected=!0,l=e,a=n.index,n.classList.add("active")),n.appendChild(s),n}));function i(){const e=t.$.menu.getElementsByClassName("active");e[0]&&e[0].classList.remove("active"),this.classList.add("active"),t._setActiveDescendant(this)}-1===a&&r.length>0&&(r[0].classList.add("active"),t._setActiveDescendant(r[0])),l&&(t.$.input.value=l.label,t.$.input.dataValue=l.value,t.setAttribute("data-value",t.$.input.dataValue)),t.$.menu.innerHTML="",0===r.length&&t.dropDownPlaceholder&&(t.$.menu.innerHTML='<div class="smart-flex smart-truncate smart-quiet" style="padding:10px; align-items: center;">'+t.dropDownPlaceholder+"</div>");for(let e=0;e<r.length;e++){const o=r[e];t.$.menu.appendChild(o),o.onmouseenter=i,o.onmouseleave=function(){this.classList.remove("active"),t._setActiveDescendant(null)},o.onclick=i}}ensureVisible(){const e=this,t=e.$.menu.querySelector(".active");t&&(t.offsetTop+t.offsetHeight>=e.$.scrollView.scrollTop+e.$.scrollView.offsetHeight&&(e.$.scrollView.scrollTop=t.offsetTop+t.offsetHeight),(t.offsetTop<=e.$.scrollView.scrollTop||t.offsetTop>=e.$.scrollView.scrollTop+e.$.scrollView.offsetHeight)&&(e.$.scrollView.scrollTop=t.offsetTop),0===[...e.$.menu.children].indexOf(t)?e.$.scrollView.scrollTop=0:[...e.$.menu.children].indexOf(t)===e.$.menu.children.length-1&&(e.$.scrollView.scrollTop=e.$.scrollView.scrollHeight))}_next(){const e=this,t=e.$.menu.querySelector(".active");if(!t){const t=e.$.menu.firstElementChild;return t.classList.add("active"),void e._setActiveDescendant(t)}t.classList.remove("active");let o=t.nextElementSibling;o||(o=e.$.menu.firstElementChild),o.classList.add("active"),e._setActiveDescendant(o),e.ensureVisible()}_prev(){const e=this,t=e.$.menu.querySelector(".active");if(!t){const t=e.$.menu.firstElementChild;return t.classList.add("active"),void e._setActiveDescendant(t)}t.classList.remove("active");let o=t.previousElementSibling;o||(o=e.$.menu.lastElementChild),o.classList.add("active"),e._setActiveDescendant(o),e.ensureVisible()}_move(e){const t=this;if(t.readonly&&!t.opened){if("ArrowUp"===e.key){const o=t.getPrevItem();o&&t.selectItem(o.value),e.preventDefault()}if("ArrowDown"===e.key){const o=t.getNextItem();o&&t.selectItem(o.value),e.preventDefault()}}if(t.opened){switch(e.keyCode){case 9:case 13:case 27:e.preventDefault();break;case 38:e.preventDefault(),t._prev();break;case 40:e.preventDefault(),t._next()}e.stopPropagation()}}_keyDownHandler(e){const t=this;if(t._suppressKeyPressRepeat=![40,38,9,13,27,16,17,18].includes(e.keyCode),t._oldValue=t.$.input.value,!(e.shiftKey||e.altKey||e.ctrlKey))return t.opened&&"Escape"===e.key?(t.close(),e.stopPropagation(),void e.preventDefault()):void t._move(e)}_keyPressHandler(e){this._suppressKeyPressRepeat||e.shiftKey||e.altKey||e.ctrlKey||this._move(e)}_keyUpHandler(e){const t=this;if(!(e.shiftKey||"F2"===e.key||"a"===e.key&&e.ctrlKey))switch(e.keyCode){case 40:case 38:case 16:case 17:case 18:40===e.keyCode&&e.altKey&&t.open(),38===e.keyCode&&e.altKey&&t.close();break;case 9:case 13:if(!t.opened)return;if(!t.readonly&&!t.$.menu.querySelector(".active")){const o=t.$.input.value;return t._performSelect(),t.value=t.$.input.value=o,e.stopPropagation(),void e.preventDefault()}t._performSelect(),e.stopPropagation(),e.preventDefault();break;case 27:if(!t.opened)return;t.close(),e.stopPropagation(),e.preventDefault();break;default:t._lookupTimer&&clearTimeout(t._lookupTimer),t._lookupTimer=setTimeout((()=>{if(t._lookup(e),!t.opened||e.ctrlKey||e.shiftKey||(e.stopPropagation(),e.preventDefault()),t.$.fireEvent("changing",{value:t.$.input.value,oldValue:t._oldValue}),t.dataSource&&t.dataSource.length)for(let e=0;e<t.dataSource.length;e++){const o=t.dataSource[e];if("string"==typeof o){if(o===t.$.input.value){t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue);break}}else if(void 0!==o.label&&o.label===t.$.input.value){t.$.input.dataValue=o.value,t.setAttribute("data-value",o.value);break}}else t.$.input.dataValue=t.$.input.value,t.setAttribute("data-value",t.$.input.dataValue);t._updateTargetValue()}),300)}}clearValue(){const e=this;e.$.input.value="",e.$.input.dataValue="",e.removeAttribute("data-value"),e.set("value",""),e.set("selectedIndex",-1),e.set("selectedValues",[e.$.input.dataValue]),e.set("selectedValue",e.$.input.dataValue)}propertyChangedHandler(e,t,o){super.propertyChangedHandler(e,t,o);const a=this;if("innerHTML"===e&&(a._getDataSourceFromOption(),a._setSelection(!1)),"selectedValue"===e){let e=-1;if(a.dataSource&&Array.isArray(a.dataSource)&&a.dataSource.forEach(((t,a)=>{"string"==typeof t?t===o&&(e=a):t&&t.value===o&&(e=a)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}a._setSelection()}if("selectedIndex"===e){let e=a.dataSource;if(a.selectedValue=null,e&&Array.isArray(e))for(let t=0;t<e.length;t++){let o=e[t];"string"!=typeof o&&"number"!=typeof o&&(o.selected=!1)}a._setSelection()}else if("dataSource"===e){if(a.dataSource&&Array.isArray(a.dataSource)){let e=-1;if(a.dataSource.forEach(((t,o)=>{t.selected&&(e=o)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}}a._setSelection(!1)}else if("dropDownClassList"===e){const e=a.$.scrollView;for(let o=0,a=t.length;o<a;o+=1)e.classList.remove(t[o]);for(let t=0,a=o.length;t<a;t+=1)e.classList.add(o[t])}else if("dropDownHeight"===e)"auto"!==a.dropDownHeight?a.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height",a.dropDownHeight+"px"):a.$.scrollView.style.setProperty("--smart-input-drop-down-menu-height","auto");else if("opened"===e)a.opened=t,o?a.open():a.close();else if("placeholder"===e){if(a.readonly){const e=a.getAttribute("aria-label");if(e&&e!==t)return;o?a.setAttribute("aria-label",o):a.removeAttribute("aria-label")}}else if("selectedValues"===e)if(null===o)a.$.input.value="",a.$.input.dataValue=o,a.setAttribute("data-value",o),a._refreshSelectedIndex();else{const e=o.join(","),t=a.value;if(a.$.input.dataValue=e,e&&-1===e.indexOf(",")){let e=-1,t=o[0];if(a.dataSource&&Array.isArray(a.dataSource)&&a.dataSource.forEach(((a,l)=>{"string"==typeof a?a!==o&&a!==t||(e=l):a&&a.value===t&&(e=l)})),e>=0){const t=a.context;a.context=a,a.selectedIndex=e,a.context=t}}a._setSelection(),a.propertyChangedHandler("value",t,a.value)}else"value"===e?(a.displayMember!==a.valueMember&&"string"!=typeof o?(a.set("value",o[a.displayMember]),a.$.input.dataValue=o[a.valueMember],a.setAttribute("data-value",a.$.input.dataValue)):(a.$.input.value=a.$.input.dataValue=o,a.setAttribute("data-value",o)),a._refreshSelectedIndex()):"readonly"===e?(a._setAriaRelations(),a._setInputPurpose()):"theme"===e||"rightToLeft"===e?a.$.scrollView[e]=o:"inputPurpose"===e?a._setInputPurpose():"inverted"===e?o?a.$.scrollView.setAttribute("inverted",""):a.$.scrollView.removeAttribute("inverted"):"disabled"!==e&&"unfocusable"!==e||a._setFocusable()}_updateTargetValue(){const e=this;if(e.dataset.target){const t=document.querySelector(e.dataset.target);if(t){const o=e.dataset.property,a=e.value;o&&void 0!==t[o]&&(t[o]=a)}}}detached(){super.detached(),this.close(),this.removeAttribute("focus")}_getDataSourceFromOption(){const e=this;if(e.innerHTML.indexOf("<option")>=0){e.$.optionsContainer.innerHTML=e.innerHTML.trim();const t=e.querySelectorAll("option");let o=[];for(let e=0;e<t.length;e++){const a=t[e],l=a.hasAttribute("selected")||a.hasAttribute("is-selected")&&"false"!==a.getAttribute("is-selected");let r=(""+a.textContent).trim();const i=(""+a.innerHTML).trim(),n=a.hasAttribute("value")?a.getAttribute("value"):r,s=a.hasAttribute("disabled"),u=a.hasAttribute("label")?a.getAttribute("label"):null;u&&(r=u),o.push({label:r,menuLabel:i,value:n,disabled:s,selected:l,className:a.className,dataset:a.dataset}),a.classList.add("smart-hidden")}e.dataSource=o}}render(){const e=this,t=e.dropDownClassList;if(e._getDataSourceFromOption(),e.selectedValues&&e.selectedValues.length){const t=e.selectedValues.join(",");e.value=t}e._createElement&&e._createElement();const o=e.$.scrollView;for(let e=0,a=t.length;e<a;e+=1)o.classList.add(t[e]);e.opened&&(e.opened=!1,e.open());const a=e.$.menu;a&&(a.setAttribute("role","presentation"),o.appendChild(a)),"auto"!==e.dropDownHeight?o.style.setProperty("--smart-input-drop-down-menu-height",e.dropDownHeight+"px"):o.style.setProperty("--smart-input-drop-down-menu-height","auto"),o.classList.add("smart-input-drop-down-menu");for(let t=0;t<e.classList.length;t++){const a=e.classList[t];"smart-element"!==a&&"smart-input"!==a&&o.classList.add(a+"-drop-down-menu")}o.id=e.id+"_"+e.tagName.toLowerCase()+"_menu_"+Math.floor(65536*(1+Math.random())).toString(16).substring(1),o.ownerElement=e;let l=e.dataSource;if("string"==typeof l&&(l=e.$.deserialize(l,"array")),l&&l.length&&Array.isArray(l)){let t=-1;if(l.forEach(((e,o)=>{e.selected&&(t=o)})),t>=0){e.selectedIndex=t;const o=l[t];e.selectedValue="string"==typeof o?l[t]:l[t].value}}e._setAriaRelations(),e._setInputPurpose(),e._setSelection(),e.isInitialized=!0,e.hasAttribute("tabindex")&&(e.readonly||(e.$.input.setAttribute("tabindex",e.getAttribute("tabindex")),e.removeAttribute("tabindex"))),super.render()}_setSelection(e){const t=this;let o=t.dataSource;if("string"==typeof o&&(o=t.$.deserialize(o,"array")),t.selectedIndex>=0&&o&&o.length>0){let a=o[t.selectedIndex];if("number"!=typeof a&&"boolean"!=typeof a||(a=""+a),"string"==typeof a){let o=t.$.input.dataValue,l=t.value;t.set("value",a),t.$.input.dataValue=a,t.$.input.setAttribute("data-value",a),t.selectedValues=[t.$.input.dataValue],t.isInitialized&&!1!==e&&(t.$.fireEvent("change",{value:t.value,label:t.label,oldValue:o,oldLabel:l}),t._updateTargetValue())}else{let o=t.$.input.dataValue,l=t.value;a&&(void 0!==a.value?(t.set("value",void 0!==a.value?a.value+"":""),t.$.input.dataValue=a.value,t.$.input.setAttribute("data-value",a.value),t.selectedValues=[t.$.input.dataValue]):a.label&&(t.selectedValues=[a.value]),a.label&&t.set("value",a.label)),t.isInitialized&&!1!==e&&(t.$.fireEvent("change",{value:t.$.input.dataValue,label:a.value,oldValue:o,oldLabel:l}),t._updateTargetValue())}}}_createElement(){const e=this,t=document.createElement("ul"),o=document.createElement("smart-scroll-viewer");o.rightToLeft=e.rightToLeft,o.theme=e.theme,o.horizontalScrollBarVisibility="hidden",e.inverted?o.setAttribute("inverted",""):o.removeAttribute("inverted"),e.$.scrollView=o,e.$.menu=t,e._setFocusable();const a=e.$.input;e.$.menu.onpointerdown=function(t){const o=t.target.closest("li"),l=e.$.menu.querySelector(".active");l&&o&&(l.classList.remove("active"),o.classList.add("active")),t.stopPropagation(),t.preventDefault(),setTimeout((()=>{e._performSelect(),o&&o.parentNode&&e.$.fireEvent("itemClick",{index:[...o.parentNode.children].indexOf(o),item:o,label:o.getAttribute("aria-label"),value:o.dataValue}),a.focus()}),50)},e.$.menu.onpointerup=function(t){t.stopPropagation(),t.preventDefault(),e.$.scrollView.$.verticalScrollBar.thumbCapture&&(e.$.scrollView.$.verticalScrollBar.thumbCapture=!1)}}_setAriaRelations(){const e=this,t=e.getAttribute("aria-label");e.readonly?(e.setAttribute("role","button"),!t&&e.placeholder&&e.setAttribute("aria-label",e.placeholder),e.removeAttribute("aria-readonly"),e.$.input.setAttribute("aria-hidden",!0),e.$.input.removeAttribute("aria-activedescendant"),e.$.input.removeAttribute("aria-controls"),e.$.dropDownButton.setAttribute("aria-hidden",!0)):(e.setAttribute("role","combobox"),t&&t===e.placeholder&&e.removeAttribute("aria-label"),e.$.input.setAttribute("role","searchbox"),e.$.input.removeAttribute("aria-hidden",!0),e.$.dropDownButton.removeAttribute("aria-hidden")),e.setAttribute("aria-expanded",e.opened),e.setAttribute("aria-haspopup","listbox"),e.setAttribute("aria-owns",e.$.scrollView.id),e.$.scrollView.setAttribute("role","listbox")}_setActiveDescendant(e){const t=this;t.readonly||(e?t.setAttribute("aria-activedescendant",e.id):t.removeAttribute("aria-activedescendant"))}_setInputPurpose(){const e=this;e.readonly?e.$.input.removeAttribute("autocomplete"):e.$.input.setAttribute("autocomplete",e.inputPurpose)}_setFocusable(){const e=this;e.disabled||e.unfocusable?e.$.input.setAttribute("tabindex",-1):e.$.input.removeAttribute("tabindex")}});
|
|
105
105
|
|
|
106
106
|
/***/ }),
|
|
107
107
|
|
|
@@ -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 v18.0.
|
|
298
|
+
/* Smart UI v18.0.11 (2024-02-10)
|
|
299
299
|
Copyright (c) 2011-2024 jQWidgets.
|
|
300
300
|
License: https://htmlelements.com/license/ */ //
|
|
301
301
|
|