-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsmart.table.js
6 lines (4 loc) · 170 KB
/
smart.table.js
1
2
3
4
5
6
/* Smart UI v15.2.0 (2023-04-20)
Copyright (c) 2011-2023 jQWidgets.
License: https://htmlelements.com/license/ */ //
Smart("smart-table",class extends Smart.ContentElement{static get properties(){return{autoLoadState:{value:!1,type:"boolean"},autoSaveState:{value:!1,type:"boolean"},columnGroups:{value:null,type:"array?"},columnMinWidth:{value:"50px",type:"any"},columnReorder:{value:!1,type:"boolean"},columnResize:{value:!1,type:"boolean"},columnResizeFeedback:{value:!1,type:"boolean"},columnResizeNormalize:{value:!1,type:"boolean"},columns:{value:[],type:"any?",reflectToAttribute:!1},columnSizeMode:{value:"default",allowedValues:["auto","default"],type:"string"},conditionalFormatting:{value:null,type:"array?",reflectToAttribute:!1},conditionalFormattingButton:{value:!1,type:"boolean"},deferredScrollDelay:{value:1,type:"number"},dataRowId:{value:null,type:"string?"},dataSource:{value:null,type:"any?",reflectToAttribute:!1},dataSourceSettings:{value:{autoGenerateColumns:{value:!1,type:"boolean"},sanitizeHTML:{value:"blackList",allowedValues:["all","blackList","none"],type:"string"},sanitizeHTMLRender:{value:"text",allowedValues:["text","html"],type:"string"},root:{value:"",type:"string"},record:{value:"",type:"string"},keyDataField:{value:"",type:"string"},parentDataField:{value:"",type:"string"},childrenDataField:{value:"",type:"string"},groupBy:{value:[],type:"array"},dataFields:{value:[],type:"array"},mapChar:{value:".",type:"string"},id:{value:"",type:"string"},virtualDataSource:{value:null,type:"any"},virtualDataSourceOnExpand:{value:null,type:"any"}},type:"object"},dataTransform:{value:null,type:"function?",reflectToAttribute:!1},editing:{value:!1,type:"boolean"},editMode:{value:"cell",allowedValues:["cell","row"],type:"string"},expandHierarchy:{value:!1,type:"boolean"},filtering:{value:!1,type:"boolean"},columnMenu:{value:!1,type:"boolean"},filterRow:{value:!1,type:"boolean"},filterTemplate:{value:null,type:"string?"},filterOperator:{value:"and",type:"string?"},footerRow:{value:null,type:"string?"},formulas:{value:!1,type:"boolean"},freezeFooter:{value:!1,type:"boolean"},freezeHeader:{value:!1,type:"boolean"},grouping:{value:!1,type:"boolean"},groupFormatFunction:{value:null,type:"any"},headerRow:{value:null,type:"any"},hideSelectionColumn:{value:!1,type:"boolean"},keyboardNavigation:{value:!1,type:"boolean"},loadColumnStateBehavior:{value:"implementationOnly",allowedValues:["stateOnly","implementationOnly","intersection"],type:"string"},messages:{value:{en:{add:"Add condition",all:"All columns",apply:"Apply",between:"Between",cancel:"Cancel",clearFilter:"Clear filter",close:"Close",column:"Column:",condition:"Condition:",conditionalFormatting:"Conditional Formatting",CONTAINS:"contains",CONTAINS_CASE_SENSITIVE:"contains (case sensitive)",DOES_NOT_CONTAIN:"does not contain",DOES_NOT_CONTAIN_CASE_SENSITIVE:"does not contain (case sensitive)",EMPTY:"empty",ENDS_WITH:"ends with",ENDS_WITH_CASE_SENSITIVE:"ends with (case sensitive)",EQUAL:"equal",equal:"Equal To",EQUAL_CASE_SENSITIVE:"equal (case sensitive)",filterCondition:"Filter condition",filterPlaceholder:"Filter",firstButton:"First",fontFamily:"Font family:",fontSize:"Font size:",format:"Format:",formatColumn:"Format Column",GREATER_THAN:"greater than",GREATER_THAN_OR_EQUAL:"greater than or equal",greaterThan:"Greater Than",highlight:"Highlight",invalidValue:"Invalid value",itemsPerPage:"Items per page:",lastButton:"Last",LESS_THAN:"less than",LESS_THAN_OR_EQUAL:"less than or equal",lessThan:"Less Than",nextButton:"Next",NOT_EMPTY:"not empty",NOT_EQUAL:"not equal",NOT_NULL:"not null",notEqual:"Not Equal To",NULL:"null",ok:"OK",previousButton:"Previous",remove:"Remove condition",secondValue:"Second value:",STARTS_WITH:"starts with",STARTS_WITH_CASE_SENSITIVE:"starts with (case sensitive)",summaryPrefix:"of",text:"Text",value:"Value:",with:"with",columnMenuItemSortAsc:"Sort Ascending",columnMenuItemSortDesc:"Sort Descending",columnMenuItemReset:"Reset",columnMenuItemRemoveSort:"Remove Sort",columnMenuItemFilter:"Show rows where:",columnMenuItemRemoveFilter:"Remove Filter",columnMenuItemColumns:"Columns",grouping:"Group field name is not found in the dataFields collection!"}},type:"object",extend:!0},onCellRender:{value:null,type:"function?",reflectToAttribute:!1},onColumnRender:{value:null,type:"function?",reflectToAttribute:!1},onUpdateComplete:{value:null,type:"function?",reflectToAttribute:!1},onInit:{value:null,type:"function?",reflectToAttribute:!1},onLoad:{value:null,type:"function?",reflectToAttribute:!1},pageSize:{value:10,allowedValues:[10,25,50],type:"int"},pageIndex:{value:0,type:"int"},paging:{value:!1,type:"boolean"},rowDetailTemplate:{value:null,type:"string?"},selected:{value:[],type:"array",reflectToAttribute:!1},selection:{value:!1,type:"boolean"},selectionMode:{value:"many",type:"string",allowedValues:["one","many","extended"]},selectionByHierarchy:{value:!0,type:"boolean"},sort:{value:null,type:"function?",reflectToAttribute:!1},sortMode:{value:"none",type:"string",allowedValues:["none","one","many"]},stateSettings:{value:["columns","expanded","filtered","grouped","selected","sorted"],type:"array"},tooltip:{value:!1,type:"boolean"},virtualization:{value:!1,type:"boolean"}}}static get listeners(){return{resize:"_resizeHandler","conditionalFormattingButton.click":"_conditionalFormattingButtonClickHandler","filterInput.keyup":"_filterInputKeyupHandler","pager.change":"_pagerChangeHandler","pager.pageSizeChanged":"_pagerPageSizeChanged","tableContainer.change":"_tableContainerChangeHandler","tableContainer.click":"_tableContainerClickHandler","tableContainer.down":"_tableContainerDownHandler","tableContainer.focus":"_tableContainerFocusHandler","tableContainer.pointerover":"_tableContainerPointeroverHandler","document.down":"_documentDownHandler","document.keydown":"_tableContainerKeydownHandler","document.keyup":"_tableContainerKeyupHandler","document.move":"_documentMoveHandler","document.up":"_documentUpHandler"}}template(){return Smart.Templates[this.nodeName]&&delete Smart.Templates[this.nodeName],this.virtualization?'<div id="container" class="smart-container" role="presentation">\n <div id="header" class="smart-table-header" role="toolbar">\n <smart-input id="filterInput" class="underlined" animation="[[animation]]" locale="[[locale]]" right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-input>\n <div id="filterTemplateContainer" class="smart-table-filter-template-container smart-hidden"></div>\n <smart-button id="conditionalFormattingButton" class="smart-table-toolbar-button conditional-formatting" animation="[[animation]]" right-to-left="[[rightToLeft]]" theme="[[theme]]" aria-label="Conditional Formatting"></smart-button>\n </div>\n <smart-scroll-viewer style="opacity: 0.99" id="virtualizationContainer" class="smart-table-virtualization-container" right-to-left="[[rightToLeft]]" theme="[[theme]]">\n <table id="tableContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-table-container">\n <content></content>\n </table>\n </smart-scroll-viewer>\n <smart-pager id="pager" animation="[[animation]]" locale="[[locale]]" page-index="[[pageIndex]]" page-size="[[pageSize]]" pages-count="null" show-first-last-navigation-buttons show-page-size-selector show-prev-next-navigation-buttons show-summary right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-pager>\n <div id="loadingIndicatorContainer" class="smart-loader-container smart-hidden" aria-label="Loading">\n <span id="loadingIndicator" class="smart-loader" role="presentation"></span>\n </div>\n </div>':'<div id="container" class="smart-container" role="presentation">\n <div id="header" class="smart-table-header" role="toolbar">\n <smart-input id="filterInput" class="underlined" animation="[[animation]]" locale="[[locale]]" right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-input>\n <div id="filterTemplateContainer" class="smart-table-filter-template-container smart-hidden"></div>\n <smart-button id="conditionalFormattingButton" class="smart-table-toolbar-button conditional-formatting" animation="[[animation]]" right-to-left="[[rightToLeft]]" theme="[[theme]]" aria-label="Conditional Formatting"></smart-button>\n </div>\n <table id="tableContainer" inner-h-t-m-l=\'[[innerHTML]]\' class="smart-table-container">\n <content></content>\n </table>\n <smart-pager id="pager" animation="[[animation]]" locale="[[locale]]" page-index="[[pageIndex]]" page-size="[[pageSize]]" pages-count="null" show-first-last-navigation-buttons show-page-size-selector show-prev-next-navigation-buttons show-summary right-to-left="[[rightToLeft]]" theme="[[theme]]"></smart-pager>\n <div id="loadingIndicatorContainer" class="smart-loader-container smart-hidden" aria-label="Loading">\n <span id="loadingIndicator" class="smart-loader" role="presentation"></span>\n </div>\n </div>'}resetState(e){const t=this;switch(e){case"expanded":t._expandedIds=[],t._state.expanded=[];break;case"selected":t._selectedIds=[],t._disabledSelection=[],t._selectableGroupRecords=[],t.set("selected",[]),t._state.selected=[];break;default:t._dblclickObject={numberOfClicks:0},t._expandedIds=[],t._selectedIds=[],t._disabledSelection=[],t._selectableGroupRecords=[],t._state={expanded:[],selected:[],sorted:[]},t.set("selected",[])}}render(){this._render(),super.render()}_render(){const e=this,t=getComputedStyle(e);if(e.setAttribute("role","presentation"),e.$.tableContainer.id=e.id+"TableContainer",e._cachedWidth=e.offsetWidth,e._cachedHeight=e.offsetHeight,e._defaults={fontFamily:t.fontFamily,fontSize:t.fontSize,text:e._toHex(t.color),highlight:e._toHex(t.backgroundColor)},e._isMobile=Smart.Utilities.Core.isMobile,e._autoScrollCoefficient=Smart.Utilities.Core.Browser.Firefox?8:Smart.Utilities.Core.Browser.Edge?16:4,e._dblclickObject={numberOfClicks:0},e._expandedIds=[],e._selectedIds=[],e._disabledSelection=[],e._selectableGroupRecords=[],e._state={expanded:[],selected:[],sorted:[]},e._rowHeight=parseFloat(t.getPropertyValue("--smart-table-row-height")),e._rowDetailHeight=parseFloat(t.getPropertyValue("--smart-table-row-detail-height")),e._animation=e.animation,e._setFocusable(),e.selection&&e.$.tableContainer.setAttribute("aria-multiselectable",!0),e.virtualization){const t=e.$.virtualizationContainer,a=e;t&&(t._mouseWheelHandler=function(e){const l=t;if(!l.disabled&&(l.computedHorizontalScrollBarVisibility||l.computedVerticalScrollBarVisibility)){if(e.shiftKey&&l.computedHorizontalScrollBarVisibility){const t=l.scrollLeft;if(0===t&&e.deltaX<0||t===l.scrollHeight&&e.deltaX>0)return;return e.stopPropagation(),e.preventDefault(),void(l.scrollWidth>0&&l.scrollTo(void 0,l.scrollLeft+l._getScrollCoefficient(e,l.offsetWidth)))}if(l.computedVerticalScrollBarVisibility){const t=l.scrollTop;if(0===t&&e.deltaY<0||t===l.scrollHeight&&e.deltaY>0)return;if(e.stopPropagation(),e.preventDefault(),l.scrollHeight>0){let t=3*a._rowHeight;e.deltaY<=0&&(t=-3*a._rowHeight),Math.abs(e.deltaY)>=100?l.scrollTop+=t:l.scrollTop+=e.deltaY}}}},t._verticalScrollbarHandler=function(t){0===e.deferredScrollDelay?e._onVerticalChange(t):(e._verticalScrollTimer&&(clearTimeout(e._verticalScrollTimer),delete e._verticalScrollTimer),e._verticalScrollTimer=setTimeout((()=>{e._onVerticalChange(t),delete e._verticalScrollTimer}),e.deferredScrollDelay))}),t.hasStyleObserver=!1,t.$.verticalScrollBar.hasStyleObserver=!1,t.$.horizontalScrollBar.hasStyleObserver=!1,e.freezeHeader=!0,e.freezeFooter=!0}e.isRendered?e.innerHTML&&e.innerHTML.trim().length>1?e._initDataSourceFromHTML():e._fullRefresh():(e._createElement(),setTimeout((()=>{const t=e.querySelectorAll("tr[row-id]");if(t.length>0){let a=!1;for(let l=0;l<t.length;l++){const i=t[l];e._rowHeight<i.offsetHeight&&(e._rowHeight=i.offsetHeight,a=!0)}a&&(e.style.setProperty("--smart-table-row-height",e._rowHeight+"px"),e._refreshDataRows())}e.onLoad&&e.onLoad()}),500),e.columnMenu&&(e._initialState=e.getState()),super.render())}_initDataSourceFromHTML(){const e=this,t=e.context;e.context=e,e.hasAttribute("smart-blazor")&&(e.$.tableContainer.innerHTML="");const a=e.columns;e.dataSource=null,e.rows=null,e.columns=null;const l=e.querySelectorAll("th");let i=[],n=[],r=[];for(let e=0;e<l.length;e++){const t=l[e].innerHTML.trim();let a={label:t,dataField:t,dataType:"string"};i.push(a),n.push(t)}if(0===l.length&&a&&a.length>0)for(let e=0;e<a.length;e++){const t=a[e];let l={label:t.label,dataField:t.dataField,dataType:t.dataType};t.width&&(l.width=t.width),t.allowResize&&(l.allowResize=t.allowResize),t.allowFilter&&(l.allowFilter=t.allowFilter),t.allowSort&&(l.allowSort=t.allowSort),t.allowHide&&(l.allowHide=t.allowHide),t.allowMenu&&(l.allowMenu=t.allowMenu),t.freeze&&(l.freeze=t.freeze),t.responsivePriority&&(l.responsivePriority=t.responsivePriority),t.columnGroup&&(l.columnGroup=t.columnGroup),i.push(l),n.push({name:t.dataField,dataType:t.dataType})}const o=e.querySelectorAll("tr");for(let e=0;e<o.length;e++){const t={},a=o[e].querySelectorAll("td");if(a.length>0){for(let e=0;e<i.length;e++)t[i[e].dataField]=a[e].innerHTML.trim();r.push(t)}}const s=new Smart.DataAdapter({dataSource:r,expandHierarchy:e.expandHierarchy,dataFields:n,id:e.dataRowId});e.$.tableContainer.innerHTML="",e.columns=i,e.context=t,e.dataSource=s}attached(){const e=this;super.attached(),e.isCompleted&&e._dialog&&(e._addDialogHandlers(),e.getShadowRootOrBody().appendChild(e._dialog)),e.isRendered&&e.isCompleted&&e.endUpdate()}detached(){const e=this;if(super.detached(),e._focusedCell&&!e.$.tableContainer.contains(e._focusedCell)&&delete e._focusedCell,!e._dialog)return;e._detachCachedTemplates();const t=e._dialog;t.removeEventListener("change",e._dialogEventHandler),t.removeEventListener("clear",e._dialogEventHandler),t.removeEventListener("click",e._dialogEventHandler),t.removeEventListener("close",e._dialogEventHandler),t.removeEventListener("filter",e._dialogEventHandler),t.remove()}addFilter(e,t){const a=this,l=a.columnByDataField[e];"string"==typeof t?t=a.dataSource._createFilter(l.dataType,[t]):Array.isArray(t)&&(t=a.dataSource._createFilter(l.dataType,t)),l&&!1!==l.allowFilter&&t instanceof Smart.Utilities.FilterGroup!=0&&(e=l.dataField,a._clearSortByRow&&a._clearSortByRow(!0),a._designerFiltersApplied&&a._clearDesignerFilters(),a._filterInfo.appliedFilters||(a._filterInfo.appliedFilters={}),a._filterInfo.appliedFilters[e]=t,a._refreshFilters("add"),l.headerCellElement&&l.headerCellElement.setAttribute("filter",""),a.$.filterInput&&t&&!a.filterRow&&!a.columnMenu&&(a.$.filterInput.value=t.filters[t.filters.length-1].value,a._filterInfo.query=a.$.filterInput.value),a._originalDynamicColumnsOrder&&(a._originalDynamicColumnsOrder=a._dynamicColumns.map((e=>e.id))))}addGroup(e){const t=this;if(!t.grouping)return;const a=t.columnByDataField[e];if(!a||!1===a.allowGroup)return;const l=t.dataSource,i=l.groupBy;e=a.dataField,-1===i.indexOf(e)&&(i.push(e),l.refreshHierarchy(),t._getSelectableGroupRecords(),t._fullRefresh(),t._updateState("grouped"),t._doNotFireEvent||t.$.fireEvent("group",{action:"add",dataField:e}))}beginEdit(e,t){const a=this;if(!a.editing)return;const l=a.columnByDataField[t];if(t=l?l.dataField:void 0,"cell"===a.editMode&&!t||l&&!1===l.allowEdit)return;const i=a.rowById[e];if(!i)return;const n=i.data.$.id;a._editing&&a.endEdit(),a._beginEdit({rowId:n,rowObject:i,dataField:t})}cancelEdit(){const e=this,t=e._editing;if(t){for(let a=0;a<t.cells.length;a++){const l=t.cells[a];l.editor.contains(e.getRootNode().activeElement)&&e._focusCell(l.element),l.editor.remove(),e._setCellContent(l.element,e._formatCellValue(t.row,e.columnByDataField[l.dataField],l.element)),l.element.classList.remove("editing")}delete e._editing}}clearFilters(e=null){const t=this,a=t._filterInfo;(a.inputFilters||a.rowFilters||a.appliedFilters)&&(t._clearFilterInput(),t._clearRowFilters(e),delete t._filterInfo.appliedFilters,t.dataSource.virtualDataSource||t.dataSource.clearFilter(),t._fullRefresh("filter"),t._updateState("filtered"),t._doNotFireEvent||t.$.fireEvent("filter",{action:"remove"}))}clearGrouping(){const e=this,t=e.dataSource;0!==t.groupBy.length&&(t.groupBy=[],t.refreshHierarchy(),e._getSelectableGroupRecords(),e._fullRefresh(),e._updateState("grouped"),e.$.fireEvent("group",{action:"remove"}))}clearSelection(){this._clearSelection(!0)}collapseAllRows(){const e=this;e._isExpandCollapseForbidden()||function t(a){for(let l=0;l<a.length;l++){const i=a[l];i.leaf||(i.children&&t(i.children),i.expanded&&e.collapseRow(i.$.id))}}(e["smart-table"===e.nodeName.toLowerCase()?"dataSource":"rows"].boundHierarchy)}collapseGroup(e){const t=this;if(!t.grouping||0===t.dataSource.groupBy.length)return;const a=t._getGroupByIndex(e);if(!a||!a.expanded)return;const l=t.$.tableContainer.querySelector(`tr[row-id="${a.$.id}"]:not([unused])`);if(!l){a.expanded=!1;let e=a.$.id;return null==e?void t.refresh():e.replace?(e=e.replace("Item","").replace(/_/gi,"."),void t.$.fireEvent("group",{action:"collapse",path:e,dataField:a.groupDataField,label:a.label})):(t.refresh(),void t.$.fireEvent("group",{action:"collapse",path:e,dataField:a.groupDataField,label:a.label}))}if(t._isCollapsed(a))return l.setAttribute("aria-expanded",!1),l.classList.remove("expanded"),void(a.expanded=!1);t._hierarchyArrowClickHandler(l)}collapseRow(e){const t=this;if(t._isExpandCollapseForbidden())return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e],l=a.data||a;if(!a||l.leaf||!l.expanded)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);return i?t._isCollapsed(l)?(i.setAttribute("aria-expanded",!1),i.classList.remove("expanded"),l.expanded=!1,t._expandedIds=t._expandedIds.filter((e=>e!==l.$.id)),t._updateState("expanded"),void t.$.fireEvent("collapse",{record:l})):void t._hierarchyArrowClickHandler(i):(l.expanded=!1,t._expandedIds=t._expandedIds.filter((e=>e!==l.$.id)),void t._updateState("expanded"))}collapseRowDetails(e){const t=this;if(!t.rowDetailTemplate)return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e],l=a.data||a;if(!a||!l)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);if(!i)return;const n=i.nextElementSibling;n&&n.classList.contains("smart-table-row-detail")&&!n.classList.contains("collapsed")&&t._toggleRowDetail(i,l.$.id)}collapseAllRowDetails(){const e=this;if(!e.rowDetailTemplate||!e.dataSource)return;let t=e.dataSource.boundSource;t||(t=e.$.tableContainer.querySelectorAll("tr[row-id]:not([unused])"));for(let a=0;a<t.length;a++)e.collapseRowDetails(t[a].$.id)}expandAllRowDetails(){const e=this;if(!e.rowDetailTemplate||!e.dataSource)return;let t=e.dataSource.boundSource;t||(t=e.$.tableContainer.querySelectorAll("tr[row-id]:not([unused])"));for(let a=0;a<t.length;a++)e.expandRowDetails(t[a].$.id)}updateRow(e,t,a){const l=this,i=l.rowById?l.rowById[e]:l.rows.dataItemById[e];if(!i)return;const n=l._selectedIds.slice(0);l._editing=!0,l.__updatedRows=!0;let r=[];l.dataSource&&l.dataSource.groupBy&&l.dataSource.groupBy.toArray&&(r=l.dataSource.groupBy.toArray().slice(0));const o=l.dataSource.boundSource.canNotify;l.dataSource.boundSource.canNotify=!1;const s=e=>{if(i.data[e]=t[e],l.dataSource.id&&i&&i.data&&i.data.$&&(i.data.$.id=t[l.dataSource.id]),i&&i.data.$&&void 0!==i.data.$.index){const a=i.data.$.index,n=l.dataSource.dataSource,o=()=>{const a=t[e];if(null==a){const t=l.columnByDataField[e];return t?"number"===t.dataType?0:"boolean"!==t.dataType&&("date"===t.dataType?new Date:""):""}return a};if(n&&n[a]&&(n[a][e]=o()),l.dataSource[a]){if(r.length>0&&!l._dirtyHierarchy&&l.dataSource[a][e]!==o()&&r.indexOf(e)>=0){const e=l._getExpandedGroups(l.dataSource.boundHierarchy);l._dirtyHierarchy=e}l.dataSource[a][e]=o()}}};for(let e=0;e<l.columns.length;e++){const a=l.columns[e];void 0!==t[a.dataField]&&s(a.dataField)}if(a){const e=l.dataSource.dataFields;if(e)for(let t=0;t<e.length;t++)e[t].map?s(e[t].map):s(e[t].name)}l._editing=!1,l.dataSource.boundSource.canNotify=o,l.__updating||(l.dataSource.refreshHierarchy(),l._fullRefresh(void 0,n,"update"))}addRow(e){const t=this;let a=[];const l=t.dataSource.boundSource.canNotify;if(t.dataSource.boundSource.canNotify=!1,t._editing=!0,t.__updatedRows=!0,t.dataSource&&t.dataSource.groupBy&&t.dataSource.groupBy.toArray&&(a=t.dataSource.groupBy.toArray().slice(0),a.length>0&&t.dataSource.beginUpdate()),a.length>0)t.dataSource?t.dataSource.add(e,!0):t._addNewRow(e,0);else if(t.dataSource)if(t.dataSource.boundHierarchy&&t.$.tableContainer&&"treegrid"===t.$.tableContainer.getAttribute("role")){const a=e[t.dataSource.parentDataField];t.dataSource.add(e,a)}else t.dataSource.add(e,!0);else t._addNewRow(e,0);t.dataSource.boundSource.canNotify=l,t._editing=!1,t._updateSelectAllState(),a.length>0||t.dataSource.boundHierarchy&&t.$.tableContainer&&"treegrid"===t.$.tableContainer.getAttribute("role")?(t._dataSourceUpdatingTimer&&clearTimeout(t._dataSourceUpdatingTimer),t._dataSourceUpdatingTimer=setTimeout((()=>{t._doNotFireEvent=!0;const e=t._getExpandedGroups(t.dataSource.boundHierarchy);a.forEach((e=>t.addGroup(e))),t.dataSource.endUpdate(),t._restoreExpandedGroups(e),t._fullRefresh("update"),t._doNotFireEvent=!1}),50)):(t._dataSourceUpdatingTimer&&clearTimeout(t._dataSourceUpdatingTimer),t._dataSourceUpdatingTimer=setTimeout((()=>{t._doNotFireEvent=!0,t._fullRefresh("update"),t._doNotFireEvent=!1})))}removeRow(e){const t=this,a=t.rowById?t.rowById[e]:t.rows.dataItemById[e];if(!a){if(t.dataSource&&t.dataSource.dataItemById){const a=t.dataSource.dataItemById[e];if(a){const l=void 0!==a.$?a.$.index:0;t.dataSource.removeAt(l),t._selectedIds.indexOf(e)>=0&&(t._selectedIds.splice(t._selectedIds.indexOf(e),1),t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:"remove"})),t.virtualization&&t.__updating||t._fullRefresh("update")}}return}const l=a.data||a,i=void 0!==l.$?l.$.index:0,n=t.dataSource.boundSource.canNotify;t.dataSource.boundSource.canNotify=!1,t._editing=!0,t.__updatedRows=!0;let r=[];t.dataSource&&t.dataSource.groupBy&&t.dataSource.groupBy.toArray&&(r=t.dataSource.groupBy.toArray().slice(0),r.length>0&&t.dataSource.beginUpdate()),t._doNotFireEvent=!0,t._sortColumns&&t._sortColumns.length?t.dataSource.remove(l):t.dataSource.removeAt(i),t._selectedIds.indexOf(e)>=0&&(t._selectedIds.splice(t._selectedIds.indexOf(e),1),t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:"remove"})),t._doNotFireEvent=!1,t.dataSource.boundSource.canNotify=n,t._editing=!1,r.length>0&&(t._dataSourceUpdatingTimer&&clearTimeout(t._dataSourceUpdatingTimer),t._dataSourceUpdatingTimer=setTimeout((()=>{const e=t._getExpandedGroups(t.dataSource.boundHierarchy);r.forEach((e=>t.addGroup(e))),t.dataSource.endUpdate(),t._restoreExpandedGroups(e),t._fullRefresh("update")}),50)),t.virtualization&&t.__updating||t._fullRefresh("update")}expandRowDetails(e){const t=this;if(!t.rowDetailTemplate)return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e];if(!a)return;const l=a.data||a;if(!a||!l)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);if(!i)return;const n=i.nextElementSibling;!n&&!t.virtualization||n&&n.classList.contains("smart-table-row-detail")&&!n.classList.contains("collapsed")||t._toggleRowDetail(i,l.$.id)}endEdit(){const e=this,t=e._editing;if(!t)return;const a=t.row,l=a.data,i=[];let n=!0;for(let a=0;a<t.cells.length;a++){const l=t.cells[a],r=e.columnByDataField[l.dataField],o=l.element,s=l.editor;let d;if(r.editor&&r.editor.template?r.editor.getValue&&(d=r.editor.getValue(s)):(d=s.value,s instanceof HTMLInputElement&&("number"===s.type?d=parseFloat(d):"date"===s.type&&(d=new Date(d),isNaN(d.getTime())&&(d=null)))),r.validation){const t=r.validation(d),a=void 0!==t&&!0!==t;if(a){let a;a="object"==typeof t&&t.message?t.message:e.localize("invalidValue"),o.setAttribute("validation-message",a)}else o.removeAttribute("validation-message");o.classList.toggle("invalid",a),n=n&&!a}i.push({column:r,newValue:d})}if(n){if(e.dataSource.virtualDataSource){const a=Object.assign({},l);for(let e=0;e<t.cells.length;e++){const l=t.cells[e],n=i[e],r=n.column;a[l.dataField]=n.newValue,r.transform&&(a[r.dataField]=r.transform(n.newValue))}for(const t of e._columns)a[t.dataField]instanceof Date&&(a[t.dataField]=a[t.dataField].toISOString().slice(0,10));e._editing.row.data=a,e._requestVirtualDataSource("update",(function(t){return t?r(!1,a):(e._editing.row.data=l,e.cancelEdit()),t}))}else r(!0,l);delete e._editing}function r(l,n){for(let r=0;r<t.cells.length;r++){const o=t.cells[r],s=i[r],d=s.column,c=o.editor;c.contains(e.getRootNode().activeElement)&&e._focusCell(o.element),c.remove(),l&&(n[o.dataField]=s.newValue,d.transform&&(n[d.dataField]=d.transform(s.newValue))),e._setCellContent(o.element,e._formatCellValue(a,d,o.element)),o.element.classList.remove("editing"),e.$.fireEvent("cellEndEdit",{id:n.$.id,row:n,value:n[o.dataField],dataField:o.dataField})}e._updateCellsWithFormulas(),"row"===e.editMode&&e.$.fireEvent("rowEndEdit",{id:n.$.id,row:n})}}expandAllRows(){const e=this;if(e._isExpandCollapseForbidden())return;e.beginUpdate();const t=e["smart-table"===e.nodeName.toLowerCase()?"dataSource":"rows"].boundHierarchy;if(t)for(let e=0;e<t.length;e++){const a=t[e],l=e=>{if(!e.leaf&&(e.expanded=!0,e.children))for(let t=0;t<e.children.length;t++){const a=e.children[t];l(a)}};l(a)}e.endUpdate()}isGroupExpanded(e){const t=this,a=t.dataSource;if(!t.grouping||0===a.groupBy.length)return;const l=t._getGroupByIndex(e);return!!l&&l.expanded}expandGroup(e){const t=this,a=t.dataSource;if(!t.grouping||0===a.groupBy.length)return;const l=t._getGroupByIndex(e);if(!l)return;const i=t._doNotFireEvent,n=t.animation,r=t.$.tableContainer.querySelector(`tr[row-id="${l.$.id}"]:not([unused])`);let o=!1;if(i&&(t.animation="none"),r){if(t._isCollapsed(l))if(i)o=!0;else{let e=l.parent;e&&!e.expanded&&t.expandGroup(l.parent.$.id.replace("Item","").replace(/_/g,"."))}l.expanded||(o||i?(l.expanded=!0,r.setAttribute("aria-expanded",!0),r.classList.add("expanded")):t._hierarchyArrowClickHandler(r,i)),i&&(l.expanded=!0,r.setAttribute("aria-expanded",!0),r.classList.add("expanded"),requestAnimationFrame((()=>t.animation=n)))}else if(l.expanded=!0,!l.expanded&&!i){let e=l.$.id;e=e.replace("Item","").replace(/_/gi,"."),t.$.fireEvent("group",{action:"expand",path:e,dataField:l.groupDataField,label:l.label})}}expandAllRootGroups(){const e=this;if(!e.grouping)return;e.beginUpdate();const t=e.dataSource.boundHierarchy;if(t)for(let e=0;e<t.length;e++)t[e].expanded=!0;e.endUpdate()}expandAllGroups(){const e=this;if(!e.grouping)return;e.beginUpdate();const t=e.dataSource.boundHierarchy;if(t)for(let e=0;e<t.length;e++){const a=t[e],l=e=>{if(e.expanded=!0,e.children)for(let t=0;t<e.children.length;t++){const a=e.children[t];l(a)}};l(a)}e.endUpdate()}collapseAllGroups(){const e=this;if(!e.grouping)return;e.beginUpdate();const t=e.dataSource.boundHierarchy;if(t)for(let e=0;e<t.length;e++)t[e].expanded=!1;e.endUpdate()}expandRow(e){const t=this;if(t._isExpandCollapseForbidden())return;const a=t.rowById?t.rowById[e]:t.rows.dataItemById[e],l=a.data||a;if(!a||l.leaf)return;const i=t.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused])`);if(!i)return l.expanded=!0,-1===t._expandedIds.indexOf(l.$.id)&&t._expandedIds.push(l.$.id),t._updateState("expanded"),void t.$.fireEvent("expand",{id:l.$.id,record:l});if(t._isCollapsed(l)){let e=l.parent;e&&!e.expanded&&t.expandRow(e.$.id)}l.expanded||t._hierarchyArrowClickHandler(i)}exportData(e,t,a,l){const i=this,n=i._columns.filter((e=>e.visible)),r=i.columnGroups,o=i.dataSource,s=getComputedStyle(i),d=s.borderRightColor,c=new Smart.Utilities.DataExporter(void 0,o.groupBy.toArray()),u={};let f,m=Array.from(i.$.tableContainer.firstElementChild.querySelectorAll("th"));if(o.virtualDataSource){f=[];for(let e=0;e<i.rows.length;e++)f.push(i.rows[e].data)}else o.boundHierarchy&&!i.grouping?(c.hierarchical=!0,f=function e(t){const l=[];return t.forEach((t=>{a&&!1===t.$.filtered||(l.push(t),t.leaf||(t._expanded=t.expanded,t.children&&(t.children=e(t.children),0===t.children.length&&(t._expanded=void 0,t.children=void 0,t.leaf=!0))))})),l}(JSON.parse(JSON.stringify(o.boundHierarchy,((e,t)=>{if("parent"!==e)return t}))))):(f=Array.from(o.toArray()),a&&(f=f.filter((e=>!1!==e.$.filtered))));c.style={border:"1px solid "+d,borderCollapse:"collapse",backgroundColor:s.backgroundColor,color:s.color,fontFamily:"Helvetica",header:{border:"1px solid "+d,fontWeight:"bold"},columns:{border:"1px solid "+d}},m=m.filter((e=>!1===e.classList.contains("smart-table-select-all")));for(let e=0;e<n.length;e++){const t=n[e],a={},l={};let i=m[e].offsetWidth+"px";u[t.dataField]=t.label,"date"===t.dataType&&(l.format="d"),a.width=i,c.style.header[t.dataField]=a,c.style.columns[t.dataField]=l}return r?c.header={columns:n,columngroups:r}:f.unshift(u),c.exportData(f,e,t,l)}getRowIndexById(e){const t=this.rowById[e];return this.dataSource&&t&&t.data&&t.data.$?t.data.$.index:-1}getSelection(){const e=this;return 0===e._selectableGroupRecords.length?e._selectedIds.filter((e=>!(""+e).startsWith("Item"))):e._selectedIds.filter((t=>-1===e._selectableGroupRecords.indexOf(t)&&!(""+t).startsWith("Item")))}getState(){return JSON.parse(this._stringifyState())}getValue(e,t){const a=this,l=a.columnByDataField[t];if(!l)return;let i=a.rowById[e];return i?i.data[l.dataField]:(i=a.dataSource.dataItemById[e],i?i[l.dataField]:void 0)}loadState(e){const t=this;if(!e&&!(e=window.localStorage.getItem("smartTable"+t.id)))return;const a=t.stateSettings;let l=!1;if(t._loadingState=!0,"string"==typeof e&&(e=JSON.parse(e)),-1!==a.indexOf("columns")){const a=t.loadColumnStateBehavior,i=t._columns,n=[],r=e.columns;for(let e=0;e<r.length;e++){let t=Object.assign({},r[e]);const l=i.find((e=>e.dataField===t.dataField));if(!l){"implementationOnly"!==a&&n.push(t);continue}const o=l.label,s=["editor","formatFunction","templateElement","templateElementSettings","transform","validation"];"stateOnly"!==a&&s.push("label");for(let e in l)-1===s.indexOf(e)&&delete l[e];t=Object.assign(l,t),"stateOnly"!==a&&o&&(t.label=o),n.push(t)}if("stateOnly"!==a)for(let e=0;e<i.length;e++){const t=i[e];n.find((e=>e.dataField===t.dataField))||n.push(t)}t.columns=n,t._initColumns(!0),l=!0,t._formattingPanel&&(t._formattingPanel.columns=t._columns)}if(t.grouping){const a=t.dataSource,i=t.dataSource.groupBy;e.grouped=e.grouped||[],JSON.stringify(i._array)!==JSON.stringify(e.grouped)&&(t.dataSource.groupBy=e.grouped,a.refreshHierarchy(),l=!0)}else t.hasAttribute("hierarchy")&&-1!==a.indexOf("expanded")&&JSON.stringify(t._expandedIds.slice(0).sort())!==JSON.stringify(e.expanded.slice(0).sort())&&(t.collapseAllRows(),t._expandedIds=e.expanded,l=!0);-1!==a.indexOf("selected")&&e.selected.slice&&JSON.stringify(t._selectedIds.slice(0).sort())!==JSON.stringify(e.selected.slice(0).sort())&&(t._selectedIds=e.selected,l=!0),l&&(t._initRows(),t.refresh());e:if(-1!==a.indexOf("filtered")){const a=t.filtering,l=e.filtered;if(t.clearFilters(),!l)break e;if(a&&t.filterRow&&l.rowFilters){const a=t.$.tableContainer.querySelector(".smart-table-filter-row"),l=Number(t.selection),i=e.filtered.filterRowValues;for(let e=0;e<t._columns.length;e++){const n=i[e];if(!n)continue;const r=t._columns[e].dataType,o=a.children[e+l].firstElementChild,s=t._filterInfo["string"===r?"stringConditions":"numberAndDateConditions"].find((e=>e.value===n.condition));if(-1===["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(s.value))if("date"===r){const e=new Date(n.value),t=(e.getMonth()+1).toString(),a=e.getDate().toString();o.children[0].value=`${e.getFullYear()}-${"0".repeat(2-t.length)}${t}-${"0".repeat(2-a.length)}${a}`}else o.children[0].value=n.value;o.children[1].value=s.label,o.children[1].$.input.dataValue=s.value}t._applyRowFilters()}else if(a&&l.inputFilters)t.$.filterInput.value=l.query,t._filterByAll(l.query);else if(l.appliedFilters){t._filterInfo.appliedFilters||(t._filterInfo.appliedFilters={});for(let e in l.appliedFilters){const a=l.appliedFilters[e],i=new window.Smart.Utilities.FilterGroup;a.filters.forEach(((e,t)=>{const l=i.createFilter(e.type.replace("Filter",""),e.value,e.condition);i.addFilter(a.logicalOperators[t],l)})),t._filterInfo.appliedFilters[e]=i}t._refreshFilters("add")}}-1!==a.indexOf("sorted")&&(t.clearSort(),e.sorted.forEach&&e.sorted.forEach((e=>{t.sortBy(e.dataField,e.direction)}))),a.forEach((e=>t._updateState(e,!1))),t.autoSaveState&&window.localStorage.setItem("smartTable"+t.id,t._stringifyState()),delete t._loadingState}navigateTo(e){const t=this;if(isNaN(e)||null===e)return;const a=t.pageIndex;t.pageIndex=Math.max(Math.min(Math.round(e),t.$.pager.pagesCount-1),0),t.paging&&t.pageIndex!==a&&(t._fullRefresh("pageIndexChange"),t.$.fireEvent("page",{action:"pageIndexChange"}))}removeFilter(e){const t=this,a=t.columnByDataField[e];a&&t.filterRow&&t.clearFilters(e),t._filterInfo.appliedFilters&&a&&(e=a.dataField,t._clearSortByRow&&t._clearSortByRow(!0),t._designerFiltersApplied&&t._clearDesignerFilters(e),delete t._filterInfo.appliedFilters[e],t._refreshFilters("remove"),t._originalDynamicColumnsOrder&&(t._originalDynamicColumnsOrder=t._dynamicColumns.map((e=>e.id))))}removeGroup(e){const t=this,a=t.columnByDataField[e];if(!t.grouping||!a)return;e=a.dataField;const l=t.dataSource,i=l.groupBy,n=i.indexOf(e);-1!==n&&(i.splice(n,1),l.refreshHierarchy(),t._getSelectableGroupRecords(),t._fullRefresh(),t._updateState("grouped"),t.$.fireEvent("group",{action:"remove",dataField:e}))}saveState(){const e=this._stringifyState();return window.localStorage.setItem("smartTable"+this.id,e),JSON.parse(e)}enableSelect(e){const t=this;t.selection&&t._disabledSelection.indexOf(e)>=0&&(t._disabledSelection.splice(t._disabledSelection.indexOf(e),1),t._fullRefresh("update"))}disableSelect(e){const t=this;t.selection&&(t._disabledSelection.push(e),t._fullRefresh("update"))}select(e){const t=this;t.selection&&(Array.isArray(e)?t._changeSelectionOfMultiple(e,"select"):t._selectSingle(e)&&(t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:t._interaction?"interaction":"programmatic"})))}setValue(e,t,a){const l=this,i=l.columnByDataField[t];if(!i)return;let n,r=l.rowById[e];if(r)n=r.data;else{if(r=l.dataSource.dataItemById[e],!r)return;n=r}t=i.dataField,l.dataSource._updating=!0,i.transform?(n[i.originalDataField]=a,n[t]=i.transform(a)):n[t]=a;const o=l.$.tableContainer.querySelector(`tr[row-id="${e}"]:not([unused]) td[data-field="${t}"]`);if(o&&(l._setCellContent(o,l._formatCellValue(r,i,o),o.classList.contains("tree-cell")),i.templateElement&&i.templateElementSettings)){const e=o.classList.contains("tree-cell"),t=o,a=e?t.children[0].children[1]:t,r=n.$.id;l._cachedTemplates&&l._cachedTemplates[i.dataField+"_"+r]&&(0===l._cachedTemplates[i.dataField+"_"+r].innerHTML.length?delete l._cachedTemplates[i.dataField+"_"+r]:(a.innerHTML="",a.appendChild(l._cachedTemplates[i.dataField+"_"+r]))),i.templateElementSettings(n[i.dataField],r,a.firstElementChild),l._cachedTemplates||(l._cachedTemplates=[]),l._cachedTemplates[i.dataField+"_"+r]||(l._cachedTemplates[i.dataField+"_"+r]=a.firstElementChild)}l._updateCellsWithFormulas(),delete l.dataSource._updating}unselect(e){const t=this;t.selection&&(Array.isArray(e)?t._changeSelectionOfMultiple(e,"unselect"):t._unselectSingle(e)&&(t._updateSelectAllState(),t._updateState("selected"),t.$.fireEvent("change",{type:t._interaction&&-1===t._disabledSelection.indexOf(e)?"interaction":"programmatic"})))}set scrollTop(e){const t=this;t.isRendered&&(e=parseInt(e),isNaN(e)||((t.virtualization?t.$.virtualizationContainer:t.$.container).scrollTop=e))}get scrollTop(){const e=this;return e.isRendered?(e.virtualization?e.$.virtualizationContainer:e.$.container).scrollTop:0}set scrollLeft(e){const t=this;t.isRendered&&(e=parseInt(e),isNaN(e)||((t.virtualization?t.$.virtualizationContainer:t.$.container).scrollLeft=e))}get scrollLeft(){const e=this;return e.isRendered?(e.virtualization?e.$.virtualizationContainer:e.$.container).scrollLeft:0}clearContent(){const e=this;for(;e.$.tableContainer.firstChild;)e.$.tableContainer.removeChild(e.$.tableContainer.firstChild)}applyContent(){const e=this;if(void 0===e.content)return void(e.content=e.$.tableContainer);if(""===e.content||null===e.content)return void e.clearContent();if(e.content instanceof HTMLElement)return e.clearContent(),void e.$.content.appendChild(e.content);const t=document.createDocumentFragment();let a=document.createElement("div");t.appendChild(a),e.content instanceof HTMLElement?a.appendChild(e.content):a.innerHTML=e.content;let l=Array.from(a.childNodes);a.parentNode.removeChild(a);for(let e=0;e<l.length;e++)t.appendChild(l[e]);e.clearContent(),e.$.tableContainer.appendChild(t)}propertyChangedHandler(e,t,a){const l=this;if(super.propertyChangedHandler(e,t,a),"innerHTML"!==e)switch(e){case"animation":case"theme":if("theme"===e){const e=getComputedStyle(l);l._defaults.text=l._toHex(e.color),l._defaults.highlight=l._toHex(e.backgroundColor)}if(l.filterRow){const t=l.$.tableContainer.querySelector(".smart-table-filter-row");Array.from(t.querySelectorAll("smart-input, smart-button")).forEach((t=>t[e]=a))}i(e,a);break;case"autoSaveState":a&&window.localStorage.setItem("smartTable"+l.id,l._stringifyState());break;case"columnGroups":a&&(l.columnResize&&(l.columnResize=!1),"auto"===l.columnSizeMode&&(l.removeAttribute("resize-max-reached"),l.columnSizeMode="default")),l.refresh();break;case"columnMinWidth":if(isNaN(parseFloat(a)))return void(l.columnMinWidth=t);l._handleAutoSizeMode(),l._handleFrozenColumnPositions(),l._refreshHorizontalScrollbar();break;case"columnResize":a&&l.columnGroups&&(l.columnResize=!1);break;case"columnResizeNormalize":l._columns&&l._columns.length>0&&""===l._columns[l._columns.length-1].dataField&&(l._columns.pop(),l.columns.pop()),l._initColumns(!0),l.refresh();break;case"columns":{l._conditionalFormatting&&delete l._conditionalFormatting;const e=l._sortColumns,t=l._filterInfo;if(l._clearFilterInput(),l._clearRowFilters(),delete l._filterInfo.appliedFilters,l._sortColumns=[],l._initColumns(!0),l.refresh(),l._formattingPanel&&(l._formattingPanel.columns=l._columns),l.dataSource.dataFields){let a=l.dataSource.dataFields||[];const i=l.columns;let n=!1;if(i.forEach((e=>{if(e.dataType){const t=a.find((t=>t.name===e.dataField));t?t.dataType=e.dataType:e.map?a.find((t=>e.map.indexOf(t.name)>=0?t:null))&&(l.dataSource.dataFields.push({name:e.dataField,map:e.map,dataType:e.dataType}),n=!0):(l.dataSource.dataFields.push({name:e.dataField,dataType:e.dataType}),n=!0)}})),n&&l.dataSource.dataBind){let a=[],i=[];if(l.dataSource&&l.dataSource.groupBy&&l.dataSource.groupBy.toArray&&(a=l.dataSource.groupBy.toArray().slice(0)),a.length>0&&(i=l._getExpandedGroups(l.dataSource.boundHierarchy)),l.dataSource.bindingCompleted=!1,l.dataSource.dataBind(),l._doNotFireEvent=!0,a.length>0&&(a.forEach((e=>l.addGroup(e))),l.dataSource.boundHierarchy&&l.dataSource.refreshHierarchy(),l._restoreExpandedGroups(i)),t.inputFilters?l._filterByAll(t.query):t.rowFilters?l._applyRowFilters():t.appliedFilters&&l._refreshFilters(),e&&(l._sortColumns=[],e.forEach((e=>{l.columnByDataField[e.dataField].sortOrder=null,l.sortBy(e.dataField,e.direction)}))),l._selectedIds.length>0){const e=JSON.stringify(l._selectedIds.slice(0).sort()),t=l.dataSource;l._selectedIds=l._selectedIds.filter((e=>void 0!==t.dataItemById[e]||-1!==l._selectableGroupRecords.indexOf(e))),e!==JSON.stringify(l._selectedIds.slice(0).sort())&&(l._updateSelectAllState(),l._updateState("selected"),l.$.fireEvent("change",{type:"remove"}))}l.virtualization&&setTimeout((()=>{const e=l.columns&&l.columns.length>0?l.columns[0].dataField:"";if(e){const t=l.querySelector('td[data-field="'+e+'"]');t&&l._rowHeight<t.offsetHeight&&(l._rowHeight=t.offsetHeight,l.style.setProperty("--smart-table-row-height",l._rowHeight+"px"),l._refreshDataRows())}}),300),delete l._doNotFireEvent}else t.inputFilters?l._filterByAll(t.query):t.rowFilters?l._applyRowFilters():t.appliedFilters&&l._refreshFilters(),e&&(l._sortColumns=[],e.forEach((e=>{l.columnByDataField[e.dataField].sortOrder=null,l.sortBy(e.dataField,e.direction)})))}break}case"columnSizeMode":if("auto"===a){if(l.columnGroups)return void(l.columnSizeMode="default");l._handleAutoSizeMode()}else l.removeAttribute("resize-max-reached"),l._columns.forEach((e=>{e.visible&&(e._isResponsive?e.headerCellElement.style.width=e.width||e._manualPercentageWidth?l._getColumnWidth(e.width||e._manualPercentageWidth,!0,e):null:e.headerCellElement.style.width=e.width||e._manualWidth?l._getColumnWidth(e.width||e._manualWidth,!0,e):null)}));l._handleFrozenColumnPositions(),l._refreshHorizontalScrollbar();break;case"conditionalFormatting":l._applyInitialConditionalFormatting(l.dataSource),l._refreshDataRows();break;case"conditionalFormattingButton":l.$.header.classList.toggle("smart-hidden",(!l.filtering||l.filterRow)&&!a),!a&&l._dialog&&l._dialog.close();break;case"dataSource":case"dataSourceSettings":{const i=l._sortColumns,n=l._filterInfo;if("dataSource"===e&&null===a&&(l.dataSource=[]),"dataSource"===e&&t&&a&&l.virtualization&&!document.hidden&&t instanceof Smart.DataAdapter&&t.length===a.length&&t.length>0&&a.length>0&&!l.dataSourceSettings.parentDataField&&!t.parentDataField){if(l.dataSource=t,l._cachedDataSource===a)return;l.beginUpdate();for(let e=0;e<a.length;e++){const t=a[e],i=l.dataSource[e].$.id;l.updateRow(i,t,!0)}return i?l.endUpdate(!0,!0):l.endUpdate(void 0,!0),void(l._cachedDataSource=a)}const r=l.$.virtualizationContainer?l.$.virtualizationContainer.scrollTop:0,o=void 0!==l.$.virtualizationContainer&&l.$.virtualizationContainer.$?l.$.virtualizationContainer.$.verticalScrollBar:null;o&&o.beginUpdate();let s=[];if(t&&t.groupBy&&t.groupBy.toArray&&(s=t.groupBy.toArray().slice(0)),l._dataBind(!0),l._doNotFireEvent=!0,s.length>0){const e=l._getExpandedGroups(t.boundHierarchy);if(l.__updating=!0,l.dataSource._groupBy&&(l.dataSource._groupBy.canNotify=!1),l._selectedIds.length>0){const e=JSON.stringify(l._selectedIds.slice(0).sort()),t=l.dataSource;l._selectedIds=l._selectedIds.filter((e=>void 0!==t.dataItemById[e]||-1!==l._selectableGroupRecords.indexOf(e))),s.forEach((e=>l.addGroup(e))),e!==JSON.stringify(l._selectedIds.slice(0).sort())&&(l._updateSelectAllState(),l._updateState("selected"),l.$.fireEvent("change",{type:"remove"}))}else s.forEach((e=>l.addGroup(e)));l.dataSource.boundHierarchy&&l.dataSource.refreshHierarchy(),l.dataSource._groupBy&&(l.dataSource._groupBy.canNotify=!0),l.__updating=!1,l._restoreExpandedGroups(e),l._fullRefresh("update")}if(n.inputFilters?l._filterByAll(n.query):n.rowFilters?l._applyRowFilters():n.appliedFilters&&l._refreshFilters(),i&&(l._sortColumns=[],i.forEach((e=>{l.columnByDataField[e.dataField].sortOrder=null,l.sortBy(e.dataField,e.direction)}))),l._selectedIds.length>0){const e=JSON.stringify(l._selectedIds.slice(0).sort()),t=l.dataSource;l._selectedIds=l._selectedIds.filter((e=>void 0!==t.dataItemById[e]||-1!==l._selectableGroupRecords.indexOf(e))),e!==JSON.stringify(l._selectedIds.slice(0).sort())&&(l._updateSelectAllState(),l._updateState("selected"),l.$.fireEvent("change",{type:"remove"}))}l.virtualization&&(setTimeout((()=>{const e=l.columns&&l.columns.length>0?l.columns[0].dataField:"";if(e){const t=l.querySelector('td[data-field="'+e+'"]');t&&l._rowHeight<t.offsetHeight&&(l._rowHeight=t.offsetHeight,l.style.setProperty("--smart-table-row-height",l._rowHeight+"px"),l._refreshDataRows())}}),300),l.$.virtualizationContainer.scrollTop=r,o&&(o.endUpdate(),l._onVerticalChange({detail:{value:o.value}},!0))),delete l._doNotFireEvent;break}case"disabled":case"unfocusable":case"keyboardNavigation":l._setFocusable(),i("unfocusable",l.disabled||l.unfocusable||!l.keyboardNavigation),"disabled"===e&&l._dialog&&l._dialog.close();break;case"hideSelectionColumn":l.refresh();break;case"columnMenu":l.$.header.classList.toggle("smart-hidden",(!l.filtering||l.filterRow||l.columnMenu)&&!l.conditionalFormattingButton),l.columnMenu&&(l._initialState=l.getState()),l.refresh();break;case"editing":a?l.$.tableContainer.removeAttribute("aria-readonly"):l.$.tableContainer.setAttribute("aria-readonly",!0);break;case"filtering":l.columnMenu||l.$.header.classList.toggle("smart-hidden",(!a||l.filterRow)&&!l.conditionalFormattingButton),a&&l.filterRow?l._createFilterRow():!1===a&&(l.filterRow&&l.$.tableContainer.querySelector(".smart-table-filter-row").remove(),(l._filterInfo.query||l._filterInfo.rowFilters||l._filterInfo.appliedFilters)&&l.clearFilters()),l.virtualization&&l.refresh();break;case"filterRow":if(l.$.header.classList.toggle("smart-hidden",(!l.filtering||a)&&!l.conditionalFormattingButton),!l.filtering)return;a?l._createFilterRow():(l.$.tableContainer.querySelector(".smart-table-filter-row").remove(),l._filterInfo.rowFilters&&l.clearFilters());break;case"filterTemplate":l._applyFilterTemplate();break;case"footerRow":{const e=l.$.tableContainer.querySelector("tfoot");e&&e.remove(),a&&l._createFooterRow();break}case"formulas":a?l._formulaParser=new Smart.FormulaParser(l):delete l._formulaParser,l._updateCellsWithFormulas(!0);break;case"freezeHeader":case"freezeFooter":l.virtualization&&(l[e]=!0);break;case"grouping":a||l.clearGrouping();break;case"headerRow":{const e=Array.from(l.$.tableContainer.firstElementChild.children);for(let t=1;t<e.length;t++)e[t].remove();a&&l._createCustomHeaderRow();break}case"locale":case"messages":{const e=l._dialog;if(l._localize(),l.filterRow){const e=l.$.tableContainer.querySelector(".smart-table-filter-row"),t=Array.from(e.querySelectorAll("smart-input.string-filter")),a=Array.from(e.querySelectorAll("smart-input.num-date-filter")),i=Array.from(e.querySelectorAll("smart-button"));t.concat(a).forEach((e=>e.title=l.localize("filterCondition"))),t.forEach((e=>{e.dataSource=l._filterInfo.stringConditions,void 0===e.$.input.dataValue?e.value=l.localize("CONTAINS"):e.value=l._filterInfo.stringConditions.find((t=>t.value===e.$.input.dataValue)).label})),a.forEach((e=>{e.dataSource=l._filterInfo.numberAndDateConditions,void 0===e.$.input.dataValue?e.value=l.localize("EQUAL"):e.value=l._filterInfo.numberAndDateConditions.find((t=>t.value===e.$.input.dataValue)).label})),i.forEach((e=>e.title=l.localize("clearFilter")))}e&&(e.$.footer.firstElementChild.innerHTML=l.localize("ok"),e.$.footer.children[1].innerHTML=l.localize("cancel"),e.classList.contains("conditional-formatting")?e.label=l.localize("conditionalFormatting"):e.classList.contains("drill-down")&&(e.label=l.localize("details"))),l._formattingPanel&&(l._formattingPanel.messages=l.messages,l._formattingPanel.locale=l.locale),Array.from(l.$.tableContainer.querySelectorAll(".group-label-value>.placeholder")).forEach((e=>{e.textContent=l.localize("EMPTY")}));break}case"pageIndex":l.pageIndex=Math.max(Math.min(Math.round(a),l.$.pager.pagesCount-1),0),l.paging&&l.pageIndex!==t&&(l._fullRefresh("pageIndexChange"),l.$.fireEvent("page",{action:"pageIndexChange"}));break;case"pageSize":l.paging&&(l._fullRefresh("pageSizeChange"),l.$.fireEvent("page",{action:"pageSizeChange"}));break;case"paging":if(!1===a){if(l.dataSource.virtualDataSource)return void(l.paging=!0);if(1===l.$.pager.pagesCount)return}l._fullRefresh();break;case"rowDetailTemplate":l._fullRefresh();break;case"rightToLeft":Array.from(l.$.tableContainer.querySelectorAll(".freeze-near, .freeze-far")).forEach((e=>{e.style.left=null,e.style.right=null,e.style.zIndex=null})),l._handleFrozenColumnPositions(),i("rightToLeft",a);break;case"selected":{const e=l._selectedIds.slice(0);l._clearSelection(),l._changeSelectionOfMultiple(a,"select","programmatic",e);break}case"selection":if(l.filterRow){const e=l.$.tableContainer.querySelector(".smart-table-filter-row");a?e.insertBefore(document.createElement("td"),e.firstElementChild):e.firstElementChild.remove()}l.refresh(),a?(l.$.tableContainer.setAttribute("aria-multiselectable",!0),l._updateSelectAllState()):l.$.tableContainer.removeAttribute("aria-multiselectable");break;case"selectionMode":{l.$.tableContainer.classList.remove("smart-unselectable");const e=l.querySelector(".smart-table-select-all");e&&("one"===l.selectionMode?e.classList.add("smart-visibility-hidden"):e.classList.remove("smart-visibility-hidden"));break}case"sortMode":"none"===a&&l.clearSort();break;case"tooltip":if(!a){const e=l.$.tableContainer.querySelector(".tooltip");e&&(e.classList.remove("tooltip"),e.removeAttribute("title"))}break;case"virtualization":l.virtualization=t}else l._initDataSourceFromHTML();function i(e,t){const a=[];l._dialog&&a.push(l._dialog,l._dialog.$.footer.firstElementChild,l._dialog.$.footer.children[1]),l._formattingPanel&&a.push(l._formattingPanel),a.forEach((a=>a[e]=t))}}_createElement(){const e=this;if(e._expandedRowDetailIds=[],e._editors={},isNaN(parseFloat(e.columnMinWidth))&&(e.columnMinWidth="50px"),e.columnGroups&&(e.columnResize=!1,e.columnSizeMode="default"),e.formulas&&(e._formulaParser=new Smart.FormulaParser(e)),e._setupPagingAndFiltering(),e._localize(),e._selectedIds=e.selected.slice(0),"one"===e.selectionMode){e._selectedIds=e._selectedIds.slice(0,1);const t=e.querySelector(".smart-table-select-all");t&&t.classList.add("smart-visibility-hidden")}e._dataBind(),e.editing||e.$.tableContainer.setAttribute("aria-readonly",!0),e.autoLoadState&&e.loadState(),e.autoSaveState&&window.localStorage.setItem("smartTable"+e.id,e._stringifyState())}_initColumns(e){const t=this,a=t.columns;if(!t.isRendered&&t.dataSource.length>0&&(!a||Array.isArray(a)&&0===a.length)&&(t.columns=t.dataSource.dataFields.map((e=>({label:e.name,dataField:e.name,dataType:e.dataType})))),t._filterInfo.stringDataFields=[],t._columns=[],t.columnByDataField={},t.columns.canNotify=!1,t.columns instanceof Smart.ObservableArray){const e=[];for(let a=0;a<t.columns.length;a++){let l=t.columns[a],i={};for(let e in l)i[e]=l[e];e.push(i)}t.columns=e}for(let a=0;a<t.columns.length;a++){let l=t.columns[a];if("string"==typeof l&&t.dataSource.dataFields){const e=t.dataSource.dataFields.find((e=>{if(e.name===l)return e}));l={label:l,dataField:l,dataType:e&&e.dataType||"string"}}void 0===l.label&&void 0===l.dataField||(void 0===l.label&&(l.label=l.dataField),void 0===l.dataField&&(l.dataField=l.label),l.dataType||(l.dataType="string"),"string"!==l.dataType&&"number"!==l.dataType||!1===l.allowFilter||!l.dataField||t._filterInfo.stringDataFields.push(l.dataField),l.visible=void 0===l.visible||!!l.visible,l.allowResize=void 0===l.allowResize||!!l.allowResize,t._transformColumnDataField(l,e),l.thHierarchy=[],t._columns.push(l),t.columnByDataField[l.dataField]=l)}if("default"===t.columnSizeMode&&t.selection){let e=!0;for(let a=0;a<t._columns.length;a++){const l=t._columns[a];if(!l.width){e=!1,l._isResponsive=!0,l._isFillRemainingWidth=!0;break}}(!t.columnResizeNormalize&&e||t.columnResizeNormalize&&e)&&t._columns.push({dataField:"",label:"",visible:!0,allowResize:!1,allowFilter:!1,allowSort:!1})}else if("default"===t.columnSizeMode&&!t.selection&&t.columnResizeNormalize){let e=!0;for(let a=0;a<t._columns.length;a++){const l=t._columns[a];if(!l.width){e=!1,l._isResponsive=!0,l._isFillRemainingWidth=!0;break}}e&&t._columns.push({dataField:"",label:"",visible:!0,allowResize:!1,allowFilter:!1,allowSort:!1})}t.columns=new Smart.ObservableArray(t._columns),t._updateState("columns"),t.columns.notify((function(e){if(!t.columns.canNotify)return;if("length"===e.action||"update"===e.action&&-1!==["allowGroup","allowSort","sortOrder"].indexOf(e.propertyName))return void t._updateState("columns");const a=e.target;if("update"===e.action){const l=a.dataField;if("allowEdit"===e.propertyName)return Array.from(t.$.tableContainer.querySelectorAll(`td[data-field="${l}"]`)).forEach((t=>{t.classList.toggle("no-edit",!1===e.newValue),!1===e.newValue?t.setAttribute("aria-readonly",!0):t.removeAttribute("aria-readonly")})),void t._updateState("columns");if("allowFilter"===e.propertyName)return"string"!==a.dataType&&"number"!==a.dataType||!l||(!1===e.newValue?t._filterInfo.stringDataFields=t._filterInfo.stringDataFields.filter((e=>e!==l)):!1===e.oldValue&&t._filterInfo.stringDataFields.push(l)),t.filterRow&&t.$.tableContainer.querySelector(`.smart-table-filter-row td[filter-for="${l}"]`).classList.toggle("no-filter",!1===e.newValue),"smart-pivot-table"===t.nodeName.toLowerCase()&&t._columnNotify(e),void t._updateState("columns");if("transform"===e.propertyName)a.sortOrder&&t.sortBy(a.dataField,null),t._transformColumnDataField(a,!0);else{if(-1!==["allowPivot","allowRowGroup","pivot","rowGroup","summary"].indexOf(e.propertyName)&&"smart-pivot-table"===t.nodeName.toLowerCase())return t._columnNotify(e),void t._updateState("columns");if("visible"===e.propertyName){const e=t._expandedRowDetailIds,a=t.$.tableContainer;let l;return t.filterRow&&(l=a.querySelector(".smart-table-filter-row"),l&&l.remove()),e&&e.length&&!t._columns.some((e=>e.visible))&&e.forEach((e=>t._toggleRowDetail(a.querySelector(`[row-id="${e}"]`),e))),t.$.tableContainer.setAttribute("aria-colcount",t._columns.filter((e=>e.visible)).length+ +t.selection),t.refresh(),void t._updateState("columns")}}}"add"===e.action&&(t.columns[t.columns.length-1].visible=!0),t._columns=t.columns._array,t.columnByDataField=[],t._columns.forEach((e=>{t.columnByDataField[e.dataField]=e,e.originalDataField&&(t.columnByDataField[e.originalDataField]=e)})),t.refresh(!0),t._updateState("columns")})),t.$.tableContainer.setAttribute("aria-colcount",t._columns.filter((e=>e.visible)).length+ +t.selection)}_transformColumnDataField(e,t){const a=this;if("function"==typeof e.transform){if(!a.isRendered||t){const l=a.dataSource,i=a.columns.canNotify;i&&(a.columns.canNotify=!1),t&&e.originalDataField&&(delete a.columnByDataField[e.dataField],e.dataField=e.originalDataField);const n=e.dataField,r=n+"Transformed";a.columnByDataField[n]=e,e.originalDataField=n,e.dataField=r,l.canNotify=!1;for(let t=0;t<l.length;t++){const a=l[t];a[r]=e.transform(a[n])}i&&(a.columns.canNotify=!0),l.canNotify=!0}}else e.transform&&(e.transform=void 0)}_initRows(){const e=this,t=e.dataSource,a=e.context;if(e.context=e,e.rows=[],e.rowById=[],t.virtualDataSource)return e._initRowsVirtualDataSource(),void(e.context=a);if(t.boundHierarchy)return e.$.tableContainer.setAttribute("role","treegrid"),e.setAttribute("hierarchy",""),e._initHierarchicalRows(),void(e.context=a);e.$.tableContainer.setAttribute("role","grid");let l=0,i=t.length,n=!1;if(e.removeAttribute("hierarchy"),e.paging){const a=e.pageSize;if(e._filterInfo.query||e._filterInfo.rowFilters||e._filterInfo.appliedFilters){let e=0;for(let a=0;a<i;a++)!1!==t[a].$.filtered&&e++;i=e,n=!0}const r=Math.max(Math.ceil(i/a),1);e.$.pager.pagesCount=r,e.$.pager.totalRecords=i,e.pageIndex=Math.max(Math.min(e.pageIndex,r-1),0),l=e.pageIndex*a,i=l+a}if(n){let a=-1;for(let n=0;n<t.length;n++){const r=t[n];if(r&&!1!==r.$.filtered){if(a++,a<l)continue;if(a>=i)break;e._addNewRow(r,n)}}}else for(let a=l;a<i;a++){const l=t[a];l&&!1!==l.$.filtered&&e._addNewRow(l,a)}e._observeRows(),e.context=a}_initRowsVirtualDataSource(){const e=this,t=e.dataSource;if(t.boundHierarchy)e.$.tableContainer.setAttribute("role","treegrid"),e.setAttribute("hierarchy",""),e._processHierarchy(t.boundHierarchy,0,t.boundHierarchy.length);else for(let a=0;a<t._dataSource.length;a++){const l=t[a];l&&!1!==l.$.filtered&&e._addNewRow(l,a)}if(e.paging){const a=t.length,l=e.pageSize,i=Math.max(Math.ceil(a/l),1),n=e.$.pager.pagesCount;if(e.$.pager.pagesCount=i,e.$.pager.totalRecords=a,e.pageIndex=Math.max(Math.min(e.pageIndex,i-1),0),null!==n&&n!==i)return void e._fullRefresh()}e._observeRows()}_initHierarchicalRows(){const e=this,t=e.dataSource.boundHierarchy;let a=0,l=t.length,i=!1;if(e.paging){const n=e.pageSize;if(e._filterInfo.query||e._filterInfo.rowFilters||e._filterInfo.appliedFilters){let e=0;for(let a=0;a<l;a++)!1!==t[a].$.filtered&&e++;l=e,i=!0}const r=Math.max(Math.ceil(l/n),1);e.$.pager.pagesCount=r,e.$.pager.totalRecords=l,e.pageIndex=Math.max(Math.min(e.pageIndex,r-1),0),a=e.pageIndex*n,l=a+n}if(i){let i=-1;for(let n=0;n<t.length;n++){const r=t[n];if(r&&!1!==r.$.filtered){if(i++,i<a)continue;if(i>=l)break;e._processHierarchy(t,n,n+1)}}}else e._processHierarchy(t,a,l);e._observeRows()}_processHierarchy(e,t,a){const l=this;for(let i=t;i<a;i++){const t=e[i];if(!t)break;t.leaf?t&&!1!==t.$.filtered&&l._addNewRow(t,i):(-1!==l._expandedIds.indexOf(t.$.id)?t.expanded=!0:void 0===t.expanded&&(t.expanded=!1),!1!==t.$.filtered&&l._addNewRow(t,i),t.children.length&&!1!==t.$.filtered&&l._processHierarchy(t.children,0,t.children.length))}}_observeRows(){const e=this;e.rows=new Smart.ObservableArray(e.rows),e.rows.notify((function(t){if(!e.rows.canNotify||t.path||!e.dataSource)return;e.rows.canNotify=!1;const a=t.action,l=e._selectedIds.slice(0);switch(e.dataSource.canNotify=!1,a){case"add":{const a={};e.dataSource.dataFields.forEach((e=>a[e.name]=""));const l=Object.assign(a,e.rows[t.index]);e.dataSource.add(e.rows[t.index]),e._editing={row:{data:l}};break}case"update":e.dataSource.update(t.index,e.rows[t.index]),e._editing={row:{data:e.rows[t.index]}};break;case"remove":{const a=t.removed[0].data,l=a.$.id,i=e._selectedIds.indexOf(l);e.dataSource.removeAt(a.$.index),delete e.rowById[l],-1!==i&&e._selectedIds.splice(i,1),e._editing={row:t.removed[0]},e._updateSelectAllState();break}}e._fullRefresh(a,l,a),delete e._editing,e.dataSource.canNotify=!0,e.rows.canNotify=!0}))}beginUpdate(){const e=this;if("smart-table"!==e.nodeName.toLowerCase())return;e.__updating=!0,e.__updatedRows=!1;const t=window.__karma__||window.karma;document.hidden&&!t||(e._dirtyHierarchy=!1,e.__updatingOldSelectedIds=e._selectedIds.slice(0),e.__updatingSortColumns=e._sortColumns,e.dataSource&&e.dataSource.clearSort&&e.dataSource.clearSort())}endUpdate(e,t){const a=this;if("smart-table"!==a.nodeName.toLowerCase())return;a.__updating=!1;const l=window.__karma__||window.karma;if(document.hidden&&!l)return;if(!1===e)return;l&&(t=!0);const i=()=>{const t=a.__updatingOldSelectedIds?a.__updatingOldSelectedIds:a._selectedIds.slice(0);a.__updatingOldSelectedIds&&delete a.__updatingOldSelectedIds,a._dirtyHierarchy&&a.dataSource.refreshHierarchy();const l=a._sortColumns,i=a._filterInfo,n=a.dataSource.groupBy._array.slice(0),r=void 0!==a.$.virtualizationContainer&&a.$.virtualizationContainer.$?a.$.virtualizationContainer.$.verticalScrollBar:null;if(r&&r.beginUpdate(),a._doNotFireEvent=!0,a._fullRefresh("update",t,"update"),n.length>0){let e=a._getExpandedGroups(a.dataSource.boundHierarchy);a._dirtyHierarchy&&(e=a._dirtyHierarchy),n.forEach((e=>a.addGroup(e))),a._restoreExpandedGroups(e)}i.inputFilters?a._filterByAll(i.query):i.rowFilters?a._applyRowFilters():i.appliedFilters&&a._refreshFilters(),l&&(a.__updatingSortColumns&&JSON.stringify(a.__updatingSortColumns)!==JSON.stringify(l)||0===n.length||!0===e||!1===a.__updatedRows)&&(a._sortColumns=[],l.forEach((e=>{a.columnByDataField[e.dataField].sortOrder=null,a.sortBy(e.dataField,e.direction)}))),r&&(r.endUpdate(),a._onVerticalChange({detail:{value:r.value}},!0),a._dirtyHierarchy&&(a._rowsInDOM.length<a.rows.length&&0===a.$.virtualizationContainer.$.verticalScrollBar.max&&a._refreshDataRows(),a._dirtyHierarchy=!1)),a.onUpdateComplete&&a.onUpdateComplete(a.rows),delete a._doNotFireEvent};if(a._verticalScrollTimer)return a._scheduleUpdate&&clearInterval(a._scheduleUpdate),void(a._scheduleUpdate=setInterval((function(){a._verticalScrollTimer||(i(),clearInterval(a._scheduleUpdate),delete a._scheduleUpdate)}),100));t?i():requestAnimationFrame((()=>{i()}))}_addNewRow(e,t){const a=this,l=e.$.id,i=new Smart.Observable({data:e,boundIndex:t});-1!==a._disabledSelection.indexOf(l)&&(i.allowSelect=!1),i.canNotify=!0,i.notify((function(t){if(a._editing||a._hierarchyChange)return;const i=a.selection;if("allowSelect"===t.propertyName){const n=a._disabledSelection.indexOf(l);if(a._hierarchyChange=!0,t.newValue||-1!==n)t.newValue&&-1!==n&&function e(t){const l=t.$.id,n=a.$.tableContainer.querySelector(`[row-id="${l}"]:not([unused])`),r=a.rowById[l];if(t.parent&&-1!==a._disabledSelection.indexOf(t.parent.$.id))r.allowSelect=!1;else if(a._disabledSelection.splice(a._disabledSelection.indexOf(l),1),n&&(n.classList.remove("disable-select"),i&&(n.setAttribute("aria-selected",!1),n.firstElementChild.firstElementChild.removeAttribute("aria-disabled"))),r&&(r.allowSelect=!0),t.children)for(let a=0;a<t.children.length;a++)e(t.children[a])}(e);else{const t=[];!function e(t,l){const n=t.$.id,r=a.$.tableContainer.querySelector(`[row-id="${n}"]:not([unused])`),o=a.rowById[n];if(l.push(n),r&&(r.removeAttribute("aria-selected"),r.classList.add("disable-select"),i&&r.firstElementChild.firstElementChild.setAttribute("aria-disabled",!0)),o&&(o.allowSelect=!1),t.children)for(let a=0;a<t.children.length;a++)e(t.children[a],l)}(e,t),a._disabledSelection=a._disabledSelection.concat(t),a.unselect(t)}delete a._hierarchyChange}})),a.rowById[l]=i,a.rows.push(i)}refresh(){const e=this;if(e.__updating)return;const t=e._columns.filter((e=>e.visible)),a=e.$.tableContainer,l=a.querySelector(".smart-table-filter-row"),i=a.querySelector("tfoot"),n=document.createElement("tbody"),r=e._getFractionOfMax(),o=e.virtualization?e.$.virtualizationContainer:e.$.tableContainer.parentElement,s={top:o.scrollTop,left:o.scrollLeft};for(e.columns.canNotify=!1;a.childNodes.length>0;)a.childNodes[0].remove();e._createTableHeader(),e.isRendered||!e.onInit||e._loadingState||e.onInit(),e._createCustomHeaderRow(),e._createFooterRow(i),e._createDataRows(n),e._createFilterRow(l);const d=a.querySelectorAll("th[data-field]");for(let a=0;a<t.length;a++){const l=t[a];l.headerCellElement=d[a],l.headerCellElement&&(l.headerCellElement.onclick=function(){const t=this.dataField;e.$.fireEvent("columnClick",{dataField:t}),e.closeColumnMenu(),"none"===e.sortMode||!1===l.allowSort||e._preventClickSort||(e._addSortIconContainer(this),e._sortOnClick=!0,this.headerCellElement.sortIconContainerElement.classList.contains("asc")?e.sortBy(t,"desc"):this.headerCellElement.sortIconContainerElement.classList.contains("desc")?e.sortBy(t,null):e.sortBy(t,"asc"),e._sortOnClick=!1)}.bind(l))}if(e._sortColumns&&e._sortColumns.length>0)for(let t=0;t<e._sortColumns.length;t++){const a=e._sortColumns[t],l=e.columnByDataField[a.dataField];e._addSortIconContainer(l,a.direction,t+1)}e._handleAutoSizeMode(),e._handleFrozenColumnPositions(),e._refreshHorizontalScrollbar(),e.isRendered&&(e.selection&&e._updateSelectAllState(),e._setFractionOfMax(r)),[o.scrollTop,o.scrollLeft]=[s.top,s.left],e.columns.canNotify=!0}_createTableHeader(){const e=this,t=e.selection,a=document.createElement("thead"),l=e._columns.filter((e=>e.visible)),i=e._getColumnHeaderStructure(),n=window.innerWidth,r={};for(let o=0;o<i;o++){const s=document.createElement("tr"),d=document.createDocumentFragment();t&&(s.innerHTML=o<i-1?'<th class="empty"></th>':'<th class="smart-table-select-all freeze-near" scope="col" aria-colindex="1"><div role="checkbox" aria-checked="false" aria-label="Toggle selection of all rows"></div></th>',e.virtualization&&Smart.Utilities.Core.Browser.Safari&&s.querySelector("th").classList.add("sticky")),o<i-1&&s.classList.add("column-groups-header");for(let a=0;a<l.length;a++){const s=l[a];if(0===o&&(s.width&&isNaN(parseFloat(s.width))&&delete s.width,s.responsivePriority&&("number"!=typeof s.responsivePriority&&(s.responsivePriority=1),s.responsivePriority=Math.max(Math.min(Math.round(s.responsivePriority),5),1),i>1&&(r[a]=e._isColumnHidden(s.responsivePriority,n)))),o<i-1){if(r[a])continue;const t=l[a],i=t.headerStructure[o];if(a>0){let r=a-1,s=l[r];for(;s&&e._isColumnHidden(s.responsivePriority,n);)r--,s=l[r];if(s&&i===s.headerStructure[o]&&e._areColumnsWithSameFreezeSettings(t,s))continue}const s=document.createElement("th");if(s.includes=[t],a<l.length-1){let r=1,d=a+1,c=l[d];for(;c;){if(!e._isColumnHidden(c.responsivePriority,n)){if(i!==c.headerStructure[o]||!e._areColumnsWithSameFreezeSettings(t,c))break;r++,s.includes.push(c)}d++,c=l[d]}s.colSpan=r}0!==o&&t.headerStructure[o-1]===i||(s.textContent=i),s.includes.forEach((e=>e.thHierarchy[o]=s)),s.classList.add("column-header"),t.freeze&&s.classList.add("freeze-"+("far"===t.freeze?"far":"near")),e.virtualization&&Smart.Utilities.Core.Browser.Safari&&s.classList.add("sticky"),d.appendChild(s)}else e._setupColumnHeaderCell(t,d,a,s)}s.appendChild(d),a.appendChild(s),e._tableHeader=a}if(e.$.tableContainer.appendChild(a),"default"===e.columnSizeMode){for(let t=0;t<e.columns.length;t++){const l=e.columns[t];if(!l.width){const t=a.querySelector('[data-field="'+l.dataField+'"]');t&&t.offsetWidth<5&&(t.style.width=parseInt(l.minWidth||e.columnMinWidth)+"px")}}if(t){const t=e.columns.filter((e=>e.visible));if(1===t.length){const e=t[0],l=a.querySelector('[data-field="'+e.dataField+'"]');l&&(l.style.width="")}}}}_getColumnHeaderStructure(){const e=this._columns,t=this.columnGroups;if(!t)return 1;let a=1;for(const l of e){let e=l.columnGroup;if(l.headerStructure=[],e&&(e=t.find((t=>t.name===e)),e))for(l.headerStructure.push(e.label||e.name);e.parentGroup&&(e=t.find((t=>t.name===e.parentGroup)),e);)l.headerStructure.unshift(e.label||e.name);l.headerStructure.push(l.label),a=Math.max(a,l.headerStructure.length)}for(const t of e){const e=t.headerStructure,l=e[0];for(;e.length<a;)e.unshift(l)}return a}_isColumnHidden(e,t){return!(!e||1===e||t>1280)&&(t<=640&&2===e||t<=800&&3===e||t<=1024&&4===e||t<=1280&&5===e)}_areColumnsWithSameFreezeSettings(e,t){return!e.freeze&&!t.freeze||e.freeze===t.freeze||!0===e.freeze&&"near"===t.freeze||"near"===e.freeze&&!0===t.freeze}getColumnProperty(e,t){const a=this,l=a.columnByDataField[e];if(!l)return null;switch(t){case"width":return l.width?a._getColumnWidth(l.width,!0,l):l._isResponsive&&l._manualPercentageWidth?a._getColumnWidth(l._manualPercentageWidth+"%",!0,l):a._getColumnWidth(l._manualWidth,!0,l);default:return l[t]}}setColumnProperty(e,t,a){const l=this;if(!l.columnByDataField[e])return null;l.columns.forEach(((i,n)=>{i.dataField===e&&(l.columns[n][t]=a)}))}_getTableRemainingWidth(){const e=this;let t=e.offsetWidth;if(e.selection){const a=e.$.tableContainer.querySelector(".smart-table-select-all");a&&(t=e.offsetWidth-a.offsetWidth),""===e.columns[e.columns.length-1].dataField&&(t-=parseInt(e.columnMinWidth))}e.virtualization&&e.$.virtualizationContainer&&e.$.virtualizationContainer.computedVerticalScrollBarVisibility&&(t-=20);let a=0;for(let t=0;t<e.columns.length;t++){const l=e.columns[t];l.visible&&l.width&&!(""+l.width).endsWith("%")&&(a+=e._getColumnWidth(l.width))}return t-=a,t}_getColumnWidth(e,t,a){const l=this,i=parseFloat(e);if((e=(e+"").trim()).endsWith("%")){let e=l.offsetWidth;if(l.selection){const t=l.$.tableContainer.querySelector(".smart-table-select-all");t&&(e=l.offsetWidth-t.offsetWidth),""===l.columns[l.columns.length-1].dataField&&(e-=parseInt(l.columnMinWidth))}l.virtualization&&l.$.virtualizationContainer&&l.$.virtualizationContainer.computedVerticalScrollBarVisibility&&(e-=20);let n=0;for(let e=0;e<l.columns.length;e++){const t=l.columns[e];t.visible&&t.width&&!(""+t.width).endsWith("%")&&(n+=l._getColumnWidth(t.width))}e-=n;const r=a&&a.minWidth||l._getNumericMinWidth(),o=t?i+"%":e*(i/100);return r>o?r:o}return isNaN(i)?"auto":t?i+"px":i}_setupColumnHeaderCell(e,t,a,l){const i=this,n=document.createElement("th");if(n.setAttribute("aria-colindex",a+1+ +e),l.width){let e=l.width;"number"==typeof e&&l.minWidth&&(e=Math.max(e,l.minWidth)),n.style.width=i._getColumnWidth(e,!0,l)}else l._manualWidth&&(l._isResponsive?n.style.width=l._manualPercentageWidth+"%":n.style.width=l._manualWidth+"px");if(1!==i._columns.length&&l.allowResize||n.setAttribute("locked",""),l.freeze&&n.classList.add("freeze-"+("far"===l.freeze?"far":"near")),l.responsivePriority&&n.classList.add("priority-"+l.responsivePriority),i.virtualization&&Smart.Utilities.Core.Browser.Safari&&n.classList.add("sticky"),n.setAttribute("data-field",l.dataField),n.innerHTML=`<div class="wrapper" role="presentation"><div class="label">${l.label}</div></div>`,i.columnMenu){const e=document.createElement("div");e.classList.add("column-menu"),e.setAttribute("aria-hidden",!0),n.firstElementChild.appendChild(e),e.onclick=e=>{i.activeColumnMenu&&i.activeColumnMenu.dataField===l.dataField?i.closeColumnMenu():i.openColumnMenu(l.dataField),e.preventDefault(),e.stopPropagation()}}i.onColumnRender&&i.onColumnRender(l.dataField,n),t.appendChild(n)}_refreshDataRows(){const e=this,t=window.scrollY,a=window.scrollX,l=e.$.tableContainer.children[1],i=Array.from(l.querySelectorAll("tr:not(.smart-table-filter-row)"));if(e._clearCachedTemplates(),e.filterRow||e.footerRow||e.headerRow)for(let e=0;e<i.length;e++)i[e].remove();else l.innerHTML="";e._createDataRows(l),e._handleAutoSizeMode(),e._handleFrozenColumnPositions(),e._refreshHorizontalScrollbar(),(a||t)&&window.scroll(a,t)}_createDataRows(e){const t=this;if(t.virtualization)return void t._createVirtualDataRows(e);const a=t.rowDetailTemplate,l=t.selection,i=document.createDocumentFragment(),n=t.hasAttribute("hierarchy");for(let e=0;e<t.rows.length;e++){const r=t.rows[e],o=r.data;o.groupDataField?t._createGroupHeader(o,i):t._createDataRow(r,i,{hierarchical:n,rowDetailTemplate:a,selection:l,virtualization:!1})}if(i.appendChild(t._createLastRow()),e.appendChild(i),t._updateState("expanded"),e.parentElement||t.$.tableContainer.insertBefore(e,t.$.tableContainer.querySelector("tfoot")),t.getRootNode().activeElement===t.$.tableContainer&&t._tableContainerFocusHandler(),t._templateTags.length){const e=t.querySelectorAll("tr");for(let a=0;a<t._templateTags.length;a++){const l=t._templateTags[a],i=l.index,n=l.dataField,r=l.td;if(e[i]){const t=e[i].querySelector('[data-field="'+n+'"]'),a=[...t.querySelectorAll("smart-button"),...t.querySelectorAll("button"),...t.querySelectorAll("a"),...t.querySelectorAll("span")],l=[...r.querySelectorAll("smart-button"),...r.querySelectorAll("button"),...r.querySelectorAll("a"),...r.querySelectorAll("span")];for(let e=0;e<a.length;e++)"button"===a[e].nodeName.toLowerCase()&&a[e].classList.contains("smart-button")||(a[e].onclick=()=>{l[e].click()})}}}}_createDataRow(e,t,a){const l=this,i=l._columns.filter((e=>e.visible)),n=e.data,r=n.$.id,o=document.createElement("tr"),s={row:o,detail:null};let d=0;o.setAttribute("aria-rowindex",n.$.index+1),l._processAndRenderSelection(n,o,a.hierarchical),a.selection&&d++;for(let t=0;t<i.length;t++){const s=document.createElement("td"),c=i[t];s.setAttribute("data-field",c.dataField),s.setAttribute("aria-colindex",t+1+ +a.selection);let u,f=l._formatCellValue(e,c,s);if(c.freeze&&s.classList.add("freeze-"+("far"===c.freeze?"far":"near")),c.responsivePriority&&s.classList.add("priority-"+c.responsivePriority),!1===c.allowEdit&&(s.classList.add("no-edit"),s.setAttribute("aria-readonly",!0)),0===t&&a.hierarchical){const e=l._areChildrenFiltered(n);n.leaf||(s.classList.add("tree-cell"),u=e),n.level&&(s.classList.add("outline-level-"+Math.min(n.level,10)),!n.leaf&&e||s.classList.add("tree-leaf"))}if(a.virtualization&&c.templateElement){const e=c.templateElement+"";u&&l._setCellContent(s,f,u);const t=u?s.children[0].children[1]:s;e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+n[c.dataField]+"</div>"):t.innerHTML=e,c.templateElementSettings&&(l._cachedTemplates&&l._cachedTemplates[c.dataField+"_"+r]&&(0===l._cachedTemplates[c.dataField+"_"+r].innerHTML.length?delete l._cachedTemplates[c.dataField+"_"+r]:(t.innerHTML="",t.appendChild(l._cachedTemplates[c.dataField+"_"+r]))),c.templateElementSettings(n[c.dataField],r,t.firstElementChild),l._cachedTemplates||(l._cachedTemplates=[]),l._cachedTemplates[c.dataField+"_"+r]||(l._cachedTemplates[c.dataField+"_"+r]=t.firstElementChild))}else l._setCellContent(s,f,u);l.onCellRender&&l.onCellRender(n,c.dataField,n[c.dataField],s),l._applyConditionalFormattingToCell(s,c.dataField,n.$.index),o.appendChild(s),d++}if(o.data=n,o.setAttribute("row-id",r),-1!==l._disabledSelection.indexOf(r)&&(o.removeAttribute("aria-selected"),o.classList.add("disable-select"),a.selection&&o.firstElementChild.firstElementChild.setAttribute("aria-disabled",!0)),n.expanded?(-1===l._expandedIds.indexOf(r)&&l._expandedIds.push(r),o.setAttribute("aria-expanded",!0),o.classList.add("expanded")):!1===n.expanded&&o.setAttribute("aria-expanded",!1),n.level&&l._isCollapsed(n)&&(o.setAttribute("aria-hidden",!0),o.classList.add("collapsed","smart-hidden")),t.appendChild(o),a.rowDetailTemplate){const i=document.createElement("tr");if(-1===l._expandedRowDetailIds.indexOf(r)){if(a.virtualization)return s;i.setAttribute("aria-hidden",!0),i.classList.add("collapsed")}else s.detail=i;i.data=Object.assign(n,{detail:!0}),i.classList.add("smart-table-row-detail"),i.innerHTML=`<td colspan="${d}"><div class="smart-table-detail-container">${l._applyRowDetailTemplate(e)}</div></td>`,t.appendChild(i)}return s}_processAndRenderSelection(e,t,a,l){const i=this,n=e.$.id,r=i._getChildCheckState(e).state;if(a&&i.selectionByHierarchy){const e=i._selectedIds.indexOf(n);!0===r&&-1===e?i._selectedIds.push(n):r||-1===e||i._selectedIds.splice(e,1)}if(!i.selection)return;let o,s;l?(o=t.firstElementChild,s=o.firstElementChild):(o=document.createElement("td"),s=document.createElement("div")),s.className="selection-checkbox",s.setAttribute("role","checkbox"),s.setAttribute("aria-checked",!!r||null===r&&"mixed"),s.setAttribute("aria-label","Toggle row selection"),o.className="smart-table-select-row freeze-near"+(r?" selected":null===r?" indeterminate":""),o.setAttribute("aria-colindex",1),l||(o.appendChild(s),t.appendChild(o)),t.setAttribute("aria-selected",!0===r)}_applyConditionalFormattingToCell(e,t,a){const l=this;if(l._conditionalFormatting&&l._conditionalFormatting[t]){const i=l._conditionalFormatting[t][a];i&&(e.style.backgroundColor=i.background,e.style.color=i.color,e.style.fontFamily=i.fontFamily,e.style.fontSize=i.fontSize)}}_createLastRow(){const e=document.createElement("tr");e.setAttribute("aria-hidden",!0),e.classList.add("last-visible");try{new ResizeObserver((t=>{try{e.classList.toggle("sized",t[0].contentRect.height>0&&null!==e.previousSibling)}catch(e){}})).observe(e)}catch(e){}return e}_createGroupHeader(e,t,a){const l=this;l.columnByDataField[e.groupDataField]||console.error(l.localize("grouping"));const i=l.columnByDataField[e.groupDataField]?l.columnByDataField[e.groupDataField].label:`${l.localize("EMPTY")}`,n=a||document.createElement("tr"),r=document.createElement("td"),o=document.createElement("div"),s=document.createElement("div"),d=document.createElement("div");let c=e.label;if((/<.+?>/.test(c)||/<./.test(c))&&c.replace&&("all"===l.dataSourceSettings.sanitizeHTML?c=c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""):"blackList"===l.dataSourceSettings.sanitizeHTML&&(c=window.Smart.Utilities.Core.sanitizeHTML(c))),""!==c&&c||(c=`<em class="placeholder">${l.localize("EMPTY")}</em>`),n.removeAttribute("aria-rowindex"),n.data=e,s.classList.add("hierarchy-arrow","smart-arrow","smart-arrow-down"),s.setAttribute("role","button"),s.setAttribute("aria-label","Toggle row"),d.classList.add("group-label"),d.innerHTML=`<span class="group-label-name">${i}: </span>\n <span class="group-label-value">${c}</span>\n <span class="group-label-count">(${l._getLeafCount(e)})</span>`,r.colSpan=l._columns.filter((e=>e.visible)).length,r.classList.add("group-header"),e.level&&(r.classList.add("outline-level-"+Math.min(e.level,10)),l._isCollapsed(e)&&(n.setAttribute("aria-hidden",!0),n.classList.add("collapsed","smart-hidden"))),n.setAttribute("row-id",e.$.id),n.setAttribute("role","group"),n.setAttribute("aria-level",e.level),o.appendChild(s),o.appendChild(d),r.appendChild(o),l._processAndRenderSelection(e,n,!0),n.appendChild(r),n.setAttribute("aria-expanded",e.expanded),n.classList.toggle("expanded",e.expanded),e&&e.$&&!1===e.$.filtered&&n.classList.add("smart-hidden"),l.groupFormatFunction){const t={value:c,row:e.$.id,column:e.groupDataField,data:e,template:null};l.groupFormatFunction(t),c!==t.value&&(d.innerHTML=`<span class="group-label-name">${i}: </span>\n <span class="group-label-value">${t.value}</span>\n <span class="group-label-count">(${l._getLeafCount(e)})</span>`),t.template instanceof HTMLElement&&(d.innerHTML="",d.appendChild(t.template));const a=t.template;let n="";if(a&&a.startsWith("#")){const e=document.querySelector(a);let t=c;if(e&&e instanceof HTMLTemplateElement){const a=e.content.cloneNode(!0),l=document.createElement("div");l.appendChild(a),t=t.toString(),t=t.replace(/'/gi,"\\'"),t=t.replace(/"/gi,'\\"'),n=l.innerHTML.replace(/{{value}}/gi,t),n.indexOf("{{value=")>=0&&(t?(n=n.substring(0,n.indexOf("{{value="))+t+n.substring(n.indexOf("}")),n=n.replace(/}/gi,""),n=n.replace(/{/gi,"")):(n=n.replace(/{{value=/gi,""),n=n.replace(/}}/gi,""))),d.innerHTML=n}}else a&&"string"==typeof a&&(n=a.replace(/{{value}}/gi,c),d.innerHTML=n)}const u=l.selection?1:0;for(let e=0;e<l.columns.length;e++){const t=document.createElement("td"),a=l.columns[e];a.visible&&(t.setAttribute("data-field",a.dataField),t.setAttribute("aria-colindex",e+1+u),t.classList.add("smart-hidden"),n.appendChild(t))}return a||t.appendChild(n),n}_getLeafCount(e){let t=0;return function e(a){for(const l of a)l.leaf?t++:l.children&&l.children.length>0&&e(l.children)}(e.children),t}_isCollapsed(e){let t=e.parent;for(;t;){if(!t.expanded)return!0;t=t.parent}return!1}_areChildrenFiltered(e){if(!e.leaf){if(0===e.children.length&&this.dataSource.virtualDataSource)return!0;for(let t=0;t<e.children.length;t++)if(!1!==e.children[t].$.filtered)return!0;return!1}}_applyRowDetailTemplate(e){const t=this,a=t.dataSource.dataFields;let l=t.rowDetailTemplate;for(let i=0;i<a.length;i++){const n=a[i].name,r=new RegExp(`{{${n}}}`,"g");let o=t.columnByDataField[n]||{dataField:n};if(r.test(l)){let a=t._formatCellValue(e,o,document.createElement("td"));"string"!=typeof a&&(a=e.data[o.dataField]),l=l.replace(r,a)}}return l}_handleFrozenColumnPositions(){const e=this,t=e.rightToLeft,a=e._columns.filter((e=>e.visible));let l=[],i=[],n=0;function r(t,l,i,r,o){const s=a[l-n],d=[s.headerCellElement];for(const e of s.thHierarchy)e.includes[0].dataField===s.dataField&&d.push(e);Array.from(e.$.tableContainer.querySelectorAll(`td:nth-child(${l+1})`)).concat(d).forEach((e=>{e.style[t]=i+"px",o&&(e.style.zIndex=2+r)}))}e.selection&&(t?i.push(0):l.push(0),n=1);for(let e=0+n;e<a.length+n;e++){const r=a[e-n];r.freeze&&(!t&&"far"===r.freeze||t&&"far"!==r.freeze?i.push(e):l.push(e))}if(l.length<2&&i.length<2)return;const o=[];e.selection&&o.push(40);for(const e of a){let t=e.width;t||(t=e.headerCellElement.offsetWidth),e.minWidth&&(t=Math.max(e.minWidth,t)),o.push(t)}if(t){for(let e=0;e<l.length-1;e++){const t=l[e];let a=0;for(let e=t+1;e<o.length;e++)-1!==l.indexOf(e)&&(a+=o[e]);r("left",t,a,e,!0)}for(let e=1;e<i.length;e++){const t=i[e];let a=0;for(let e=0;e<t;e++)-1!==i.indexOf(e)&&(a+=o[e]);r("right",t,a,e,!1)}}else{for(let e=1;e<l.length;e++){const t=l[e];let a=0;for(let e=0;e<t;e++)-1!==l.indexOf(e)&&(a+=o[e]);r("left",t,a,e,!1)}for(let e=0;e<i.length-1;e++){const t=i[e];let a=0;for(let e=t+1;e<o.length;e++)-1!==i.indexOf(e)&&(a+=o[e]);r("right",t,a,e,!0)}}}_formatCellValue(e,t,a,l){const i=this;let n=e&&e.data?e.data.$.id:e;if(void 0===l&&(l=e.data[t.dataField]),"string"==typeof l&&(l.indexOf(">")>=0||l.indexOf("<")>=0)&&l.replace&&("all"===i.dataSourceSettings.sanitizeHTML?l=l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""):"blackList"===i.dataSourceSettings.sanitizeHTML&&(l=window.Smart.Utilities.Core.sanitizeHTML(l))),i._cellsWithFormulas){const e=t.dataField+":"+n;if("string"==typeof l&&/=.+/.test(l)){const t=i._formulaParser;i._cellsWithFormulas[e]=!0,t&&(l=t.parse(l.slice(1)))}else delete i._cellsWithFormulas[e]}if(t.formatFunction){const i={value:l,row:n,column:t.dataField,data:e.data,cell:a,template:null};if(t.formatFunction(i),l=i.value,i.template instanceof HTMLElement)return i.template;if(null===i.template||"string"!=typeof i.template)return l;const r=i.template;let o="";if(r.startsWith("#")){const e=document.querySelector(r);if(e&&e instanceof HTMLTemplateElement){const t=e.content.cloneNode(!0),a=document.createElement("div");return a.appendChild(t),l=(l=(l=l.toString()).replace(/'/gi,"\\'")).replace(/"/gi,'\\"'),o=a.innerHTML.replace(/{{value}}/gi,l),o.indexOf("{{value=")>=0&&(l?(o=o.substring(0,o.indexOf("{{value="))+l+o.substring(o.indexOf("}")),o=o.replace(/}/gi,""),o=o.replace(/{/gi,"")):(o=o.replace(/{{value=/gi,""),o=o.replace(/}}/gi,""))),o}}return o='<div class="smart-table-cell-template">'+r.replace(/{{value}}/gi,l)+"</div>",o}return"date"===t.dataType&&l instanceof Date?l.toLocaleDateString():l}_setCellContent(e,t,a){if(t instanceof HTMLElement==1){for(;e.childNodes.length>0;)e.childNodes[0].remove();if(a){const a=document.createElement("div");a.innerHTML='<div class="hierarchy-arrow smart-arrow smart-arrow-down" role="button" aria-label="Toggle row"></div><div></div>',a.children[1].appendChild(t),e.appendChild(a)}else e.appendChild(t)}else if(a)e.innerHTML=t=`<div>\n <div class="hierarchy-arrow smart-arrow smart-arrow-down" role="button" aria-label="Toggle row"></div>\n <div>${t}</div>\n </div>`;else if("string"==typeof t&&t.indexOf(">")>=0)if(/<.+?>/.test(t)||/&\S+;/.test(t)){if(e._content===t)return;e.innerHTML=t,e._content=t}else e.textContent!==t&&(e.textContent=t);else"html"===this.dataSourceSettings.sanitizeHTMLRender?e.innerHTML!==t&&("string"==typeof t&&t.indexOf(" ")>=0&&(t=t.replaceAll(" "," ")),e.innerHTML=t):e.textContent!==t&&(e.textContent=t)}_dataBind(e){const t=this;if(t._cellsWithFormulas={},t._templateTags=[],t.dataSource){if(t.dataSource instanceof Smart.DataAdapter==0){const e=t.dataSource;if(Array.isArray(e)){const a=t.columns;let l;if(e.length>0){const t=e[0];l=[];for(let e in t){const a=t[e];"number"==typeof a?l.push({name:e,dataType:"number"}):"boolean"==typeof a?l.push({name:e,dataType:"boolean"}):a instanceof Date?l.push({name:e,dataType:"date"}):a instanceof Object?l.push({name:e,dataType:"any"}):l.push({name:e,dataType:"string"})}}a&&a.length>0&&(l=l||[],a.forEach((e=>{if(e.dataType){const t=l.find((t=>t.name===e.dataField));t?t.dataType=e.dataType:e.map?l.find((t=>e.map.indexOf(t.name)>=0?t:null))&&l.push({name:e.dataField,map:e.map,dataType:e.dataType}):l.push({name:e.dataField,dataType:e.dataType})}}))),t.dataSourceSettings.dataFields&&t.dataSourceSettings.dataFields.length>0?t.dataSource=new Smart.DataAdapter({dataSource:t.dataSource,dataSourceType:t.dataSourceSettings.dataSourceType,dataFields:t.dataSourceSettings.dataFields,keyDataField:t.dataSourceSettings.keyDataField,parentDataField:t.dataSourceSettings.parentDataField,childrenDataField:t.dataSourceSettings.childrenDataField,groupBy:t.dataSourceSettings.groupBy,mapChar:t.dataSourceSettings.mapChar,root:t.dataSourceSettings.root,record:t.dataSourceSettings.record,autoGenerateColumns:t.autoGenerateColumns,id:t.dataSourceSettings.id||t.dataRowId,expandHierarchy:t.expandHierarchy,virtualDataSource:t.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:t.dataSourceSettings.virtualDataSourceOnExpand}):t.dataSource=new Smart.DataAdapter({dataSource:t.dataSource,dataFields:l,id:t.dataRowId||t.dataSourceSettings.id,dataSourceType:t.dataSourceSettings.dataSourceType,keyDataField:t.dataSourceSettings.keyDataField,parentDataField:t.dataSourceSettings.parentDataField,childrenDataField:t.dataSourceSettings.childrenDataField,groupBy:t.dataSourceSettings.groupBy,mapChar:t.dataSourceSettings.mapChar,root:t.dataSourceSettings.root,record:t.dataSourceSettings.record,autoGenerateColumns:t.autoGenerateColumns,expandHierarchy:t.expandHierarchy,virtualDataSource:t.dataSourceSettings.virtualDataSource,virtualDataSourceOnExpand:t.dataSourceSettings.virtualDataSourceOnExpand})}else t.dataSource=new Smart.DataAdapter({dataSource:[],id:t.dataRowId,expandHierarchy:t.expandHierarchy})}}else{if(t.dataFields=[],!t.columns||Array.isArray(t.columns)&&0===t.columns.length){t.columns=[];const e=t.querySelectorAll("th");for(let a=0;a<e.length;a++){const l=e[a].innerHTML.trim();let i={label:l,dataField:l,dataType:"string"};t.columns.push(i),t.dataFields.push(l)}}else for(let e=0;e<t.columns.length;e++){const a=t.columns[e];"string"==typeof a?t.dataFields.push(a):"object"==typeof a&&t.dataFields.push(a.dataField+(a.dataType?": "+a.dataType:""))}let e=[];if(!t.rows){const a=t.querySelectorAll("tr");for(let l=0;l<a.length;l++){const i={},n=a[l].querySelectorAll("td");if(n.length>0){for(let e=0;e<t.columns.length;e++){const a=t.columns[e];i[a.dataField]=n[e].innerHTML.trim(),i[a.dataField].indexOf("<")>=0&&t._templateTags.push({index:l,dataField:a.dataField,td:n[e]})}e.push(i)}}t.dataSource=new Smart.DataAdapter({dataSource:e,expandHierarchy:t.expandHierarchy,dataFields:t.dataFields,id:t.dataRowId})}const a=t.$.container.querySelectorAll("table");a.length>1&&a[a.length-1].parentNode.removeChild(a[a.length-1])}t.dataSource.expandHierarchy=t.expandHierarchy,t._transformDataSource(),t._applyInitialConditionalFormatting(t.dataSource),t._initColumns(e),t._initRows(),t.dataSource.notify((function(e){if(t.dataSource._updating)return void delete t.dataSource._updating;if(t._editing)return;const a=e.data,l=t._selectedIds.slice(0);let i=e.action;switch(t.rows.canNotify=!1,e.action){case"add":if(a.length)for(let e=0;e<a.length;e++)t._addNewRow(a[e],t.dataSource.length-a.length+e);else t._addNewRow(a,t.dataSource.length-1);break;case"update":if(a.length)for(let l=0;l<a.length;l++){const i=e.index[l];t.rows[i].data=a[l]}break;case"insert":t._addNewRow(a,e.index);for(let e=0;e<t.rows.length;e++)t.rows[e].dataIndex=e;break;case"remove":case"removeLast":i="remove",function(e){const a=e.$.id,l=t._selectedIds.indexOf(a);delete t.rowById[a],t.rows.splice(e.$.index,1),-1!==l&&t._selectedIds.splice(l,1)}(a);break;case"bindingComplete":if(t.filtering&&t.filterRow){const e=t._filterInfo;e.inputFilters?t._filterByAll(e.query):e.rowFilters?t._applyRowFilters():e.appliedFilters&&t._refreshFilters()}}t.rows.canNotify=!0,this.refreshHierarchy(),t._fullRefresh(void 0,l,i)})),t.refresh(),t.dataSource.virtualDataSource&&(t.paging=!0,t._requestVirtualDataSource("dataBind")),t.$.tableContainer.setAttribute("aria-rowcount",t.dataSource.length)}_requestVirtualDataSource(e,t,a=null){const l=this,i=l.pageSize,n=Math.max(l.pageIndex*i,0),r=n+i,o=[],s=[],d={};let c=null;if(l.dataSource._updating=!0,l._sortColumns&&(l._sortColumns.forEach(((e,t)=>o[e.dataField]={sortOrder:e.direction,sortIndex:t})),o.length=l._sortColumns.length),l._filterInfo.appliedFilters){for(let e in l._filterInfo.appliedFilters)s[e]=l._filterInfo.appliedFilters[e];s.length=Object.keys(l._filterInfo.appliedFilters).length,c="and"}else{const e=l._filterInfo.inputFilters||l._filterInfo.rowFilters;e&&(e.forEach((e=>s[e[0]]=e[1])),s.length=e.length),c=l._filterInfo.inputFilters?"or":"and"}l._editing&&(d.row=l._editing.row.data),l.$.loadingIndicatorContainer.classList.remove("smart-hidden"),l.setAttribute("loading",""),l.dataSource.onVirtualDataSourceRequested((function(i){let n=!0;-1!==["add","update","remove"].indexOf(e)&&t&&(n=t(i.result)),l.$.loadingIndicatorContainer.classList.add("smart-hidden"),l.removeAttribute("loading"),n&&(a&&(a.expanded=!0),l._initRows(),l._refreshDataRows())}),{first:n,last:r,sorting:o,filtering:s,filterOperator:c,grouping:[],edit:d,row:a,action:e})}sortBy(e,t){const a=this,l=a.columnByDataField[e];if(l){if(!1===l.allowSort)return;e=l.dataField}if(a._sortBy({column:l,columnDataField:e,sortOrder:t,dataFields:a.dataSource.dataFields,columnByDataField:"columnByDataField"}),null===e){const e=!0===a._sortOnClick?"interaction":"programmatic";a.$.fireEvent("sort",{columns:[],sortDataFields:[],sortOrders:[],sortDataTypes:[],type:e})}}_sortBy(e){const t=this,a=e.column,l=e.columnDataField,i=e.sortOrder,n=e.dataFields,r=e.columnByDataField,o=[],s=[],d=[],c=function(e){t._addSortIconContainer(e),e.headerCellElement&&(e.headerCellElement.removeAttribute("aria-sort"),e.headerCellElement.sortIconContainerElement.classList.remove("desc"),e.headerCellElement.sortIconContainerElement.classList.remove("asc")),e.sortOrder=null},u=function(){if(t._sortColumns&&t._sortColumns.length>0)for(let e=0;e<t._sortColumns.length;e++){const a=t._sortColumns[e],l=t[r][a.dataField];c(l)}t._sortColumns=[]};if(null==a)return void(t._sortColumns&&t._sortColumns.length>0&&(u(),t._sortCallback(o,s,d),t._updateState("sorted")));if("none"===t.sortMode||!t.dataSource)return;if(i&&a.sortOrder===i)return;let f=i||"asc";null===i&&(f=null),c(a),t._sortColumns||(t._sortColumns=[]);let m="string";for(let e=0;e<n.length;e++){const t=n[e];if(t.name===l){m=t.dataType,"any"===m&&(m="number");break}}let h=!0;for(let e=0;e<t._sortColumns.length;e++){const n=t._sortColumns[e];if(n.dataField===l)if(h=!1,null===f&&(n.direction="desc"),"asc"===n.direction)n.direction="desc",f="desc";else if("desc"===n.direction){t._sortColumns.splice(e,1),c(a),f=i;break}}h&&("one"===t.sortMode&&u(),t._sortColumns.push({dataField:l,direction:f,dataType:m})),t._addSortIconContainer(a),null!==f?(a.headerCellElement&&(a.headerCellElement.sortIconContainerElement.classList.remove("asc"),a.headerCellElement.sortIconContainerElement.classList.remove("desc")),a.sortOrder=f,a.headerCellElement&&("desc"===f?(a.headerCellElement.sortIconContainerElement.classList.add("desc"),a.headerCellElement.setAttribute("aria-sort","descending")):(a.headerCellElement.sortIconContainerElement.classList.add("asc"),a.headerCellElement.setAttribute("aria-sort","ascending")))):a.headerCellElement&&(a.headerCellElement.sortIconContainerElement.classList.remove("asc"),a.headerCellElement.sortIconContainerElement.classList.remove("desc"),a.headerCellElement.removeAttribute("aria-sort"));for(let e=0;e<t._sortColumns.length;e++){const a=t._sortColumns[e],l=t[r][a.dataField];o.push(a.dataField),s.push(a.direction),d.push(a.dataType),l.headerCellElement&&l.headerCellElement.sortIconContainerElement.setAttribute("order",e+1)}if(t._sortCallback(o,s,d),t._updateState("sorted"),!t._doNotFireEvent){const e=!0===t._sortOnClick?"interaction":"programmatic";t.$.fireEvent("sort",{columns:t._sortColumns,sortDataFields:o,sortOrders:s,sortDataTypes:d,type:e})}}_addSortIconContainer(e,t,a){const l=e.headerCellElement;if(l&&!l.sortIconContainerElement){const e=document.createElement("div");e.classList.add("sort-by"),e.setAttribute("aria-hidden",!0),t&&e.classList.add(t),l.firstElementChild.appendChild(e),l.sortIconContainerElement=e,"asc"===t?l.setAttribute("aria-sort","ascending"):"desc"===t?l.setAttribute("aria-sort","descending"):l.removeAttribute("aria-sort"),void 0!==a&&e.setAttribute("order",a)}}_sortCallback(e,t,a){const l=this,i=l.dataSource;if(!i.virtualDataSource){let n=null;for(let e=0;e<l.columns.length;e++){const t=l.columns[e];t.sort&&(n||(n={}),n[t.dataField]=t.sort)}i._sort(l.dataSource.boundSource,e,t,a,l.sort,n);let r=[],o=[];if(i.groupBy&&i.groupBy.toArray&&(r=i.groupBy.toArray().slice(0)),r.length>0&&(o=l._getExpandedGroups(i.boundHierarchy)),i.refreshHierarchy(),r.length>0){const e=l._doNotFireEvent;l._doNotFireEvent=!0,l._restoreExpandedGroups(o),l._doNotFireEvent=e}}l._fullRefresh("sort")}clearSort(){this.sortBy(null)}_fullRefresh(e,t,a,l){const i=this;if(i.__updating)return;if(i.dataSource.virtualDataSource)return void i._requestVirtualDataSource(e,l);const n=i._getFractionOfMax();t||(t=i._selectedIds.slice(0)),t=JSON.stringify(t.sort()),i._initRows(),i._refreshDataRows(),i._setFractionOfMax(n),"filter"===e&&(i._updateSelectAllState(),a||(a="filter")),t!==JSON.stringify(i._selectedIds.slice(0).sort())&&("filter"!==e&&i._updateSelectAllState(),i._updateState("selected"),i.$.fireEvent("change",{type:a})),"string"==typeof e&&-1!==e.indexOf("page")&&i._fixFrozenHeaderFirefox()}_pagerChangeHandler(e){const t=this;(t.isInShadowDOM?e.composedPath()[0]:e.target)===t.$.pager&&(t.pageIndex=e.detail.index,t._fullRefresh("pageIndexChange"),t.$.fireEvent("page",{action:"pageIndexChange"}))}_pagerPageSizeChanged(e){const t=this;t.pageSize=e.detail.value,t._fullRefresh("pageSizeChange"),t.$.fireEvent("page",{action:"pageSizeChange"})}_filterInputKeyupHandler(){const e=this;clearTimeout(e._filterInputTimeout),e._filterInputTimeout=setTimeout((function(){if(e._filterInfo&&e.$.filterInput.value!==e._filterInfo.query){const t=e.context;e.context=e,e._filterByAll(e.$.filterInput.value),e.context=t}}),500)}_filterByAll(e){const t=this;if(t._filterInfo.query=e,""===e)return void t.clearFilters();const a=[];t._clearRowFilters(),delete t._filterInfo.appliedFilters,t._filterInfo.stringDataFields.forEach((t=>{const l=new Smart.Utilities.FilterGroup,i=l.createFilter("string",e,"CONTAINS");l.addFilter("or",i),a.push([t,l])})),t.dataSource.virtualDataSource||t.dataSource._filter(a,"or"),t._filterInfo.inputFilters=a,t._fullRefresh("filter"),t._updateState("filtered"),t._doNotFireEvent||t.$.fireEvent("filter",{action:"add",filters:a})}_setupPagingAndFiltering(){const e=this;e.$.pager.$.pageSizeSelector.classList.add("underlined"),e.$.pager.$.pageSizeSelector.dropDownAppendTo="body",e._filterInfo={query:""},e._applyFilterTemplate(),e.$.header.classList.toggle("smart-hidden",(!e.filtering||e.filterRow||e.columnMenu)&&!e.conditionalFormattingButton)}_applyFilterTemplate(){const e=this,t=e.filterTemplate;if(e.$.filterTemplateContainer.innerHTML="",!t)return e.$.filterInput.classList.remove("smart-hidden"),e.$.filterTemplateContainer.classList.add("smart-hidden"),void(e.filterTemplate=null);const a=document.getElementById(t);if(a&&a instanceof HTMLTemplateElement){const t=document.importNode(a.content,!0);e.$.filterInput.classList.add("smart-hidden"),e.$.filterTemplateContainer.classList.remove("smart-hidden"),e.$.filterTemplateContainer.appendChild(t)}else e.filterTemplate=null,e.$.filterInput.classList.remove("smart-hidden"),e.$.filterTemplateContainer.classList.add("smart-hidden")}_refreshFilters(e){const t=this,a=[];for(let e in t._filterInfo.appliedFilters){let l=t._filterInfo.appliedFilters[e];a.push([e,l])}0!==a.length?(t._clearFilterInput(),t._clearRowFilters(),t.dataSource.virtualDataSource||t.dataSource._filter(a,t.filterOperator),t._fullRefresh("filter"),t._updateState("filtered"),e&&!t._doNotFireEvent&&t.$.fireEvent("filter",{action:e,filters:a})):t.clearFilters()}_localize(){const e=this,t=e.$.pager;t.messages[e.locale]||(t.messages[e.locale]={}),t.messages[e.locale].pageSizeLabel=e.localize("itemsPerPage"),t.messages[e.locale].summaryPrefix=e.localize("summaryPrefix"),t.messages[e.locale].summarySuffix="",t.$.firstButton.setAttribute("tooltip",e.localize("firstButton")),t.$.previousButton.setAttribute("tooltip",e.localize("previousButton")),t.$.nextButton.setAttribute("tooltip",e.localize("nextButton")),t.$.lastButton.setAttribute("tooltip",e.localize("lastButton")),e.$.filterInput.placeholder=e.localize("filterPlaceholder"),e.$.conditionalFormattingButton.setAttribute("tooltip",e.localize("conditionalFormatting")),e._filterInfo.stringConditions=[{value:"EMPTY",label:e.localize("EMPTY")},{value:"NOT_EMPTY",label:e.localize("NOT_EMPTY")},{value:"CONTAINS",label:e.localize("CONTAINS")},{value:"CONTAINS_CASE_SENSITIVE",label:e.localize("CONTAINS_CASE_SENSITIVE")},{value:"DOES_NOT_CONTAIN",label:e.localize("DOES_NOT_CONTAIN")},{value:"DOES_NOT_CONTAIN_CASE_SENSITIVE",label:e.localize("DOES_NOT_CONTAIN_CASE_SENSITIVE")},{value:"STARTS_WITH",label:e.localize("STARTS_WITH")},{value:"STARTS_WITH_CASE_SENSITIVE",label:e.localize("STARTS_WITH_CASE_SENSITIVE")},{value:"ENDS_WITH",label:e.localize("ENDS_WITH")},{value:"ENDS_WITH_CASE_SENSITIVE",label:e.localize("ENDS_WITH_CASE_SENSITIVE")},{value:"EQUAL",label:e.localize("EQUAL")},{value:"EQUAL_CASE_SENSITIVE",label:e.localize("EQUAL_CASE_SENSITIVE")},{value:"NULL",label:e.localize("NULL")},{value:"NOT_NULL",label:e.localize("NOT_NULL")}],e._filterInfo.numberAndDateConditions=[{value:"EQUAL",label:e.localize("EQUAL")},{value:"NOT_EQUAL",label:e.localize("NOT_EQUAL")},{value:"LESS_THAN",label:e.localize("LESS_THAN")},{value:"LESS_THAN_OR_EQUAL",label:e.localize("LESS_THAN_OR_EQUAL")},{value:"GREATER_THAN",label:e.localize("GREATER_THAN")},{value:"GREATER_THAN_OR_EQUAL",label:e.localize("GREATER_THAN_OR_EQUAL")},{value:"NULL",label:e.localize("NULL")},{value:"NOT_NULL",label:e.localize("NOT_NULL")}]}_createFilterRow(e){const t=this;if(!t.filtering||!t.filterRow)return;if(e)return void t.$.tableContainer.children[1].insertBefore(e,t.$.tableContainer.children[1].firstElementChild);const a=document.createElement("tr"),l=t._columns.filter((e=>e.visible));let i="";a.className="smart-table-filter-row",t.selection&&(i+='<td style="left: 0px; z-index: 99; position: sticky; background: var(--smart-background);"></td>');for(let e=0;e<l.length;e++){const a=l[e];i+=t._createFilterRowInput(a)}a.innerHTML=i,t.$.tableContainer.children[1].insertBefore(a,t.$.tableContainer.children[1].firstElementChild)}_createFilterRowInput(e){const t=this,a=` animation="${t.animation}" `,l=t.rightToLeft?" right-to-left":"",i=[];let n,r,o,s;return"string"===e.dataType?(n=t._filterInfo.stringConditions,r="string",o="string-filter",s=t.localize("CONTAINS")):(n=t._filterInfo.numberAndDateConditions,r=e.dataType,o="num-date-filter",s=t.localize("EQUAL")),e.freeze&&i.push("freeze-"+("far"===e.freeze?"far":"near")),e.responsivePriority&&i.push("priority-"+e.responsivePriority),!1===e.allowFilter&&i.push("no-filter"),`<td${i.length?' class="'+i.join(" ")+'"':""} filter-for="${e.dataField}">\n <div>\n <input type="${r}" class="filter-value" aria-label="Filter value" />\n <smart-input class="${o}${a}data-source='${JSON.stringify(n)}' drop-down-button-position="right" drop-down-width="auto" readonly${l} value="${s}" title="${t.localize("filterCondition")}" aria-label="Filter condition"></smart-input>\n <smart-button class="smart-hidden" title="${t.localize("clearFilter")}"${a}${l} aria-label="Clear filter"></smart-button>\n </div>\n </td>`}_tableContainerChangeHandler(e){const t=this,a=t.isInShadowDOM?e.composedPath()[0]:e.target;a.classList.contains("filter-value")&&("date"===a.type||a instanceof Smart.Input&&(""!==a.previousElementSibling.value||-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(e.detail.value)))&&t._applyRowFilters(),(a.classList.contains("string-filter")||a.classList.contains("num-date-filter"))&&a instanceof Smart.Input&&(""!==a.previousElementSibling.value||-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(e.detail.value))&&t._applyRowFilters()}_tableContainerClickHandler(e){const t=this;if(t._editing)return;const a=t.isInShadowDOM?e.composedPath()[0]:e.target;if(!t.$.tableContainer.contains(a))return;const l=a.closest("tbody tr[row-id], tfoot tr.grand-total");if(l){t.closeColumnMenu();const i=a.closest("td");if(a.classList.contains("hierarchy-arrow")){const e=t.animation;return t.virtualization&&(t._animation="none"),t._hierarchyArrowClickHandler(l,i),void(t.virtualization&&(t._animation=e))}const n=l.getAttribute("row-id");let r;n&&(r=t.rowById?t.rowById[n].data:t.rows.dataItemById[n]);const o=r?r.$.id:void 0,s=i?i.getAttribute("data-field"):void 0;if(!r&&l.classList.contains("grand-total")&&(r=l.data),void 0!==s){const a={};for(let e=0;e<t.columns.length;e++){const l=t.columns[e];a[l.dataField]=r[l.dataField]}t.$.fireEvent("cellClick",{id:n,row:a,dataField:s,value:r[s],originalEvent:e})}if(t._toggleSelection(l,r,e,a),t.editing||t.drillDown){if(!s||i.classList.contains("no-edit"))return;clearTimeout(t._dblclickObject.timeout),t._dblclickObject.numberOfClicks++,2===t._dblclickObject.numberOfClicks?(t._dblclickObject.numberOfClicks=0,t._beginEdit({rowElement:l,cell:i,dataField:s})):t._dblclickObject.timeout=setTimeout((function(){t._dblclickObject.numberOfClicks=0}),300)}return void(t.rowDetailTemplate&&t._toggleRowDetail(l,o))}const i=a.closest(".smart-table-select-all");if(i){if("one"===t.selectionMode)return;return void t._selectAllCheckboxClickHandler(i)}const n=a.closest(".smart-table-filter-row smart-button")||a.closest(".smart-table-column-menu smart-button");if(n){const e=n.parentElement.firstElementChild,a=n.parentElement.children[1];return e.value="",-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(a.$.input.dataValue)&&(a.value=t.localize("text"===e.type?"CONTAINS":"EQUAL"),delete a.$.input.dataValue),void t._applyRowFilters()}}_toggleSelection(e,t,a,l){const i=this;if(!i.selection||"cell"===i.selectionMode||e.classList.contains("disable-select")||e.classList.contains("grand-total"))return;function n(){i._selectedIds=[],Array.from(i.$.tableContainer.querySelectorAll(".smart-table-select-row.selected")).forEach((e=>{e.parentElement.classList.contains("disable-select")||e.parentElement.setAttribute("aria-selected",!1),e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1)}))}const r=t.$.id;let o=-1!==i._selectedIds.indexOf(r);if(i._interaction=!0,"one"===i.selectionMode){if(o)return;n(),i.select(r)}if("many"===i.selectionMode)if(o)i.unselect(r);else{if(i._disabledSelection.length>0&&t.children&&t.children.length>0){let e=0,a=0,l=[];if(t.children.forEach((t=>{const n=t.$.id;-1===i._selectedIds.indexOf(n)?e++:l.push(n),-1!==i._disabledSelection.indexOf(n)&&a++})),e===a)return i.unselect(l),void delete i._interaction}i.select(r),i._selectionStart={data:t,element:e}}else{if(i._selectionStart&&a.shiftKey){let t,a,l;if(i.virtualization?(t=i.rows,a=t.findIndex((e=>e.data.$.id===r)),l=t.findIndex((e=>e.data.$.id===i._selectionStart.data.$.id))):(t=Array.from(i.$.tableContainer.querySelectorAll("tr[row-id]:not([unused])")),a=t.indexOf(e),l=t.indexOf(i._selectionStart.element)),a!==l){const e=JSON.stringify(i._selectedIds.slice(0).sort()),r=Math.min(a,l),o=Math.max(a,l);n();const s=[];for(let e=r;e<=o;e++){const a=t[e];s.push(a.data.$.id)}return i._changeSelectionOfMultiple(s,"select","interaction",e),getSelection().removeAllRanges(),void delete i._interaction}if(1===i._selectedIds.length)return void delete i._interaction}const s=!!l&&(l.classList.contains("selection-checkbox")||l.classList.contains("smart-table-select-row"));let d=!1;if(1===i._selectedIds.length)d=!0;else if(i.hasAttribute("hierarchy")&&i.selectionByHierarchy){const e=[];!function e(t,a){const l=t.$.id;-1!==i._selectedIds.indexOf(l)&&a.push(l),t.children&&t.children.forEach((t=>e(t,a)))}(t,e),i._selectedIds.length===e.length&&(d=!0),t&&t.leaf&&(d=!0),o=i._getChildCheckState(t).maxSelected}else i.hasAttribute("hierarchy")&&!i.selectionByHierarchy&&(d=!0);if(o&&(s||d||a.ctrlKey||a.metaKey))return delete i._selectionStart,i.unselect(r),void delete i._interaction;s||a.ctrlKey||a.metaKey||n(),i.select(r),i._selectionStart={data:t,element:e}}delete i._interaction}_selectAllCheckboxClickHandler(e,t){const a=this;if(void 0===t){const l=a._filterInfo;if(l.inputFilters||l.rowFilters||l.appliedFilters)return void a._selectAllCheckboxClickHandlerFiltering(e);if(t=a.dataSource,a.hasAttribute("hierarchy")&&a._disabledSelection.length>0){const e=t.boundHierarchy,l=a._getChildCheckState({children:e}).maxSelected;return void a._changeSelectionOfMultiple(e.map((e=>e.$.id)),l?"unselect":"select","interaction")}}const l=t.length,i=a._selectedIds.length===l-a._disabledSelection.length+a._selectableGroupRecords.length,n=a._selectedIds.slice(0);if(a._selectedIds=[],i)a._updateCSSOnUnselectAll(e);else{let i,n=0;for(let e=0;e<l;e++){const l=t[e].$.id;-1===a._disabledSelection.indexOf(l)&&(a._selectedIds.push(l),n++)}n===l?i=!0:0===n&&(i=!1),a._updateCSSOnSelectAll(e,i),a._selectableGroupRecords.length>0&&(a._selectedIds=a._selectedIds.concat(a._selectableGroupRecords))}n.length!==a._selectedIds.length&&(a._updateState("selected"),a.$.fireEvent("change",{type:"interaction"}))}_selectAllCheckboxClickHandlerFiltering(e){const t=this,a=t.dataSource,l=t._selectedIds.slice(0),i=[],n=[];let r=0;for(let e=0;e<a.length;e++){const o=a[e];if(!1===o.$.filtered)continue;const s=o.$.id;r++,-1!==l.indexOf(s)&&i.push(s),-1===t._disabledSelection.indexOf(s)&&n.push(s)}const o=i.length===n.length;if(t._selectedIds=t._selectedIds.filter((e=>-1===n.indexOf(e))),o)t._updateCSSOnUnselectAll(e);else{let a;t._selectedIds=t._selectedIds.concat(n),n.length===r?a=!0:0===n.length&&(a=!1),t._updateCSSOnSelectAll(e,a)}l.length!==t._selectedIds.length&&(t._updateState("selected"),t.$.fireEvent("change",{type:"interaction"}))}_updateCSSOnUnselectAll(e){e.classList.remove("indeterminate","selected"),e.firstElementChild.setAttribute("aria-checked",!1),Array.from(this.$.tableContainer.querySelectorAll(".smart-table-select-row")).forEach((e=>{e.parentElement.classList.contains("disable-select")||e.parentElement.setAttribute("aria-selected",!1),e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1)}))}_updateCSSOnSelectAll(e,t){t?(e.classList.remove("indeterminate"),e.classList.add("selected"),e.firstElementChild.setAttribute("aria-checked",!0)):!1===t?(e.classList.remove("indeterminate","selected"),e.firstElementChild.setAttribute("aria-checked",!1)):(e.classList.remove("selected"),e.classList.add("indeterminate"),e.firstElementChild.setAttribute("aria-checked","mixed")),Array.from(this.$.tableContainer.querySelectorAll(".smart-table-select-row")).forEach((e=>{e.parentElement.classList.contains("disable-select")||(e.parentElement.setAttribute("aria-selected",!0),e.classList.remove("indeterminate"),e.classList.add("selected"),e.firstElementChild.setAttribute("aria-checked",!0))}))}_beginEdit(e){const t=this,a=t.editMode,l=e.dataField;let i=e.rowId,n=e.rowElement,r=e.rowObject,o=e.cell,s=[],d=[];if(t.editing){n||(n=t.$.tableContainer.querySelector(`tr[row-id="${i}"]:not([unused])`)),r||(i=n.getAttribute("row-id"),r=t.rowById[i],i=r.data.$.id),"row"===a?(s=n.querySelectorAll("td[data-field]"),d=t._columns.filter((e=>e.visible)).map((e=>e.dataField)),o||(o=l?n.querySelector(`td[data-field="${l}"`):s[0])):(o||(o=n.querySelector(`td[data-field="${l}"`)),s=[o],d=[l]),t._editing={row:r,cells:[]};for(let e=0;e<d.length;e++){const a=s[e];let l=d[e];const n=t.columnByDataField[l];if(!1===n.allowEdit)continue;n.transform&&(l=n.originalDataField);const c=r.data[l],u=t._initEditor(n,i,l,c);let f=u instanceof HTMLInputElement&&"date"===u.type;if(n.editor&&n.editor.template)n.editor.onRender&&n.editor.onRender(i,l,u,c);else if(f)if(c instanceof Date&&!isNaN(c.getTime())){const e=(c.getMonth()+1).toString(),t=c.getDate().toString();u.value=`${c.getFullYear()}-${"0".repeat(2-e.length)}${e}-${"0".repeat(2-t.length)}${t}`}else u.value="";else u.value=void 0===c?"":c;a.classList.add("editing"),a.innerHTML="",a.appendChild(u),a===o&&u.focus&&(u.focus(),n.editor&&n.editor.template||f||!u.select||u.select()),t._editing.cells.push({dataField:l,editor:u,element:a}),t.$.fireEvent("cellBeginEdit",{id:r.data.$.id,row:r.data,value:r.data[l],dataField:l})}"row"===a&&t.$.fireEvent("rowBeginEdit",{id:r.data.$.id,row:r.data})}}_initEditor(e,t,a,l){let i=this._editors[a];if(i)return i;if(e.editor&&e.editor.template){const n=document.createElement("div");return n.innerHTML=e.editor.template,i=n.firstElementChild,i.className="smart-table-editor",e.editor.onInit&&e.editor.onInit(t,a,i,l),i}return i=document.createElement("input"),i.className="smart-table-editor standard","number"===e.dataType?i.type="number":"date"===e.dataType?i.type="date":i.type="text",this._editors[a]=i,i}_toggleRowDetail(e,t){const a=this;if(a.virtualization)return void a._toggleRowDetailVirtualization(e,t);const l=e.nextElementSibling;l.classList.toggle("collapsed"),l.classList.contains("collapsed")?(l.setAttribute("aria-hidden",!0),a._expandedRowDetailIds=a._expandedRowDetailIds.filter((e=>e!==t))):(l.removeAttribute("aria-hidden"),a._expandedRowDetailIds.push(t))}_toggleRowDetailVirtualization(e,t){const a=this;let l=e.nextElementSibling;function i(){let e=a.$.virtualizationContainer.$.verticalScrollBar,t=a.$.virtualizationContainer.$.verticalScrollBar.value;a._ignoreVerticalChange=!0,a._refreshDataRows(),t=Math.min(e.max,t),e.value=t,delete a._ignoreVerticalChange,a._onVerticalChange({detail:{value:t}},!0)}if(l&&l.classList.contains("smart-table-row-detail")&&!l.classList.contains("collapsed"))return l.setAttribute("aria-hidden",!0),a._expandedRowDetailIds=a._expandedRowDetailIds.filter((e=>e!==t)),l.classList.add("collapsed"),l.remove(),void i();const n=e.data;l=document.createElement("tr"),l.classList.add("collapsed"),a._createRowDetailOnDemand(l,{data:n},n),e.parentElement.insertBefore(l,e.nextElementSibling),a._expandedRowDetailIds.push(t),l.classList.remove("collapsed"),i()}_setFocusable(){const e=this,t="smart-table"===e.nodeName.toLowerCase();if(!e.keyboardNavigation||e.disabled||e.unfocusable||e.hasAttribute("modal"))return e.$.tableContainer.removeAttribute("tabindex"),t&&(e.$.filterInput.unfocusable=!0,e.$.pager.unfocusable=!0),void(e.$.conditionalFormattingButton.unfocusable=!0);const a=e.$.tableContainer.getAttribute("tabindex");(null===a||a<0)&&e.$.tableContainer.setAttribute("tabindex",0),t&&(e.$.filterInput.unfocusable=!1,e.$.pager.unfocusable=!1),e.$.conditionalFormattingButton.unfocusable=!1}_tableContainerFocusHandler(){const e=this;e._focusedCell&&e.$.tableContainer.contains(e._focusedCell)||e._focusCell(e.$.tableContainer.children[1].querySelector("tr:not([unused]) td[data-field], tr:not([unused]) td.group-header"))}_tableContainerDownHandler(e){const t=this.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;this._focusCell(t.closest("td[data-field], td.group-header")),e.stopPropagation()}_focusCell(e,t){const a=this;if(!e||!e.hasAttribute("data-field")&&!e.classList.contains("group-header")||e.parentElement.classList.contains("grand-total"))return!1;if(a._focusedCell){if(a._focusedCell===e)return!1;a._focusedCell.removeAttribute("focus")}if(a._focusedCell=e,e.setAttribute("focus",""),!t)return;const l=a.$.tableContainer.parentElement,i=a.$.header.offsetHeight,n=a.freezeHeader?a.$.tableContainer.firstElementChild.offsetHeight:0,r=l.scrollTop;let o=e.offsetTop-i-n;if(o<r)l.scrollTop=o;else{const t=a.footerRow&&a.freezeFooter?a.$.tableContainer.lastElementChild.offsetHeight:0,s=a.$.pager.offsetHeight,d=l.clientHeight-(i+n+t+s);o+=e.offsetHeight,o>r+d&&(l.scrollTop=o-d)}if(e.classList.contains("freeze-near")||e.classList.contains("freeze-far"))return;const s=l.scrollLeft,d=a.$.tableContainer.querySelector("tr[row-id]:not([unused])");let c,u=0;if(Array.from(d.children).forEach((e=>{e.classList.contains("freeze-near")&&(u+=e.offsetWidth)})),a.rightToLeft){let t=e.previousElementSibling;for(c=0;t;)t.classList.contains("freeze-near")||(c-=t.offsetWidth),t=t.previousElementSibling;if(c>s)l.scrollLeft=c;else{const t=l.clientWidth;c-=e.offsetWidth,c<s-t&&(l.scrollLeft=c+t-u)}}else if(c=e.offsetLeft-u,c<s)l.scrollLeft=c;else{const t=l.clientWidth;c+=e.offsetWidth+u,c>s+t&&(l.scrollLeft=c-t)}}focus(){const e=this;!e.keyboardNavigation||e.disabled||e.unfocusable||e.hasAttribute("modal")||e.$.tableContainer.focus()}blur(){this.$.tableContainer.blur()}_tableContainerKeydownHandler(e){const t=this,a=t.isInShadowDOM?e.composedPath()[0]:e.target,l=e.key;if("Shift"===l)return void("extended"===t.selectionMode&&t.$.tableContainer.classList.add("smart-unselectable"));if(!t.contains(a))return;if(a&&"INPUT"===a.nodeName&&!t._editing)return;const i=t._focusedCell;if(!i)return;const n=t.virtualization,r=i.classList.contains("group-header");if(r&&-1!==["ArrowRight","ArrowLeft","Home","End","Escape","F2"].indexOf(l))return void e.preventDefault();if(t._editing){switch(l){case"Enter":t.endEdit();break;case"Escape":t.cancelEdit();break;default:return}return t.$.tableContainer.focus(),void e.preventDefault()}const o=i.parentElement;if(n&&o){const e=t.$.virtualizationContainer.$.verticalScrollBar,a=e.value,i=o.data.$.id;if("ArrowUp"===l&&0===a&&i===t._rowsVirtual[0].data.$.id||"ArrowDown"===l&&a===e.max&&i===t._rowsVirtual[t._rowsVirtual.length-1].data.$.id)return}let s="ArrowRight",d="ArrowLeft";switch(t.rightToLeft&&(s="ArrowLeft",d="ArrowRight"),l){case s:case d:{const a=l===s?"nextElementSibling":"previousElementSibling";let r=i[a];for(;r&&r.classList.contains("smart-hidden");)r=r[a];t._focusCell(r,!n,e),t._scrollToVirtualization(l===s?"nextArrow":"prevArrow",r);break}case"ArrowUp":case"ArrowDown":{const a="ArrowUp"===l?"previousElementSibling":"nextElementSibling";let s=o[a];for(;s&&(s.classList.contains("smart-table-row-detail")||s.classList.contains("collapsed"));)s=s[a];s&&(r?t._focusCell(s.querySelector("td[data-field], .group-header"),!n,e):t._focusCell(s.querySelector(`td[data-field="${i.getAttribute("data-field")}"], .group-header`),!n,e),t._scrollToVirtualization(l,s));break}case"Home":t._focusCell(o.querySelector("td[data-field]"),!n,e),t._scrollToVirtualization(l);break;case"End":{const a=o.querySelectorAll("td[data-field]");let i=a.length-1,r=a[i];for(;r.classList.contains("smart-hidden");)i--,r=a[i];t._focusCell(r,!n,e),t._scrollToVirtualization(l);break}case"PageDown":t._pageDownHandler(i,e);break;case"PageUp":t._pageUpHandler(i,e);break;case"Enter":{const a=o.data;t.dataSource.boundHierarchy&&t._areChildrenFiltered(a)?t._hierarchyArrowClickHandler(o,i,e):t.rowDetailTemplate&&t._toggleRowDetail(o,a.$.id);break}case" ":t._toggleSelection(o,o.data,e);break;case"F2":t.beginEdit(o.data.$.id,i.getAttribute("data-field"));break;default:return}if(e.preventDefault(),t.onKeyboardScroll){const e=n?t.$.virtualizationContainer:t.$.container;t.onKeyboardScroll(l,e.scrollTop,e.scrollLeft)}}_pageDownHandler(e,t){const a=this,l=a.paging;if(!l&&e.parentElement===e.parentElement.parentElement.lastElementChild)return;const i=a.virtualization,n=a.$.tableContainer,r=n.parentElement,o=i?a.$.virtualizationContainer:r;let s=e.getAttribute("data-field");function d(){const e=n.querySelectorAll("tr[row-id]:not([unused])");let t=i?0:a.$.header.offsetHeight+a.$.pager.offsetHeight;a.footerRow&&a.freezeFooter&&(t+=n.lastElementChild.offsetHeight);for(let a=e.length-1;a>=0;a--){const l=e[a];if(!l.classList.contains("collapsed")&&l.offsetTop+l.offsetHeight<=(i?-r.offsetTop:r.scrollTop)+o.clientHeight-t)return l.querySelector(`td[data-field${s}], .group-header`)}}s=s?`="${s}"`:"";let c=d();if(c)if(e===c){const u=(a.freezeHeader?n.firstElementChild.offsetHeight:0)+a._rowHeight;let f;if(i?(f=o.$.verticalScrollBar.value,o.$.verticalScrollBar.value+=o.clientHeight-u):r.scrollTop+=r.clientHeight-u,c=d(),l&&(i&&f===o.$.verticalScrollBar.value||!i&&e===c)){const e=a.pageIndex;a.navigateTo(a.pageIndex+1),a.pageIndex!==e&&(i&&(o.$.verticalScrollBar.value=0),a._focusCell(n.querySelector(`tr[row-id]:not([unused]) td[data-field${s}], tr[row-id]:not([unused]) .group-header`),!i,t))}else a._focusCell(c,void 0,t)}else a._focusCell(c,void 0,t)}_pageUpHandler(e,t){const a=this,l=a.virtualization,i=a.$.tableContainer,n=i.parentElement,r=l?a.$.virtualizationContainer:n;let o=e.getAttribute("data-field");function s(){const e=i.querySelectorAll("tr[row-id]:not([unused])");let t=0;a.freezeHeader&&(t=i.firstElementChild.offsetHeight);for(let a=0;a<e.length;a++){const i=e[a];if(!i.classList.contains("collapsed")&&i.offsetTop>=(l?-n.offsetTop:n.scrollTop)+t)return i.querySelector(`td[data-field${o}], .group-header`)}}o=o?`="${o}"`:"";let d=s();if(d)if(e===d){const c=(a.freezeHeader?i.firstElementChild.offsetHeight:0)+a._rowHeight;let u;if(l?(u=r.$.verticalScrollBar.value,r.$.verticalScrollBar.value-=r.clientHeight-c):n.scrollTop-=n.clientHeight-c,d=s(),a.paging&&(l&&u===r.$.verticalScrollBar.value||!l&&e===d)){const e=a.pageIndex;if(a.navigateTo(a.pageIndex-1),a.pageIndex!==e){l&&(r.$.verticalScrollBar.value=r.$.verticalScrollBar.max);const e=i.querySelectorAll(`tr[row-id]:not([aria-hidden="true"]) td[data-field${o}], tr[row-id]:not([aria-hidden="true"]) .group-header`);a._focusCell(e[e.length-1],!l,t)}}else a._focusCell(d,void 0,t)}else a._focusCell(d,void 0,t)}_tableContainerKeyupHandler(e){const t=this,a=t.isInShadowDOM?e.composedPath()[0]:e.target;if("Shift"===e.key&&"extended"===t.selectionMode&&t.$.tableContainer.classList.remove("smart-unselectable"),t.contains(a))return a.classList.contains("filter-value")&&"date"!==a.type?(clearTimeout(t._filterRowTimeout),void(t._filterRowTimeout=setTimeout((function(){const e=t.context;t.context=t,t._applyRowFilters(),t.context=e}),500))):void 0}_tableContainerPointeroverHandler(e){const t=this;if(!t.tooltip)return;const a=(t.isInShadowDOM?e.composedPath()[0]:e.target).closest("tbody td[data-field], thead th[data-field]");if(!a)return;const l=t.$.tableContainer.querySelector(".tooltip"),i=t.columnByDataField[a.getAttribute("data-field")],n=t.virtualization;if(l&&(l.classList.remove("tooltip"),l.removeAttribute("title")),"th"!==a.tagName.toLowerCase())(a.classList.contains("tree-cell")&&a.firstElementChild&&a.firstElementChild.children[1].scrollWidth>a.firstElementChild.children[1].offsetWidth||a.scrollWidth>a.offsetWidth)&&(a.classList.add("tooltip"),a.title=n&&i&&i.templateElement?"":a.innerText);else{const e=a.querySelector(".label");e&&e.scrollWidth>e.offsetWidth&&(a.classList.add("tooltip"),a.title=n&&i&&i.templateElement?"":e.innerText)}}_documentDownHandler(e){const t=this,a=t.isInShadowDOM?e.originalEvent.composedPath()[0]:e.originalEvent.target;function l(){"default"!==t.columnSizeMode&&(t._preventClickSort=!0,clearTimeout(t._dblclickObject.timeout),t._dblclickObject.numberOfClicks++,2===t._dblclickObject.numberOfClicks?(t._dblclickObject.numberOfClicks=0,t._autoResizeColumnOnDblclick()):t._dblclickObject.timeout=setTimeout((function(){t._dblclickObject.numberOfClicks=0}),300))}if(delete t._preventClickSort,t._editing&&!a.closest(".smart-table-editor")){const e=a.closest(".smart-drop-down")||a.closest(".smart-input-drop-down-menu");if(!e)return void t.endEdit();const l=e.ownerElement;if(!l)return void t.endEdit();if(t.$.container.contains(l)&&l.classList.contains("smart-table-editor"))return;return void t.endEdit()}const i=t.columnReorder,n=t.columnResize;if(i&&!t.columnTotals||n){const r=a.closest("th[data-field]:not(.smart-pivot-table-total-header)");if(r&&t.$.tableContainer.contains(r)){if(t.$.tableContainer.classList.add("smart-unselectable"),n&&t._columns.length>1&&!t.hasAttribute("resize-max-reached")){const a=t.rightToLeft,i=r.getBoundingClientRect();let n=null;if(!a&&e.clientX<=i.left+5||a&&e.clientX>=i.right-5){const i=r.previousElementSibling;if(i&&i.hasAttribute("data-field")){if(i.hasAttribute("locked"))return;for(let e=0;e<t.columns.length;e++){const a=t.columns[e];if(a.headerCellElement===i){n=a;break}}const r=i.getBoundingClientRect(),o=n&&n.minWidth||t._getNumericMinWidth();return t._resizeDetails={FeedbackShown:!1,Item:i,ItemStart:r[a?"right":"left"]+window.scrollX,Min:o,StartPosition:{left:e.pageX,top:e.pageY},StartTime:new Date},t._resizeDetails.Max=t._getCurrentResizeMax(),void l()}}if(!a&&e.clientX>=i.right-5||a&&e.clientX<=i.left+5){if(r.hasAttribute("locked"))return;for(let e=0;e<t.columns.length;e++){const a=t.columns[e];if(a.headerCellElement===r){n=a;break}}const o=n&&n.minWidth||t._getNumericMinWidth();return t._resizeDetails={FeedbackShown:!1,Item:r,ItemStart:i[a?"right":"left"]+window.scrollX,Min:o,StartPosition:{left:e.pageX,top:e.pageY},StartTime:new Date},t._resizeDetails.Max=t._getCurrentResizeMax(),void l()}}i&&(t._dragDetails={FeedbackShown:!1,Item:r,StartPosition:{left:e.pageX,top:e.pageY},StartTime:new Date})}}}_documentMoveHandler(e){const t=this,a=t._dragDetails;if(!a)return void(t._resizeDetails&&t._handleResizeOnMove(e));if(!a.FeedbackShown){const l=(new Date).getTime()-a.StartTime.getTime()>500,i=Math.abs(a.StartPosition.left-e.pageX)>5||Math.abs(a.StartPosition.top-e.pageY)>5;if(!i||!(!t._isMobile||t._isMobile&&l))return void(t._isMobile&&i&&!l&&(delete t._dragDetails,t.$.tableContainer.classList.remove("smart-unselectable")));t._hideBodyOverflow(),a.Feedback=t._addDragFeedback(),a.FeedbackShown=!0,a.Item.classList.add("dragged"),t.classList.add("smart-unselectable")}const l=t.$.tableContainer.parentElement;a.Feedback.style.left=e.pageX+10+"px",a.Feedback.style.top=e.pageY+10+"px",a.HoveredItem&&(a.HoveredItem.classList.remove("drop-column","left","right"),delete a.HoveredItem),l.offsetWidth<l.scrollWidth&&(clearInterval(t._dragInterval),t._dragInterval=setInterval((function(){const a=l.getBoundingClientRect();a.left<=e.clientX&&a.left+a.width>=e.clientX?e.clientX>=a.left&&e.clientX<=a.left+25?l.scrollLeft-=t._autoScrollCoefficient:e.clientX>=a.left+a.width-25&&e.clientX<=a.left+a.width?l.scrollLeft+=t._autoScrollCoefficient:clearInterval(t._dragInterval):clearInterval(t._dragInterval)}),10));const i=t._getClosestThToHover(e);i&&(i.classList.add("drop-column"),a.HoveredItem=i)}_hideBodyOverflow(){const e=(document.scrollingElement||document.documentElement).scrollHeight>document.documentElement.clientHeight,t=(document.scrollingElement||document.documentElement).scrollWidth>document.documentElement.clientWidth;this._originalBodyOverflow={overflowX:document.body.style.overflowX,overflowY:document.body.style.overflowY,overflow:document.body.style.overflow},document.body.classList.add("smart-dragging"),document.body.style.overflow=document.body.style.overflowX=document.body.style.overflowY="",e&&!t?document.body.style.overflowX="hidden":t&&!e?document.body.style.overflowY="hidden":t||e||(document.body.style.overflow="hidden")}_addDragFeedback(){const e=this,t=e._dragDetails.Item,a=document.createElement("div");return a.className="smart-table-feedback",a.setAttribute("parent-table-id",e.id),a.innerHTML=e.columnByDataField[t.getAttribute("data-field")].label,e.theme&&a.setAttribute("theme",e.theme),document.body.appendChild(a),a}_getClosestThToHover(e){const t=e.clientX,a=Array.from(this.$.tableContainer.querySelectorAll("th[data-field]:not(.smart-pivot-table-total-header)"));let l,i,n;for(let e=0;e<a.length;e++){const r=a[e];if(!r||this._dragDetails.Item===r)continue;const o=r.getBoundingClientRect(),s=Math.abs(t-o.left),d=Math.abs(t-o.right),c=Math.min(s,d);if(!(void 0===i||c<i))break;l=r,i=c,n=s<d?"left":"right"}return l&&l.classList.add(n),l}_handleResizeOnMove(e){const t=this,a=t._resizeDetails;if(!a.FeedbackShown){const l=(new Date).getTime()-a.StartTime.getTime()>500,i=Math.abs(a.StartPosition.left-e.pageX)>=1||Math.abs(a.StartPosition.top-e.pageY)>=1;if(!i||!(!t._isMobile||t._isMobile&&l))return void(t._isMobile&&i&&!l&&(delete t._resizeDetails,t.$.tableContainer.classList.remove("smart-unselectable","resizing"),document.body.style.cursor=null));a.Feedback=t._addResizeFeedbacks(),a.FeedbackShown=!0,t.classList.add("smart-unselectable","resizing"),document.body.style.cursor="col-resize"}const l=a.Feedback,i=a.ItemStart;let n;t.rightToLeft?(n=Math.min(a.Max,Math.max(a.Min,Math.round(i-e.pageX))),l.style.left=i-n+"px"):(n=Math.min(a.Max,Math.max(a.Min,Math.round(e.pageX-i))),l.style.left=i+n+"px"),l.classList.toggle("min",n===a.Min),l.classList.toggle("max",n===a.Max),t.columnResizeFeedback&&(l.innerHTML=n+"px"),a.Width=n}_addResizeFeedbacks(){const e=this,t=e._resizeDetails,a=e.$.container.getBoundingClientRect(),l=a.top+window.scrollY+"px",i=a.height+"px",n=document.createElement("div"),r=document.createElement("div");return r.className="smart-table-resize-feedback static",r.setAttribute("parent-table-id",e.id),r.style.top=l,r.style.left=t.ItemStart+"px",r.style.height=i,e._resizeDetails.StaticFeedback=r,n.className="smart-table-resize-feedback",n.setAttribute("parent-table-id",e.id),n.style.top=l,n.style.height=i,e.theme&&(r.setAttribute("theme",e.theme),n.setAttribute("theme",e.theme)),document.body.appendChild(n),document.body.appendChild(r),n}_resolveResize(e){const t=this,a=t._resizeDetails;if(delete t._resizeDetails,t.$.tableContainer.classList.remove("smart-unselectable","resizing"),e){if(!a.FeedbackShown)return;a.StaticFeedback.remove(),a.Feedback.remove()}const l=t._columns.find((e=>e.headerCellElement===a.Item));t.classList.remove("smart-unselectable","resizing"),document.body.style.cursor=null;let i=a.Width;i<parseInt(t.columnMinWidth)&&(i=parseInt(t.columnMinWidth));const n=t._getTableRemainingWidth();if(l){const e=l._isResponsive||!!(l.width&&l.width.toString().indexOf("%")>=0);if(delete l.width,l.minWidth&&i<l.minWidth&&(i=l.minWidth),l._manualWidth=i,l._manualPercentageWidth=parseFloat(i/n*100),l._isResponsive=e,a.Item.style.width=l._isResponsive?parseFloat(i/n*100)+"%":i+"px",l._isFillRemainingWidth){let e=!0;for(let a=0;a<t._columns.length;a++){const l=t._columns[a];if(!l.width&&!l._manualWidth){e=!1;break}}!t.columnResizeNormalize&&e&&(t.columns.push({dataField:"",label:"",visible:!0,allowResize:!1,allowFilter:!1,allowSort:!1}),t._initColumns(!0),t.refresh())}}else a.Item.style.width=i+"px";t._handleAutoSizeMode(l),t._handleFrozenColumnPositions(),t._refreshHorizontalScrollbar();const r=parseFloat(i/n*100);t.$.fireEvent("columnResize",{dataField:l.dataField,headerCellElement:a.Item,widthInPercentages:r,width:i})}openColumnMenu(e){const t=this,a=t.columnByDataField[e];if(!a)return;const l=a.headerCellElement;if(!l)return;if(a&&!1===a.allowMenu)return;const i=l.querySelector(".column-menu");if(!i)return;const n=()=>{const e=c.getBoundingClientRect(),a=t.activeColumnMenu;t._columnsSettingsMenu.style.top=e.top+window.scrollY+"px",t._columnsSettingsMenu.style.left=e.right+window.scrollX+"px",e.right-i.offsetWidth+window.scrollX+a.offsetWidth>t.getBoundingClientRect().right&&(t._columnsSettingsMenu.style.left=10+e.right-a.offsetWidth-t._columnsSettingsMenu.offsetWidth+window.scrollX+"px")},r=()=>{const e=a.headerCellElement;e.hasAttribute("column-menu-button")||e.setAttribute("column-menu-button","");const l=e.querySelector(".column-menu"),i=l.getBoundingClientRect();o.style.top=i.bottom+10+window.scrollY+"px",o.style.left=i.right-l.offsetWidth+window.scrollX+"px",i.right-l.offsetWidth+window.scrollX+o.offsetWidth>t.getBoundingClientRect().right&&(o.style.left=i.right-o.offsetWidth+window.scrollX+"px");const n=o.querySelector("input");n&&n.focus()};a.columnMenu&&a.columnMenu.remove(),t.closeColumnMenu();const o=document.createElement("div");o.classList.add("smart-table-column-menu","wrapper"),o.owner=l,o.dataField=e;const s=document.createElement("div");s.innerHTML=`<span class='menu-icon sort-asc'></span><span class="label">${t.localize("columnMenuItemSortAsc")}</span>`,s.classList.add("smart-table-menu-item");const d=document.createElement("div");d.innerHTML=`<span class='menu-icon sort-desc'></span><span class="label">${t.localize("columnMenuItemSortDesc")}</span>`,d.classList.add("smart-table-menu-item");const c=document.createElement("div");c.innerHTML=`<span class='menu-icon columns'></span><span class="label">${t.localize("columnMenuItemColumns")}</span>`,c.classList.add("smart-table-menu-item","columns-item");const u=document.createElement("div");u.innerHTML=`<span class='menu-icon filter-by'></span><span class="label">${t.localize("columnMenuItemFilter")}</span>`,u.classList.add("smart-table-menu-item","filter-item");const f=document.createElement("div");f.innerHTML=`<span class='menu-icon filter-by-remove'></span><span class="label">${t.localize("columnMenuItemRemoveFilter")}</span>`,f.classList.add("smart-table-menu-item","remove-filter-item","smart-hidden");const m=document.createElement("div");m.innerHTML=`<span class='menu-icon sort-remove'></span><span class="label">${t.localize("columnMenuItemRemoveSort")}</span>`,m.classList.add("smart-table-menu-item","remove-sort-item","smart-hidden");const h=document.createElement("div");h.innerHTML=`<span class='menu-icon reset'></span><span class="label">${t.localize("columnMenuItemReset")}</span>`,h.classList.add("smart-table-menu-item","reset-item"),c.onmouseleave=e=>{const a=t._columnsSettingsMenu.getBoundingClientRect();e.pageX>=a.left-20&&e.pageX<=a.right+20&&e.pageY>=a.top-20&&e.pageY<=a.bottom+20||t._columnsSettingsMenu&&t._columnsSettingsMenu.remove()},c.onmouseenter=()=>{t._columnsSettingsMenu=(()=>{t._columnsSettingsMenu&&t._columnsSettingsMenu.remove();const a=document.createElement("div");a.classList.add("smart-table-column-menu","wrapper","smart-table-columns-menu");let l=0,i=null;for(let o=0;o<t.columns.length;o++){const s=document.createElement("div");s.innerHTML=`<span class='column-item menu-icon'></span><span class="label">${t.columns[o].label}</span>`,s.classList.add("smart-table-menu-item"),s.column=t.columns[o],e!==s.column.dataField&&!1!==s.column.allowHide&&(s.column.visible?(l++,i=s):s.firstElementChild.classList.add("off"),s.onpointerdown=e=>{s.column.visible=!s.column.visible,s.column.visible?s.firstElementChild.classList.remove("off"):s.firstElementChild.classList.add("off"),r(),n(),e.stopPropagation(),e.preventDefault()},a.appendChild(s))}return 1===l&&i&&i.classList.add("smart-disabled"),document.body.appendChild(a),a})(),n()};const p=t._createFilterRowInput(a);if(t.filtering&&!1!==a.allowFilter)if(t.filterRow)o.insertBefore(f,o.firstElementChild);else{o.innerHTML=p,o.insertBefore(u,o.firstElementChild);const e=o.querySelector(".filter-value");e.onkeyup=a=>{"Enter"===a.key&&t.closeColumnMenu(),"Escape"===a.key&&(e.value="")},e.nextElementSibling.onchange=()=>{t._applyRowFilters()}}o.insertBefore(h,o.firstElementChild),o.insertBefore(c,o.firstElementChild),o.insertBefore(m,o.firstElementChild),!1!==a.allowSort&&"none"!==t.sortMode&&(o.insertBefore(d,o.firstElementChild),o.insertBefore(s,o.firstElementChild),a.headerCellElement.hasAttribute("aria-sort")&&(m.classList.remove("smart-hidden"),"ascending"===a.headerCellElement.getAttribute("aria-sort")?s.classList.add("smart-disabled"):d.classList.add("smart-disabled")),m.onclick=()=>{t.sortBy(a.dataField,null),t.closeColumnMenu()},s.onclick=()=>{t.sortBy(a.dataField,"asc"),t.closeColumnMenu()},d.onclick=()=>{t.sortBy(a.dataField,"desc"),t.closeColumnMenu()}),h.onclick=()=>{if(t._initialState){if(t.loadState(t._initialState),t._filterInfo.filterRowValues&&delete t._filterInfo.filterRowValues,t.clearFilters(),t.filterRow){const e=t.$.tableContainer.querySelector(".smart-table-filter-row");e&&e.remove()}t._initRows(),t.refresh()}t.closeColumnMenu()};const g=t.columns.findIndex((e=>e.dataField===a.dataField));t.appendChild(o);const _=o.lastElementChild.children[2];_&&(_.onclick=()=>{const e=_.parentElement.firstElementChild,a=_.parentElement.children[1];e.value="",-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(a.$.input.dataValue)&&(a.value=t.localize("text"===e.type?"CONTAINS":"EQUAL"),delete a.$.input.dataValue),t._applyRowFilters()});const b=t._filterInfo&&t._filterInfo.filterRowValues?t._filterInfo.filterRowValues[g]:null;if(b&&!t.filterRow){const e=o.lastElementChild,l=a.dataType,i=t._filterInfo["string"===l?"stringConditions":"numberAndDateConditions"].find((e=>e.value===b.condition));if(-1===["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(i.value))if("date"===l){const t=new Date(b.value),a=(t.getMonth()+1).toString(),l=t.getDate().toString();e.children[0].value=`${t.getFullYear()}-${"0".repeat(2-a.length)}${a}-${"0".repeat(2-l.length)}${l}`}else e.children[0].value=b.value;e.children[1].value=i.label,e.children[1].$.input.dataValue=i.value,e.children[2].classList.remove("smart-hidden")}a.headerCellElement.hasAttribute("filter")&&f.classList.remove("smart-hidden"),f.onclick=()=>{t.removeFilter(a.dataField),t.closeColumnMenu()},r(),a.columnMenu=t.activeColumnMenu=o,t.$.fireEvent("openColumnMenu",{dataField:e})}closeColumnMenu(){const e=this;e.activeColumnMenu&&(e.activeColumnMenu.owner.hasAttribute("column-menu-button")&&e.activeColumnMenu.owner.removeAttribute("column-menu-button"),e._columnsSettingsMenu&&e._columnsSettingsMenu.remove(),e.$.fireEvent("closeColumnMenu",{dataField:e.activeColumnMenu.dataField}),e.activeColumnMenu.remove(),delete e.activeColumnMenu)}_documentUpHandler(e){const t=this,a=t._dragDetails;if(t.activeColumnMenu){const a=e.originalEvent?e.originalEvent:e;if(a){let e=!1,l=a.target;for(;l;)if(l=l.parentNode,l===t){e=!0;break}(t.activeColumnMenu.contains(a.target)||t._columnsSettingsMenu&&t._columnsSettingsMenu.contains(a.target))&&(e=!0);const i=t.activeColumnMenu.querySelector("smart-input");i&&i.$.scrollView.contains(a.target)&&(e=!0),e||t.closeColumnMenu()}}if(t._selectDrag)return t.$.main.classList.remove("prevent-scroll"),void delete t._selectDrag;if(!a)return t._resizeDetails&&t._resolveResize(!0),void t.$.tableContainer.classList.remove("smart-unselectable");if(delete t._dragDetails,t.$.tableContainer.classList.remove("smart-unselectable"),!a.FeedbackShown)return;const l=a.HoveredItem;document.body.classList.remove("smart-dragging"),document.body.style.overflow=t._originalBodyOverflow.overflow,document.body.style.eoverflowX=t._originalBodyOverflow.overflowX,document.body.style.overflowY=t._originalBodyOverflow.overflowY,delete t._originalBodyOverflow,t.classList.remove("smart-unselectable"),a.Item.classList.remove("dragged"),document.body.removeChild(a.Feedback),clearInterval(t._dragInterval),delete t._dragInterval,l&&t._applyColumnReorder(a,l),t._preventClickSort=!0,requestAnimationFrame((()=>delete t._preventClickSort))}_applyColumnReorder(e,t){const a=this,l=a.rightToLeft,i=a._columns,n=e.Item.getAttribute("data-field"),r=i.find((e=>e.dataField===n)),o=t.getAttribute("data-field"),s=t.classList.contains("right"),d=a._columns.filter((e=>e.dataField!==n)),c=d.findIndex((e=>e.dataField===o));t.classList.remove("drop-column","left","right"),s&&!l||!s&&l?d.splice(c+1,0,r):d.splice(c,0,r),i.map((e=>e.dataField)).join(",")!==d.map((e=>e.dataField)).join(",")&&(a.columns=d,a._initColumns(),a.refresh())}_applyRowFilters(){const e=this;if(!e.filtering||!e.filterRow&&!e.columnMenu)return;const t=e.filterRow?e.$.tableContainer.querySelector(".smart-table-filter-row"):null,a=Number(e.selection),l=e._columns.filter((e=>e.visible)),i=[],n=[];for(let r=0;r<l.length;r++){const o=l[r].dataField,s=l[r].dataType;if(l[r].headerCellElement&&l[r].headerCellElement.hasAttribute("filter")&&l[r].headerCellElement.removeAttribute("filter"),!e.filterRow&&!l[r].columnMenu){n.push(null);continue}const d=e.filterRow?t.children[r+a].firstElementChild:l[r].columnMenu.lastElementChild,c=d.children[2];let u=d.firstElementChild.value,f=d.children[1].value;"string"===s?f=e._filterInfo.stringConditions.find((e=>e.label===f)).value:(f=e._filterInfo.numberAndDateConditions.find((e=>e.label===f)).value,""!==u&&("number"===s?(u=parseFloat(u),isNaN(u)&&(d.firstElementChild.value="",u="")):"date"===s&&(u=new Date(u),u.setHours(0,0,0))));const m=-1!==["EMPTY","NOT_EMPTY","NULL","NOT_NULL"].indexOf(f);if(""!==u||m){const e=new Smart.Utilities.FilterGroup,t=e.createFilter(s,u,f);e.addFilter("or",t),i.push([o,e]),c.classList.remove("smart-hidden"),n.push({condition:f,value:u}),l[r].headerCellElement&&l[r].headerCellElement.setAttribute("filter","")}else c.classList.add("smart-hidden"),n.push(null),l[r].headerCellElement&&l[r].headerCellElement.hasAttribute("filter")&&l[r].headerCellElement.removeAttribute("filter");m?d.firstElementChild.setAttribute("disabled",!0):d.firstElementChild.removeAttribute("disabled")}i.length>0?(e.dataSource.virtualDataSource||e.dataSource._filter(i,e.filterOperator),e._filterInfo.rowFilters=i,e._filterInfo.filterRowValues=n,delete e._filterInfo.appliedFilters,e._fullRefresh("filter"),e._updateState("filtered"),e._doNotFireEvent||e.$.fireEvent("filter",{action:"add",filters:i})):e._filterInfo.rowFilters?(e._filterInfo.filterRowValues&&delete e._filterInfo.filterRowValues,e.clearFilters()):e._filterInfo.filterRowValues&&delete e._filterInfo.filterRowValues}_clearFilterInput(){const e=this;e._filterInfo.query="",delete e._filterInfo.inputFilters,e.$.filterInput.value=""}_clearRowFilters(e){const t=this;if(!t._filterInfo.rowFilters)return;const a=t.$.tableContainer.querySelector(".smart-table-filter-row"),l=t.selection?1:0;let i=t._columns.filter((e=>e.visible));if(e&&(i=t._columns.filter((t=>t.dataField===e))),a)for(let e=0;e<i.length;e++){const t=a.children[e+l]?a.children[e+l].firstElementChild:null;t&&(t.firstElementChild.value="",t.children[2].classList.add("smart-hidden")),i[e].headerCellElement&&i[e].headerCellElement.hasAttribute("filter")&&i[e].headerCellElement.removeAttribute("filter")}delete t._filterInfo.rowFilters}_createFooterRow(e){const t=this,a=t.footerRow;if(!a)return;if(e)return void t.$.tableContainer.appendChild(e);const l=document.getElementById(a);if(l&&l instanceof HTMLTemplateElement){const e=document.createElement("tfoot"),a=document.importNode(l.content,!0);e.appendChild(a),t.$.tableContainer.appendChild(e)}else t.footerRow=null}_createCustomHeaderRow(){const e=this,t=e.$.tableContainer.firstElementChild;let a=e.headerRow;if(a){if("function"==typeof a)a.call(e,t);else if("string"==typeof a){const e=document.getElementById(a);if(!e)return void(t.innerHTML=`<tr><th>${a}</th></tr>`);a=e}a instanceof HTMLTemplateElement?t.appendChild(document.importNode(a.content,!0)):a.nodeName?t.appendChild(a):e.headerRow=null}}_updateSelectAllState(e){const t=this;if(!t.selection||"cell"===t.selectionMode)return;const a=t.$.tableContainer.querySelector(".smart-table-select-all");let l;if(void 0===e){const a=t.dataSource,i=t._filterInfo;if(i.inputFilters||i.rowFilters||i.appliedFilters){const i=t._selectedIds;e=0,l=0;for(let t=0;t<a.length;t++){const n=a[t];if(!1===n.$.filtered)continue;const r=n.$.id;e++,-1!==i.indexOf(r)&&l++}}else e=t.dataSource.length}void 0===l&&(l=t._selectedIds.length),0===l||0===e?(a.classList.remove("selected","indeterminate"),a.firstElementChild.setAttribute("aria-checked",!1)):l===e+t._selectableGroupRecords.length?(a.classList.remove("indeterminate"),a.classList.add("selected"),a.firstElementChild.setAttribute("aria-checked",!0)):(a.classList.remove("selected"),a.classList.add("indeterminate"),a.firstElementChild.setAttribute("aria-checked","mixed"))}_resizeHandler(){const e=this;clearTimeout(e._resizeTimeout);const t=()=>{if(Smart.Utilities.Core.Browser.Firefox&&e.virtualization){const t=e.$.virtualizationContainer.$.verticalScrollBar.value;e._onVerticalChange({detail:{value:t}},!0)}};t(),"default"===e.columnSizeMode&&e._handleAutoSizeMode(),e._resizeTimeout=setTimeout((function(){if(e.columnGroups&&e._columns.some((e=>e.responsivePriority&&e.responsivePriority>1)))return void e.refresh();const a=e.offsetWidth,l=e.offsetHeight;if(e.virtualization&&e._cachedHeight!==l){const i=e._getFractionOfMax();return e._refreshDataRows(),e._setFractionOfMax(i),e._cachedWidth=a,e._cachedHeight=l,void t()}e._handleAutoSizeMode(),e._handleFrozenColumnPositions(),e._refreshHorizontalScrollbar(),e._cachedWidth=a,e._cachedHeight=l,t()}),75)}_hierarchyArrowClickHandler(e,t){const a=this,l=!a.grouping,i=e.data;if(a.animation=a._animation,a.expandHierarchy&&(a._collapsedIds||(a._collapsedIds=[]),!0===i.expanded?a._collapsedIds[i.$.id]=!0:delete a._collapsedIds[i.$.id],a.dataSource&&a.expandHierarchy&&(a.dataSource._collapsedIds=a._collapsedIds)),l&&a.dataSource.virtualDataSource&&!i.expanded&&i.children&&0===i.children.length)return a._requestVirtualDataSource("expand",void 0,i),void a.$.fireEvent("expand",{id:i.$.id,record:i});if(a.virtualization)return void a._hierarchyArrowClickHandlerVirtualization(e,t);const n=a.$.tableContainer,r=i.$.id;function o(e){e.forEach((e=>{a._expandSingleChildRow(n.querySelector(`tr[row-id="${e.$.id}"]:not([unused])`)),e.children&&e.expanded&&requestAnimationFrame((()=>o(e.children)))}))}if(i.expanded?function e(t){t.forEach((t=>{a._collapseSingleChildRow(n.querySelector(`tr[row-id="${t.$.id}"]:not([unused])`)),t.children&&e(t.children)}))}(i.children):requestAnimationFrame((()=>o(i.children))),i.expanded=!i.expanded,e.setAttribute("aria-expanded",i.expanded),e.classList.toggle("expanded",i.expanded),l)i.expanded?(-1===a._expandedIds.indexOf(r)&&a._expandedIds.push(r),a.$.fireEvent("expand",{id:i.$.id,record:i})):(a._expandedIds=a._expandedIds.filter((e=>e!==r)),a.$.fireEvent("collapse",{id:i.$.id,record:i})),a._updateState("expanded");else if(!0!==t){let e=""+i.$.id;e=e.replace("Item","").replace(/_/gi,"."),i.expanded?a.$.fireEvent("group",{action:"expand",path:e,dataField:i.groupDataField,label:i.label}):a.$.fireEvent("group",{action:"collapse",path:e,dataField:i.groupDataField,label:i.label})}}_expandSingleChildRow(e,t=[]){e&&(t.push(!1),"none"!==this.animation?(e.classList.remove("smart-hidden"),requestAnimationFrame((()=>{e.classList.add("no-height"),e.ontransitionend=function(){e.classList.remove("no-height"),e.ontransitionend=null,t.pop()},e.removeAttribute("aria-hidden"),e.classList.remove("collapsed")}))):(e.removeAttribute("aria-hidden"),e.classList.remove("collapsed","smart-hidden"),t.pop()))}_collapseSingleChildRow(e,t=[]){e&&(t.push(!1),"none"!==this.animation?e.ontransitionend=function(){e.classList.add("smart-hidden"),e.ontransitionend=null,t.pop()}:(e.classList.add("smart-hidden"),t.pop()),e.setAttribute("aria-hidden",!0),e.classList.add("collapsed"))}_getGroupByIndex(e){"number"==typeof e&&(e=e.toString());const t=this.dataSource.boundHierarchy,a=e.split(".");let l=t[a[0]];if(l){for(let e=1;e<a.length;e++)if(l=l.children[a[e]],!l||l.leaf)return;return l}}getGroupChildren(e){"number"==typeof e&&(e=e.toString());const t=this.dataSource.boundHierarchy,a=e.split(".");let l=t[a[0]];if(!l)return[];for(let e=1;e<a.length;e++)if(l=l.children[a[e]],!l||l.leaf)return[];return l.children}_createDialog(){const e=this,t=document.createElement("smart-window"),a=document.createElement("template"),l=` animation=${e.animation} theme="${e.theme}"${e.rightToLeft?" right-to-left":""}${!e.keyboardNavigation||e.unfocusable?" unfocusable":""}`;a.innerHTML=`<smart-button class="ok primary"${l}>${e.localize("ok")}</smart-button>\n<smart-button class="cancel"${l}>${e.localize("cancel")}</smart-button>`,t.animation=e.animation,t.footerTemplate=a,t.headerButtons=["close"],t.rightToLeft=e.rightToLeft,t.theme=e.theme,t.unfocusable=!e.keyboardNavigation||e.unfocusable,t.className="smart-table-window",t.ownerElement=e,e._dialog=t,e._addDialogHandlers(),e.getShadowRootOrBody().appendChild(t),e.setAttribute("aria-owns",t.id)}_addDialogHandlers(){const e=this,t=e._dialog;t.addEventListener("close",e._dialogEventHandler),t.addEventListener("click",e._dialogEventHandler)}_dialogEventHandler(e){const t=this,a=t.ownerElement,l=t.isInShadowDOM?e.composedPath()[0]:e.target,i=e.type,n=a.context;if(a.context=a,"close"===i){if(l!==t)return void(a.context=n);const e=t.classList.contains("conditional-formatting"),i=t.classList.contains("fields");t.ok?(e&&a._applyConditionalFormatting(),delete t.ok):e&&JSON.stringify(a._formattingPanel.items)!==JSON.stringify(a._formattingPanel.getItems())&&(a._formattingPanel.$.itemsContainer.innerHTML="",a._formattingPanel._addDefaultItems()),t.content.innerHTML="",t.classList.remove("conditional-formatting","drill-down","fields"),!a.keyboardNavigation||a.disabled||a.unfocusable||(a.$.tableContainer.setAttribute("tabindex",0),"smart-table"===a.nodeName.toLowerCase()&&(a.$.filterInput.unfocusable=!1,a.$.pager.unfocusable=!1),a.$.conditionalFormattingButton.unfocusable=!1),a.removeAttribute("modal"),e?a.$.conditionalFormattingButton.focus():i&&a.$.fieldsButton?a.$.fieldsButton.focus():a.$.tableContainer.focus()}else"click"===i&&t.$.footer.contains(l)&&(l.closest(".ok")?(t.ok=!0,t.close()):l.closest(".cancel")&&t.close());a.context=n}_openDialog(e,t,a){const l=this;l._dialog||l._createDialog();const i=l._dialog;i.label=e,i.classList.add(a),i.appendChild(t),l.$.tableContainer.removeAttribute("tabindex"),"smart-table"===l.nodeName.toLowerCase()&&(l.$.filterInput.unfocusable=!0,l.$.pager.unfocusable=!0),"drill-down"!==a?i.setAttribute("aria-controls",l.$.tableContainer.id):i.removeAttribute("aria-controls"),l.$.conditionalFormattingButton.unfocusable=!0,l.setAttribute("modal",""),i.open()}_conditionalFormattingButtonClickHandler(e,t,a){const l=this;let i;l._formattingPanel?i=l._formattingPanel:(i=document.createElement("smart-formatting-panel"),i.animation=l.animation,i.columns=t||l._columns,i.dataSource=a||l.dataSource,i.locale=l.locale,i.messages=l.messages,i.rightToLeft=l.rightToLeft,i.theme=l.theme,i.unfocusable=!l.keyboardNavigation||l.unfocusable,i.ownerElement=l,l._formattingPanel=i),l.conditionalFormatting&&(i.items=l.conditionalFormatting.slice(0)),l._openDialog(l.localize("conditionalFormatting"),i,"conditional-formatting")}_transformDataSource(){const e=this;if(!e.isRendered&&e.dataTransform){const t=e.dataSource;for(let a=0;a<t.length;a++)e.dataTransform(t[a])}}_applyInitialConditionalFormatting(e){const t=this,a=t.conditionalFormatting;if(!a||0===a.length)return void(t._conditionalFormatting=null);const l=t._defaults,i=new Smart.Utilities.ConditionalFormatter(e),n=[];let r;if("smart-pivot-table"===t.nodeName.toLowerCase()){const e=t._dynamicColumns;r=function(t){return"all"===t?e.map((e=>e.id)):e.filter((e=>e.dataFields[e.dataFields.length-1].dataField===t)).map((e=>e.id))}}else r=function(e){return"all"===e?t._columns.map((e=>e.value)):[e]};for(let e=0;e<a.length;e++){a[e]=Object.assign({column:"all",condition:"lessThan",firstValue:0,secondValue:1,fontFamily:l.fontFamily,fontSize:l.fontSize,text:l.text,highlight:l.highlight},a[e]);const t=a[e],o=r(t.column),s=t.condition;i.color=t.highlight,i.comparator=t.firstValue,i.min=t.firstValue,i.max=t.secondValue;const d=i.format(s,o);for(let e in d){const a=d[e];for(let e in a){const l=a[e];l.color=t.text,l.fontFamily=t.fontFamily,l.fontSize=t.fontSize}}n.push(d)}if(t._formattingPanel&&(t._formattingPanel.items=a.slice(0)),0===n.length)return n[0];const o={};for(let e=0;e<n.length;e++){const t=n[e];for(let e in t){const a=t[e];o[e]||(o[e]={});for(let t in a)o[e][t]=Object.assign({},o[e][t],a[t])}}t._conditionalFormatting=o}_toHex(e){if(-1!==e.indexOf("#"))return e;const t=/rgb\((\d+), (\d+), (\d+)\)/g.exec(e);return t?"#"+(parseFloat(t[1]).toString(16).padStart(2,"0")+parseFloat(t[2]).toString(16).padStart(2,"0")+parseFloat(t[3]).toString(16).padStart(2,"0")).toUpperCase():"#FFFFFF"}_applyConditionalFormatting(){const e=this,t=e._conditionalFormatting;e._conditionalFormatting=e._formattingPanel.apply(),e.conditionalFormatting=e._formattingPanel.getItems(),e._conditionalFormatting!==t&&e._refreshDataRows()}_updateState(e,t){const a=this;let l;if("selected"===e&&(l=a.getSelection(),a.selected=l),-1===a.stateSettings.indexOf(e))return;const i=a._state;switch(e){case"columns":i.columns=a._columns;break;case"expanded":i.expanded=a._expandedIds;break;case"filtered":i.filtered=a._filterInfo;break;case"grouped":i.grouped=a.dataSource.groupBy._array.slice(0);break;case"selected":i.selected=l;break;case"sorted":i.sorted=a._sortColumns||[]}a.autoSaveState&&a.isRendered&&!1!==t&&window.localStorage.setItem("smartTable"+a.id,a._stringifyState())}_stringifyState(){const e=this,t=JSON.parse(JSON.stringify(e._state));return["columns","expanded","filtered","grouped","selected","sorted"].forEach((a=>{-1===e.stateSettings.indexOf(a)&&delete t[a]})),JSON.stringify(t,(function(e,t){if(!("function"==typeof t||t instanceof HTMLElement||"sortOrder"===e||"thHierarchy"===e))return t}))}_handleAutoSizeMode(){const e=this;if("default"===e.columnSizeMode){const t=e._columns.filter((e=>e.visible)),a=[],l=t=>{const a=t.headerCellElement;if(!a)return;const l=parseInt(t.minWidth||e.columnMinWidth);a.offsetWidth<l?a.style.width=l+"px":(a.style.width="",a.offsetWidth<l&&(a.style.width=l+"px"))};t.forEach((t=>{if(t.width||t._manualWidth||(l(t),a.push(t)),t.width&&"string"==typeof t.width&&t.width.endsWith("%")){const a=e._getColumnWidth(t.width,!1,t);!1===t.autoWidth?t.headerCellElement.style.width=t.width:(t.headerCellElement.setAttribute("responsive-width",t.width),t.headerCellElement.style.width=a+"px")}else if(t._manualPercentageWidth)if(t._isResponsive){const a=e._getColumnWidth(t._manualPercentageWidth+"%",!1,t);!1===t.autoWidth?t.headerCellElement.style.width=t.width:(t.headerCellElement.setAttribute("responsive-width",t._manualPercentageWidth+"%"),t.headerCellElement.style.width=a+"px")}else t.headerCellElement.style.width=t._manualWidth+"px"}));for(let e=0;e<a.length;e++)l(a[e]);if(e.columnResizeNormalize&&""===e._columns[e._columns.length-1].dataField){const t=e._columns[e._columns.length-1].headerCellElement.offsetWidth;if(t){let a=[];e._columns.forEach((e=>{e.width&&e.width.indexOf("%")>=0&&a.push(e)}));let l=t/a.length;a.forEach((e=>{e.width&&e.width.indexOf("%")>=0&&(e.headerCellElement.style.width=parseInt(e.headerCellElement.style.width)+l+"px")}))}}return}const t=e._columns.filter((e=>e.visible)),a=e._getNumericMinWidth();let l,i;t.forEach((e=>{e.width||e._manualWidth||(l||(l=e),i=e,e.headerCellElement.style.width=null)}));const n=e.$.tableContainer.offsetWidth-(e.selection?e.$.tableContainer.querySelector(".smart-table-select-all").offsetWidth:0);let r=new Map,o=0,s=0,d=0;e.removeAttribute("resize-max-reached"),e.setAttribute("auto-size",""),l&&(l.headerCellElement.style.width="100%");for(let i=0;i<t.length;i++){const n=t[i];if(n===l){d++;continue}const c=n.headerCellElement;let u,f;n.width?(u=f=e._getColumnWidth(n.width,!1,n),n.minWidth&&u<f&&(u=n.minWidth,f=n.minWidth)):n._manualWidth?(u=n._manualWidth,f=n.minWidth||a,u<f&&(u=f)):(u=Math.max(c.offsetWidth,a),f=n.minWidth||a,d++),o+=u,s+=f,n._isResponsive&&(u=e._getColumnWidth(n._manualPercentageWidth+"%",!1,n),u<f&&(u=f)),r.set(n,{width:u,minWidth:f})}function c(){l.headerCellElement.style.width=null;const e=Math.max(l.headerCellElement.offsetWidth,a),t=l.minWidth||a;r.set(l,{width:e,minWidth:t}),o+=Math.max(e,t),s+=t}if(l)if(l!==i)i.headerCellElement.style.width="100%",c(),i.headerCellElement.style.width=null;else if(t.length>1){const e=t.find((e=>e!==l));e.headerCellElement.style.width="100%",c(),e._isResponsive?e.headerCellElement.style.width=r.get(e).width+"%":e.headerCellElement.style.width=r.get(e).width+"px"}else c();if(n<=s||0===d)t.forEach((t=>{if(t._isResponsive){if(t.headerCellElement.style.width=(t._manualPercentageWidth?t._manualPercentageWidth+"%":r.get(t).minWidth)+"px",t._manualPercentageWidth){const a=e._getColumnWidth(t._manualPercentageWidth+"%",!1,t),l=t.minWidth||e.columnMinWidth;a===l&&(t.headerCellElement.style.width=l+"px")}}else t.headerCellElement.style.width=(t._manualWidth?t._manualWidth:r.get(t).minWidth)+"px"})),n<=s&&e.setAttribute("resize-max-reached","");else if(n>s)if(n<o){const a=[];let l,i=o-n,s=d;for(;i>0&&s>0;)l=Math.ceil(i/s),t.forEach((e=>{if(e.width||e._manualWidth||-1!==a.indexOf(e))return;const t=r.get(e);let n=Math.max(t.width-l,t.minWidth);const o=t.width-n;i-=o,n===t.minWidth&&(s--,a.push(e)),t.width=n}));t.forEach((t=>{if(t._isResponsive){if(t.headerCellElement.style.width=r.get(t).width+"%",t._manualPercentageWidth){const a=e._getColumnWidth(t._manualPercentageWidth+"%",!1,t),l=t.minWidth||e.columnMinWidth;a===l&&(t.headerCellElement.style.width=l+"px")}}else t.headerCellElement.style.width=r.get(t).width+"px"}))}else n===o?t.forEach((e=>{e._isResponsive?e.headerCellElement.style.width=r.get(e).width+"%":e.headerCellElement.style.width=r.get(e).width+"px"})):t.forEach((e=>{const t=r.get(e).width;e.headerCellElement.style.width=e===l?n-o+t+"px":t+"px"}));e.removeAttribute("auto-size")}_getNumericMinWidth(){const e=this,t=e.columnMinWidth;return"string"==typeof t&&-1!==t.indexOf("%")?e.offsetWidth*(parseFloat(t)/100):parseFloat(t)}_getCurrentResizeMax(){const e=this;if("default"===e.columnSizeMode)return 1/0;const t=e._resizeDetails,a=e._columns,l=a.find((e=>e.headerCellElement===t.Item)),i=a.indexOf(l);let n,r=a.length-1;for(let e=a.length-1;e>=0;e--)if(a[e].visible){r=e;break}if(i===r)return t.Item.offsetWidth;for(let t=i+1;t<a.length;t++){const l=a[t];t===r&&l.headerCellElement&&(n=l.headerCellElement.getBoundingClientRect()[e.rightToLeft?"left":"right"]+window.scrollX)}return n}_autoResizeColumnOnDblclick(){const e=this,t=e._resizeDetails,a=t.Item,l=e._columns.find((e=>e.headerCellElement!==a)).headerCellElement,i=l.style.width;e.setAttribute("auto-size",""),a.style.width=null,l.style.width="100%";let n=a.offsetWidth;l.style.width=i,e.removeAttribute("auto-size",""),n=Math.min(t.Max,Math.max(t.Min,n)),t.Width=n,e._resolveResize()}_isExpandCollapseForbidden(){const e=this;return(!e.hasAttribute("hierarchy")||e.grouping)&&"smart-pivot-table"!==e.nodeName.toLowerCase()}_selectSingle(e){const t=this,a=t.rowById?t.rowById[e]||t.dataSource.dataItemById[e]:t.rows.dataItemById[e];if(!a)return;const l=a.data?a.data.$.id:a.$.id;if(-1!==t._selectedIds.indexOf(l)||-1!==t._disabledSelection.indexOf(l))return;const i=t.$.tableContainer.querySelector(`tr[row-id="${l}"]:not([unused])`);if("one"===t.selectionMode&&(t._clearSelection(),t._selectedIds=[]),t._selectedIds.push(l),i){const e=i.firstElementChild;e.classList.remove("indeterminate"),e.classList.add("selected"),e.firstElementChild.setAttribute("aria-checked",!0),i.setAttribute("aria-selected",!0)}return t._handleHierarchicalSelection(a,!0),!0}_unselectSingle(e){const t=this,a=t.rowById?t.rowById[e]||t.dataSource.dataItemById[e]:t.rows.dataItemById[e];if(!a)return;const l=a.data?a.data.$.id:a.$.id,i=t._selectedIds.indexOf(l),n=t.$.tableContainer.querySelector(`tr[row-id="${l}"]:not([unused])`);if(-1!==i&&t._selectedIds.splice(i,1),n){const e=n.firstElementChild;e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1),n.setAttribute("aria-selected",!1)}return t._handleHierarchicalSelection(a,!1),!0}_changeSelectionOfMultiple(e,t,a="programmatic",l){const i=this;l||(l=JSON.stringify(i._selectedIds.slice(0).sort()));for(let a=0;a<e.length;a++)i[`_${t}Single`](e[a]);l!==JSON.stringify(i._selectedIds.slice(0).sort())&&(i._updateSelectAllState(),i._updateState("selected"),i.$.fireEvent("change",{type:a}))}_handleHierarchicalSelection(e,t){const a=this;if(!a.hasAttribute("hierarchy"))return;if(!1===a.selectionByHierarchy)return;const l=e.data;let i=l;for(l&&l.children&&function e(t,l){const i=t.children;let n=0;for(let t=0;t<i.length;t++){const r=i[t];if(!1===r.$.filtered)continue;let o=a._setThreeStateCheckbox(r,l);r.children&&r.children.length>0&&(o=e(r,l)),l&&!1===o&&n++}if(l&&n>0)return a._setThreeStateCheckbox(t,n!==i.length&&null)}(l,t);i&&i.parent;){const e=i.parent,t=a._getChildCheckState(e).state;a._setThreeStateCheckbox(e,t),i=e}}_getChildCheckState(e){const t=this,a=t._selectedIds,l=t._disabledSelection,i=e.children;if(!i||0===i.length||!t.selectionByHierarchy){const t=e.$.id,i=-1!==a.indexOf(t);return{state:i,maxSelected:!!i||-1!==l.indexOf(t)}}let n=!0,r=0,o=0,s=0;for(let e=0;e<i.length;e++){const a=i[e];if(!1===a.$.filtered)continue;const l=t._getChildCheckState(a);r++,l.state?o++:null===l.state?s++:!1===l.maxSelected&&(n=!1)}return 0!==o&&o===r?{state:!0,maxSelected:!0}:0===o&&0===s?{state:!1,maxSelected:n}:{state:null,maxSelected:n}}_setThreeStateCheckbox(e,t){const a=this,l=e.$.id,i=a._selectedIds,n=i.indexOf(l);t&&(-1!==a._disabledSelection.indexOf(l)?t=!1:-1===n&&i.push(l)),t||-1===n||i.splice(n,1);const r=a.$.tableContainer.querySelector(`tr[row-id="${l}"]:not([unused])`);if(!r)return t;const o=r.firstElementChild,s=o.firstElementChild;return t?(o.classList.remove("indeterminate"),o.classList.add("selected"),s.setAttribute("aria-checked",!0),r.setAttribute("aria-selected",!0)):!1===t?(o.classList.remove("selected","indeterminate"),s.setAttribute("aria-checked",!1),r.setAttribute("aria-selected",!1)):(o.classList.remove("selected"),o.classList.add("indeterminate"),s.setAttribute("aria-checked","mixed"),r.setAttribute("aria-selected",!1)),t}_getSelectableGroupRecords(){const e=this,t=e.dataSource,a=t.boundHierarchy;e._selectableGroupRecords=[],a?(function t(a){a.forEach((a=>{a.groupDataField&&(e._selectableGroupRecords.push(a.$.id),t(a.children))}))}(a),e._selectedIds=e._selectedIds.filter((a=>void 0!==t.dataItemById[a]||-1!==e._selectableGroupRecords.indexOf(a)))):e._selectedIds=e._selectedIds.filter((e=>void 0!==t.dataItemById[e]))}_clearSelection(e){const t=this;if(0===t._selectedIds.length)return;const a=t.$.tableContainer.querySelector(".smart-table-select-all");Array.from(t.$.tableContainer.querySelectorAll(".smart-table-select-row")).forEach((e=>{e.parentElement.classList.contains("disable-select")||e.parentElement.setAttribute("aria-selected",!1),e.classList.remove("selected","indeterminate"),e.firstElementChild.setAttribute("aria-checked",!1)})),a&&(a.classList.remove("indeterminate","selected"),a.firstElementChild.setAttribute("aria-checked",!1)),t._selectedIds=[],e&&(t._updateState("selected"),t.$.fireEvent("change",{type:"programmatic"}))}_updateCellsWithFormulas(e){const t=this,a=t.formulas,l=t._cellsWithFormulas;if(a||e)for(let e in l){const a=/(.+):(.+)/.exec(e),l=t.columnByDataField[a[1]],i=t.rowById[a[2]];if(!l||!i)continue;const n=t.$.tableContainer.querySelector(`tr[row-id="${i.data.$.id}"]:not([unused]) td[data-field="${l.dataField}"]`);n&&t._setCellContent(n,t._formatCellValue(i,l,n),n.classList.contains("tree-cell"))}}_createVirtualDataRows(e){const t=this,a=t.rowDetailTemplate,l=t.selection,i=t.hasAttribute("hierarchy"),n=document.createDocumentFragment(),r=t.$.virtualizationContainer,o=t.$.tableContainer,s=t._rowHeight;t.isRendered&&(r.scrollWidth=0,r.scrollHeight=0,r.$.scrollViewerContainer.classList.remove("hscroll","vscroll"));const d=r.$.scrollViewerContainer.offsetHeight-o.firstElementChild.offsetHeight-(t.filtering&&t.filterRow?s:0)-(t.footerRow?o.lastElementChild.offsetHeight:0),c=d<5,u=t._getVirtualRecords(i,c),f=u.length;let m=i?2*d:d+3*s,h=s*f,p=0;t._rowsVirtual=u,t._rowsInDOM=[];for(let e=0;e<f;e++){const r=u[e],o=r.data;if(!r.detail){if(o.groupDataField)t._rowsInDOM.push(t._createGroupHeader(o,n));else{const e=t._createDataRow(r,n,{hierarchical:i,rowDetailTemplate:a,selection:l,virtualization:!0});t._rowsInDOM.push(e.row),e.detail&&(t._rowsInDOM.push(e.detail),p+=t._rowDetailHeight,m+=t._rowDetailHeight)}if(p+=s,!c&&p>m)break}}e.appendChild(n),t._updateState("expanded"),e.parentElement||t.$.tableContainer.insertBefore(e,t.$.tableContainer.querySelector("tfoot")),r.refresh(),a&&(h+=t._expandedRowDetailIds.length*(t._rowDetailHeight-s));let g=Math.max(0,h-d);g>0&&r.computedHorizontalScrollBarVisibility&&(g+=r.$.horizontalScrollBar.offsetHeight),r.$.scrollViewerContentContainer.style.top=0,r.$.verticalScrollBar.max=g,t._scrollHeight=h,t._start={view:0,data:0},!c&&t._rowsInDOM.length>0&&r.$.scrollViewerContentContainer.offsetHeight<r.$.scrollViewerContainer.offsetHeight&&t._rowsInDOM[t._rowsInDOM.length-1].classList.add("last-row"),t._fixFrozenHeaderFirefox(),t._focusEquivalentCell()}_getVirtualRecords(e,t){const a=this,l=e&&!t?a.rows.filter((e=>0===e.data.level||!a._isCollapsed(e.data))):a.rows;if(e||!a.rowDetailTemplate)return l;const i=[];return l.forEach((e=>{i.push(e),-1!==a._expandedRowDetailIds.indexOf(e.data.$.id)&&i.push({detail:!0,data:e.data})})),i}_onVerticalChange(e,t){const a=this;if(a._ignoreVerticalChange)return;const l=a.rows,i=a._rowHeight,n=a.$.virtualizationContainer;let r,o,s=e.detail.value;if(Smart.Utilities.Core.Browser.Firefox&&a.virtualization&&(n.$.scrollViewerContentContainer.style.top=null),a.setAttribute("ignore-detail-animation",""),a._rowsInDOM.length===l.length||0===n.$.verticalScrollBar.max){const e=Math.floor(s/i);return a._start={view:e,data:e},n.$.scrollViewerContentContainer.style.top=-s+"px",requestAnimationFrame((()=>a.removeAttribute("ignore-detail-animation"))),void a._fixFrozenHeaderFirefox()}if(a._expandedRowDetailIds.length>0){let e,t=0;r=1;for(let l=0;l<a._rowsVirtual.length;l++){const i=t;if(a._rowsVirtual[l].detail?t+=a._rowDetailHeight:t+=a._rowHeight,void 0===o&&s<=t){o=l,e=s-i;break}}n.computedVerticalScrollBarVisibility?s=e+a._rowHeight:r=0}else{for(s=s%(2*i)+i,s<i&&(s+=i);s+n.$.scrollViewerContainer.offsetHeight>a.$.tableContainer.offsetHeight;)s-=i;r=Math.floor(s/i),o=Math.floor(e.detail.value/i),r<0&&(o-=r,r=0)}n.$.scrollViewerContentContainer.style.top=-s+"px",a._updateVisibleRows(r,o,t||a._expandedRowDetailIds.length>0),a._fixFrozenHeaderFirefox(),requestAnimationFrame((()=>a.removeAttribute("ignore-detail-animation")))}_fixFrozenHeaderFirefox(){const e=this;e.virtualization&&e.$.virtualizationContainer&&e.$.virtualizationContainer.$.scrollViewerContentContainer&&(e._tableHeader.style.top=-parseFloat(e.$.virtualizationContainer.$.scrollViewerContentContainer.style.top)+"px"),Smart.Utilities.Core.Browser.Firefox&&e.virtualization}_focusEquivalentCell(e){const t=this,a=t._focusedCell;if(!e&&!a)return;let l;if(!e){if(!a.parentElement)return;e={rowId:a.parentElement.data.$.id,dataField:a.getAttribute("data-field")}}l=e.dataField?t.$.tableContainer.querySelector(`tr[row-id="${e.rowId}"]:not([unused]) td[data-field="${e.dataField}"]`):t.$.tableContainer.querySelector(`tr[row-id="${e.rowId}"]:not([unused]) td.group-header`),t._focusCell(l)}_detachCachedTemplates(){const e=this;e._cachedTemplates&&(delete e._cachedTemplates,e._tableCachedTemplates&&(e._tableCachedTemplates.remove(),delete e._tableCachedTemplates))}_clearCachedTemplates(){const e=this;if(e._cachedTemplates&&Object.keys(e._cachedTemplates).length>0){e._tableCachedTemplates||(e._tableCachedTemplates=document.createElement("div"),e._tableCachedTemplates.style.display="none",document.body.appendChild(e._tableCachedTemplates));const t=document.createDocumentFragment();for(let a in e._cachedTemplates)t.appendChild(e._cachedTemplates[a]);e._tableCachedTemplates.appendChild(t)}}_updateVisibleRows(e,t,a){const l=this,i=t-e,n=l._rowsVirtual.length,r={hierarchical:l.hasAttribute("hierarchy"),selection:l.selection};let o;if(a=a&&(r.hierarchical||!!l.rowDetailTemplate),r.hierarchical&&!l.grouping&&(a=!0),l._sortColumns&&l._sortColumns.length>0&&(a=!0),l._focusedCell){const e=l._focusedCell.parentElement;e&&(o={rowId:e.data.$.id,dataField:l._focusedCell.getAttribute("data-field")})}for(let t=0;t<e;t++){const e=l._rowsInDOM[t];let n=i+t;n>=0&&(a||e.data.$.index!==n||e.data.detail)&&l._updateVisibleRow(e,n,r),e.setAttribute("unused",""),e.setAttribute("aria-hidden",!0),e.classList.remove("smart-table-row-detail")}for(let t=e;t<l._rowsInDOM.length;t++){const e=l._rowsInDOM[t],o=i+t;o<n?(e.removeAttribute("unused"),e.removeAttribute("aria-hidden"),(a||e.data.$.index!==o||e.data.parent)&&l._updateVisibleRow(e,o,r)):e.setAttribute("aria-hidden",!0)}l._start={view:e,data:t},l._focusEquivalentCell(o)}_updateVisibleRow(e,t,a){const l=this,i=l._columns.filter((e=>e.visible));if(!i.length)return;const n=l._rowsVirtual[t],r=n.data,o=r.$.id,s=Number(a.selection),d=!r.groupDataField&&!e.firstElementChild.classList.contains("group-header")&&!n.detail&&!e.classList.contains("smart-table-row-detail")&&e.childElementCount>1;if(e.className="",d){const t=e.attributes;for(;t.length>0;)e.removeAttribute(t[0].name)}else e.innerHTML="";if(r.groupDataField)l._createGroupHeader(r,void 0,e);else if(n.detail)l._createRowDetailOnDemand(e,n,r);else{e.setAttribute("aria-rowindex",r.$.index+1),l._processAndRenderSelection(r,e,a.hierarchical,d);for(let t=0;t<i.length;t++){const c=i[t];let u=d?e.children[t+s]:document.createElement("td"),f=!1;if(u&&(l.grouping&&!r.groupDataField||l.dataSource&&l.dataSource.groupBy&&l.dataSource.groupBy.length>0)&&u.removeAttribute("colspan"),!u){if(!d)continue;u=document.createElement("td"),f=!0,e.appendChild(u)}d&&(u.className=""),u.setAttribute("data-field",c.dataField),u.setAttribute("aria-colindex",t+1+s);let m,h=l._formatCellValue(n,c,u);if(f&&l._setCellContent(u,h,m),c.freeze&&u.classList.add("freeze-"+("far"===c.freeze?"far":"near")),c.responsivePriority&&u.classList.add("priority-"+c.responsivePriority),!1===c.allowEdit?(u.classList.add("no-edit"),u.setAttribute("aria-readonly",!0)):u.removeAttribute("aria-readonly"),0===t&&a.hierarchical){const e=l._areChildrenFiltered(r);r.leaf||(u.classList.add("tree-cell"),m=e),r.level&&(u.classList.add("outline-level-"+Math.min(r.level,10)),!r.leaf&&e||u.classList.add("tree-leaf"))}if(c.templateElement){if(f&&l.grouping){const e=c.templateElement+"",t=u;e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=e}else if(a.hierarchical&&l.grouping&&r.leaf){const e=c.templateElement+"",t=u;if((!t.firstElementChild||!(t.firstElementChild.hasAttribute("ng-version")||t.innerHTML.indexOf("ng-version")>=0))&&t.firstElementChild&&!t.firstElementChild.classList.contains(".smart-table-cell-template")){const a=t.innerHTML;e.substring(e.lastIndexOf("</"))!==a.substring(a.lastIndexOf("</"))&&(e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=e)}}if(m&&!u.querySelector(".hierarchy-arrow")){l._setCellContent(u,h,m);const e=u.children[0].children[1],t=c.templateElement+"";t.indexOf("{{value}}")>=0?e.innerHTML=t.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):e.innerHTML=t}else if(a.hierarchical&&!l.grouping&&r.leaf){const e=u;if(!e.firstElementChild||!(e.firstElementChild.hasAttribute("ng-version")||e.innerHTML.indexOf("ng-version")>=0)){l._setCellContent(u,h,!1);const t=c.templateElement+"";t.indexOf("{{value}}")>=0?e.innerHTML=t.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):e.innerHTML=t}}if(!d){const e=c.templateElement+"",t=m?u.children[0].children[1]:u;e.indexOf("{{value}}")>=0?t.innerHTML=e.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=e}let e=m?u.children[0].children[1].firstElementChild:u.firstElementChild;if(!e&&a.hierarchical){l._setCellContent(u,h,!1);const t=u,a=c.templateElement+"";a.indexOf("{{value}}")>=0?t.innerHTML=a.replace(/{{value}}/gi,'<div class="smart-table-cell-template">'+r[c.dataField]+"</div>"):t.innerHTML=a,e=m?u.children[0].children[1].firstElementChild:u.firstElementChild}c.templateElementSettings?c.templateElementSettings(r[c.dataField],o,e):c.templateElement.indexOf("{{value}}")>=0&&(u.querySelector(".smart-table-cell-template").textContent=r[c.dataField])}else c.formatFunction,l._setCellContent(u,h,m);l.onCellRender&&l.onCellRender(r,c.dataField,r[c.dataField],u),l._applyConditionalFormattingToCell(u,c.dataField,r.$.index),d||e.appendChild(u)}e.data=r,e.setAttribute("row-id",o),-1!==l._disabledSelection.indexOf(o)&&(e.removeAttribute("aria-selected"),e.classList.add("disable-select"),a.selection&&e.firstElementChild.firstElementChild.setAttribute("aria-disabled",!0)),r.expanded?(-1===l._expandedIds.indexOf(o)&&l._expandedIds.push(o),e.setAttribute("aria-expanded",!0),e.classList.add("expanded")):!1===r.expanded&&e.setAttribute("aria-expanded",!1),r.level&&l._isCollapsed(r)&&(e.setAttribute("aria-hidden",!0),e.classList.add("collapsed","smart-hidden"))}}_createRowDetailOnDemand(e,t,a){const l=this,i=Number(l.selection)+l._columns.filter((e=>e.visible)).length;e.data=Object.assign(a,{detail:!0}),e.classList.add("smart-table-row-detail"),e.removeAttribute("aria-rowindex"),e.removeAttribute("row-id"),e.innerHTML=`<td colspan="${i}"><div class="smart-table-detail-container">${l._applyRowDetailTemplate(t)}</div></td>`}_hierarchyArrowClickHandlerVirtualization(e,t){const a=this,l=!a.grouping,i=a.$.tableContainer,n={nextRow:e.nextElementSibling,tbody:i.children[1]},r=e.data,o=[],s=[],d=Math.ceil((a.$.virtualizationContainer.$.scrollViewerContainer.offsetHeight-i.firstElementChild.offsetHeight)/a._rowHeight);function c(){0===o.length?function(){if(a._ignoreVerticalChange=!0,r.expanded=!r.expanded,l)r.expanded?(-1===a._expandedIds.indexOf(r.$.id)&&a._expandedIds.push(r.$.id),a.$.fireEvent("expand",{id:r.$.id,record:r})):(a._expandedIds=a._expandedIds.filter((e=>e!==r.$.id)),a.$.fireEvent("collapse",{id:r.$.id,record:r})),a._updateState("expanded");else if(!0!==t){const e=t=>{for(let a=0;a<t.length;a++){const l=t[a];if(l.$.id===r.$.id)return l;if(l.children){let t=e(l.children);if(t)return t}}return null},t=e(a.dataSource.boundHierarchy);t&&(t.expanded=r.expanded);let l=""+r.$.id;l=l.replace("Item","").replace(/_/gi,"."),r.expanded?a.$.fireEvent("group",{action:"expand",path:l,dataField:r.groupDataField,label:r.label}):a.$.fireEvent("group",{action:"collapse",path:l,dataField:r.groupDataField,label:r.label})}for(const e of s)e.remove();let e=a.$.virtualizationContainer.$.verticalScrollBar,i=a.$.virtualizationContainer.$.verticalScrollBar.value;a._refreshDataRows(),i=Math.min(e.max,i),e.value=i,delete a._ignoreVerticalChange,a._onVerticalChange({detail:{value:i}},!0)}():requestAnimationFrame((()=>c()))}function u(e){for(const t of e){if(s.length>=d)break;!1!==t.$.filtered&&(s.push(a._expandSingleChildRowVirtualization(t,n,o)),t.children&&t.expanded&&u(t.children))}}r.expanded?function e(t){t.forEach((t=>{a._collapseSingleChildRow(i.querySelector(`tr[row-id="${t.$.id}"]:not([unused])`),o),t.children&&e(t.children)}))}(r.children):requestAnimationFrame((()=>u(r.children))),e.setAttribute("aria-expanded",!r.expanded),e.classList.toggle("expanded",!r.expanded),requestAnimationFrame((()=>c()))}_expandSingleChildRowVirtualization(e,t,a){const l=this,i=l.rowById[e.$.id],n=document.createDocumentFragment();let r;if(i){if(r=i.data.groupDataField?l._createGroupHeader(i.data,n):l._createDataRow(i,n,{virtualization:!0,hierarchical:!0,selection:l.selection}).row,-1===[...t.tbody.children].indexOf(t.nextRow)){let a=!1;e.children&&0===e.children.length&&(a=!0),e.children||(a=!0),l._rowsInDOM&&l._rowsInDOM.length===l.rows.length&&(a=!0),a||t.tbody.appendChild(n)}else t.tbody.insertBefore(n,t.nextRow);return l._expandSingleChildRow(r,a),r}}_getFractionOfMax(){const e=this;return e.isRendered&&e.virtualization?{vertical:function(){const t=e.$.virtualizationContainer.$.verticalScrollBar,a=t.max;return 0===a?0:t.value/a}(),horizontal:function(){const t=e.$.virtualizationContainer.$.horizontalScrollBar,a=t.max;return 0===a?0:t.value/a}()}:null}_setFractionOfMax(e){if(!this.virtualization||null===e)return;const t=this.$.virtualizationContainer,a=t.$.verticalScrollBar,l=t.$.horizontalScrollBar;a.value=a.max*e.vertical,l.value=l.max*e.horizontal}_refreshHorizontalScrollbar(){const e=this.$.virtualizationContainer;if(!e)return;const t=e.$.scrollViewerContainer,a=e.$.horizontalScrollBar,l=e.$.verticalScrollBar,i=e.$.scrollViewerContentContainer.offsetWidth-t.offsetWidth;let n,r;i>0&&!t.classList.contains("hscroll")?(t.classList.add("hscroll"),n="add"):i<=0&&t.classList.contains("hscroll")&&(r=a.offsetHeight,t.classList.remove("hscroll"),n="subtract"),e.scrollWidth!==i&&(e.scrollWidth=i),e.computedVerticalScrollBarVisibility&&("add"===n?(r=a.offsetHeight,l.max+=r):"subtract"===n&&(l.max-=r))}_scrollToVirtualization(e,t){const a=this;if(!a.virtualization)return;const l=a.$.virtualizationContainer,i=l.$.scrollViewerContentContainer,n=l.$.verticalScrollBar,r=l.$.horizontalScrollBar,o=a.$.tableContainer,s=i.offsetLeft,d=i.offsetTop,c=n.value;let u,f;switch(t&&(u=t.offsetLeft,f=t.offsetTop),e){case"nextArrow":{if(!t||!l.computedHorizontalScrollBarVisibility)return;const e=s+u+t.offsetWidth-l.offsetWidth;e>0&&(r.value+=e+n.offsetWidth);break}case"prevArrow":if(!t||!l.computedHorizontalScrollBarVisibility||u>=-s)return;r.value=u-s-r.value;break;case"ArrowUp":{const e=o.firstElementChild.offsetHeight-d-f;if(e<=0)return;let t;if(a._focusedCell){const e=a._focusedCell.parentElement;e&&(t={rowId:e.data.$.id,dataField:a._focusedCell.getAttribute("data-field")})}const l=Math.max(0,c-e);l!==c&&(n.value=l,a._focusEquivalentCell(t));break}case"ArrowDown":{const e=d+f+t.offsetHeight-l.offsetHeight;if(e<=0)return;const a=Math.min(n.max,c+e);a!==c&&(n.value=a);break}case"Home":case"End":if(!l.computedHorizontalScrollBarVisibility)return;r.value="Home"===e?0:r.max}}_getExpandedGroups(e){const t=this,a=[];return e?(function e(l){l.forEach((l=>{l.expanded&&a.push({groupDataField:l.groupDataField,label:l.label,ancestorSignature:t._getGroupAncestorSignature(l)}),l.children&&l.children.length>0&&!1===l.children[0].leaf&&e(l.children)}))}(e),a):[]}_getGroupAncestorSignature(e){const t=[];let a=e.parent;for(;a;)t.push({groupDataField:a.groupDataField,label:a.label}),a=a.parent;return JSON.stringify(t)}_restoreExpandedGroups(e){if(0===e.length)return;const t=this,a=t.dataSource,l=[];!function a(i){i&&i.forEach(((i,n)=>{if(e.some((e=>e.groupDataField===i.groupDataField&&e.label===i.label&&e.ancestorSignature===t._getGroupAncestorSignature(i)))){let e=i.$.id;"string"==typeof e&&(e=e.replace("Item","").replace(/_/g,".")),0===i.level?l.push(n):l.push(e)}i.children&&i.children.length>0&&!1===i.children[0].leaf&&a(i.children)}))}(a.boundHierarchy);const i=t._doNotFireEvent;t._doNotFireEvent=!0,l.forEach((e=>t.expandGroup(e))),t._doNotFireEvent=i}});