-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsmart.grid.edit.js
6 lines (4 loc) · 82.5 KB
/
smart.grid.edit.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.Utilities.Assign("Grid.Edit",class{_renderCommandBar(){const e=this,t=e.editing.commandBar.dataSource,i="icon"!==e.editing.commandBar.displayMode,n="label"!==e.editing.commandBar.displayMode,o=o=>{for(let l in t){const a=t[l],d=document.createElement("div");d.classList.add("smart-grid-command-item"),d.label="{{messages}}"===a.label?e.localize(l):a.label;const r=d.label;let s="";n&&i?(s+='<span class="smart-grid-icon '+a.icon+'"></span>',s+='<span class="smart-grid-label">'+r+"</span>"):n&&!i?s+='<span title="'+r+'" class="smart-grid-icon '+a.icon+'"></span>':i&&!n&&(s+='<span class="smart-grid-label">'+r+"</span>"),d.innerHTML=s,a.visible||d.classList.add("smart-hidden"),d.command=a.command,d.onclick=function(){const t=d.command;e._applyCommand(t,[])},o.appendChild(d)}};e.editing.enabled&&e.editing.commandBar.visible&&(e.$.headerCommandBar.innerHTML="",e.$.footerCommandBar.innerHTML="","far"!==e.editing.commandBar.position&&o(e.$.headerCommandBar),"near"!==e.editing.commandBar.position&&o(e.$.footerCommandBar))}commandKeyEditCommand(){const e=this;if(e._selection&&e._selection.focusedCell&&void 0!==e._selection.focusedCell.id){const t=e.rowById[e._selection.focusedCell.id];e.beginEdit(t.id)}}commandKeyCancelCommand(){this.cancelEdit()}commandKeyUpdateCommand(){this.endEdit()}commandColumnMenuCommand(){this._openColumnChooserMenu(this._commandColumn)}commandColumnEditCommand(e){this.beginEdit(e.id)}commandColumnUpdateCommand(){this.endEdit()}commandColumnRowMenuCommand(){}commandColumnCancelCommand(e){const t=this;if(t.editing.batch){const i=t._rowsDeleted?t._rowsDeleted.indexOf(e):-1;i>=0&&t._rowsDeleted.splice(i,1);for(let i=0;i<t.columns.length;i++){const n=t.columns[i].dataField;t._cellsUpdatedValues&&t._cellsUpdatedValues[e.id+"_"+n]&&(delete t._cellsUpdatedValues[e.id+"_"+n],t._cellsUpdatedValues.length--)}t._recycle(!1)}t.cancelEdit()}commandColumnDeleteCommand(e){this.deleteRow(e.id)}_renderAddNewRow(){const e=this;e._frozenNearDefaultRows=[],e._frozenFarDefaultRows=[];const t=new Smart.Grid.Row({data:{},index:-1,grid:e,freeze:"near",visible:"far"!==e.editing.addNewRow.position,autoGenerated:!0,addNewRow:!0}),i=new Smart.Grid.Row({data:{},index:-2,grid:e,freeze:"far",visible:"near"!==e.editing.addNewRow.position,autoGenerated:!0,addNewRow:!0});if(e._newNearRow){const t=e._frozenNearRows.indexOf(e._newNearRow);if(t>=0&&(e._frozenNearRows.splice(t,1),e.$.rowNearContainer.children.length>0)){const t=e.$.rowNearContainer.children[0];t.parentNode.removeChild(t)}}if(e._newFarRow){const t=e._frozenFarRows.indexOf(e._newFarRow);if(t>=0&&(e._frozenFarRows.splice(t,1),e.$.rowFarContainer.children.length>0)){const t=e.$.rowFarContainer.children[e.$.rowFarContainer.children.length-1];t.parentNode.removeChild(t)}}e.editing.addNewRow.visible&&"button"!==e.editing.addNewRow.displayMode&&(e._frozenNearDefaultRows.push(t),e._frozenFarDefaultRows.push(i),e._frozenNearRows.splice(0,0,t),e._frozenFarRows.push(i));const n=()=>{e.editing.addNewRow.autoCreate&&e._scrollView.vScrollBar.value===e._scrollView.vScrollBar.max&&(e.addUnboundRow(1),e._scrollView.vScrollBar.value=e._scrollView.vScrollBar.max),"button"===e.editing.addNewRow.displayMode&&e._scrollView.vScrollBar.value===e._scrollView.vScrollBar.max&&(e._add({}),e._scrollView.vScrollBar.value=e._scrollView.vScrollBar.max)};if(e._addRowOnButtonClickHandler||(e._addRowOnButtonClickHandler=n),e._scrollView&&e._scrollView.vScrollBar&&(e._scrollView.vScrollBar.$.farButton.removeEventListener("click",e._addRowOnButtonClickHandler),e._scrollView.vScrollBar.$.farButton.addEventListener("click",e._addRowOnButtonClickHandler)),e._newNearRow=t,e._newFarRow=i,e.editing.addNewRow.visible&&"button"!==e.editing.addNewRow.displayMode){if(!e._newNearRow.element){const t=e._newNearRow,i=t.createElement();t.visible="far"!==e.editing.addNewRow.position,t.element=i,e.$.rowNearContainer.children.length>0?e.$.rowNearContainer.insertBefore(i,e.$.rowNearContainer.children[0]):e.$.rowNearContainer.appendChild(i)}if(!e._newFarRow.element){const t=e._newFarRow,i=t.createElement();t.visible="near"!==e.editing.addNewRow.position,t.element=i,e.$.rowFarContainer.children.length>0?e.$.rowFarContainer.insertBefore(i,e.$.rowFarContainer.children[0]):e.$.rowFarContainer.appendChild(i)}}}_insertNewRowAfter(e){return this._insertNewRowBefore(e,!0)}_insertNewRowBefore(e,t=!1){const i=this,n=new Smart.Grid.Row({index:t?0:-1,id:Smart.Utilities.Core.createGUID(),grid:i}),o={};for(let e=0;e<i.columns.length;e++){const t=i.columns[e];void 0!==t.defaultValue&&(o[t.dataField]=t.defaultValue)}n.data=o;const l=function(t,n){i._suppressSort=i._suppressFilter=!0;const o=e=>{i._supressEnter=!0,i.scrollTop=n?i.scrollHeight:0,i.editing.addDialog.enabled||setTimeout((function(){if(i.editing.enabled&&i.editing.addNewRow.autoEdit){i.ensureVisible(e.id);let t=null;if(!t)if(i.columns[0]&&i.columns[0].allowEdit&&i.columns[0].visible)t=i.columns[0].dataField;else for(let e=0;e<i.columns.length;e++)if(i.columns[e].allowEdit&&i.columns[e].visible){t=i.columns[e].dataField;break}const n=()=>{i._selection.focusedCell={id:e.id,dataField:t,index:e.index},i._selection.rows=[],i._selection.columns=[],i._selection.cells=[],i._setSelection(e.id,t)};i.paging.enabled?setTimeout((()=>{if(!e.element){const t=e.createElement();e.element=t}n(),i._beginEdit(e)}),200):(n(),i._beginEdit(e))}}),100),i._suppressSort=i._suppressFilter=!1};!0===i.editing.batch||i.editing.batch&&i.editing.batch.indexOf("add")>=0?(i._batchAddRow(t,n?i.rows.length:0),o(t),e&&e(t)):i.addRow(t.data,n,(t=>{o(t),e&&e(t)}))}.bind(this);return i.editing.addDialog.enabled?i._openAddRowDialog(n,l):l(n,t),!0}commandBarBatchSaveCommand(){this._saveBatchEdit()}commandBarAddRowCommand(){this._insertNewRowAfter()}commandBarAddTopRowCommand(){this._insertNewRowBefore()}commandBarDeleteRowCommand(){const e=this;let t=1,i=e.rows[e.rows.length-t];for(e._rowsDeleted||(e._rowsDeleted=[]);e._rowsDeleted.indexOf(e.rows[e.rows.length-t])>=0;)t++;if(i=e.rows[e.rows.length-t],e.selection.enabled)if(e.selection.allowCellSelection){const t=e.getSelectedCells();if(t.length>0){const n=t[0][0];i=e.rowById[n]}}else{const t=e.getSelectedRowIds();t.length>0&&(i=e.rowById[t[0]])}i&&e.commandColumnDeleteCommand(i)}commandBarBatchRevertCommand(){this.revertBatchEdit()}_beginEdit(e,t){const i=this;if(!t)if(i.columns[0]&&i.columns[0].allowEdit&&i.columns[0].visible)t=i.columns[0].dataField;else for(let e=0;e<i.columns.length;e++)if(i.columns[e].allowEdit&&i.columns[e].visible){t=i.columns[e].dataField;break}const n=i.columnByDataField[t];if(i.editing.allowColumnHeaderEdit&&!e&&n)return void i._beginColumnEdit(n);if(!e||!n||n&&n.autoGenerated)return!1;const o=e.getCell(t);if(!o)return!1;i.$.fireEvent("beginEdit",{id:e.id,dataField:n.dataField,row:e,column:n,cell:o,data:o.row.data,value:o.value}).defaultPrevented||("cell"===i.editing.mode?i._beginCellEdit(o):"row"===i.editing.mode&&i._beginRowEdit(e,o))}_saveUnboundRows(e){const t=this;if(t._unboundRows&&t._unboundRows.length>0&&t.editing.addNewRow.autoSave){const i=t.rowById[e];if(!i.unbound)return;const n=t._unboundRows.indexOf(i);if(n<0)return;const o=n+1;t.beginUpdate();for(let e=0;e<o;e++){const i=t._unboundRows[e];if(!i)continue;delete t.rowById[i.id],i.unbound=!1;let n=!1;t._selection.focusedCell&&t._selection.focusedCell.id===i.id&&(n=!0),t._nearRowsAdded&&t._nearRowsAdded.indexOf(i)>=0?(t._nearRowsAdded.splice(t._nearRowsAdded.indexOf(i),1),t._add(0,i.data),n&&(t._selection.focusedCell.id=t.rows[0].id,t._selection.focusedCell.index=t.rows[0].index)):t._farRowsAdded&&t._farRowsAdded.indexOf(i)>=0&&(t._farRowsAdded.splice(t._farRowsAdded.indexOf(i),1),t._add(i.data),n&&(t._selection.focusedCell.id=t.rows[t.rows.length-1].id,t._selection.focusedCell.id=t.rows[t.rows.length-1].index))}t._unboundRows.splice(0,o),t.endUpdate()}}_validateCell(e,t,n){const o=this;if(o._errorOverlay&&(o._errorOverlay.remove(),o._errorMessage.remove(),o._isUpdating=!1),e.column.validationRules||n||e.column.editor&&e.column.editor.onValidate){let l={},a=e._updating;if(e._updating=!0,e.error="",n){for(let i in n)n[i]&&"valid"!==i&&(e.error=n.message),"custom"===i&&n[i].minLength?e.error=o.localize("invalidCellValue",{value:t,validationRule:"minLength: "+n[i].value}):"custom"===i&&n[i].maxLength&&(e.error=o.localize("invalidCellValue",{value:t,validationRule:"maxLength: "+n[i].value}));e.error&&(o._isUpdating=!0)}for(let n of e.column.validationRules){switch(n.type){case"min":l.min=i.min(t,n.value);break;case"max":l.max=i.max(t,n.value);break;case"minLength":l.minLength=i.minLength(t,n.value);break;case"maxLength":l.maxLength=i.maxLength(t,n.value);break;case"minDate":l.minDate=i.minDate(t,n.value);break;case"maxDate":l.maxDate=i.maxDate(t,n.value);break;case"required":l.required=i.required(t);break;case"requiredTrue":l.requiredTrue=i.requiredTrue(t);break;case"pattern":l.pattern=i.pattern(t,n.value);break;case"email":l.email=i.email(t);break;case"null":l.null=i.null(t)}l[n.type]&&(n.message?e.error=n.message:e.error=o.localize("invalidCellValue",{value:t,validationRule:void 0!==n.value?n.type+": "+n.value:n.type}),e._updating=a,o._isUpdating=!0,e.element&&e.element.setAttribute("error",e.error),e.row.element.setAttribute("error",""),o.clearSelection())}if(e.column.editor&&e.column.editor.onValidate){const i=e.column.editor.onValidate(t,e.row.data);"string"==typeof i&&(e.error=i,e._updating=a,o._isUpdating=!0,e.element&&e.element.setAttribute("error",e.error),e.row.element.setAttribute("error",""),o.clearSelection())}if(e._updating=a,e.error){o._errorOverlay=o._createOverlay(),o._errorOverlay.onpointerdown=function(){o.endEdit()};const t=document.createElement("div");t.innerHTML=e.error,t.classList.add("smart-grid-validation-error");const i=o.offset(e.element),n=e.element.getBoundingClientRect(),l=o.offset(o);return i.left=i.left-l.left,i.top=i.top-l.top,i.top+n.height+5-o.offsetTop>o.offsetHeight?t.style.top=i.top-n.height-5-o.offsetTop+"px":t.style.top=i.top+n.height+5-o.offsetTop+"px",t.style.left=i.left-o.offsetLeft+"px",o._errorMessage=t,o.$.root.appendChild(o._errorOverlay),o.$.root.appendChild(o._errorMessage),!1}o._isUpdating=!1}return!0}_endCellEdit(e){const t=this,i=e||t.editing.editCell;if(!i||i&&!i.isEditing)return null;let n=t._getEditorValue(i),o=null;n&&n.error&&(i.canNotify=!1,i.element.setAttribute("error",""),i.row.element.setAttribute("error",""),i.error=!0,i.canNotify=!0,o=n.validity,n=n.value);const l=function(e,t){return"date"===i.column.dataType?e&&t?e.valueOf()===t.valueOf():!e&&!t:!("any"!==i.column.dataType||void 0===e||void 0===t||!Array.isArray(e)||0!==e.length||""!==t)||(!(null!=t&&""!==t||null!==e&&""!==e)||e===t)},a=function(){const e=t._getEditorId(i);t._cellEditors[e].detach(),i.row.element.removeAttribute("edit"),i.element&&(i.element.removeAttribute("editor"),i.element.removeAttribute("error")),i.row.element.removeAttribute("error"),i.isEditing=!1,i.element&&(i.element.content.innerHTML="");const o=function(){t.editing.editRow||(t.dataSource&&t.dataSource.boundHierarchy?(t.dataSource.refreshHierarchy(),t._refreshRowHierarchy(),t.refresh()):t.layout.allowCellsWrap?t.refresh():t._recycle(!1))},a=t._cellsUpdatedValues?t._cellsUpdatedValues[i.row.id+"_"+i.column.dataField]:void 0,d=void 0!==a?a:i.value,r=()=>{if(t._fireEndEdit){let e=i.value;if(t.editing.batch&&i.row&&i.column){const t=i.modifiedValue;void 0!==t&&(e=t)}t.$.fireEvent("endEdit",{id:i.row.id,dataField:i.column.dataField,row:i.row,column:i.column,cell:i,data:i.row.data,value:e}),t._fireEndEdit=!1}};if(l(n,d))r(),t.editing.editCell=null,t.editing.editRow||(t.editing.isEditing=!1,o());else{const e=function(){t.editing.editCell=null,t.editing.editRow||(t.editing.isEditing=!1),delete t._editInfo};if(!0===t.editing.batch||t.editing.batch&&t.editing.batch.indexOf("update")>=0)e(),t._batchUpdateCell(i.row,i.column,n,i.value),o(),r();else{const l=function(){e(),i._updating=!0,i.value=n,i._updating=!1,o(),r()};if(!t.editing.editRow&&t.dataSource&&t.dataSource.virtualDataSource){const e={};e[i.column.dataField]=n,t.updateRow(i.row.id,e,(()=>{l()}))}else l()}}return t.editing.commandColumn.visible&&!t.editing.commandColumn.width&&"cell"===t.editing.mode&&t.refresh(),t.focus(),!0};let d=t._validateCell(i,n,o);if(!d)return i.editor.instance&&!i.editor.autoOpen&&setTimeout((()=>{i.editor.instance.focus()}),50),!1;const r=t._cellsUpdatedValues?t._cellsUpdatedValues[i.row.id+"_"+i.column.dataField]:void 0,s=void 0!==r?r:i.value;if(l(n,s))return a(),!!d;if(t._setCellUndoRedo(i,s,n),t.onCellUpdate&&!t.editing.editRow){t.beginUpdate(),t.appearance.displayLoadingIndicator=!0,t._setLoadingIndicatorVisibility();const e=t._createOverlay();t.$.root.appendChild(e),t.onCellUpdate([i],[s],[n],(function(o){o?a():t.cancelEdit(),t.appearance.displayLoadingIndicator=!1,t._setLoadingIndicatorVisibility(),e.parentNode.removeChild(e),t.endUpdate(),t.onCellUpdated&&t.onCellUpdated([i.row.index],[i.row],[i.column],[i.row.data],[s],[n],t),t._onCellUpdated&&t._onCellUpdated(i.row.index,i.row,i.column,i.row.data,s,n)}),t)}else if(t.onRowUpdate){t.beginUpdate(),t.appearance.displayLoadingIndicator=!0,t._setLoadingIndicatorVisibility();const e=t._createOverlay();t.$.root.appendChild(e);const o=i.column.dataField,l=Object.assign({},i.row.data),d=Object.assign({},i.row.data);d[o]=n,t.onRowUpdate([i.row.index],[i.row],[l],[d],(function(n){n?a():t.cancelEdit(),t.appearance.displayLoadingIndicator=!1,t._setLoadingIndicatorVisibility(),e.parentNode.removeChild(e),t.endUpdate(),t.onRowUpdated&&t.onRowUpdated([i.row.index],[i.row],[i.row.data],t),t._onRowUpdated&&t._onRowUpdated(i.row.index,i.row,i.row.data)}),t)}else a();return!!d}_endRowEdit(){const e=this,t=e.editing.editRow;if(!t)return!1;let i=!0;const n=t.cells;let o={},l={};t.element.removeAttribute("error");for(let a=0;a<n.length;a++){const d=n[a];let r=e._getEditorValue(d),s=null;r&&r.error&&(d.canNotify=!1,d.element.setAttribute("error",""),d.row.element.setAttribute("error",""),d.error=!0,d.canNotify=!0,s=r.validity,r=r.value),o[d.column.dataField]=d.value,l[d.column.dataField]=r;if(!e._validateCell(d,r,s))return i=!1,t.element.setAttribute("error",""),e._isUpdating=!0,d.editor.instance&&setTimeout((()=>{d.editor.instance.focus()}),50),!1}if(i){const i=function(){const i=e._fireEndEdit;e._fireEndEdit=!1;for(let t=0;t<n.length;t++){const i=n[t];e._endCellEdit(i)}e._fireEndEdit=i,e.onRowUpdate||null===e.onRowUpdated||e.onRowUpdated([t.index],[t],[t.data],e),e.editing.isEditing=!1,e.editing.editRow=null,e.editing.commandColumn.visible&&!e.editing.commandColumn.width?e.refresh():e._recycle(!1)};if(!0===e.editing.batch||e.editing.batch&&e.editing.batch.indexOf("update")>=0)i();else if(e.onRowUpdate){e.beginUpdate(),e.appearance.displayLoadingIndicator=!0,e._setLoadingIndicatorVisibility();const n=e._createOverlay();e.$.root.appendChild(n);const a=e.onRowHistory;e.onRowHistory=null,t.updatedDate=new Date,t.updatedBy=e.currentUser,e.storeHistory&&e._updateRowHistory(t,o,l),setTimeout((()=>{e.onRowHistory=a}),100),e.onRowUpdate([t.index],[t],[o],[l],(function(o){const l=e.onRowUpdate,a=e.onCellUpdate;e.onRowUpdate=null,e.onCellUpdate=null,o?i():e.cancelEdit(),e.onRowUpdate=l,e.onCellUpdate=a,e.appearance.displayLoadingIndicator=!1,e._setLoadingIndicatorVisibility(),n.parentNode.removeChild(n),e.endUpdate(),e.onRowUpdated&&e.onRowUpdated([t.index],[t],[t.data])}),e)}else if(e.dataSource&&e.dataSource.virtualDataSource&&e.editing.isEditing){e.beginUpdate(),e.appearance.displayLoadingIndicator=!0,e._setLoadingIndicatorVisibility();const t=e._createOverlay();e.$.root.appendChild(t);let n=Object.assign({},e.editing.editRow.data);for(let t=0;t<e.editing.editRow.cells.length;t++){const i=e.editing.editRow.cells[t];if(!i.column.allowEdit)continue;const o=e._getEditorValue(i);void 0!==o&&(n[i.column.dataField]=o)}e._editInfo={row:n},e._virtualDataRequest("update",(function(n){n?i():e.cancelEdit(),e.appearance.displayLoadingIndicator=!1,e._setLoadingIndicatorVisibility(),t.parentNode.removeChild(t),e.endUpdate()}))}else i();return!0}return e.focus(),!1}_batchDeleteRow(e){const t=this;if(t._rowsDeleted||(t._rowsDeleted=[]),t.onRowRemove){if(!1===t.onRowRemove([e.id],t))return}t._rowsDeleted.push(e.id),t._recycle(!1),t.onRowRemoved&&t.onRowRemoved([e.id],[e.data.$.index],t)}_batchAddRow(e,t){const i=this;i._rowsAdded||(i._rowsAdded=[]),i._rowsAdded.push(e.id),i.rowById[e.id]=e,e.index=i.rows.length+(i._rowsAdded?i._rowsAdded.length:0),0===t?i._nearRowsAdded.splice(0,0,e):i._farRowsAdded.push(e);i.isInitialized&&i._rowElements&&i._rowElements.length<i.rows.length+i._rowsAdded.length&&i._initializeRowElements(),i.refresh()}_batchUpdateCell(e,t,i,n){const o=this;o._cellsUpdatedValues||(o._cellsUpdatedValues=[]);!function(e,i){return"date"===t.dataType?!(!e&&i)&&(!(e&&!i)&&e.valueOf()===i.valueOf()):e===i}(i,n)?o._cellsUpdatedValues[e.id+"_"+t.dataField]=i:delete o._cellsUpdatedValues[e.id+"_"+t.dataField],o._cellsUpdatedValues.length++}_saveBatchEdit(){const e=this;for(let t in e._cellsUpdatedValues){const i=e._cellsUpdatedValues[t],n=t.substring(0,t.indexOf("_")),o=t.substring(t.indexOf("_")+1),l=e.rowById[n],a=l.getCell(o);if(e.dataSource.virtualDataSource){const t={};t[a.column.dataField]=i,l.data.$&&l.data.$.id?e.updateRow(l.data.$.id,t):(a._updating=!0,a.value=i,a._updating=!1)}else a._updating=!0,a.value=i,a._updating=!1}const t=e._rowsDeleted&&e._rowsDeleted.length>0||e._rowsAdded&&e._rowsAdded.length>0;if(t&&e.beginUpdate(),e._rowsAdded&&e._rowsAdded.length>0)for(let t in e._rowsAdded){const i=e._rowsAdded[t],n=e.rowById[i];if(n){if(e._rowsDeleted&&e._rowsDeleted.length>0){let t=!1;for(let n=0;n<e._rowsDeleted.length;n++){if(e._rowsDeleted[n].id===i){t=!0;break}}if(t)continue}e.dataSource.virtualDataSource?e.addRow(n.data,!0):e._nearRowsAdded.indexOf(n)>=0?e.rows.splice(0,0,n):e._farRowsAdded.indexOf(n)>=0&&e.rows.push(n)}}if(e._rowsDeleted&&e._rowsDeleted.length>0)for(let t=0;t<e._rowsDeleted.length;t++){const i=e._rowsDeleted[t],n=e.rowById[i];if(n)if(e.dataSource&&e.dataSource.virtualDataSource)e._editInfo={row:n.data},e._virtualDataRequest("remove",(function(t){if(t){const t=e.rows.indexOf(n);e.rows.splice(t,1),delete e.rowById[n.id]}}));else{const t=e.rows.indexOf(n);e.rows.splice(t,1)}}t&&e.endUpdate(),e._clearBatchEdit(!1),e.$.fireEvent("saveBatchEdit")}_clearBatchEdit(){const e=this;let t=!1;e._rowsAdded&&e._rowsAdded.length>0&&(t=!0),e._cellsUpdatedValues=[],e._rowsAdded=[],e._rowsDeleted=[],e._nearRowsAdded=[],e._farRowsAdded=[],t?e.refresh():e._recycle(!1),e.$.fireEvent("clearBatchEdit")}_getEditorId(e){const t=e.column._editorId?e.column._editorId:"";return e.editor!==e.column.editor?e.editor.template+"_"+e.column.dataField+"_"+e.row.id+t:e.editor.template+"_"+e.column.dataField+t}_applyCommand(e,t){const i=this;t||(t=[]);const n=function(){"function"==typeof e?e.apply(i,t):i[e]?i[e].apply(i,t):Smart[e]?Smart[e].apply(i,t):window[e]&&window[e].apply(i,t)};if(i.onCommand){t||(t=[]),t[1]||(t[1]=null);const o={name:e,command:n,details:t[0],event:t[1],handled:!1};setTimeout((()=>{i.onCommand.apply(i,[o]),o.handled||n()}),200)}else n()}_getCommandColumnCommandsTemplate(){const e=this,t=e.editing.commandColumn.dataSource,i="icon"!==e.editing.commandColumn.displayMode,n="label"!==e.editing.commandColumn.displayMode;let o="";for(let l in t){const a=t[l];let d="<div",r=!1;if("commandColumnMenu"===l)continue;r||(d+=' item="'+l+'" command="'+a.command+'" class="smart-grid-command-item">',r=!0);const s="{{messages}}"===a.label?e.localize(l):a.label;n&&i?(d+='<span class="smart-grid-icon '+a.icon+'"></span>',d+='<span class="smart-grid-label">'+s+"</span>"):n&&!i?d+='<span title="'+s+'" class="smart-grid-icon '+a.icon+'"></span>':i&&!n&&(d+='<span class="smart-grid-label">'+s+"</span>"),d+="</div>",o+=d}return o}_updateCommandColumnCommandsVisibility(e,t){const i=this,n=e.children,o=i.editing.commandColumn.dataSource;for(let e=0;e<n.length;e++){const l=n[e],a=l.getAttribute("item"),d=o[a].visible;!0===d?l.classList.remove("smart-hidden"):!1===d?l.classList.add("smart-hidden"):"auto"===d&&(!i.editing.dialog.enabled&&(i.editing.editRow===t||i.editing.editCell&&i.editing.editCell.row===t)?"commandColumnEdit"===a?l.classList.add("smart-hidden"):"commandColumnUpdate"!==a&&"commandColumnCancel"!==a||n[e].classList.remove("smart-hidden"):"commandColumnEdit"===a?l.classList.remove("smart-hidden"):"commandColumnUpdate"!==a&&"commandColumnCancel"!==a||n[e].classList.add("smart-hidden"))}}_handleEditKeyDown(e){const t=this,i=e.key,n=t.editing.commandKeys;if(!t.editing.dialog.enabled)for(let o in n){const l=n[o],a=l.key.replace(/ /gi,"").split("|");if(("Tab"!==i||!t.editing.editRow)&&a.indexOf(i)>=0){if(t._applyCommand(l.command),"Enter"===i&&e){if(e.stopPropagation(),t._supressEnter)return void delete t._supressEnter;t.selection.enabled&&t.selection.allowCellSelection&&t._keyDownHandler(e)}break}}}_getCustomCellEditor(e){const t=this;e.editor.selector=e.editor.template,e.editor.template="custom";const i=t._getEditorId(e);if(!t._cellEditors[i]){let n=document.createElement("div");t._applyCellEditorUserSettings(n,e),n.classList.add("smart-grid-cell-editor");const o=function(e){"keydown"!==e.type||t._handleEditKeyDown(e)},l=function(){const t=e.editor.instance.element.firstElementChild;Smart.Utilities.Core.isMobile||(e.editor.focus?setTimeout((function(){e.editor.focus.apply(e.editor.instance.element,[])}),50):setTimeout((function(){t.focus()}),50))},a=function(t){const i=e.editor.instance.element.firstElementChild;e.editor.blur?e.editor.blur.apply(e.editor.instance.element,[t]):i.blur()},d=function(t){const i=e.editor.instance.element.firstElementChild;if(!e.editor.isInitialized&&e.editor.settings&&i)for(let t in e.editor.settings)i[t]=e.editor.settings[t];if(e.editor.setValue)e.editor.setValue.apply(e.editor.instance.element,[t]);else{if(i.innerHTML.indexOf("{{")>=0){const n=i.innerHTML.replace(/{{value}}/gi,t).replace(/{{id}}/gi,e.row.id);i.innerHTML=n}i.value=t,t instanceof Date&&(i.value=t.toISOString().split("T")[0]),e.editor.instance.element.value=i.value}},r=function(){const t=e.editor.instance.element.firstElementChild;if(e.editor.getValue){const i=t.querySelector("input");return i&&i.blur(),e.editor.getValue.apply(e.editor.instance.element,[t.value])}const i=t.value;return e.editor.settings&&e.editor.settings.valueProperty?i?Array.isArray(i)&&i.length>0?i[0][e.editor.settings.valueProperty]:i[e.editor.settings.valueProperty]:"":i||""},s=function(){n.removeEventListener("keydown",o),e.editor.detach&&e.editor.detach.apply(n,[])},c=function(){n.addEventListener("keydown",o),e.editor.attach&&e.editor.attach.apply(n,[])};let u=null;if((e.editor.selector.startsWith("#")||e.editor.selector.startsWith("."))&&(u=document.querySelector(e.editor.selector)),u)n.appendChild(u.content.cloneNode(!0).firstElementChild);else{const i=function(e){const t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild}(e.editor.selector);if(i){if("#text"===i.nodeName)return t._getInputCellEditor(e);n.appendChild(i)}}t._cellEditors[i]={element:n,focus:l,blur:a,getValue:r,setValue:d,attach:c,detach:s}}return t._cellEditors[i]}_getSliderCellEditor(e){const t=this,i=t._getEditorId(e),n=document.createElement("div"),o=document.createElement("input"),l=document.createElement("div"),a=document.createElement("smart-number-input");if(o.type="range",o.step="0.01",t._applyCellEditorUserSettings(n,e),"{}"===JSON.stringify(a.numberFormat)){let i={};if(e.column.cellsFormat)if(e.column.cellsFormat.indexOf("c")>=0){i={style:"currency",currency:t.messages[t.locale].calendar.currency};let n=parseInt(e.column.cellsFormat.substring(1));isNaN(n)||(i.maximumFractionDigits=n)}else if(e.column.cellsFormat.indexOf("p")>=0){i={style:"percent"};let t=parseInt(e.column.cellsFormat.substring(1));isNaN(t)||(i.maximumFractionDigits=t)}else e.column.Intl&&e.column.Intl.NumberFormat&&(i=e.column.Intl.NumberFormat);a.numberFormat=i}e.editor.min&&(o.min=a.min=e.editor.min),e.editor.max&&(o.max=a.max=e.editor.max),n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-slider-cell-editor"),l.classList.add("nav"),a.classList.add("smart-flex"),a.style.paddingLeft="6px",l.classList.add("smart-icon-resize-full","smart-grid-icon");const d=function(e){if("keydown"===e.type&&(t._handleEditKeyDown(e),"Backspace"!==e.key&&"Delete"!==e.key&&"Tab"!==e.key&&"Escape"!==e.key&&!e.altKey&&!e.shiftKey))return l.click(),void e.preventDefault()};l.onclick=function(){const i=document.createElement("div"),n=document.createElement("input");n.type="range";const d=e.editor.instance.element,r=document.createElement("div");r.classList.add("smart-slider-editor"),i.setAttribute("theme",t.theme),r.appendChild(n);const s=Smart.Utilities.Core.createGUID().replace(/-/gi,"");i.id="Slider"+s,d.setAttribute("aria-owns",i.id),r.classList.add("smart-grid-slider-container"),n.value=o.value,o.min&&(n.min=o.min),o.max&&(n.max=o.max),l.sliderEditorDialog=i,l.popupSlider=n,n.onchange=n.oninput=function(){a.value=parseFloat(n.value)};const c=e=>{e&&e.key&&("Enter"===e.key&&(i.parentNode.removeChild(i),o.value=parseFloat(n.value),t.endEdit()),"Escape"===e.key&&(i.parentNode.removeChild(i),t.cancelEdit()))};a.onchange=a.onkeyup=e=>{n.value=a.value,c(e)},n.onkeydown=function(e){c(e)},i.classList.add("smart-grid-slider-dialog"),i.appendChild(r),document.body.appendChild(i),i.style.top=t._offsetTop(d)+d.offsetHeight+"px",i.style.left=t._offsetLeft(d)+15+d.offsetWidth-i.offsetHeight+"px",i.style.width=d.offsetWidth+"px";const u=t._offsetLeft(t)+t.offsetWidth;t._offsetLeft(d)+i.offsetWidth>u&&(i.style.left=u-i.offsetWidth-10+"px")};let r=e.value;void 0===r&&(r=0),a.value=r,o.value=r,n.appendChild(a);const s=e=>{"Escape"===e.key&&(l.sliderEditorDialog&&l.sliderEditorDialog.parentNode.removeChild(l.sliderEditorDialog),t.cancelEdit()),"Enter"===e.key&&(l.sliderEditorDialog&&l.sliderEditorDialog.parentNode.removeChild(l.sliderEditorDialog),o.value=parseFloat(a.value),t.endEdit())};return t._cellEditors[i]={element:n,focus:function(){l.click(),Smart.Utilities.Core.isMobile||setTimeout((function(){a.focus(),t.$.scrollView.scrollTop=0}),50)},blur:function(){},setValue:function(e){o.value=void 0!==e&&""!==e?parseFloat(e):0,a.isReady&&a.setValue(e)},getValue:function(){const e=parseFloat(o.value);return l.sliderEditorDialog&&l.sliderEditorDialog.parentNode?(o.value=parseFloat(l.popupSlider.value),o.value):e},attach:function(){o.addEventListener("keydown",d),a.addEventListener("keydown",s)},detach:function(){o.removeEventListener("keydown",d),a.removeEventListener("keydown",s),l.sliderEditorDialog&&l.sliderEditorDialog.parentNode&&(o.value=l.popupSlider.value,l.sliderEditorDialog.parentNode.removeChild(l.sliderEditorDialog))}},t._cellEditors[i]}_getTextAreaCellEditor(e){const t=this,i=t._getEditorId(e),n=document.createElement("div"),o=document.createElement("textarea"),l=document.createElement("div");t._applyCellEditorUserSettings(n,e),o.style.direction="",t.rightToLeft&&(o.style.direction="rtl"),e.editor.min&&(o.minLength=e.editor.min),e.editor.max&&(o.maxLength=e.editor.max),o.classList.add("smart-input"),n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-text-area-cell-editor"),l.classList.add("nav"),l.classList.add("smart-icon-resize-full","smart-grid-icon");const a=function(e){if("keydown"===e.type&&(t._handleEditKeyDown(e),"Backspace"!==e.key&&"Delete"!==e.key&&"Tab"!==e.key&&"Escape"!==e.key&&!e.altKey&&!e.shiftKey))return l.click(),void e.preventDefault()};l.onclick=function(){const n=document.createElement("div"),a=document.createElement("textarea"),d=e.editor.instance.element,r=document.createElement("div"),s=document.createElement("smart-scroll-bar");l.textAreaEditorDialog&&l.textAreaEditorDialog.parentNode&&l.textAreaEditorDialog.parentNode.contains(l.textAreaEditorDialog)&&l.textAreaEditorDialog.parentNode.removeChild(l.textAreaEditorDialog),n.id="TextArea"+i,d.setAttribute("aria-owns",n.id),t.rightToLeft&&(a.style.direction="rtl"),s.orientation="vertical",s.onpointerdown=e=>{e.preventDefault(),e.stopPropagation()},n.setAttribute("theme",t.theme),r.appendChild(a),r.classList.add("smart-grid-text-area-container"),r.appendChild(s),a.value=o.value,a.classList.add("smart-input"),o.minLength>=0&&(a.minLength=o.minLength),o.maxLength>=0&&(a.maxLength=o.maxLength),l.textAreaEditorDialog=n,l.popupTextArea=a;const c=function(){s.value=a.scrollTop,s.max=a.scrollHeight-a.offsetHeight,s.onChange=null,a.offsetHeight>=a.scrollHeight?s.classList.add("smart-hidden"):s.classList.remove("smart-hidden"),s.onChange=function(){a.scrollTop=s.value}};if(a.onkeyup=function(){c()},a.onscroll=function(){c()},a.onkeydown=function(e){if(a._key=e.key,"Escape"===e.key){try{n.parentNode.contains(n)&&n.parentNode.removeChild(n)}catch(e){n.error=e}t.editing.editCell&&t.cancelEdit()}("Tab"===e.key||"Enter"===e.key&&e.shiftKey)&&(o.value=a.value,t.editing.editCell?t.endEdit():a.blur(),e.preventDefault(),e.stopPropagation())},n.classList.add("smart-grid-text-area-dialog"),n.appendChild(r),document.body.appendChild(n),setTimeout((function(){Smart.Utilities.Core.isMobile||a.select(),c()}),50),c(),n.style.top=t._offsetTop(d)+"px",n.style.left=t._offsetLeft(d)+"px",n.style.width=d.offsetWidth+"px",t.grouping.enabled&&e.column._treeColumn){const e=d.parentNode.parentNode;n.style.top=t._offsetTop(e)+"px",n.style.left=t._offsetLeft(e)+"px",n.style.width=e.offsetWidth+"px"}a.onblur=()=>{"Escape"!==a._key&&(o.value=l.popupTextArea.value),o.focus();try{l.textAreaEditorDialog.parentNode&&l.textAreaEditorDialog.parentNode.removeChild(l.textAreaEditorDialog)}catch(e){l.error=e}}},n.appendChild(o);return t._cellEditors[i]={element:n,focus:function(){l.click()},blur:function(){},setValue:function(e){const i=t._unescapeString(e);o.value=i,l.popupTextArea&&(l.popupTextArea.value=o.value)},getValue:function(){const e=o.value;return l.textAreaEditorDialog&&l.textAreaEditorDialog.parentNode?(o.value=l.popupTextArea.value,o.value):e},attach:function(){o.addEventListener("keydown",a)},detach:function(){if(o.removeEventListener("keydown",a),l.textAreaEditorDialog&&l.textAreaEditorDialog.parentNode){o.value=l.popupTextArea.value;try{l.textAreaEditorDialog.parentNode&&l.textAreaEditorDialog.parentNode.removeChild(l.textAreaEditorDialog)}catch(e){l.error=e}}}},t._cellEditors[i]}_getColorInputCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=t._getColorInput();t._applyCellEditorUserSettings(n,e),n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-color-input-cell-editor"),n.dropDownWidth=50,n.autocomplete="off",n.style.direction="",t.rightToLeft&&(n.rightToLeft=!0);const o=function(e){"keydown"!==e.type||t._handleEditKeyDown(e)},l=function(){Smart.Utilities.Core.isMobile||setTimeout((function(){n.select()}),50)},a=function(){},d=function(e){n.value=e},r=function(){return n.value},s=function(){n.removeEventListener("keydown",o)},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:a,getValue:r,setValue:d,attach:c,detach:s}}return t._cellEditors[i]}_getInputCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=document.createElement("input");t._applyCellEditorUserSettings(n,e),e.editor.min&&(n.minLength=e.editor.min),e.editor.max&&(n.maxLength=e.editor.max),n.classList.add("smart-input"),n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-input-cell-editor"),n.autocomplete="off",n.style.direction="",t.rightToLeft&&(n.style.direction="rtl");const o=function(i){if("keydown"===i.type)return"number"!==e.column.dataType&&"int"!==e.column.dataType&&"float"!==e.column.dataType||t.editing.editColumn||i.key.match(/[0-9]/)||"-"===i.key||1!==i.key.length?void t._handleEditKeyDown(i):(i.preventDefault(),void i.stopPropagation())},l=function(){Smart.Utilities.Core.isMobile||setTimeout((function(){n.select()}),50)},a=function(){},d=function(i){if(e.column.rowHeaderColumn&&!i)return void(n.value=e.editor.row.visibleIndex+1);if("number"===e.column.dataType||"int"===e.column.dataType||"float"===e.column.dataType){if(""===i)return;if(i&&!i.toString().match(/[0-9]/)&&"-"!==i)return}const o=t._unescapeString(i);n.value=o},r=function(){return n.value},s=function(){n.removeEventListener("keydown",o)},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:a,getValue:r,setValue:d,attach:c,detach:s}}return t._cellEditors[i]}_applyCellEditorUserSettings(e,t){for(let i in t.editor)"template"!==i&&("list"!==i?"onInit"!==i&&"onRender"!==i&&(e[i]=t.editor[i]):e.setAttribute(i,t.editor[i]));if(t.editor.settings)for(let i in t.editor.settings)e[i]=t.editor.settings[i]}_getCheckInputCellEditor(e){return this._getAutoCompleteCellEditor(e,"smart-check-input")}_getMultiInputCellEditor(e){return this._getAutoCompleteCellEditor(e,"smart-multi-input")}_getMultiComboInputCellEditor(e){const t=this._getAutoCompleteCellEditor(e,"smart-multi-combo-input");return"tags"!==e.column.template&&"collaborator"!==e.column.template||(t.getValue=()=>{const e=t.element.selectedItems;if(e&&0===e.length)return"";let i=[];for(let t=0;t<e.length;t++){const n=e[t];"string"==typeof n?i.push(n):i.push(n.value)}return i.toString()},t.setValue=e=>{if(e&&e.indexOf("{")>=0||e&&e.indexOf("[")>=0)t.element.selectedItems=JSON.parse(e);else if(e&&e.indexOf(",")>=0)if(e=e.split(",").map((e=>e.trim())),t.element.readonly){let i=[];t.element.dataSource.forEach((t=>{for(let n=0;n<e.length;n++){const o=e[n];("string"==typeof t&&""+t===o||t&&void 0!==t.label&&""+t.value===o)&&i.push(t)}})),t.element.selectedItems=i}else t.element.selectedItems=e;else if(t.element.readonly){let i=[];t.element.dataSource.forEach((t=>{("string"==typeof t&&""+t===e||t&&void 0!==t.label&&""+t.value===e)&&i.push(t)})),t.element.selectedItems=i}else t.element.value=e},t.focus=function(){if(Smart.Utilities.Core.isMobile)return;const e=t.element;setTimeout((()=>{t.element.readonly?t.element.focus():e&&e.select&&e.select()}),50)}),t}_getAutoCompleteCellEditor(e,t){const i=this,n=i._getEditorId(e);if(i._cellEditors[n]&&e.column.editor.isDirty&&(delete e.column.editor.isDirty,delete i._cellEditors[n]),!i._cellEditors[n]){let o=document.createElement("smart-input");t&&(o=document.createElement(t)),i._applyCellEditorUserSettings(o,e),o.readonly&&(o.dropDownButtonPosition="right"),o.dropDownOpenPosition="auto";const l=function(e){o.opened||"keydown"!==e.type||i._handleEditKeyDown(e)};o.rightToLeft=i.rightToLeft,o.classList.add("smart-grid-cell-editor"),o.classList.add("smart-grid-auto-complete-cell-editor");const a=function(){Smart.Utilities.Core.isMobile||setTimeout((()=>{o&&o.select&&o.select()}),50)},d=function(e){e&&1===e.length&&o.readonly||(o.value=null!==e?e:"")},r=function(){return o.value},s=function(){o&&o.close&&(o.value="",o.close(),o.removeEventListener("keydown",l))},c=function(){},u=function(){o.addEventListener("keydown",l)};i._cellEditors[n]={element:o,focus:a,blur:c,setValue:d,getValue:r,attach:u,detach:s}}if(e.editor.dataSource||e.editor.isInitialized){if(e.column.editor.collaborator){let t=[];for(let e=0;e<i.users.length;e++)t.push({color:i.users[e].color,label:i.users[e].name,id:i.users[e].id,value:i.users[e].id,name:i.users[e].name,image:i.users[e].image});e.column.editor.singleSelect&&(t=[""].concat(t)),t&&i._cellEditors[n]&&i._cellEditors[n].element&&i._cellEditors[n].element.dataSource&&JSON.stringify(t)!==JSON.stringify(i._cellEditors[n].element.dataSource)&&(i._cellEditors[n].element.dropDownHeight="auto",i._cellEditors[n].element.dataSource=t,e.column.editor.dataSource=t)}}else{const t=i.getVisibleRows(),o=[];for(let n=0;n<t.length;n++){let l=i.dataSource[t[n].index];if(l){if(l=l[e.column.dataField],!l)continue;-1===o.indexOf(l)&&o.push(l)}}o.length<7?i._cellEditors[n].element.dropDownHeight="auto":i._cellEditors[n].element.dropDownHeight=200,i._cellEditors[n].element.dataSource=o}return i._cellEditors[n]}_getDateRangeInputCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=document.createElement("smart-date-range-input");n.dropDownButtonPosition="right",n.dropDownAppendTo="body",n.autoClose=!0,n.selectionMode="default",n.rightToLeft=t.rightToLeft,n.timepicker=!0,t._applyCellEditorUserSettings(n,e);const o=function(e){n.opened||"keydown"!==e.type||t._handleEditKeyDown(e)};n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-date-time-picker-cell-editor");const l=function(){Smart.Utilities.Core.isMobile||setTimeout((()=>{n.select()}),50)},a=function(e){n.value=e},d=function(){return n._performSelect(),n.selectedDates},r=function(){n.value="",n.close(),n.removeEventListener("keydown",o)},s=function(e){const i=n.getAttribute("aria-controls");if(i&&n.opened){const n=t.getBoundingRect(document.getElementById(i));e.pageX<n.left||e.pageX>n.right||e.pageY<n.top||e.pageY>n.bottom||e.preventDefault()}},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:s,setValue:a,getValue:d,attach:c,detach:r}}return t._cellEditors[i]}_getDateTimePickerCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=document.createElement("smart-date-time-picker");n.calendarButton=!0,n.dropDownAppendTo="body",n.autoClose=!0,n.dropDownDisplayMode="calendar",n.rightToLeft=t.rightToLeft,e.column.cellsFormat&&(n.formatString=e.column.cellsFormat),t._applyCellEditorUserSettings(n,e);const o=function(e){n.opened||"keydown"!==e.type||t._handleEditKeyDown(e)};n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-date-time-picker-cell-editor");const l=function(){setTimeout((()=>{if(n.autoOpen&&!t.editing.editRow)n.open();else{if(Smart.Utilities.Core.isMobile)return;n.select()}}),50)},a=function(e){if("string"==typeof e&&1===e.length){if("string"==typeof e&&n.autoOpen&&"Invalid Date"===(e=new Date(e)).toString())return;n.$.input.value=e}else n.value=e},d=function(){return n.value&&n.value instanceof Smart.Utilities.DateTime?(n._validateValue(n.$.input.value),n.value.toDate()):n.value},r=function(){n.value="",n.close(),n.removeEventListener("keydown",o)},s=function(e){const i=n.getAttribute("aria-controls");if(i&&n.opened){const n=t.getBoundingRect(document.getElementById(i));e.pageX<n.left||e.pageX>n.right||e.pageY<n.top||e.pageY>n.bottom||e.preventDefault()}},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:s,setValue:a,getValue:d,attach:c,detach:r}}return t._cellEditors[i]}_getTimeInputCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=document.createElement("smart-time-input");n.calendarButton=!0,n.dropDownAppendTo="body",n.autoClose=!0,n.dropDownDisplayMode="calendar",n.rightToLeft=t.rightToLeft,t._applyCellEditorUserSettings(n,e);const o=function(e){n.opened||"keydown"!==e.type||t._handleEditKeyDown(e)};n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-date-time-picker-cell-editor");const l=function(){Smart.Utilities.Core.isMobile||setTimeout((()=>{n.select()}),50)},a=function(e){n.value=e},d=function(){const e=new Date;return e.setHours(n.value[0]),e.setMinutes(n.value[1]),"Invalid Date"===e.toString()?new Date:e},r=function(){n.value="",n.close(),n.removeEventListener("keydown",o)},s=function(e){const i=n.getAttribute("aria-controls");if(i&&n.opened){const n=t.getBoundingRect(document.getElementById(i));e.pageX<n.left||e.pageX>n.right||e.pageY<n.top||e.pageY>n.bottom||e.preventDefault()}},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:s,setValue:a,getValue:d,attach:c,detach:r}}return t._cellEditors[i]}_getDateInputCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=document.createElement("smart-date-input");n.calendarButton=!0,n.dropDownAppendTo="body",n.autoClose=!0,n.dropDownDisplayMode="calendar",n.rightToLeft=t.rightToLeft,n.formatString=(!e.column.cellsFormat||1!==e.column.cellsFormat.length&&"d"!==e.column.cellsFormat)&&e.column.cellsFormat?e.column.cellsFormat:"MM/dd/yyyy",t._applyCellEditorUserSettings(n,e);const o=function(e){n.opened?"Enter"!==e.key&&"Escape"!==e.key||t._handleEditKeyDown(e):"keydown"!==e.type||t._handleEditKeyDown(e)};n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-date-time-picker-cell-editor");const l=function(){setTimeout((()=>{if(e.editor.autoOpen&&!t.editing.editRow)n.open();else{if(Smart.Utilities.Core.isMobile)return;n.select()}}),50)},a=function(e){"string"==typeof e&&e.length>1&&"Invalid Date"===(e=new Date(e)).toString()||(n.value=e)},d=function(){return n.getValue()},r=function(){n.value="",n.close(),n.removeEventListener("keydown",o)},s=function(e){const i=n.getAttribute("aria-controls");if(i&&n.opened){const n=t.getBoundingRect(document.getElementById(i));e.pageX<n.left||e.pageX>n.right||e.pageY<n.top||e.pageY>n.bottom||e.preventDefault()}},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:s,setValue:a,getValue:d,attach:c,detach:r}}return t._cellEditors[i]}_getAttachmentCellEditor(e){const t=this,i=t._getEditorId(e);if(t._dialogFile&&(t._dialogFile.cell=e),!t._cellEditors[i]){const n=document.createElement("div");n.innerHTML=`\n <div style="display: grid;"><div title="${t.localize("addAttachments")}" class="smart-grid-icon smart-icon-plus show"></div><div class="attachments"><div class="container"></div></div></div>\n `,n.rightToLeft=t.rightToLeft,n.tabIndex=0,n.firstElementChild.style.gridTemplateColumns="25px 1fr",t.rightToLeft&&(n.style.direction="rtl");const o=n.querySelector(".smart-grid-icon"),l=n.querySelector(".attachments");o.onpointerdown=()=>{t._openFileDialog(t._dialogFile?t._dialogFile.cell:e,!0)},l.onclick=e=>{const i=JSON.parse(n.value),o=[...l.children[0].children].indexOf(e.target.parentNode);if(i[o]){const e=document.createElement("a");if(i[o].value.indexOf(window.location.host)>=0)fetch(i[o].value).then((e=>e.blob())).then((t=>{const n=URL.createObjectURL(t);e.download=i[o].label,e.href=n,e.click()}));else{if(i[o].value.indexOf("base64")>=0){const n=t._getFileFromBase64(i[o].value);e.href=URL.createObjectURL(n)}else e.href=i[o].value;e.target="_blank",e.click()}}},n.ondrop=i=>{i.preventDefault(),t._openFileDialog(t._dialogFile?t._dialogFile.cell:e,!0),t._dialogFile.dropZone.dropHere(i)},n.ondragover=e=>{e.preventDefault()},t._applyCellEditorUserSettings(n,e),n.classList.add("smart-grid-cell-editor");const a=function(){n.focus(),setTimeout((()=>{n.focus()}),50)},d=function(e){n.value=e,l.innerHTML=`<div class="container"><div style="justify-content: center; align-items: center; display: flex; margin-top: 3px;" class="smart-drop-file smart-micro smart-quiet">${t.localize("dropFiles")}</div></div>`;const i=l.firstElementChild;if(t._findIsFile(e)){let t="";try{t=JSON.parse(e)}catch(e){console.log(e)}e=t}Array.isArray(e)&&(i.innerHTML="",e.forEach((e=>{const t=document.createElement("div");t.title=e.label,t.classList.add("item"),t.innerHTML="<div></div>",t.firstElementChild.classList.add("smart-grid-icon","show","attachment"),e.label.indexOf("png")>=0||e.label.indexOf("jpg")>=0||e.label.indexOf("jpeg")>=0||e.label.indexOf("gif")>=0?t.firstElementChild.classList.add("smart-icon-image"):e.label.indexOf(".pdf")>=0?t.firstElementChild.classList.add("smart-icon-pdf"):e.label.indexOf(".tsv")>=0||e.label.indexOf(".txt")>=0||e.label.indexOf(".csv")>=0?t.firstElementChild.classList.add("smart-icon-text"):e.label.indexOf(".xls")>=0||e.label.indexOf(".xlsx")>=0?t.firstElementChild.classList.add("smart-icon-excel"):e.label.indexOf(".ppt")>=0?t.firstElementChild.classList.add("smart-icon-powerpoint"):e.label.indexOf(".zip")>=0||e.label.indexOf(".rar")>=0||e.label.indexOf(".7z")>=0?t.firstElementChild.classList.add("smart-icon-archive"):e.label.indexOf(".doc")>=0||e.label.indexOf(".docx")>=0?t.firstElementChild.classList.add("smart-icon-word"):t.firstElementChild.classList.add("smart-icon-file"),i.appendChild(t)})))},r=function(){let e=n.value;return e&&(Array.isArray(e)||("string"==typeof e&&e.indexOf("base64"))>=0)&&Array.isArray(e)&&(e=JSON.stringify(e)),e},s=i=>{("+"===i.key||i.altKey&&"ArrowDown"===i.key)&&t._openFileDialog(t._dialogFile?t._dialogFile.cell:e.true),"Escape"===i.key&&t.cancelEdit(),"Enter"===i.key&&t.endEdit()},c=function(){n.value="",t._dialogFile&&t._dialogFile.close(),n.removeEventListener("keydown",s)},u=function(){},m=function(){n.addEventListener("keydown",s)};t._cellEditors[i]={element:n,focus:a,blur:u,setValue:d,getValue:r,attach:m,detach:c}}return t._cellEditors[i]}_getImageCellEditor(e){const t=this,i=t._getEditorId(e);if(t._dialogFile&&(t._dialogFile.cell=e),!t._cellEditors[i]){const n=document.createElement("div");n.innerHTML=`\n <div style="display: grid;"><div title="${t.localize("addImages")}" class="smart-grid-icon smart-icon-plus show"></div><div class="images"><div class="container"></div></div></div>\n `,n.rightToLeft=t.rightToLeft,n.tabIndex=0,n.firstElementChild.style.gridTemplateColumns="25px 1fr",t.rightToLeft&&(n.style.direction="rtl");const o=n.querySelector(".smart-grid-icon"),l=n.querySelector(".images");o.onpointerdown=()=>{t._openFileDialog(t._dialogFile?t._dialogFile.cell:e)},l.onclick=e=>{"IMG"===e.target.nodeName&&t._openImagePreviewDialog(e.target)},n.ondrop=i=>{i.preventDefault(),t._openFileDialog(t._dialogFile?t._dialogFile.cell:e),t._dialogFile.dropZone.dropHere(i)},n.ondragover=e=>{e.preventDefault()},t._applyCellEditorUserSettings(n,e),n.classList.add("smart-grid-cell-editor");const a=function(){n.focus(),setTimeout((()=>{n.focus()}),50)},d=function(e){n.value=e,l.innerHTML=`<div class="container"><div style="justify-content: center; align-items: center; display: flex; margin-top: 3px;" class="smart-drop-image smart-micro smart-quiet">${t.localize("dropImages")}</div></div>`;const i=l.firstElementChild;if(t._findIsFile(e)){let t="";try{t=JSON.parse(e)}catch(e){console.log(e)}e=t}Array.isArray(e)&&(i.innerHTML="",e.forEach((e=>{const n=document.createElement("img");n.style.display="none";let o="";o=e.small?e.small:e.medium?e.medium:e.large?e.large:e.value,n.onload=()=>{n.style.display=""},o.indexOf("base64")>=0?n.src=o:(t._imagesCache||(t._imagesCache=[]),t._imagesCache[o]?t.uploadSettings.url?t._findUserFile(e)?(n.src=o,n.setAttribute("data-url",e.large||e.value),n.style.display=""):n.style.display="none":(n.src=o,n.setAttribute("data-url",e.large||e.value)):(t._imagesCache[o]=!0,n.style.display="none",t.uploadSettings.url?t._findUserFile(e)?(n.src=o,n.setAttribute("data-url",e.large||e.value),n.style.display=""):n.style.display="none":(n.src=o,n.style.display="")),n.onerror=()=>{n.style.display="none"}),i.appendChild(n)})))},r=function(){let e=n.value;return e&&(Array.isArray(e)||("string"==typeof e&&e.indexOf("base64"))>=0)&&Array.isArray(e)&&(e=JSON.stringify(e)),e},s=i=>{("+"===i.key||i.altKey&&"ArrowDown"===i.key)&&t._openFileDialog(t._dialogFile?t._dialogFile.cell:e),"Escape"===i.key&&t.cancelEdit(),"Enter"===i.key&&t.endEdit()},c=function(){n.value="",t._dialogFile&&t._dialogFile.close(),t._dialogImagePreview&&t._dialogImagePreview.close(),n.removeEventListener("keydown",s)},u=function(){},m=function(){n.addEventListener("keydown",s)};t._cellEditors[i]={element:n,focus:a,blur:u,setValue:d,getValue:r,attach:m,detach:c}}return t._cellEditors[i]}_getPhoneCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=document.createElement("smart-phone-input");n.rightToLeft=t.rightToLeft,t._applyCellEditorUserSettings(n,e);const o=function(e){n.opened||"keydown"!==e.type||t._handleEditKeyDown(e)};n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-phone-input-cell-editor");const l=function(){Smart.Utilities.Core.isMobile||setTimeout((()=>{n.select()}),50)},a=function(e){n.value=e,1===e.length&&(n.$.input.value=e,n.$.input.selectionStart=n.$.input.selectionEnd=n.$.input.value.indexOf(e)+1),t._phoneNumbers&&t._phoneNumbers[e]&&(n.selectedCountry=t._phoneNumbers[e])},d=function(){return t._phoneNumbers||(t._phoneNumbers=[]),n.value&&(t._phoneNumbers[n.value]=n.selectedCountry),n.value},r=function(){n.value="",n.removeEventListener("keydown",o)},s=function(){},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:s,setValue:a,getValue:d,attach:c,detach:r}}return t._cellEditors[i]}_getPasswordCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=document.createElement("smart-password-input");n.rightToLeft=t.rightToLeft,t._applyCellEditorUserSettings(n,e);const o=function(e){n.opened||"keydown"!==e.type||t._handleEditKeyDown(e)};n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-password-input-cell-editor");const l=function(){Smart.Utilities.Core.isMobile||setTimeout((()=>{n.select()}),50)},a=function(e){n.value=e,1===e.length&&(n.$.input.selectionStart=n.$.input.selectionEnd=n.$.input.value.indexOf(e)+1)},d=function(){return n.value},r=function(){n.value="",n.removeEventListener("keydown",o)},s=function(){},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:s,setValue:a,getValue:d,attach:c,detach:r}}return t._cellEditors[i]}_getMaskCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=document.createElement("smart-masked-text-box");n.rightToLeft=t.rightToLeft,t._applyCellEditorUserSettings(n,e);const o=function(e){n.opened||"keydown"!==e.type||t._handleEditKeyDown(e)};n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-masked-text-box-cell-editor");const l=function(){Smart.Utilities.Core.isMobile||setTimeout((()=>{n.select()}),50)},a=function(e){n.value=e,1===e.length&&(n.$.input.selectionStart=n.$.input.selectionEnd=n.$.input.value.indexOf(e)+1)},d=function(){return n.value},r=function(){n.value="",n.removeEventListener("keydown",o)},s=function(){},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:s,setValue:a,getValue:d,attach:c,detach:r}}return t._cellEditors[i]}_getNumberInputCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const n=document.createElement("smart-number-input");if(e&&e.editor&&(void 0!==e.editor.min&&(e.editor.min=parseInt(e.editor.min)),void 0!==e.editor.max&&(e.editor.max=parseInt(e.editor.max))),t._applyCellEditorUserSettings(n,e),"{}"===JSON.stringify(n.numberFormat)){let i={};if(e.column.cellsFormat)if(e.column.cellsFormat.indexOf("c")>=0){i={style:"currency",currency:t.messages[t.locale].calendar.currency};let n=parseInt(e.column.cellsFormat.substring(1));isNaN(n)||(i.maximumFractionDigits=n)}else if(e.column.cellsFormat.indexOf("p")>=0){i={style:"percent"};let t=parseInt(e.column.cellsFormat.substring(1));isNaN(t)||(i.maximumFractionDigits=t,i.minimumFractionDigits=t)}else if(e.column.cellsFormat.indexOf("d")>=0){i={style:"decimal"};let t=parseInt(e.column.cellsFormat.substring(1));isNaN(t)||(i.maximumFractionDigits=t)}else if(e.column.cellsFormat.indexOf("f")>=0||e.column.cellsFormat.indexOf("n")>=0){i={};let t=parseInt(e.column.cellsFormat.substring(1));isNaN(t)||(i.minimumFractionDigits=t,i.maximumFractionDigits=t)}else e.column.Intl&&e.column.Intl.NumberFormat&&(i=e.column.Intl.NumberFormat);n.numberFormat=i}n.classList.add("smart-grid-cell-editor"),n.classList.add("smart-grid-number-input-cell-editor");const o=function(e){t._handleEditKeyDown(e)},l=function(){Smart.Utilities.Core.isMobile||setTimeout((function(){n.focus(),t.$.scrollView.scrollTop=0}),50)},a=function(){},d=function(e){n.isReady&&("string"==typeof e&&n.numberFormat&&n.numberFormat.style&&"percent"===n.numberFormat.style&&(e=parseFloat(e),e=""+(e/=100)),null!==e&&""!==e||(e=0),n.setValue(e))},r=function(){return n.getValue()},s=function(){n.removeEventListener("keydown",o)},c=function(){n.addEventListener("keydown",o)};t._cellEditors[i]={element:n,focus:l,blur:a,getValue:r,setValue:d,attach:c,detach:s}}return t._cellEditors[i]}_getCheckBoxCellEditor(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors[i]){const e=document.createElement("div");e.classList.add("smart-input"),e.classList.add("smart-grid-cell-editor"),e.classList.add("smart-grid-check-box-cell-editor"),e.tabIndex=0;const n=function(){!0!==e.value&&!1!==e.value&&null!==e.value&&(e.value=!1),null===e.value?e.value=!1:e.value=!e.value,!1===e.value?e.removeAttribute("checked"):e.setAttribute("checked",e.value?"":"indeterminate")},o=function(e){if(" "!==e.key){switch(e.key){case"ArrowLeft":case"ArrowDown":case"ArrowRight":case"ArrowUp":if(t.editing.dialog.enabled)return;t.endEdit()}t._handleEditKeyDown(e)}else n()},l=function(t){e.value="string"==typeof t?"false"!==t&&"0"!==t&&"null"!==t&&"undefined"!==t:t,!1===e.value?e.removeAttribute("checked"):e.setAttribute("checked",e.value?"":"indeterminate")},a=function(){Smart.Utilities.Core.isMobile||(e.focus(),setTimeout((function(){e.focus()}),25))},d=function(){return e.value},r=function(){e.value=!1,e.removeEventListener("click",n),e.removeEventListener("keydown",o)},s=function(){},c=function(){e.addEventListener("keydown",o),e.addEventListener("click",n)};t._cellEditors[i]={getValue:d,setValue:l,focus:a,blur:s,element:e,detach:r,attach:c}}return t._cellEditors[i]}_unescapeString(e){if(null==e)return e;if("string"!=typeof e)return e;const t=[{regex:"&",entity:"&"},{regex:">",entity:">"},{regex:"<",entity:"<"},{regex:'"',entity:"""},{regex:"'",entity:"'"},{regex:"=",entity:"="},{regex:"/",entity:"/"},{regex:"`",entity:"`"}];let i;for(let n in t)i=new RegExp(t[n].entity,"g"),e=e.replace(i,t[n].regex);return e}_getEditorValue(e){const t=this,i=t._getEditorId(e);if(!t._cellEditors)return;const n=t._cellEditors[i];if(!n)return;const o=function(t){switch(e.column.dataType){case"string":t=null==t?"":void 0!==t&&"number"==typeof t?parseFloat(t):t&&"object"==typeof t&&t[0]&&t[0].label?t[0].label.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,"""):t&&"object"==typeof t&&t instanceof Date?t.toLocaleString():(t=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")).replaceAll("\t"," ");break;case"float":case"int":case"number":t="int"===e.column.dataType?parseInt(t):parseFloat(t),isNaN(t)&&(t=0);break;case"bool":case"boolean":"true"!==t&&"1"!==t||(t=!0),"false"!==t&&"0"!==t||(t=!1);break;case"date":if(t instanceof Date)return t;"string"==typeof t&&(t=new Date(t));break;case"dateTime":t=new Smart.Utilities.DateTime(t)}return t};let l=null;switch(e.editor.template){case"dateRangeInput":try{l=n.getValue()}catch(t){l=e.value}if(e.editor.getValue){const t=e.editor.getValue(e,l);void 0!==t&&(l=t)}break;case"input":case"autoComplete":case"numberInput":case"slider":case"dateInput":case"timeInput":case"deteTimePicker":case"checkBox":try{l=o(n.getValue())}catch(t){l=e.value}if(e.editor.getValue){const t=e.editor.getValue(e,l);void 0!==t&&(l=t)}break;case"multiComboInput":case"attachment":case"image":l=n.getValue();break;default:l=o(n.getValue())}let a=!0,d=!1,r=!1;if(e.column.validator)a=e.column.validator.evaluate(l,e.row.data);else if("string"==typeof l){const t=e.editor.minLength||e.editor.min||0,i=e.editor.maxLength||e.editor.max||999999;(l.length<t||l>i)&&(a=!1),l.length<t&&(d=!0),l.length>i&&(r=!0),e.editor.required&&0===l.length&&(a=!1),e.editor.instance.element&&e.editor.instance.element.checkValidity&&(a=e.editor.instance.element.checkValidity())}if(a)return l;let s=null;const c=e.editor.instance.element;return c&&(s=c.validity,s&&(s.custom&&delete s.custom,d&&(s.custom={minLength:!0,value:e.editor.min}),r&&(s.custom={maxLength:!0,value:e.editor.max}),s.message=c.validationMessage)),{error:!0,validity:s,value:l}}_beginRowEdit(e,t){const i=this;if(e===i.editing.editRow)return!1;if(i.editing.editRow){if(!i.endEdit())return!1}const n=e.cells;i.editing.editRow=e,i.editing.commandColumn.visible&&(i.editing.isEditing=!1,i.refresh(),i.editing.isEditing=!0),e.isEditing=!0;let o=!1;for(let e=0;e<n.length;e++){const l=n[e],a=l.column;if(!a.allowEdit||!1===a._visible)continue;const d=i._beginCellEdit(l);if(d){if(!0!==i.editing.recordNavigation&&i.editing.enabled){if(Smart.Utilities.Core.isMobile)return;let e=!0;switch(l.editor.template){case"textarea":case"slider":e=!1}e&&(t?l===t&&l.editor.instance.focus():d&&!o&&(o=!0,l.editor.instance.focus()))}i.editing.commandColumn.visible&&l.column.commandColumn&&l.render()}}return!0}_beginCellEdit(e,t){const i=this;if(e.isEditing&&"checkBox"!==e.column.template)return!1;if(i._isUpdating)return!1;if(i.onCellBeginEdit){if(!i.onCellBeginEdit(e.row.id,e.column.dataField,e.value,i))return!1}let n=!1;if(e.column.autoGenerated&&e.column.rowHeaderColumn&&i.editing.allowRowHeaderEdit&&new Date-i._clickTime<i.behavior.doubleClickTimingDelay&&i._clickedCell===e.element&&(n=!0),(!e.column.allowEdit||e.column.autoGenerated||e.readonly)&&!n)return!1;if(i.editing.editCell&&!i.editing.editRow){i._fireEndEdit=!0;if(!1===i._endCellEdit())return!1}if(i._cellEditors||(i._cellEditors=[]),i.editing.editRow||(i.editing.editCell=e),i.editing.commandColumn.visible&&!i.editing.editRow&&(i.editing.isEditing=!1,i.refresh(),i.editing.isEditing=!0),!e.row.element)return!1;e.row.element.setAttribute("edit",""),i.editing.isEditing=!0,i._selection.selectionRect&&i._selection.selectionRect.classList.add("smart-visibility-hidden");const o=t=>{const n=t.element;i.editing.dialog.enabled?i._openEditDialog(e,t):(e.element||e.createElement(),e.element.setAttribute("editor","string"==typeof e.editor.template?e.editor.template:"template"),e.element.content.innerHTML="",e.element.content.appendChild(n),e.column.cellsWrap||e.element.content.classList.add("nowrap"),i.editing.editRow&&e.element.setAttribute("row-editor","")),t.attach(),e.editor.row=e.row,e.editor.column=e.column,e.editor.cell=e,e.editor.instance=t,e.isEditing=!0},l=i._cellsUpdatedValues?i._cellsUpdatedValues[e.row.id+"_"+e.column.dataField]:void 0;let a=void 0!==l?l:e.value;if(void 0===a){a="";const t=e.column;"number"===t.dataType||"int"===t.dataType||"float"===t.dataType?a=0:"date"===t.dataType&&(a=new Date,a.setHours(0,0,0))}switch(e.editor||(e.editor="input"),"string"==typeof e.editor&&(e.canNotify=!1,e.editor={template:e.editor,autoFocus:!0},e.canNotify=!0),e.editor.template){default:case"custom":{const t=i._getCustomCellEditor(e);o(t),t.setValue(a);break}case"attachment":{const t=i._getAttachmentCellEditor(e);o(t),t.setValue(a);break}case"image":{const t=i._getImageCellEditor(e);o(t),t.setValue(a);break}case"checkBox":{const n=i._getCheckBoxCellEditor(e);o(n);const l=!0===a||1===a;if("checkBox"===e.template&&t){(i.enableShadowDOM?i.shadowRoot:i.getRootNode()).elementsFromPoint(t.clientX,t.clientY)[0].classList.contains("smart-input")?n.setValue(!l):n.setValue(l)}else n.setValue(l);break}case"autoComplete":{const t=i._getAutoCompleteCellEditor(e);o(t),t.setValue(a),e.editor.autoOpen&&!i.editing.editRow&&t.element.open();break}case"list":case"dropDownList":{e.editor.autoOpen=!0,e.editor.readonly=!0,e.editor.dropDownButtonPosition="right";const t=i._getAutoCompleteCellEditor(e);o(t),t.setValue(a),e.editor.autoOpen&&!i.editing.editRow&&t.element.open();break}case"comboBox":{e.editor.readonly=!1,e.editor.dropDownButtonPosition="right";const t=i._getAutoCompleteCellEditor(e);o(t),t.setValue(a),e.editor.autoOpen&&!i.editing.editRow&&t.element.open();break}case"password":{const t=i._getPasswordCellEditor(e);o(t),t.setValue(a);break}case"phone":{const t=i._getPhoneCellEditor(e);o(t),t.setValue(a);break}case"maskedTextBox":{const t=i._getMaskCellEditor(e);o(t),t.setValue(a);break}case"multiInput":{const t=i._getAutoCompleteCellEditor(e,"smart-multi-input");o(t),t.setValue(a),e.editor.autoOpen&&!i.editing.editRow&&t.element.open();break}case"checkInput":{const t=i._getAutoCompleteCellEditor(e,"smart-check-input");o(t),t.setValue(a),e.editor.autoOpen&&!i.editing.editRow&&t.element.open();break}case"tags":case"multiComboInput":{e.editor.readonly=!0,e.editor.autoOpen=!0;const t=i._getMultiComboInputCellEditor(e);o(t),t.setValue(a),e.editor.autoOpen&&!i.editing.editRow&&t.element.open();break}case"timeInput":{const t=i._getTimeInputCellEditor(e);o(t),t.setValue(a),e.editor.autoOpen&&!i.editing.editRow&&t.element.open();break}case"dateInput":{const t=i._getDateInputCellEditor(e);o(t),t.setValue(a);break}case"dateRangeInput":{const t=i._getDateRangeInputCellEditor(e);o(t),t.setValue(a),e.editor.autoOpen&&!i.editing.editRow&&t.element.open();break}case"dateTimePicker":{const t=i._getDateTimePickerCellEditor(e);o(t),t.setValue(a);break}case"slider":{const t=i._getSliderCellEditor(e);o(t),t.setValue(a);break}case"colorInput":{const t=i._getColorInputCellEditor(e);o(t),t.setValue(a);break}case"textarea":case"textArea":{const t=i._getTextAreaCellEditor(e);o(t),t.setValue(a);break}case"numberInput":case"text":case"input":{const t="numberInput"===e.editor.template?i._getNumberInputCellEditor(e):i._getInputCellEditor(e);o(t),t.setValue(a);break}}if(!e.editor.isInitialized&&(e.editor.isInitialized=!0,e.editor.onInit)){const t=e.editor.onInit(e.row.index,e.column.dataField,e.editor.instance.element,e.row.data);if(t&&t instanceof Promise)t.then((t=>{const i="custom"===e.editor.template?e.editor.instance.element.firstElementChild:e.editor.instance.element;for(let e in t)i[e]=t[e]}));else if(t){const i=t,n="custom"===e.editor.template?e.editor.instance.element.firstElementChild:e.editor.instance.element;for(let e in i)n[e]=i[e]}}if(e.editor.onRender){const t=e.editor.onRender(e.row.index,e.column.dataField,e.editor.instance.element,e.row.data);if(t&&t instanceof Promise)t.then((t=>{const i="custom"===e.editor.template?e.editor.instance.element.firstElementChild:e.editor.instance.element;for(let e in t)i[e]=t[e]}));else if(t){const i=t,n="custom"===e.editor.template?e.editor.instance.element.firstElementChild:e.editor.instance.element;for(let e in i)n[e]=i[e]}}return i.editing.editCell&&e.editor.instance.focus(),"checkBox"===e.editor.template&&i._endCellEdit(),!0}_onColumnDoubleClick(e){this._beginColumnEdit(e)}_beginColumnEdit(e){const t=this;if(t.editing.enabled&&t.editing.allowColumnHeaderEdit&&e.allowHeaderEdit){t.editing.isEditing&&t.endEdit(),t.editing.editColumn=e,t._cellEditors||(t._cellEditors=[]);const i=t._getInputCellEditor({column:e,row:t.rows[0],editor:{template:"input"}});i.element.value=e.label,i.focus(),e.headerEditor=i,e.element.setAttribute("edit",""),e.element.label.appendChild(i.element),i.attach(),t.editing.isEditing=!0;t.$.fireEvent("beginEdit",{id:null,dataField:e.dataField,row:null,column:e,cell:null,data:null,value:null}).defaultPrevented&&t.cancelEdit()}}_endColumnEdit(e){const t=this;if(!1===t.editing.isEditing||t.editing.isEditing&&null===t.editing.editColumn)return!1;const i=t.editing.editColumn;return i.canNotify=!1,i.headerEditor.detach(),i.headerEditor.element.parentNode.removeChild(i.headerEditor.element),!0!==e&&(i.label=i.headerEditor.getValue()),i.headerEditor=null,t.editing.isEditing=!1,i.element.removeAttribute("edit"),i.element.scrollLeft=0,t.editing.editColumn=null,i.canNotify=!0,i.refresh(),t._recycle(),!0}_cancelColumnEdit(){this._endColumnEdit(!0)}_onCellClick(e,t){const i=this;if(e.row.addNewRow)e.row.inline?i._addNewGridRow():"far"===e.row.freeze?i._insertNewRowAfter():i._insertNewRowBefore();else if(!e.row.filterRow&&i.editing.enabled)if(i.editing.editColumn)i.endEdit();else{if(i.editing.commandColumn.visible)if(e.column.commandColumn){const n=(i.enableShadowDOM?i.shadowRoot:i.getRootNode()).elementsFromPoint(t.clientX,t.clientY);let o=null;for(let e=0;e<n.length;e++)if(n[e].classList.contains("smart-grid-command-item")){o=n[e];break}if(o||(o=e.element.querySelector(".smart-grid-command-item")),o&&!o.classList.contains("smart-hidden")){const n=o.getAttribute("command");return void i._applyCommand(n,[e.row,t])}}else if(i.editing.commandColumn.inline){const e=(i.enableShadowDOM?i.shadowRoot:i.getRootNode()).elementsFromPoint(t.pageX,t.pageY);for(let t=0;t<e.length;t++)if(e[t].classList.contains("smart-grid-command-item"))return}if("none"===i.editing.action&&i.editing.isEditing){let t=!1;i.editing.editCell&&i.editing.editCell.row!==e.row&&(t=!0),i.editing.editRow&&i.editing.editRow!==e.row&&(t=!0),i.editing.editColumn&&(t=!0),t&&i.endEdit()}if(e.column.autoGenerated){if(i.editing.allowRowHeaderEdit&&e.column.rowHeaderColumn){if(i.editing.isEditing&&i.endEdit(),void 0!==e.row.label)return;i._beginCellEdit(e,t),i.editing.isEditing&&i.$.fireEvent("beginEdit",{id:e.row.id,dataField:e.column.dataField,row:e.row,column:e.column,cell:e,data:e.row.data,value:e.value})}}else if("click"===i.editing.action&&(!i.selection.enabled||e.selected||"extended"!==i.selection.mode))if("cell"===i.editing.mode){const n=e.parent();if(void 0!==e.row.label)return;i.ensureVisible(e.row.id,e.column.dataField),setTimeout((function(){if(n)i._beginCellEdit(n,t),i.$.fireEvent("beginEdit",{id:n.row.id,dataField:n.column.dataField,row:n.row,column:n.column,cell:n,data:n.row.data,value:n.value});else{i._beginCellEdit(e,t);i.$.fireEvent("beginEdit",{id:e.row.id,dataField:e.column.dataField,row:e.row,column:e.column,cell:e,data:e.row.data,value:e.value}).defaultPrevented&&i.cancelEdit()}}),25)}else if("row"===i.editing.mode){if(void 0!==e.row.label)return;i._beginRowEdit(e.row,e,t);i.$.fireEvent("beginEdit",{id:e.row.id,dataField:e.column.dataField,row:e.row,column:e.column,cell:e,data:e.row.data,value:e.value}).defaultPrevented&&i.cancelEdit()}}}_onCellDoubleClick(e,t){const i=this;i.editing.enabled&&("doubleClick"!==i.editing.action||i.editing.isEditing||e.column.autoGenerated||("cell"===i.editing.mode?i._beginCellEdit(e,t):"row"===i.editing.mode&&i._beginRowEdit(e.row,e,t)))}_onRowClick(){}_onRowDoubleClick(){}beginEdit(e,t){const i=this,n=i.rowById[e];n&&i._beginEdit(n,t)}cancelEdit(){const e=this;if(e.editing.isEditing){if(e._errorOverlay){if(e._errorOverlay.remove(),e._errorMessage.remove(),e.editing.editCell&&(e.editing.editCell.error=""),e.editing.editRow){const t=e.editing.editRow.cells;for(let e=0;e<t.length;e++){t[e].error=""}e.editing.editRow.element.removeAttribute("error"),e.editing.editRow.error=null}e._isUpdating=!1}if(e.editing.editRow){const t=e.editing.editRow.cells;for(let e=0;e<t.length;e++){const i=t[e],n=i.element;0===e&&i.row.element.removeAttribute("edit"),n&&(n.removeAttribute("editor"),n.removeAttribute("error"),n.content.innerHTML=""),i.isEditing=!1}e.editing.editRow=null}else e.editing.editCell?(e.editing.editCell.row.element.removeAttribute("edit"),e.editing.editCell.row.element.removeAttribute("error"),e.editing.editCell.element.removeAttribute("editor"),e.editing.editCell.element.removeAttribute("error"),e.editing.editCell.element.content.innerHTML="",e.editing.editCell.isEditing=!1,e.editing.editCell=null):e.editing.editColumn&&e._cancelColumnEdit();e.editing.dialog.visible&&e.editing.dialog.enabled&&e._dialogEdit.close(),e.editing.isEditing=!1,e._recycle(!1),e.editing.commandColumn.visible&&e.refresh(),e.$.fireEvent("cancelEdit"),e.focus()}}deleteColumn(e){const t=this,i=this.columns.findIndex((t=>t.dataField===e));i>=0&&t.columns.splice(i,1)}removeRow(e,t){return this.deleteRow(e,t)}deleteRow(e,t){const i=this;if(e&&Array.isArray(e)){if(i.onRowRemove){if(!1===i.onRowRemove(e,i))return}i.beginUpdate();const n=i.dataSource.canNotify,o=i.rows.canNotify;i.rows.canNotify=!1,i.dataSource.canNotify=!1;const l=i.onRowRemoved;i.onRowRemoved=null;let a=[];for(let n in e){const o=i.rowById[e[n]];a.push(o.data.$.index),i.deleteRow(e[n],t),i.dataSource.removeAt(o.data.$.index)}return i.rows.canNotify=o,i.dataSource.canNotify=n,i.onRowRemoved=l,i.endUpdate(),i._refreshSummary(),void(l&&l(e,a,i))}const n=i.rowById[e];if(!n)return!1;const o=function(e){if(!0===i.editing.batch||i.editing.batch&&i.editing.batch.indexOf("delete")>=0)i._batchDeleteRow(e);else{if(i.dataSource&&i.dataSource.virtualDataSource)return i._editInfo={row:e.data},void i._virtualDataRequest("remove",(function(n){if(n){const n=i.rows.indexOf(e);i.rows.splice(n,1),delete i.rowById[e.id],t&&t(e)}}));const n=i.rows.indexOf(e);i._removeAt(n)}t&&t(e)};return i.editing.deleteDialog.enabled?i._openDeleteRowDialog(n,o):o(n),!0}addRow(e,t,i){const n=this;e||(e={});for(let t=0;t<n.columns.length;t++){const i=n.columns[t];void 0!==i.defaultValue&&void 0===e[i.dataField]&&(e[i.dataField]=i.defaultValue)}if(void 0===t&&(t=!0),n.dataSource&&n.dataSource.virtualDataSource)n._editInfo={row:e},n._virtualDataRequest("add",(o=>{o&&(n._add(e,t?n.rows.length:0),i&&i(t?n.rows[n.rows.length-1]:n.rows[0]))}));else{if(n.editing.batch)return void(t?n._insertNewRowAfter(i):n._insertNewRowBefore(i));"number"==typeof t?n._add(e,t,i):n._add(e,t?n.rows.length:0,i)}}insertRow(e,t,i){this.addRow(e,t,i)}flashCell(e,t){const i=this;i._flashTimer&&clearTimeout(i._flastTimer),i.highlightedCells&&i.highlightedCells[e]&&(i.highlightedCells[e][t]="off_smart-flash-cell"),i.highlightCell(e,t,"smart-flash-cell"),i._flashTimer=setTimeout((()=>{i.highlightedCells&&i.highlightedCells[e]&&(i.highlightedCells[e][t]="off_smart-flash-cell",delete i.highlightedCells[e][t])}),2e3)}highlightCell(e,t,i){const n=this,o=n.rowById[e],l=n.columnByDataField[t];o&&l&&(n.highlightedCells||(n.highlightedCells=[]),n.highlightedCells[e]||(n.highlightedCells[e]=[]),void 0!==n.highlightedCells[e][t]?i?n.highlightedCells[e][t].startsWith("off")?n.highlightedCells[e][t]=i||"":n.highlightedCells[e][t]="off_"+i:delete n.highlightedCells[e][t]:n.highlightedCells[e][t]=i||"",n._recycle(!1))}highlightRow(e,t){const i=this;i.rowById[e]&&(i.highlightedRows||(i.highlightedRows=[]),void 0!==i.highlightedRows[e]?t?i.highlightedRows[e].startsWith("off")?i.highlightedRows[e]=t||"":i.highlightedRows[e]="off_"+t:delete i.highlightedRows[e]:i.highlightedRows[e]=t||"",i._recycle(!1))}highlightColumn(e,t){const i=this.columnByDataField[e];i.highlight=!i.highlight,i._highlightCSS=t,this._recycle(!1)}setRowProperty(e,t,i){const n=this.rowById[e];n&&(n[t]=i)}getRowProperty(e,t){const i=this.rowById[e];if(i)return i[t]}getColumn(e){const t=this.columnByDataField[e];return t||null}getColumnProperty(e,t){const i=this.columnByDataField[e];if(i)return i[t]}setColumnProperty(e,t,i){const n=this.columnByDataField[e];n&&(n[t]=i)}getCellValue(e,t){const i=this.rowById[e],n=this.columnByDataField[t];if(!i||!n)return;return i.getCell(t).value}setCellValue(e,t,n,o){const l=this,a=l.rowById[e],d=l.columnByDataField[t];if(!a||!d)return!1;let r=[];if(d.validationRules&&d.validationRules.length>0&&(r=((e,t)=>{let n=[];for(let o of e){switch(o.type){case"min":n.min=i.min(t,o.value);break;case"max":n.max=i.max(t,o.value);break;case"minLength":n.minLength=i.minLength(t,o.value);break;case"maxLength":n.maxLength=i.maxLength(t,o.value);break;case"minDate":n.minDate=i.minDate(t,o.value);break;case"maxDate":n.maxDate=i.maxDate(t,o.value);break;case"required":n.required=i.required(t);break;case"requiredTrue":n.requiredTrue=i.requiredTrue(t);break;case"pattern":n.pattern=i.pattern(t,o.value);break;case"email":n.email=i.email(t);break;case"null":n.null=i.null(t)}null===n[o.type]&&delete n[o.type]}return n})(d.validationRules,n),Object.keys(r).length>0))return!1;const s=()=>{if(!0===l.editing.batch||l.editing.batch&&l.editing.batch.indexOf("update")>=0){const e=a.getCell(t);return l._batchUpdateCell(e.row,e.column,n,e.value),o&&o(a),void l._recycle()}l.beginUpdate();const e=a.getCell(t);l._setCellUndoRedo(e,e.value,n),e.value=n,l.endUpdate(),o&&o(a)};if(l.dataSource&&l.dataSource.virtualDataSource){l.dataSource.id?a[l.dataSource.id]=e:a.id||(a.id=e);const i={};for(let e=0;e<l.columns.length;e++){const o=l.columns[e],d=a.getCell(o.dataField);i[o.dataField]=d.value,o.dataField===t&&(i[o.dataField]=n)}l._editInfo={row:i},l._virtualDataRequest("update",(function(e){e&&s(),l.appearance.displayLoadingIndicator=!1,l._setLoadingIndicatorVisibility()}))}else s()}setRowData(e,t){this.updateRow(e,t,null)}getRowData(e){const t=this.rowById[e];if(!t)return null;const i=JSON.parse(JSON.stringify((e=>{const t={};for(let i in e)"leaf"!==i&&"$"!==i&&"parent"!==i&&"history"!==i&&"comments"!==i&&"style"!==i&&(t[i]=e[i]);return t})(t.data)));return delete i.$,i}getRow(e){const t=this.rowById[e];return t||null}forEachRow(e){const t=this;if(e)for(let i=0;i<t.rows.length;i++)e(t.rows[i])}forEachRowAfterFilterAndSort(e){const t=this;if(e)for(let i=0;i<t._recyclingRows.length;i++)e(t._recyclingRows[i])}getRowById(e){return this.rowById[e]}getRowByIndex(e){const t=this.rows[e];return t||null}getRowId(e){const t=this.rows[e];if(!t)return null;return t.id}validateRow(e,t){const n=this;if(!n.rowById[e])return!1;const o=(e,t)=>{let n=[];for(let o of e)switch(o.type){case"min":n.min=i.min(t,o.value);break;case"max":n.max=i.max(t,o.value);break;case"minLength":n.minLength=i.minLength(t,o.value);break;case"maxLength":n.maxLength=i.maxLength(t,o.value);break;case"minDate":n.minDate=i.minDate(t,o.value);break;case"maxDate":n.maxDate=i.maxDate(t,o.value);break;case"required":n.required=i.required(t);break;case"requiredTrue":n.requiredTrue=i.requiredTrue(t);break;case"pattern":n.pattern=i.pattern(t,o.value);break;case"email":n.email=i.email(t);break;case"null":n.null=i.null(t)}return n.filter((e=>{}))},l=[];for(let e=0;e<n.columns.length;e++){const i=n.columns[e];let a=[];if(void 0!==t[i.dataField])if(i.validationRules&&i.validationRules.length>0){let e=t[i.dataField];e&&e.error&&(e=e.value),a=o(i.validationRules,e),Object.keys(a).length>0&&(l[i.dataField]=a)}else{let e=null,n=t[i.dataField];n&&n.error&&(e=n.validity,n=n.value);for(let t in e)e[t]&&"valid"!==t&&"message"!==t&&(a[t]=!0),("custom"===t&&e[t].minLength||"custom"===t&&e[t].maxLength)&&(a[t]=!0);Object.keys(a).length>0&&(l[i.dataField]=a)}}return l}_getGroupAncestorSignature(e){const t=[];let i=e.parent;for(;i;)t.push({groupDataField:i.groupDataField,label:i.label}),i=i.parent;return JSON.stringify(t)}_getExpandedGroups(e){const t=this,i=[];if(!e)return[];return function e(n){n.forEach((n=>{n.expanded&&i.push({groupDataField:n.groupDataField,label:n.label,ancestorSignature:t._getGroupAncestorSignature(n)}),n.children&&n.children.length>0&&!1===n.children[0].leaf&&e(n.children)}))}(e),i}_updateRow(e,t,i){const n=this,o=n.rowById?n.rowById[e]:n.dataSource.dataItemById[e];if(!o)return;if(void 0===t)return;let l=[];n.dataSource&&n.dataSource.groupBy&&n.dataSource.groupBy.toArray&&(l=n.dataSource.groupBy.toArray().slice(0));const a=n.dataSource.boundSource.canNotify;n.dataSource.boundSource.canNotify=!1;const d=e=>{if(o.data[e]=t[e],n.dataSource.id&&o&&o.data&&o.data.$&&(o.data.$.id=t[n.dataSource.id]),o&&o.data.$&&void 0!==o.data.$.index){const i=o.data.$.index,a=n.dataSource.dataSource,d=()=>{const i=t[e];if(null==i){const t=n.columnByDataField[e];return t?"number"===t.dataType?0:"boolean"!==t.dataType&&("date"===t.dataType?new Date:""):""}return i};if(a&&a[i]&&(a[i][e]=d()),n.dataSource[i]){if(l.length>0&&!n._dirtyHierarchy){if(n.dataSource[i][e]!==d()&&l.indexOf(e)>=0){const e=n._getExpandedGroups(n.dataSource.boundHierarchy);n._dirtyHierarchy=e}}n.dataSource[i][e]=d()}}};let r=[];for(let e=0;e<n.columns.length;e++){const i=n.columns[e];void 0!==t&&(void 0!==t[i.dataField]&&(r[i.dataField]=!0,d(i.dataField)))}if(i){const e=n.dataSource.dataFields;if(e)for(let t=0;t<e.length;t++)r[e[t].name]||(e[t].map?d(e[t].map):d(e[t].name))}n.dataSource.boundSource.canNotify=a,n.__updating||n.dataSource.refreshHierarchy()}updateRow(e,t,i){const n=this,o=n.rowById[e];if(!o)return!1;const l=n.validateRow(e,t);if(Object.keys(l).length>0)return!1;const a=()=>{if(!0===n.editing.batch||n.editing.batch&&n.editing.batch.indexOf("update")>=0){for(let e in t){if("$"===e)continue;const i=o.getCell(e);i?(n._batchUpdateCell(i.row,i.column,t[e],i.value),n._recycle()):o.data[e]&&(o.data[e]=t[e])}i&&i(o)}else{n.beginUpdate();for(let e in t){if("$"===e)continue;const i=o.getCell(e);i?i.value=t[e]:o.data[e]&&(o.data[e]=t[e])}n.endUpdate(),i&&i(o)}};n.dataSource&&n.dataSource.virtualDataSource?(n.dataSource.id?t[n.dataSource.id]=e:t.id||(t.id=e),n._editInfo={row:t},n._virtualDataRequest("update",(function(e){e&&a(),n.appearance.displayLoadingIndicator=!1,n._setLoadingIndicatorVisibility()}))):n.onRowUpdate?n.onRowUpdate([e],[o],[o.data],[t],(e=>{e&&a()}),n):a()}addUnboundRow(e,t){const i=this;void 0===e&&(e=1),void 0===t&&(t="far"),i._nearRowsAdded||(i._nearRowsAdded=[],i._farRowsAdded=[]),i._unboundRows||(i._unboundRows=[]),i.beginUpdate();for(let n=0;n<e;n++){const e=Smart.Utilities.Core.createGUID().replace(/-/gi,""),n=new Smart.Grid.Row({index:-1,unbound:!0,id:e,grid:i});i.rowById[n.id]=n,"far"===t?i._farRowsAdded.push(n):i._nearRowsAdded.push(n),i._unboundRows.push(n)}i.endUpdate()}addNewRow(e){const t=this;"near"===e?t._insertNewRowBefore():t._insertNewRowAfter()}_updateRowHistory(e,t,i){const n=this;if(!n._currentUser||n._currentUser&&!n._currentUser.info)return;const o="taskChecklist",l="taskColor",a="taskDueDate",d="taskPriority",r="taskProgress",s="taskStartDate",c="taskStatus",u="taskTags",m="taskText",g="taskDescription",f="taskUserId",p=()=>({user:n._currentUser.info.id,date:e.updatedDate}),h=[];if(i[f]!==t[f]){const n=p();n.action="user";let o=!0;t[f]||i[f]||(o=!1),o&&(n.details={oldValue:t[f],value:i[f]},e.addHistory(n)),h.push(f)}if(""+i[a]!=""+t[a]){const n=p();n.action="deadline",n.details={oldValue:t[a]?new Date(t[a]).toLocaleDateString():"",value:new Date(i[a]).toLocaleDateString()},e.addHistory(n),h.push(a)}if(""+i[s]!=""+t[s]){const n=p();n.action="deadline",n.details={oldValue:t[s]?new Date(t[s]).toLocaleDateString():"",value:new Date(i[s]).toLocaleDateString()},e.addHistory(n),h.push(s)}if(i[l]!==t[l]){const n=p();n.action="color",n.details={oldValue:t[l],value:i[l]},e.addHistory(n),h.push(c)}if(i[c]!==t[c]){const n=p();n.action="status",n.details={oldValue:t[c],value:i[c]},e.addHistory(n),h.push(c)}if(JSON.stringify(i[o])!==JSON.stringify(t[o])){const n=p();n.action="subtasks";let l=t[o],a=i[o];const d=e=>{let t=[];if(!e)return"";for(let i=0;i<e.length;i++)t.push(e[i].text+": "+(e[i].completed?"Y":"N"));return t.toString()};l=d(l),a=d(a),n.details={oldValue:l,value:a},e.addHistory(n),h.push(o)}else h.push(o);if(void 0!==i[r]&&parseFloat(i[r])!==parseFloat(t[r])){let n=!0;if(null===t[r]&&0===parseFloat(i[r])&&(n=!1),null===(null===t[r]&&i[r])&&(n=!1),n){const n=p();n.action="progress",n.details={oldValue:t[r]?100*t[r]+"%":"0%",value:100*i[r]+"%"},e.addHistory(n)}h.push(r)}if(i[g]!==t[g]){const n=p();n.action="description",n.details={oldValue:t[g],value:i[g]},e.addHistory(n),h.push(g)}if(i[d]!==t[d]){const n=p();n.action="priority",n.details={oldValue:t[d],value:i[d]},e.addHistory(n),h.push(d)}if(i[u]!==t[u]){const n=p();n.action="tags",n.details={oldValue:t[u],value:i[u]},e.addHistory(n),h.push(u)}if(i[m]!==t[m]){const n=p();n.action="text",n.details={oldValue:t[m],value:i[m]},e.addHistory(n),h.push(m)}for(let o=0;o<n.columns.length;o++){const l=n.columns[o].dataField;let a=t[l],d=i[l];if("image"===n.columns[o].template&&(a&&"string"==typeof a&&(a.indexOf("[{")>=0?(a=JSON.parse(a),a=a.map((e=>e.label)),a=a.toString()):a=""),null==a&&(a=""),d&&"string"==typeof d&&(d.indexOf("[{")>=0?(d=JSON.parse(d),d=d.map((e=>e.label)),d=d.toString()):d=""),null==d&&(d="")),-1===h.indexOf(l)&&a!==d){const t=p();"date"===n.columns[o].dataType&&(d&&"string"==typeof d&&(d=new Date(d)),a&&"string"==typeof a&&(a=new Date(a))),t.action=l,t.details={oldValue:a,value:d},e.addHistory(t)}}n.onRowHistory&&(n._tempRowHistory||(n._tempRowHistory=[]),n._tempRowHistory[e.index]={index:e.index,row:e,history:e.history},n._tempRowHistoryTimer&&clearTimeout(n._tempRowHistoryTimer),n._tempRowHistoryTimer=setTimeout((()=>{const e=[],t=[],i=[];for(let o in n._tempRowHistory)t.push(o),e.push(n._tempRowHistory[o].row),i.push(n._tempRowHistory[o].history);n.onRowHistory(t,e,i,n),delete n._tempRowHistory}),50))}_stringifyRow(e){const t=this;let i={};for(let n=0;n<t.columns.length;n++){const o=t.columns[n];i[o.dataField]=e.data[o.dataField]}return i=JSON.parse(JSON.stringify(i)),i}endEdit(){const e=this;let t=!1,i=null;e.editing.dialog.enabled&&e.editing.dialog.visible&&e._dialogEdit&&e._dialogEdit.close();let n=null,o=null,l=null;e._fireEndEdit=!0;let a=null,d=null,r=null;if(e.editing.editRow){o=e.editing.editRow,i=e.editing.editRow.id;let n=null;if(e.storeHistory&&(n=e._stringifyRow(o)),t=e._endRowEdit(),a=n,t&&!e.onRowUpdate&&(o.updatedDate=new Date,o.updatedBy=e.currentUser,e.storeHistory)){const t=e._stringifyRow(o);e._updateRowHistory(o,n,t)}}else if(e.editing.editCell){o=e.editing.editCell.row,l=e.editing.editCell.column,n=e.editing.editCell,i=e.editing.editCell.row.id,r=!0;let s=null;e.storeHistory&&(s=e._stringifyRow(o));const c=void 0!==n.value?n.value:"";d=c,a=s;let u=!1;const m=t=>{if(t!==c){if(o.updatedDate=new Date,o.updatedBy=e.currentUser,e.storeHistory){const i=e._stringifyRow(o);i[n.column.dataField]=t,e._updateRowHistory(o,s,i)}u=!0}};if(e.onCellUpdate&&e.onRowHistory){const t=e.onRowHistory;e.onRowHistory=null;m(e._getEditorValue(n)),setTimeout((()=>{e.onRowHistory=t}),100)}t=e._endCellEdit(),t&&!u&&n&&m(n.value)}else e.editing.editColumn&&(i=null,l=e.editing.editColumn,t=e._endColumnEdit());if(e._saveUnboundRows(i),e._selection.selectionRect&&e._selection.selectionRect.classList.remove("smart-visibility-hidden"),e.$.scrollView.scrollTop=0,e._fireEndEdit){e.$.fireEvent("endEdit",{id:o?o.id:null,dataField:l?l.dataField:null,row:o,column:l,cell:n,data:o?o.data:null,value:n?n.value:l?l.label:null}).defaultPrevented&&(r?e.setCellValue(o.id,l.dataField,d):e.setRowData(o.id,a))}return e.summaryRow.visible&&t&&(e.editing.isEditing=!1,e._calculateSummary(),e._recycle(!1)),e._refreshDataFilters(),e._renderConditionalFormatting(),t}getEditCells(){const e=this;return e.editing.editRow?e.editing.editRow.cells:e.editing.editCell?[e.editing.editCell]:[]}getBatchEditChanges(){const e=this,t=[],i=[],n=[];for(let i in e._cellsUpdatedValues){const n=e._cellsUpdatedValues[i],o=i.substring(0,i.indexOf("_")),l=i.substring(i.indexOf("_")+1),a=e.rowById[o].getCell(l);t.push({id:o,dataField:l,oldValue:a.value,newValue:n})}if(e._rowsDeleted&&e._rowsDeleted.length>0)for(let t=0;t<e._rowsDeleted.length;t++){const n=e._rowsDeleted[t],o=e.rowById[n];i.push({id:o.id,data:o.data})}if(e._rowsAdded&&e._rowsAdded.length>0)for(let t=0;t<e._rowsAdded.length;t++){const i=e._rowsAdded[t],o=e.rowById[i];n.push({id:o.id,data:o.data})}return{updated:t,deleted:i,added:n}}saveBatchEdit(){this._saveBatchEdit()}revertBatchEdit(){this._clearBatchEdit(!0)}});const e=/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;function t(e){return null==e||0===e.length}class i{static null(e){return null===e}static email(i){return t(i)||e.test(i)?null:{email:!0}}static min(e,i){return(e=>{if(t(e)||t(i))return null;const n=parseFloat(e);return!isNaN(n)&&n<i?{min:{min:i,actual:n}}:null})(e)}static max(e,i){return(e=>{if(t(e)||t(i))return null;const n=parseFloat(e);return!isNaN(n)&&n>i?{max:{max:i,actual:n}}:null})(e)}static minDate(e,i){return(e=>{if(t(e)||t(i))return null;let n=e;return e&&e instanceof Smart.Utilities.DateTime&&(n=e.toDate()),!isNaN(n)&&n<i?{min:{min:i,actual:n}}:null})(e)}static maxDate(e,i){return(e=>{if(t(e)||t(i))return null;let n=e;return e&&e instanceof Smart.Utilities.DateTime&&(n=e.toDate()),!isNaN(n)&&n>i?{max:{max:i,actual:n}}:null})(e)}static required(e){return t(e)?{required:!0}:null}static requiredTrue(e){return!0===e?null:{required:!0}}static minLength(e,i){return(e=>{if(t(e))return null;const n=e?e.length:0;return n<i?{minlength:{requiredLength:i,actualLength:n}}:null})(e)}static maxLength(e,t){return(e=>{const i=e?e.length:0;return i>t?{maxlength:{requiredLength:t,actualLength:i}}:null})(e)}static url(e){return/^(ftp|http|https):\/\/[^ "]+$/.test(e)?null:{pattern:{requiredPattern:'^(ftp|http|https)://[^ "]+$',actualValue:e}}}static pattern(e,n){if(!n)return i.null;let o,l;return"string"==typeof n?(l="","^"!==n.charAt(0)&&(l+="^"),l+=n,"$"!==n.charAt(n.length-1)&&(l+="$"),o=new RegExp(l)):(l=n.toString(),o=n),(e=>t(e)||o.test(e)?null:{pattern:{requiredPattern:l,actualValue:e}})(e)}}window.Smart.Validator=i})();