text: function(e,t,i){"use strict";var n,a=q(e("../../core/renderer")),o,d=q(e("../../core/dom_adapter")),l=e("../../core/utils/window"),r,s=q(e("../../events/core/events_engine")),u,c=q(e("../../core/guid")),f,h=q(e("../../core/utils/type")),p=e("../../core/utils/iterator"),g=e("../../core/utils/extend"),m,w=q(e("./ui.grid_core.modules")),_,C=q(e("../../events/click")),v,x=q(e("../../events/pointer")),I=e("./ui.grid_core.utils"),E=e("../../events/utils"),y,b=q(e("../dialog")),R,D=q(e("../../localization/message")),k,V=q(e("../button")),T,B=q(e("../popup")),F,P=q(e("../widget/ui.errors")),A,O=q(e("../../core/devices")),S,U=q(e("../form")),M,W=q(e("../../events/hold")),N=e("../../core/utils/deferred"),K=q(N),G,H=q(e("../../core/utils/common")),j,$=q(e("../../core/utils/icon")),z,L=q(e("../scroll_view/ui.scrollable"));function q(e){return e&&e.__esModule?e:{default:e}}var X="edit-form",J="edit-form-item",Y="focus-overlay",Q="readonly",Z="edit-popup",ee="form-buttons-container",te="addrow-button",ie="dx-link",ne="dx-editor-cell",ae="dx-selection",oe="dx-edit-row",de="dx-edit-button",le="dx-command-edit",re="dx-command-edit-with-icons",se="dx-scrollable-container",ue="dx-button",ce="__DX_INSERT_INDEX__",fe="dx-row",he="dx-row-removed",pe="dx-row-inserted",ge="dx-row-modified",me="dx-cell-modified",we="dx-highlight-outline",_e="dxDataGridEditing",Ce="dx-data-row",ve="dx-cell-focus-disabled",xe="input:not([type='hidden'])",Ie="[tabindex], "+xe,Ee="batch",ye="row",be="cell",Re="form",De="popup",ke="insert",Ve="update",Te="remove",Be="dx-pointer-events-none",Fe="dx-pointer-events-target",Pe=["batch","row","cell","form","popup"],Ae=["row","form","popup"],Oe=["batch","cell"],Se=["form","popup"],Ue=["row","form"],Me={save:"dx-link-save",cancel:"dx-link-cancel",edit:"dx-link-edit",undelete:"dx-link-undelete",delete:"dx-link-delete",add:"dx-link-add"},We={save:"save",cancel:"revert",edit:"edit",undelete:"revert",delete:"trash",add:"add"},Ne={edit:"editRow",delete:"deleteRow",undelete:"undeleteRow",save:"saveEditData",cancel:"cancelEditData",add:"addRowByRowIndex"},Ke={add:"allowAdding",edit:"allowUpdating",delete:"allowDeleting"},Ge=["edit","save","cancel","delete","undelete"],He=function(e){var t=e.option("editing.mode");return-1!==Pe.indexOf(t)?t:"row"},je=function(e){var t=He(e);return-1!==Ae.indexOf(t)},$e=function(){return"desktop"===O.default.real().deviceType?x.default.down:C.default.name},ze=w.default.ViewController.inherit((Le=function(e){return function(t,i){var n=(0,a.default)("<div>").appendTo(t);e.getController("editorFactory").createEditor(n,(0,g.extend)({},i.column,{value:i.value,setValue:i.setValue,row:i.row,parentType:"dataRow",width:null,readOnly:!i.setValue,isOnForm:i.isOnForm,id:i.id}))}},qe=function(e){var t=e.component.option("editing.texts")||{};return{save:t.saveRowChanges,cancel:t.cancelRowChanges,edit:t.editRow,undelete:t.undeleteRow,delete:t.deleteRow,add:t.addRowToNode}},Xe=function(e,t){var i=-1;return e.some(function(e,n){if(Je(e)===t)return i=n,!0}),i},Je=function(e){return h.default.isObject(e)?e.name:e},{init:function(){var e=this;e._editRowIndex=-1,e._editData=[],e._editColumnIndex=-1,e._columnsController=e.getController("columns"),e._dataController=e.getController("data"),e._rowsView=e.getView("rowsView"),e._editForm=null,e._dataChangedHandler||(e._dataChangedHandler=e._handleDataChanged.bind(e),e._dataController.changed.add(e._dataChangedHandler)),e._saveEditorHandler||(e.createAction("onInitNewRow",{excludeValidators:["disabled","readOnly"]}),e.createAction("onRowInserting",{excludeValidators:["disabled","readOnly"]}),e.createAction("onRowInserted",{excludeValidators:["disabled","readOnly"]}),e.createAction("onEditingStart",{excludeValidators:["disabled","readOnly"]}),e.createAction("onRowUpdating",{excludeValidators:["disabled","readOnly"]}),e.createAction("onRowUpdated",{excludeValidators:["disabled","readOnly"]}),e.createAction("onRowRemoving",{excludeValidators:["disabled","readOnly"]}),e.createAction("onRowRemoved",{excludeValidators:["disabled","readOnly"]}),e._saveEditorHandler=e.createAction(function(t){var i,n,o,d,r,s,u=t.event;je(e)||e._editCellInProgress||(i=(s=(0,a.default)(u.target)).closest(".dx-dropdowneditor-overlay").length,n=s.closest((0,l.getWindow)().document).length,d=s.closest("."+e.addWidgetPrefix("addrow-button")).length,o=s.hasClass(e.addWidgetPrefix("focus-overlay")),r="cell"===He(e),i||o||d&&r&&e.isEditing()||!n||e._closeEditItem.bind(e)(s))}),s.default.on(d.default.getDocument(),$e(),e._saveEditorHandler)),e._updateEditColumn(),e._updateEditButtons()},getUpdatedData:function(e){var t=this._dataController.keyOf(e),i=this._editData,n=(0,I.getIndexByKey)(t,i);return i[n]?(0,I.createObjectWithChanges)(e,i[n].data):e},getInsertedData:function(){return this._editData.filter(function(e){return e.data&&"insert"===e.type}).map(function(e){return e.data})},getRemovedData:function(){return this._editData.filter(function(e){return e.oldData&&"remove"===e.type}).map(function(e){return e.oldData})},_needToCloseEditableCell:function(e){var t=e.closest(".dx-data-row").length,i=e.closest(".dx-row> td"),n=this.getView("rowsView"),a=n.getRowIndex(i.parent()),o=n.getCellElements(a).index(i),d=this._columnsController.getVisibleColumns(),l=d[o]&&d[o].allowEditing;return this.isEditing()&&(!t||t&&!l&&!this.isEditCell(a,o))},_closeEditItem:function(e){this._needToCloseEditableCell(e)&&this.closeEditCell()},_handleDataChanged:function(e){var t=this,i=this._editForm;"standard"===this.option("scrolling.mode")&&this.resetRowAndPageIndices(),"prepend"===e.changeType&&(0,p.each)(this._editData,function(t,i){i.rowIndex+=e.items.length,"insert"===i.type&&(i.key.rowIndex+=e.items.length,i.key.dataRowIndex+=e.items.filter(function(e){return"data"===e.rowType}).length)}),"refresh"===e.changeType&&"popup"===He(this)&&i&&i.option("visible")&&i.repaint()},_isDefaultButtonVisible:function(e,t){var i=!0,n=je(this),a=t.row&&t.row.rowIndex===this._getVisibleEditRowIndex()&&n;switch(e.name){case"edit":i=!a&&this.allowUpdating(t)&&n;break;case"save":case"cancel":i=a;break;case"delete":i=!a&&this.allowDeleting(t)&&!t.row.removed;break;case"undelete":i=this.allowDeleting(t)&&t.row.removed}return i},_isButtonVisible:function(e,t){var i=e.visible;return h.default.isDefined(i)?h.default.isFunction(i)?i.call(e,{component:t.component,row:t.row,column:t.column}):i:this._isDefaultButtonVisible(e,t)},_getButtonConfig:function(e,t){var i=this,n=h.default.isObject(e)?e:{},a=Je(e),o=qe(t),d=Ne[a],l=this.option("editing"),r=Ke[a],s=!r||l[r];return(0,g.extend)({name:a,text:o[a],cssClass:Me[a],onClick:function(e){var n=e.event;n.stopPropagation(),n.preventDefault(),setTimeout(function(){t.row&&s&&i[d]&&i[d](t.row.rowIndex)})}},n)},_getEditingButtons:function(e){var t=this,i,n=!!e.column.buttons,a=(e.column.buttons||[]).slice();return n?((i=Xe(a,"edit"))>=0&&(Xe(a,"save")<0&&a.splice(i+1,0,"save"),Xe(a,"cancel")<0&&a.splice(Xe(a,"save")+1,0,"cancel")),(i=Xe(a,"delete"))>=0&&Xe(a,"undelete")<0&&a.splice(i+1,0,"undelete")):a=Ge.slice(),a.map(function(i){return t._getButtonConfig(i,e)})},_renderEditingButtons:function(e,t,i){var n=this;t.forEach(function(t){n._isButtonVisible(t,i)&&n._createButton(e,t,i)})},_getEditCommandCellTemplate:function(){var e=this;return function(t,i){var n,o=(0,a.default)(t);"data"===i.rowType?(i.rtlEnabled=e.option("rtlEnabled"),n=e._getEditingButtons(i),e._renderEditingButtons(o,n,i),i.watch&&i.watch(function(){return n.map(function(t){return e._isButtonVisible(t,i)})},function(){o.empty(),e._renderEditingButtons(o,n,i)})):(0,I.setEmptyText)(o)}},correctEditRowIndexAfterExpand:function(e){this._editRowIndex>this._dataController.getRowIndexByKey(e)&&this._editRowIndex++},correctEditRowIndex:function(e){this._editRowIndex+=e(this._getVisibleEditRowIndex())},isRowEditMode:function(){return je(this)},isFormEditMode:function(){var e=He(this);return-1!==Se.indexOf(e)},getEditMode:function(){return He(this)},getFirstEditableColumnIndex:function(){var e,t=this.getController("columns"),i=this._firstFormItem;if("form"===He(this)&&i){var n=this._rowsView.getCellElements(this._editRowIndex);e=this._rowsView._getEditFormEditorVisibleIndex(n,i.column)}else{var a=t.getVisibleColumns();(0,p.each)(a,function(t,i){if(i.allowEditing)return e=t,!1})}return e},getFirstEditableCellInRow:function(e){var t=this.getView("rowsView");return t&&t._getCellElement(e||0,this.getFirstEditableColumnIndex())},getFocusedCellInRow:function(e){return this.getFirstEditableCellInRow(e)},getIndexByKey:function(e,t){return(0,I.getIndexByKey)(e,t)},hasChanges:function(e){for(var t=this,i=!1,n=0;n<this._editData.length;n++)if(this._editData[n].type&&(!h.default.isDefined(e)||this._dataController.getRowIndexByKey(this._editData[n].key)===e)){i=!0;break}return i},dispose:function(){this.callBase(),clearTimeout(this._inputFocusTimeoutID),s.default.off(d.default.getDocument(),$e(),this._saveEditorHandler)},optionChanged:function(e){if("editing"===e.name){if(this._editPopup&&this._editPopup.option("visible")&&0===e.fullName.indexOf("editing.form")){var t=this._getVisibleEditRowIndex();t>=0&&this._showEditPopup(t)}else this.init();e.handled=!0}else this.callBase(e)},publicMethods:function(){return["insertRow","addRow","removeRow","deleteRow","undeleteRow","editRow","editCell","closeEditCell","saveEditData","cancelEditData","hasEditData"]},refresh:function(){"cell"!==He(this)&&("batch"!==He(this)?this.init():(this._editRowIndex=-1,this._editColumnIndex=-1))},isEditing:function(){return this._editRowIndex>-1},isEditRow:function(e){var t=He(this);return this._getVisibleEditRowIndex()===e&&-1!==Ae.indexOf(t)},getEditRowKey:function(){var e,t=this._dataController.items()[this._getVisibleEditRowIndex()];return t&&t.key},getEditRowIndex:function(){return this._getVisibleEditRowIndex()},getEditFormRowIndex:function(){var e=He(this);return"form"===e||"popup"===e?this._getVisibleEditRowIndex():-1},isEditCell:function(e,t){var i;return!(!Array.isArray(this._editData)||!this._editData.length)&&this._getVisibleEditRowIndex()===e&&this._editColumnIndex===t},getPopupContent:function(){var e=He(this),t=this._editPopup&&this._editPopup.option("visible");if("popup"===e&&t)return this._$popupContent},getEditForm:function(){return this._editForm},_needInsertItem:function(e,t){var i=this,n=this._dataController.dataSource(),a=this.option("scrolling.mode"),o=n.pageIndex(),d=n.beginPageIndex?n.beginPageIndex():o,l=n.endPageIndex?n.endPageIndex():o;if("standard"!==a)switch(t){case"append":return e.key.pageIndex===l;case"prepend":return e.key.pageIndex===d;case"refresh":e.key.rowIndex=0,e.key.dataRowIndex=0,e.key.pageIndex=0;break;default:return e.key.pageIndex>=d&&e.key.pageIndex<=l}return e.key.pageIndex===o},_generateNewItem:function(e){var t={key:e};return e&&e[ce]&&(t[ce]=e[ce]),t},processItems:function(e,t){var i,n,a,o,d=this;for(this.update(t),o=this._editData,i=0;i<o.length;i++)n=o[i].key,a=this._generateNewItem(n),"insert"===o[i].type&&this._needInsertItem(o[i],t,e,a)&&e.splice(n.dataRowIndex,0,a);return e},processDataItem:function(e,t,i){var n,a,o,d,l=this,r=t.visibleColumns,s=e.data[ce]?e.data.key:e.key;if((d=(0,I.getIndexByKey)(s,this._editData))>=0)switch(a=He(this),n=(o=this._editData[d]).data,e.isEditing=!1,o.type){case"insert":"popup"===a&&(e.visible=!1),e.inserted=!0,e.key=s,e.data=n;break;case"update":e.modified=!0,e.oldData=e.data,e.data=(0,I.createObjectWithChanges)(e.data,n),e.modifiedValues=i(n,r,!0);break;case"remove":"batch"===a&&(e.data=(0,I.createObjectWithChanges)(e.data,n)),e.removed=!0}},insertRow:function(){return P.default.log("W0002","dxDataGrid","insertRow","15.2","Use the 'addRow' method instead"),this.addRow()},_initNewRow:function(e,t){this.executeAction("onInitNewRow",e);var i=this._dataController,n=i.items(),a=n[t.rowIndex];a&&(!a.isEditing&&"detail"===a.rowType||"detailAdaptive"===a.rowType)&&t.rowIndex++,t.dataRowIndex=i.getRowIndexDelta()+n.filter(function(e,i){return i<t.rowIndex&&("data"===e.rowType||"group"===e.rowType)}).length},_getInsertIndex:function(){var e=0;return this._editData.forEach(function(t){"insert"===t.type&&t.key[ce]>e&&(e=t.key[ce])}),e+1},addRow:function(e){var t,i=this,n=i._dataController,a=n.store(),o=a&&a.key(),d=i.getView("rowsView"),l={data:{}},r=n.getRowIndexByKey(e),u={pageIndex:n.pageIndex(),rowIndex:r>=0?r+1:d?d.getTopVisibleItemIndex(!0):0,parentKey:e},f=i._getVisibleEditRowIndex(),h=He(i);if(a){"cell"===h&&i.hasChanges()&&i.saveEditData(),i.refresh();var p=i._getInsertIndex();"batch"!==h&&p>1||(o||(l.data.__KEY__=String(new c.default)),i._initNewRow(l,u),"batch"!==(h=He(i))&&(i._editRowIndex=u.rowIndex+i._dataController.getRowIndexOffset()),u[ce]=p,i._addEditData({key:u,data:l.data,type:"insert"}),n.updateItems({changeType:"update",rowIndices:[f,u.rowIndex]}),"popup"===h?i._showEditPopup(u.rowIndex):(t=i.getFirstEditableCellInRow(u.rowIndex),i._editCellInProgress=!0,i._delayedInputFocus(t,function(){i._editCellInProgress=!1;var e=i.getFirstEditableCellInRow(u.rowIndex);e&&s.default.trigger(e,C.default.name)})),i._afterInsertRow({key:u,data:l.data}))}else n.fireError("E1052",this.component.NAME)},_isEditingStart:function(e){return this.executeAction("onEditingStart",e),e.cancel},_beforeEditCell:function(e,t,i){var n=this;if("cell"===He(n)&&!i.inserted&&n.hasChanges()){var a=new N.Deferred;return n.saveEditData().always(function(){a.resolve(n.hasChanges())}),a}},_beforeUpdateItems:function(){},_getVisibleEditRowIndex:function(){return this._editRowIndex>=0?this._editRowIndex-this._dataController.getRowIndexOffset():-1},editRow:function(e){var t,i=this,n=i._dataController,a=n.items(),o=a[e],d={data:o&&o.data,cancel:!1},l=i._getVisibleEditRowIndex();if(o){if(e===l)return!0;if(o.inserted||(d.key=o.key),!i._isEditingStart(d)){i.init(),i._pageIndex=n.pageIndex(),i._editRowIndex=(a[0].inserted?e-1:e)+i._dataController.getRowIndexOffset(),i._addEditData({data:{},key:o.key,oldData:o.data});var r=[l,e],s=He(i);i._beforeUpdateItems(r,e,l),"popup"===s?i._showEditPopup(e):n.updateItems({changeType:"update",rowIndices:r}),-1!==Ue.indexOf(s)&&(t=i.getFocusedCellInRow(i._getVisibleEditRowIndex()),i._delayedInputFocus(t,function(){t&&i.component.focus(t)}))}}},_showEditPopup:function(e){var t=this,i="desktop"!==O.default.current().deviceType,n=(0,g.extend)({showTitle:!1,fullScreen:i,toolbarItems:[{toolbar:"bottom",location:"after",widget:"dxButton",options:this._getSaveButtonConfig()},{toolbar:"bottom",location:"after",widget:"dxButton",options:this._getCancelButtonConfig()}],contentTemplate:this._getPopupEditFormTemplate(e)},this.option("editing.popup"));if(!this._editPopup){var o=(0,a.default)("<div>").appendTo(this.component.$element()).addClass(this.addWidgetPrefix("edit-popup"));this._editPopup=this._createComponent(o,B.default,{}),this._editPopup.on("hiding",this._getEditPopupHiddenHandler()),this._editPopup.on("shown",function(e){s.default.trigger(e.component.$content().find(Ie).not(".dx-scrollable-container").first(),"focus")})}this._editPopup.option(n),this._editPopup.show()},_getEditPopupHiddenHandler:function(){var e=this;return function(t){e.isEditing()&&e.cancelEditData()}},_getPopupEditFormTemplate:function(e){var t=this,i=t.component.getVisibleRows()[e],n={row:i,rowType:i.rowType,key:i.key};return function(e){var i=t.getEditFormTemplate(),o=t._createComponent((0,a.default)("<div>").appendTo(e),L.default);t._$popupContent=o.$content(),i(t._$popupContent,n,!0)}},_getSaveButtonConfig:function(){return{text:this.option("editing.texts.saveRowChanges"),onClick:this.saveEditData.bind(this)}},_getCancelButtonConfig:function(){return{text:this.option("editing.texts.cancelRowChanges"),onClick:this.cancelEditData.bind(this)}},_removeEditDataItem:function(e){e>=0&&this._editData.splice(e,1)},editCell:function(e,t){var i=this,n=i._columnsController,a=i._dataController,o,d=a.items()[e],l={data:d&&d.data,cancel:!1},r=i._getVisibleEditRowIndex(),s=n.getVisibleColumns(),u=s[i._editColumnIndex];h.default.isString(t)&&(t=n.columnOption(t,"index"),t=n.getVisibleIndex(t));var c=l.column=s[t];if(c&&d&&("data"===d.rowType||"detailAdaptive"===d.rowType)&&!d.removed&&!je(i)){if(i.isEditCell(e,t))return!0;var f=e+a.getRowIndexOffset();return(0,N.when)(i._beforeEditCell(e,t,d)).done(function(e){e||(i._prepareEditCell(l,d,t,f)?H.default.deferRender(function(){i._repaintEditCell(c,u,r)}):i._processCanceledEditingCell())})}return!1},_processCanceledEditingCell:function(){},_prepareEditCell:function(e,t,i,n){var a=this;return t.inserted||(e.key=t.key),!this._isEditingStart(e)&&(this._editRowIndex=n,this._editColumnIndex=i,this._pageIndex=this._dataController.pageIndex(),this._addEditData({data:{},key:t.key,oldData:t.data}),!0)},_repaintEditCell:function(e,t,i){var n=this,a=n._rowsView;e&&e.showEditorAlways&&(!t||t.showEditorAlways)||(n._editCellInProgress=!0,n.getController("editorFactory").loseFocus(),n._dataController.updateItems({changeType:"update",rowIndices:[i,n._getVisibleEditRowIndex()]}));var o=a&&a._getCellElement(n._getVisibleEditRowIndex(),n._editColumnIndex);o&&!o.find(":focus").length?n._focusEditingCell(function(){n._editCellInProgress=!1},o,!0):n._editCellInProgress=!1},_delayedInputFocus:function(e,t,i){var n=this;function a(){t&&t(),e&&s.default.trigger(e.find(Ie).first(),"focus"),n._beforeFocusCallback=null}O.default.real().ios||O.default.real().android?a():(n._beforeFocusCallback&&n._beforeFocusCallback(),clearTimeout(n._inputFocusTimeoutID),i&&(n._beforeFocusCallback=t),n._inputFocusTimeoutID=setTimeout(a))},_focusEditingCell:function(e,t,i){var n=this,a=this.getView("rowsView");t=t||a&&a._getCellElement(this._getVisibleEditRowIndex(),this._editColumnIndex),this._delayedInputFocus(t,e,i)},removeRow:function(e){return P.default.log("W0002","dxDataGrid","removeRow","15.2","Use the 'deleteRow' method instead"),this.deleteRow(e)},deleteRow:function(e){var t,i,n=this,a=n.option("editing"),o=a&&a.texts,d=o&&o.confirmDeleteTitle,l=a&&"batch"===a.mode,r=o&&o.confirmDeleteMessage,s=n._dataController,u=n._getVisibleEditRowIndex(),c=s.items()[e],f=c&&c.key,p=l||!this.isEditing();c&&p&&(t=function(t){n.refresh();var i=(0,I.getIndexByKey)(t,n._editData);i>=0?"insert"===n._editData[i].type?n._removeEditDataItem(i):n._addEditData({key:t,type:"remove"}):n._addEditData({key:t,oldData:c.data,type:"remove"}),l?s.updateItems({changeType:"update",rowIndices:[u,e]}):n.saveEditData()},l||!r?t(f):(i=h.default.isDefined(d)&&d.length>0,b.default.confirm(r,d,i).done(function(e){e&&t(f)})))},undeleteRow:function(e){var t=this,i=this._dataController,n=i.items()[e],a=this._getVisibleEditRowIndex(),o=n&&n.key;if(n){var d,l=(0,I.getIndexByKey)(o,this._editData);l>=0&&(d=this._editData[l],h.default.isEmptyObject(d.data)?this._removeEditDataItem(l):this._addEditData({key:o,type:"update"}),i.updateItems({changeType:"update",rowIndices:[a,e]}))}},_saveEditDataCore:function(e,t,i){var n=this,a=n._dataController.store(),o=!0;function d(e,t,i){var a=new N.Deferred;function o(e){return function(t){var i=t instanceof Error?t:new Error(t&&String(t)||"Unknown error");e.reject(i)}}return n.executeAction(e,t),(0,N.when)((0,N.fromPromise)(t.cancel)).done(function(e){e?setTimeout(function(){a.resolve("cancel")}):i(t).done(a.resolve).fail(o(a))}).fail(o(a)),a}return(0,p.each)(n._editData,function(l,r){var s,u,c,f=r.data,p=r.oldData,g=r.type;if(!n._beforeSaveEditData(r,l)){switch(g){case"remove":s=d("onRowRemoving",c={data:p,key:r.key,cancel:!1},function(){return a.remove(r.key).done(function(e){i.push({type:"remove",key:e})})});break;case"insert":s=d("onRowInserting",c={data:f,cancel:!1},function(){return a.insert(c.data).done(function(e,t){h.default.isDefined(t)&&(r.key=t),e&&h.default.isObject(e)&&e!==c.data&&(r.data=e),i.push({type:"insert",data:e,index:0})})});break;case"update":s=d("onRowUpdating",c={newData:f,oldData:p,key:r.key,cancel:!1},function(){return a.update(r.key,c.newData).done(function(e,t){e&&h.default.isObject(e)&&e!==c.newData&&(r.data=e),i.push({type:"update",key:t,data:e})})})}s&&(u=new N.Deferred,s.always(function(e){o="cancel"!==e,t.push({key:r.key,result:e})}).always(u.resolve),e.push(u.promise()))}}),o},_processSaveEditDataResult:function(e){var t,i,n,a,o,d,l,r=this,s=this._dataController,u=!1,c=He(this);for(t=0;t<e.length;t++)if(n="cancel"===(i=e[t].result),o=(0,I.getIndexByKey)(e[t].key,this._editData),a=this._editData[o],d=i&&i instanceof Error){if(a&&(a.error=i),l=this.getPopupContent(),s.dataErrorOccurred.fire(i,l),"batch"!==c){a&&"remove"===a.type&&this._removeEditDataItem(o);break}}else n&&a&&("batch"===c||"remove"!==a.type)||(this._removeEditDataItem(o),u=!n);return u},_fireSaveEditDataEvents:function(e){var t=this;(0,p.each)(e,function(e,i){var n=i.data,a=i.key,o=i.type,d={key:a,data:n};switch(i.error&&(d.error=i.error),o){case"remove":t.executeAction("onRowRemoved",(0,g.extend)({},d,{data:i.oldData}));break;case"insert":t.executeAction("onRowInserted",d);break;case"update":t.executeAction("onRowUpdated",d)}})},saveEditData:function(){var e,t=this,i=[],n=[],o=[],d=t._dataController,l=d.dataSource(),r=He(t),s=new N.Deferred,u=function(e){"cell"!==r&&(e._editColumnIndex=-1,e._editRowIndex=-1)};return t._beforeSaveEditData()||t._saving?(t._afterSaveEditData(),s.resolve().promise()):(e=t._editData.slice(0),t._saveEditDataCore(n,i,o)||"cell"!==r||t._focusEditingCell(),n.length?(t._saving=!0,l&&l.beginLoading(),N.when.apply(a.default,n).done(function(){if(t._processSaveEditDataResult(i)){u(t),"popup"===r&&t._editPopup&&t._editPopup.hide(),l&&l.endLoading();var n=t.option("editing.refreshMode"),a="reshape"!==n&&"repaint"!==n;a||d.push(o),(0,N.when)(d.refresh({selection:a,reload:a,load:"reshape"===n,changesOnly:t.option("repaintChangesOnly")})).always(function(){t._fireSaveEditDataEvents(e),t._afterSaveEditData(),s.resolve()})}else l&&l.endLoading(),s.resolve()}).fail(function(){l&&l.endLoading(),s.resolve()}),s.always(function(){t._focusEditingCell(),t._saving=!1}).promise()):(je(t)?t.hasChanges()||t.cancelEditData():-1!==Oe.indexOf(r)?(u(t),d.updateItems()):t._focusEditingCell(),t._afterSaveEditData(),s.resolve().promise()))},isSaving:function(){return this._saving},_updateEditColumn:function(){var e=this,t=this._isEditColumnVisible(),i,n="dx-command-edit"+(this.option("editing.useIcons")?" dx-command-edit-with-icons":"");this._columnsController.addCommandColumn({type:"buttons",command:"edit",visible:t,cssClass:n,width:"auto",alignment:"center",cellTemplate:this._getEditCommandCellTemplate(),fixedPosition:"right"}),this._columnsController.columnOption("command:edit",{visible:t,cssClass:n})},_isEditColumnVisible:function(){var e=this,t=this.option("editing");if(t){var i,n=!1;switch(He(this)){case"row":n=t.allowUpdating||t.allowAdding;break;case"form":case"popup":n=t.allowUpdating}return t.allowDeleting||n}},_updateEditButtons:function(){var e=this,t=this.getView("headerPanel"),i=this.hasChanges();t&&(t.setToolbarItemDisabled("saveButton",!i),t.setToolbarItemDisabled("revertButton",!i))},_applyModified:function(e){e&&e.addClass(me)},_beforeCloseEditCellInBatchMode:function(){},cancelEditData:function(){var e=this,t=He(this),i=this._getVisibleEditRowIndex(),n=this._dataController;this._beforeCancelEditData(),this.init(),-1!==Ae.indexOf(t)&&i>=0?n.updateItems({changeType:"update",rowIndices:[i,i+1]}):n.updateItems(),"popup"===t&&this._hideEditPopup()},_hideEditPopup:function(){this._editPopup&&this._editPopup.option("visible",!1)},hasEditData:function(){return this.hasChanges()},closeEditCell:function(){var e=this,t=He(e),i=e._getVisibleEditRowIndex(),n=e._dataController,a=K.default.when();return je(e)||(a=K.default.Deferred(),setTimeout(function(){if("cell"===t&&e.hasChanges())e.saveEditData().done(function(){e.hasChanges()||e.closeEditCell()});else if(i>=0){var o=[i];e._editRowIndex=-1,e._editColumnIndex=-1,e._beforeCloseEditCellInBatchMode(o),n.updateItems({changeType:"update",rowIndices:o})}a.resolve()})),a.promise()},update:function(e){var t=this,i=this._dataController;i&&this._pageIndex!==i.pageIndex()&&("refresh"===e&&this.refresh(),this._pageIndex=i.pageIndex()),this._updateEditButtons()},_getRowIndicesForCascadeUpdating:function(e,t){return t?[]:[e.rowIndex]},updateFieldValue:function(e,t,i,n){var o,d,l=this,r={},s=e.data,u=e.key,c=(0,a.default)(e.cellElement),f=He(this),h=e.column.setCellValue!==e.column.defaultSetCellValue;if(void 0===u&&this._dataController.fireError("E1043"),e.column.setCellValue){if(void 0!==u&&("batch"===f&&this._applyModified(c,e),e.value=t,e.column.setCellValue(r,t,(0,g.extend)(!0,{},s),i),i&&e.column.displayValueMap&&(e.column.displayValueMap[t]=i)),o={data:r,key:u,oldData:s,type:"update"},this._addEditData(o,e.row),this._updateEditButtons(),e.column.showEditorAlways&&!n){if("cell"===f&&e.row&&!e.row.inserted)return this.saveEditData();"batch"===f&&(d=this._columnsController.getVisibleColumns(),n=h||d.some(function(e){return e.calculateCellValue!==e.defaultCalculateCellValue}))}e.row&&(n||h)&&this._updateEditRow(e.row,n)}},_updateEditRowCore:function(e,t){var i=this,n=this._editForm,a;"popup"===He(this)?n&&n.repaint():this._dataController.updateItems({changeType:"update",rowIndices:this._getRowIndicesForCascadeUpdating(e,t)})},_updateEditRow:function(e,t){var i=this;t||!je(i)?(i._updateEditRowCore(e,!t),t||i._focusEditingCell()):setTimeout(function(){var t=(0,a.default)(d.default.getActiveElement()),n=i._rowsView.getCellIndex(t,e.rowIndex),o=t.get(0),l=(0,I.getSelectionRange)(o);if(i._updateEditRowCore(e),n>=0){var r=i._rowsView._getCellElement(e.rowIndex,n);i._delayedInputFocus(r,function(){setTimeout(function(){o=d.default.getActiveElement(),l.selectionStart>=0&&(0,I.setSelectionRange)(o,l)})})}})},_addEditData:function(e,t){var i=this,n=(0,I.getIndexByKey)(e.key,this._editData);return n<0&&(n=this._editData.length,this._editData.push(e)),this._editData[n]&&(e.data&&(this._editData[n].data=(0,I.createObjectWithChanges)(this._editData[n].data,e.data)),this._editData[n].type&&e.data||!e.type||(this._editData[n].type=e.type),t&&(t.oldData=this._editData[n].oldData,t.data=(0,I.createObjectWithChanges)(t.data,e.data))),n},_getFormEditItemTemplate:function(e,t){return t.editCellTemplate||Le(this)},renderFormEditTemplate:function(e,t,i,n,o){var d=this,r=(0,a.default)(n),s=t.column,u=e.row&&e.row.data,c=(0,g.extend)({},e,{data:u,cellElement:null,isOnForm:!0,item:t,value:s.calculateCellValue(u),column:(0,g.extend)({},s,{editorOptions:t.editorOptions}),id:i.getItemID(t.name||t.dataField),columnIndex:s.index,setValue:!o&&s.allowEditing&&function(e){d.updateFieldValue(c,e)}}),f=d._getFormEditItemTemplate.bind(d)(c,s);d._rowsView.renderTemplate(r,f,c,!!r.closest((0,l.getWindow)().document).length)&&d._rowsView._updateCell(r,c)},getFormEditorTemplate:function(e,t){var i=this;return function(n,a){i.renderFormEditTemplate.bind(i)(e,t,n.component,a)}},getEditFormTemplate:function(){var e=this;return function(t,i,n){var o=e.option("editing.form"),d=e.option("editing.form.items"),l=e.option("editing.form.customizeItem"),r=e._editData[(0,I.getIndexByKey)(i.key,e._editData)],s=e.addWidgetPrefix("edit-form-item");if(!d){var u=e.getController("columns").getColumns();d=[],(0,p.each)(u,function(e,t){t.isBand||t.type||d.push({column:t,name:t.name,dataField:t.dataField})})}if(e._firstFormItem=void 0,e._editForm=e._createComponent((0,a.default)("<div>").appendTo(t),U.default,(0,g.extend)({},o,{items:d,formID:"dx-"+new c.default,validationGroup:r,customizeItem:function(t){var n;if((t.column||t.dataField||t.name)&&(n=t.column||e._columnsController.columnOption(t.name?"name:"+t.name:"dataField:"+t.dataField)),n){t.label=t.label||{},t.label.text=t.label.text||n.caption,t.template=t.template||e.getFormEditorTemplate(i,t),t.column=n,n.formItem&&(0,g.extend)(t,n.formItem),void 0===t.isRequired&&n.validationRules&&(t.isRequired=n.validationRules.some(function(e){return"required"===e.type}),t.validationRules=[]);var a=!h.default.isDefined(t.visible)||t.visible;!e._firstFormItem&&a&&(e._firstFormItem=t)}l&&l.call(this,t),t.cssClass=h.default.isString(t.cssClass)?t.cssClass+" "+s:s}})),!n){var f=(0,a.default)("<div>").addClass(e.addWidgetPrefix("form-buttons-container")).appendTo(t);e._createComponent((0,a.default)("<div>").appendTo(f),V.default,e._getSaveButtonConfig()),e._createComponent((0,a.default)("<div>").appendTo(f),V.default,e._getCancelButtonConfig())}e._editForm.on("contentReady",function(){e._editPopup&&e._editPopup.repaint()})}},getColumnTemplate:function(e){var t,i,n,a=this,o=e.column,d=e.row&&e.row.rowIndex,l=je(a),r=a.isEditRow(d),s=a.isEditCell(d,e.columnIndex);return!(o.showEditorAlways||o.setCellValue&&(r&&o.allowEditing||s))||"data"!==e.rowType&&"detailAdaptive"!==e.rowType||o.command?"detail"===o.command&&"detail"===e.rowType&&r&&(t=a.getEditFormTemplate(e)):((((i=a.allowUpdating(e))||r)&&o.allowEditing||s)&&(l&&r||!l)&&(o.showEditorAlways&&!l&&(n={cancel:!1,key:e.row.inserted?void 0:e.row.key,data:e.row.data,column:o},a._isEditingStart(n)),n&&n.cancel||(e.setValue=function(t,i){a.updateFieldValue(e,t,i)})),t=o.editCellTemplate||Le(a)),t},_createButton:function(e,t,i){var n,o=this,d=We[t.name],l=this.option("editing.useIcons"),r=(0,a.default)("<a>").attr("href","#").addClass("dx-link").addClass(t.cssClass);t.template?this._rowsView.renderTemplate(e,t.template,i,!0):(l&&d||t.icon?(d=t.icon||d,"image"===(n=$.default.getImageSourceType(d))?r=$.default.getImageContainer(d):r.addClass("dx-icon"+("dxIcon"===n?"-":" ")+d).attr("title",t.text),e.addClass("dx-command-edit-with-icons")):r.text(t.text),h.default.isDefined(t.hint)&&r.attr("title",t.hint),s.default.on(r,(0,E.addNamespace)("click",_e),this.createAction(function(e){t.onClick.call(t,(0,g.extend)({},e,{row:i.row,column:i.column})),e.event.preventDefault()})),i.rtlEnabled?e.prepend(r,"&nbsp;"):e.append(r,"&nbsp;"))},prepareEditButtons:function(e){var t=this,i=t.option("editing")||{},n=t.option("editing.texts")||{},o={revert:n.cancelAllChanges,save:n.saveAllChanges,addRow:n.addRow},d={revert:"cancel",save:"save",addRow:"addrow"},l=[],r=function(i,n,l){var r=d[i],s=function(i){(0,a.default)(i.element).addClass(e._getToolbarButtonClass("dx-edit-button "+t.addWidgetPrefix(r)+"-button"))},u=o[i],c=("save"===r||"cancel"===r)&&!t.hasChanges();return{widget:"dxButton",options:{onInitialized:s,icon:"edit-button-"+r,disabled:c,onClick:function(){setTimeout(function(){t[n]()})},text:u,hint:u},showText:"inMenu",name:i+"Button",location:"after",locateInMenu:"auto",sortIndex:l}};return i.allowAdding&&l.push(r("addRow","addRow",20)),(i.allowUpdating||i.allowAdding||i.allowDeleting)&&"batch"===He(t)&&(l.push(r("save","saveEditData",21)),l.push(r("revert","cancelEditData",22))),l},showHighlighting:function(e){var t=e.find(".dx-highlight-outline");"TD"!==e.get(0).tagName||t.length||e.wrapInner((0,a.default)("<div>").addClass("dx-highlight-outline dx-pointer-events-target"))},resetRowAndPageIndices:function(e){var t=this;(0,p.each)(t._editData,function(i,n){(n.pageIndex!==t._pageIndex||e)&&(delete n.pageIndex,delete n.rowIndex)})},_afterInsertRow:function(){},_beforeSaveEditData:function(e){if(e&&!h.default.isDefined(e.key)&&h.default.isDefined(e.type))return!0},_afterSaveEditData:function(){},_beforeCancelEditData:function(){},_allowEditAction:function(e,t){var i=this.option("editing."+e);return h.default.isFunction(i)&&(i=i({component:this.component,row:t.row})),i},allowUpdating:function(e){return this._allowEditAction("allowUpdating",e)},allowDeleting:function(e){return this._allowEditAction("allowDeleting",e)}})),Le,qe,Xe,Je;i.exports={defaultOptions:function(){return{editing:{mode:"row",refreshMode:"full",allowAdding:!1,allowUpdating:!1,allowDeleting:!1,useIcons:!1,texts:{editRow:D.default.format("dxDataGrid-editingEditRow"),saveAllChanges:D.default.format("dxDataGrid-editingSaveAllChanges"),saveRowChanges:D.default.format("dxDataGrid-editingSaveRowChanges"),cancelAllChanges:D.default.format("dxDataGrid-editingCancelAllChanges"),cancelRowChanges:D.default.format("dxDataGrid-editingCancelRowChanges"),addRow:D.default.format("dxDataGrid-editingAddRow"),deleteRow:D.default.format("dxDataGrid-editingDeleteRow"),undeleteRow:D.default.format("dxDataGrid-editingUndeleteRow"),confirmDeleteMessage:D.default.format("dxDataGrid-editingConfirmDeleteMessage"),confirmDeleteTitle:""},form:{colCount:2},popup:{}}}},controllers:{editing:ze},extenders:{controllers:{data:{init:function(){this._editingController=this.getController("editing"),this.callBase()},reload:function(e,t){var i,n=this.getController("editing");return!t&&this._editingController.refresh(),(i=this.callBase.apply(this,arguments))&&i.done(function(){n.resetRowAndPageIndices(!0)})},repaintRows:function(){if(!this.getController("editing").isSaving())return this.callBase.apply(this,arguments)},_updateEditRow:function(e){var t=this._editingController,i,n=e[t.getEditRowIndex()];n&&(n.isEditing=!0,"form"===t.getEditMode()&&(n.rowType="detail"))},_updateItemsCore:function(e){this.callBase(e),this._updateEditRow(this.items())},_applyChangeUpdate:function(e){this._updateEditRow(e.items),this.callBase(e)},_applyChangesOnly:function(e){this._updateEditRow(e.items),this.callBase(e)},_processItems:function(e,t){return e=this._editingController.processItems(e,t),this.callBase(e,t)},_processDataItem:function(e,t){return this._editingController.processDataItem(e,t,this.generateDataValues),this.callBase(e,t)},_processItem:function(e,t){return(e=this.callBase(e,t)).inserted&&(t.dataIndex--,delete e.dataIndex),e},_correctRowIndices:function(e){this.callBase.apply(this,arguments),this._editingController.correctEditRowIndex(e)},_getChangedColumnIndices:function(e,t,i,n){var a=this.getController("editing"),o=a.isRowEditMode();if(!(e.inserted!==t.inserted||e.removed!==t.removed||o&&e.isEditing!==t.isEditing))return e.rowType===t.rowType&&o&&a.isEditRow(i)&&n?[]:this.callBase.apply(this,arguments)},_isCellChanged:function(e,t,i,n,a){var o=this.getController("editing"),d=e.cells&&e.cells[n],l=o&&o.isEditCell(i,n);return(!a||!l)&&(!(!d||d.isEditing===l)||this.callBase.apply(this,arguments))}}},views:{rowsView:{init:function(){this.callBase(),this._editingController=this.getController("editing")},getCellElements:function(e){var t=this.callBase(e),i=this._editingController,n=i.getEditForm(),a;return i.getEditFormRowIndex()===e&&t&&n?n.$element().find("."+this.addWidgetPrefix("edit-form-item")+", .dx-button"):t},getCellIndex:function(e,t){if(!e.is("td")&&t>=0){var i=this.getCellElements(t),n=-1;return(0,p.each)(i,function(t,i){(0,a.default)(i).find(e).length&&(n=t)}),n}return this.callBase.apply(this,arguments)},_getVisibleColumnIndex:function(e,t,i){var n,a;return this._editingController.getEditFormRowIndex()===t&&h.default.isString(i)?(n=this._columnsController.columnOption(i),this._getEditFormEditorVisibleIndex(e,n)):this.callBase.apply(this,arguments)},_getEditFormEditorVisibleIndex:function(e,t){var i,n=-1;return(0,p.each)(e,function(e,o){if((i=(0,a.default)(o).find(".dx-field-item-content").data("dx-form-item"))&&i.column&&t&&i.column.index===t.index)return n=e,!1}),n},publicMethods:function(){return this.callBase().concat(["cellValue"])},_getCellTemplate:function(e){var t=this,i;return this._editingController.getColumnTemplate(e)||this.callBase(e)},_isNativeClick:function(){return(O.default.real().ios||O.default.real().android)&&this.option("editing.allowUpdating")},_createTable:function(){var e=this,t=e.callBase.apply(e,arguments);return!je(e)&&e.option("editing.allowUpdating")&&s.default.on(t,(0,E.addNamespace)(W.default.name,"dxDataGridRowsView"),"td:not(.dx-editor-cell)",e.createAction(function(){var t=e._editingController;t.isEditing()&&t.closeEditCell()})),t},_createRow:function(e){var t,i,n,a,o,d=this.callBase(e);return e&&(i=(t=this._editingController).isEditRow(e.rowIndex),n=!!e.removed,a=!!e.inserted,o=!!e.modified,"batch"===He(this)?n&&d.addClass(he):i&&d.addClass(oe),a&&d.addClass(pe),o&&d.addClass(ge),(i||a||n)&&d.removeClass(ae),i&&"detail"===e.rowType&&d.addClass(this.addWidgetPrefix("edit-form"))),d},_getColumnIndexByElement:function(e){for(var t=e.closest("table"),i=this.getTableElements();t.length&&!i.filter(t).length;)e=t.closest("td"),t=e.closest("table");return this._getColumnIndexByElementCore(e)},_getColumnIndexByElementCore:function(e){var t=e.closest(".dx-row> td:not(.dx-master-detail-cell)");return this.getCellIndex(t)},_rowClick:function(e){var t=this,i=this._editingController,n=(0,a.default)(e.event.target),o=this._getColumnIndexByElement(n),d=this._dataController.items()[e.rowIndex],l=i.allowUpdating({row:d})||d&&d.inserted,r=this._columnsController.getVisibleColumns()[o],s=r&&(r.allowEditing||i.isEditCell(e.rowIndex,o));n.closest(".dx-row> td").hasClass("dx-pointer-events-none")||l&&s&&i.editCell(e.rowIndex,o)||i.isEditRow(e.rowIndex)||this.callBase(e)},_cellPrepared:function(e,t){var i=t.columnIndex,n=this._editingController,a=!!t.column.command,o=t.setValue,d=t.isEditing||n.isEditRow(t.rowIndex)&&t.column.allowEditing;if("data"===t.rowType&&!t.column.command&&(d||t.column.showEditorAlways)){var l=t.column.alignment;e.addClass("dx-editor-cell").toggleClass(this.addWidgetPrefix("readonly"),!o).toggleClass("dx-cell-focus-disabled",!o),l&&e.find(xe).first().css("textAlign",l)}var r=t.row&&(t.row.inserted?t.row.values:t.row.modifiedValues);r&&void 0!==r[i]&&t.column&&!a&&t.column.setCellValue?(n.showHighlighting(e),e.addClass(me)):o&&n.showHighlighting(e,!0),this.callBase.apply(this,arguments)},_formItemPrepared:function(){},_isFormItem:function(e){var t="detail"===e.rowType||"detailAdaptive"===e.rowType,i="data"===e.rowType&&"popup"===He(this);return(t||i)&&e.item},_updateCell:function(e,t){this._isFormItem(t)?this._formItemPrepared(t,e):this.callBase(e,t)},_update:function(e){this.callBase(e),"updateSelection"===e.changeType&&this.getTableElements().children("tbody").children("."+oe).removeClass(ae)},_getCellOptions:function(e){var t=this.callBase(e);return t.isEditing=this._editingController.isEditCell(t.rowIndex,t.columnIndex),t},_renderCellContent:function(e,t){"data"===t.rowType&&"popup"===He(this)&&!1===t.row.visible||this.callBase.apply(this,arguments)},cellValue:function(e,t,i,n){var a=this.getCellOptions(e,t);if(a){if(void 0===i)return a.value;this._editingController.updateFieldValue(a,i,n,!0)}}},headerPanel:{_getToolbarItems:function(){var e=this.callBase(),t;return this.getController("editing").prepareEditButtons(this).concat(e)},optionChanged:function(e){switch(e.name){case"editing":e.fullName&&0===e.fullName.indexOf("editing.popup")||this._invalidate(),this.callBase(e);break;default:this.callBase(e)}},isVisible:function(){var e=this,t=this.getController("editing").option("editing");return this.callBase()||t&&(t.allowAdding||(t.allowUpdating||t.allowDeleting)&&"batch"===t.mode)}}}}}}
  
  