/*
    *
    * Wijmo Library 5.20181.462
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
function tryGetModuleWijmoGridDetail(){let e,t;return(e=window.wijmo)&&(t=e.grid)&&t.detail}function tryGetModuleWijmoInput(){let e;return(e=window.wijmo)&&e.input}import*as wjcGrid from"wijmo/wijmo.grid";import*as wjcCore from"wijmo/wijmo";import{Component,NgModule}from"@angular/core";import{ElementRef,Injector,Directive,ViewContainerRef,TemplateRef,Optional,forwardRef,Renderer}from"@angular/core";import{Inject,ChangeDetectorRef,SkipSelf}from"@angular/core";import{CommonModule}from"@angular/common";import{NG_VALUE_ACCESSOR}from"@angular/forms";import{WjDirectiveBehavior,WjDirectiveBaseModule,WjValueAccessorFactory}from"wijmo/wijmo.angular2.directiveBase";export var wjFlexGridMeta={selector:"wj-flex-grid",template:`<div><ng-content></ng-content></div>`,inputs:["wjModelProperty","isDisabled","newRowAtTop","allowAddNew","allowDelete","allowDragging","allowMerging","allowResizing","allowSorting","quickAutoSize","autoScroll","autoSizeMode","autoGenerateColumns","childItemsPath","groupHeaderFormat","headersVisibility","showSelectedHeaders","showMarquee","itemFormatter","isReadOnly","imeEnabled","mergeManager","selectionMode","showGroups","showSort","showDropDown","showAlternatingRows","showErrors","validateEdits","treeIndent","itemsSource","autoClipboard","frozenRows","frozenColumns","cloneFrozenCells","deferResizing","sortRowIndex","stickyHeaders","preserveSelectedState","preserveOutlineState","keyActionTab","keyActionEnter","rowHeaderPath","virtualizationThreshold"],outputs:["initialized","gotFocusNg: gotFocus","lostFocusNg: lostFocus","beginningEditNg: beginningEdit","cellEditEndedNg: cellEditEnded","cellEditEndingNg: cellEditEnding","prepareCellForEditNg: prepareCellForEdit","formatItemNg: formatItem","resizingColumnNg: resizingColumn","resizedColumnNg: resizedColumn","autoSizingColumnNg: autoSizingColumn","autoSizedColumnNg: autoSizedColumn","draggingColumnNg: draggingColumn","draggingColumnOverNg: draggingColumnOver","draggedColumnNg: draggedColumn","sortingColumnNg: sortingColumn","sortedColumnNg: sortedColumn","resizingRowNg: resizingRow","resizedRowNg: resizedRow","autoSizingRowNg: autoSizingRow","autoSizedRowNg: autoSizedRow","draggingRowNg: draggingRow","draggingRowOverNg: draggingRowOver","draggedRowNg: draggedRow","deletingRowNg: deletingRow","deletedRowNg: deletedRow","loadingRowsNg: loadingRows","loadedRowsNg: loadedRows","rowEditStartingNg: rowEditStarting","rowEditStartedNg: rowEditStarted","rowEditEndingNg: rowEditEnding","rowEditEndedNg: rowEditEnded","rowAddedNg: rowAdded","groupCollapsedChangedNg: groupCollapsedChanged","groupCollapsedChangingNg: groupCollapsedChanging","itemsSourceChangedNg: itemsSourceChanged","selectionChangingNg: selectionChanging","selectionChangedNg: selectionChanged","scrollPositionChangedNg: scrollPositionChanged","updatingViewNg: updatingView","updatedViewNg: updatedView","updatingLayoutNg: updatingLayout","updatedLayoutNg: updatedLayout","pastingNg: pasting","pastedNg: pasted","pastingCellNg: pastingCell","pastedCellNg: pastedCell","copyingNg: copying","copiedNg: copied"],providers:[{provide:NG_VALUE_ACCESSOR,useFactory:WjValueAccessorFactory,multi:!0,deps:["WjComponent"]}]};export class WjFlexGrid extends wjcGrid.FlexGrid{constructor(e,t,l,i){super(WjDirectiveBehavior.getHostElement(e,t)),this.isInitialized=!1;this._wjBehaviour=WjDirectiveBehavior.attach(this,e,t,l);new DirectiveCellFactory(this,i),this.deferUpdate(()=>{if(this.rows.defaultSize<10){let e=this.hostElement,t=getComputedStyle(e),l=getComputedStyle(document.body),i=2*parseInt(t.fontSize&&wjcCore.contains(document.body,e)?t.fontSize:l.fontSize);this.rows.defaultSize=i,this.columns.defaultSize=4*i,this.columnHeaders.rows.defaultSize=i,this.rowHeaders.columns.defaultSize=Math.round(1.25*i)}}),this.created()}created(){}ngOnInit(){this._wjBehaviour.ngOnInit()}ngAfterViewInit(){this._wjBehaviour.ngAfterViewInit()}ngOnDestroy(){this._wjBehaviour.ngOnDestroy()}addEventListener(e,t,l,i=!1){let o=WjDirectiveBehavior,r=o.ngZone;r&&o.outsideZoneEvents[t]?r.runOutsideAngular(()=>{super.addEventListener(e,t,l,i)}):super.addEventListener(e,t,l,i)}};WjFlexGrid.meta={outputs:wjFlexGridMeta.outputs},WjFlexGrid.decorators=[{type:Component,args:[{selector:wjFlexGridMeta.selector,template:wjFlexGridMeta.template,inputs:wjFlexGridMeta.inputs,outputs:wjFlexGridMeta.outputs,providers:[{provide:"WjComponent",useExisting:forwardRef(()=>WjFlexGrid)},...wjFlexGridMeta.providers]}]}],WjFlexGrid.ctorParameters=(()=>[{type:ElementRef,decorators:[{type:Inject,args:[ElementRef]}]},{type:Injector,decorators:[{type:Inject,args:[Injector]}]},{type:void 0,decorators:[{type:Inject,args:["WjComponent"]},{type:SkipSelf},{type:Optional}]},{type:ChangeDetectorRef,decorators:[{type:Inject,args:[ChangeDetectorRef]}]}]);export var wjFlexGridColumnMeta={selector:"wj-flex-grid-column",template:`<div><ng-content></ng-content></div>`,inputs:["asyncBindings","wjProperty","name","dataMap","dataType","binding","sortMemberPath","format","header","width","maxLength","minWidth","maxWidth","align","allowDragging","allowSorting","allowResizing","allowMerging","aggregate","isReadOnly","cssClass","isContentHtml","isSelected","visible","wordWrap","multiLine","mask","inputType","isRequired","showDropDown","dropDownCssClass","quickAutoSize"],outputs:["initialized","isSelectedChangePC: isSelectedChange"],providers:[]};export class WjFlexGridColumn extends wjcGrid.Column{constructor(e,t,l){super(),this.isInitialized=!1,this.wjProperty="columns";let i=(this._wjBehaviour=WjDirectiveBehavior.attach(this,e,t,l)).parentBehavior.directive;i.autoGenerateColumns&&(i.autoGenerateColumns=!1,i.columns.clear()),this.created()}created(){}ngOnInit(){this._wjBehaviour.ngOnInit()}ngAfterViewInit(){this._wjBehaviour.ngAfterViewInit()}ngOnDestroy(){this._wjBehaviour.ngOnDestroy()}};WjFlexGridColumn.meta={outputs:wjFlexGridColumnMeta.outputs,changeEvents:{"grid.selectionChanged":["isSelected"]}},WjFlexGridColumn.decorators=[{type:Component,args:[{selector:wjFlexGridColumnMeta.selector,template:wjFlexGridColumnMeta.template,inputs:wjFlexGridColumnMeta.inputs,outputs:wjFlexGridColumnMeta.outputs,providers:[{provide:"WjComponent",useExisting:forwardRef(()=>WjFlexGridColumn)},...wjFlexGridColumnMeta.providers]}]}],WjFlexGridColumn.ctorParameters=(()=>[{type:ElementRef,decorators:[{type:Inject,args:[ElementRef]}]},{type:Injector,decorators:[{type:Inject,args:[Injector]}]},{type:void 0,decorators:[{type:Inject,args:["WjComponent"]},{type:SkipSelf},{type:Optional}]}]);export class WjFlexGridCellTemplate{constructor(e,t,l,i,o,r,n){this.viewContainerRef=e,this.templateRef=t,this.elRef=l,this.domRenderer=o,this.cdRef=n,this.autoSizeRows=!0,this.forceFullEdit=!0,i instanceof WjFlexGrid?this.grid=i:i instanceof WjFlexGridColumn&&(this.column=i,this.grid=WjDirectiveBehavior.getBehavior(i).parentBehavior.directive)}static _getTemplContextProp(e){return"$__cellTempl"+CellTemplateType[e]}ngOnInit(){this.ownerControl=this.column&&this.column.grid===this.grid?this.column:this.grid,this._attachToControl()}ngOnDestroy(){this.cellTypeStr&&(this.viewContainerRef.clear(),this.ownerControl[WjFlexGridCellTemplate._getTemplContextProp(this.cellType)]=null,this.grid.invalidate())}_instantiateTemplate(e,t){return WjDirectiveBehavior.instantiateTemplate(e,this.viewContainerRef,this.templateRef,this.domRenderer,!1,t)}_attachToControl(){if(!this.cellTypeStr)return;let e=this.cellType=wjcCore.asEnum(this.cellTypeStr,CellTemplateType),t=this.ownerControl;t[WjFlexGridCellTemplate._getTemplContextProp(e)]=this,t instanceof wjcGrid.Column&&(e===CellTemplateType.Cell||e===CellTemplateType.ColumnHeader||e===CellTemplateType.ColumnFooter)&&t._setFlag(wjcGrid.RowColFlags.HasTemplate,!0),this.grid.invalidate()}};WjFlexGridCellTemplate.decorators=[{type:Directive,args:[{selector:"[wjFlexGridCellTemplate]",inputs:["wjFlexGridCellTemplate","cellTypeStr: cellType","cellOverflow","valuePaths","autoSizeRows","forceFullEdit"],exportAs:"wjFlexGridCellTemplate",providers:[{provide:"WjComponent",useExisting:forwardRef(()=>WjFlexGridCellTemplate)}]}]}],WjFlexGridCellTemplate.ctorParameters=(()=>[{type:ViewContainerRef,decorators:[{type:Inject,args:[ViewContainerRef]}]},{type:TemplateRef,decorators:[{type:Inject,args:[TemplateRef]},{type:Optional}]},{type:ElementRef,decorators:[{type:Inject,args:[ElementRef]}]},{type:void 0,decorators:[{type:Inject,args:["WjComponent"]},{type:SkipSelf},{type:Optional}]},{type:Renderer,decorators:[{type:Inject,args:[Renderer]}]},{type:Injector,decorators:[{type:Inject,args:[Injector]}]},{type:ChangeDetectorRef,decorators:[{type:Inject,args:[ChangeDetectorRef]}]}]);export var CellTemplateType;!function(e){e[e.Cell=0]="Cell",e[e.CellEdit=1]="CellEdit",e[e.ColumnHeader=2]="ColumnHeader",e[e.RowHeader=3]="RowHeader",e[e.RowHeaderEdit=4]="RowHeaderEdit",e[e.TopLeft=5]="TopLeft",e[e.GroupHeader=6]="GroupHeader",e[e.Group=7]="Group",e[e.NewCellTemplate=8]="NewCellTemplate",e[e.ColumnFooter=9]="ColumnFooter",e[e.BottomLeft=10]="BottomLeft"}(CellTemplateType||(CellTemplateType={}));class DirectiveCellFactory extends wjcGrid.CellFactory{constructor(e,t){if(super(),this._needsCdCheck=!1,this._lastApplyTimeStamp=0,this._noApplyLag=!1,this._startingEditing=!1,this._cellStampCounter=0,this._composing=!1,this.grid=e,this._gridCdRef=t,!DirectiveCellFactory._templateTypes){DirectiveCellFactory._templateTypes=[];for(var l in CellTemplateType)isNaN(l)&&DirectiveCellFactory._templateTypes.push(l)}var i=this;this._baseCf=e.cellFactory,e.cellFactory=this,this._evtInput=document.createEvent("HTMLEvents"),this._evtInput.initEvent("input",!0,!1),this._evtBlur=document.createEvent("HTMLEvents"),this._evtBlur.initEvent("blur",!1,!1),e.prepareCellForEdit.addHandler(function(e,t){i._noApplyLag=!0}),e.cellEditEnded.addHandler(function(t,l){(l.range.col<0||l.range.col<e.columns.length&&!e.columns[l.range.col][WjFlexGridCellTemplate._getTemplContextProp(CellTemplateType.CellEdit)])&&(i._editChar=null),setTimeout(function(){i._noApplyLag=!1},300)}),e.beginningEdit.addHandler(function(e,t){i._startingEditing=!0}),e.hostElement.addEventListener("keydown",function(e){i._startingEditing=!1},!0),e.hostElement.addEventListener("keypress",function(t){var l=t.charCode>32?String.fromCharCode(t.charCode):null;l&&wjcCore.closest(t.target,".wj-flexgrid")===e.hostElement&&(!e.activeEditor||i._startingEditing?i._editChar=l:i._editChar&&(i._editChar+=l))},!0),e.hostElement.addEventListener("compositionstart",function(e){i._composing=!0},!0),e.hostElement.addEventListener("compositionend",function(e){i._composing=!1},!0),e.updatedView.addHandler(()=>{this._needsCdCheck&&(this._needsCdCheck=!1,this._gridCdRef.markForCheck())},this)}updateCell(e,t,l,i,o){this._cellStampCounter=(this._cellStampCounter+1)%1e7;let r=i[DirectiveCellFactory._cellStampProp]=this._cellStampCounter;i.style.overflow&&(i.style.overflow="");let n=t,a=l;o&&!o.isSingleCell&&(t=o.row,l=o.col);let d,s=this,p=e.grid,c=p.editRange,u=e.rows[t],g=u.dataItem,m=!1,C=!1,w=!1,h=!1;switch(e.cellType){case wjcGrid.CellType.Cell:if(c&&c.row===t&&c.col===l)d=CellTemplateType.CellEdit,C=w=!0;else if(u instanceof wjcGrid.GroupRow){var f=!((h=g instanceof wjcCore.CollectionViewGroup)||u.hasChildren);l==e.columns.firstVisibleIndex?d=f?CellTemplateType.Cell:CellTemplateType.GroupHeader:(d=f?CellTemplateType.Cell:CellTemplateType.Group,C=!0)}else u instanceof wjcGrid._NewRowTemplate?d=CellTemplateType.NewCellTemplate:tryGetModuleWijmoGridDetail()&&tryGetModuleWijmoGridDetail().DetailRow&&u instanceof tryGetModuleWijmoGridDetail().DetailRow||(d=CellTemplateType.Cell);break;case wjcGrid.CellType.ColumnHeader:d=CellTemplateType.ColumnHeader;break;case wjcGrid.CellType.RowHeader:d=p.collectionView&&p.collectionView.currentEditItem===g?CellTemplateType.RowHeaderEdit:CellTemplateType.RowHeader,m=!0;break;case wjcGrid.CellType.TopLeft:d=CellTemplateType.TopLeft,m=!0;break;case wjcGrid.CellType.ColumnFooter:d=CellTemplateType.ColumnFooter,C=!0;break;case wjcGrid.CellType.BottomLeft:d=CellTemplateType.BottomLeft,m=!0}var y=!1;if(null!=d){var v=h&&d==CellTemplateType.GroupHeader?p.columns.getColumn(g.groupDescription.propertyName):l>=0&&l<e.columns.length?e.columns[l]:null;if(v){var j=WjFlexGridCellTemplate._getTemplContextProp(d),E=(m?p:v)[j];if(E||(d===CellTemplateType.RowHeaderEdit?(d=CellTemplateType.RowHeader,j=WjFlexGridCellTemplate._getTemplContextProp(d),E=p[j]):d!==CellTemplateType.Group&&d!==CellTemplateType.GroupHeader||h||(d=CellTemplateType.Cell,j=WjFlexGridCellTemplate._getTemplContextProp(d),E=v[j])),E){var T;C&&(T=e.getCellData(t,l,!1));{y=!0;let l=i.getAttribute(wjcGrid.FlexGrid._WJS_MEASURE),d=l&&"true"===l.toLowerCase();w&&this._baseCf.updateCell(e,n,a,i,o,!0);let c,m=i[j]||{},C=m.column!==v||!m.viewRef||m.templateContextProperty!==j||i.firstChild!=m.rootElement,h=w&&this._composing&&p.imeEnabled;if(C){if(w){var _=i.firstElementChild;_&&(h||i.focus(),_.style.display="none")}else i.textContent="";this._doDisposeCell(i);let e={};c=this._setViewRefContext(e,u,v,g,T,E.valuePaths);let t=E._instantiateTemplate(i,e);m.column=v,m.viewRef=t.viewRef,m.rootElement=t.rootElement,m.templateContextProperty=j,i[j]=m}else c=this._setViewRefContext(m.viewRef.context,u,v,g,T,E.valuePaths);if(E.cellOverflow&&(i.style.overflow=E.cellOverflow),d?E.cdRef.detectChanges():E.autoSizeRows&&!h?setTimeout(()=>{if(r===i[DirectiveCellFactory._cellStampProp]){var l=i.scrollHeight,n=e.rows,a=o&&o.rowSpan||1;if(t<n.length&&n[t].renderHeight*a<l-1){if(n.defaultSize=l/a,w){let e=s._isFullEdit();return p.refresh(),void p.startEditing(e)}}else w&&this._initEditInput(m,E,null)}},0):w&&setTimeout(()=>{h?this._initImeEditInput(m,E):this._initEditInput(m,E,null)},0),w){s._cellEditorVars=c.localVars;var R=function(e,t){if(p.cellEditEnding.removeHandler(R),!t.stayInEditMode){let e=wjcCore.getActiveElement();e&&e.dispatchEvent(s._evtBlur),i.focus()}if(s._triggerEditorEvents(i),!t.cancel&&!t.stayInEditMode){let e=c.localVars,t=Object.getOwnPropertyNames(c.bindings);for(let l of t)c.bindings[l].setValue(e,c.localVars.values[l])}var l=i.querySelectorAll(".wj-dropdown");[].forEach.call(l,function(e){var t=wjcCore.Control.getControl(e);t&&tryGetModuleWijmoInput()&&t instanceof tryGetModuleWijmoInput().DropDown&&(t.isDroppedDown=!1)})};let e=function(t,l){p.cellEditEnded.removeHandler(e),s._cellEditorVars=null};p.cellEditEnding.addHandler(R),p.cellEditEnded.addHandler(e)}else this._baseCf.updateCell(e,n,a,i,o,!1)}}}}y||(this._doDisposeCell(i),this._baseCf.updateCell(e,n,a,i,o))}getEditorValue(e){if(this._cellEditorVars){let t=e.editRange;return t&&t.isValid&&this._triggerEditorEvents(e.cells.getCellElement(t.row,t.col)),this._cellEditorVars.value}return super.getEditorValue(e)}disposeCell(e){this._doDisposeCell(e)}_doDisposeCell(e){for(var t=DirectiveCellFactory._templateTypes,l=0;l<t.length;l++){var i=WjFlexGridCellTemplate._getTemplContextProp(CellTemplateType[t[l]]),o=e[i];if(o&&o.viewRef){let t=(o.column||this.grid)[i];if(t){let e=t.viewContainerRef.indexOf(o.viewRef);e>-1&&t.viewContainerRef.remove(e)}o.viewRef=null,o.rootElement=null,o.column=null,o.templateContextProperty=null,e[i]=null}}}_setViewRefContext(e,t,l,i,o,r){this._needsCdCheck=!0,e.row=t,e.col=l,e.item=i;let n={},a=e.cell||{},d={},s={localVars:a,bindings:d};if(a.row=t,a.col=l,a.item=i,a.value=o,a.values=n,r){let e=Object.getOwnPropertyNames(r);for(let t of e){let e=new wjcCore.Binding(r[t]);d[t]=e,n[t]=e.getValue(a)}}return e.cell!==a&&(e.cell=a),s}_initEditInput(e,t,l){this._setFullEdit(t);let i=this._findInitialInput(e);if(i){var o=()=>{i.removeEventListener("focus",o),setTimeout(()=>{let e=null!=l?l:this._editChar;e&&(i.value=e,this._editChar=null,DirectiveCellFactory._setSelectionRange(i,e.length,e.length),i.dispatchEvent(this._evtInput))},DirectiveCellFactory._FOCUS_INTERVAL)};i.addEventListener("focus",o),i.focus()}}_initImeEditInput(e,t){let l=wjcCore.getActiveElement();if(l&&l instanceof HTMLInputElement&&wjcCore.hasClass(l,"wj-grid-ime")){let i=o=>{l.removeEventListener("compositionend",i),wjcCore.setCss(l,wjcGrid._ImeHandler._cssHidden),this._initEditInput(e,t,l.value)};l.addEventListener("compositionend",i);let o=this._findInitialInput(e);if(o){let e=o.getBoundingClientRect(),t=l.getBoundingClientRect(),i=window.getComputedStyle(l),r=parseFloat(i.left),n=parseFloat(i.top);wjcCore.setCss(l,{left:r+e.left-t.left+"px",top:n+e.top-t.top+"px",width:e.width+"px",height:e.height+"px"})}}}_findInitialInput(e){let t=e&&e.rootElement&&e.rootElement.querySelectorAll("input,textarea");if(t)for(var l=0;l<t.length;l++){var i=t[l],o=window.getComputedStyle(i);if("none"!==o.display&&"visible"===o.visibility)return i}return null}static _setSelectionRange(e,t,l=t){if(wjcCore.contains(document.body,e)&&!e.disabled&&"none"!=e.style.display)try{e.setSelectionRange(wjcCore.asNumber(t),wjcCore.asNumber(l),wjcCore.isIE()?null:"backward"),e.focus()}catch(e){}}_triggerEditorEvents(e){if(e){let t=e.querySelectorAll(".wj-control");for(let e=0;e<t.length;e++){let l=t[e],i=wjcCore.Control.getControl(l);if(i){let e=WjDirectiveBehavior.getBehavior(i);e&&e.flushPendingEvents()}}}}_isFullEdit(){let e=this.grid;return!e.activeEditor||e._edtHdl._fullEdit}_setFullEdit(e){let t=this.grid;e.forceFullEdit&&t.activeEditor&&(t._edtHdl._fullEdit=!0)}}DirectiveCellFactory._cellStampProp="__wjCellStamp",DirectiveCellFactory._FOCUS_INTERVAL=wjcCore.Control._FOCUS_INTERVAL+20;let moduleExports=[WjFlexGrid,WjFlexGridColumn,WjFlexGridCellTemplate];export class WjGridModule{};WjGridModule.decorators=[{type:NgModule,args:[{imports:[WjDirectiveBaseModule,CommonModule],declarations:[...moduleExports],exports:[...moduleExports]}]}],WjGridModule.ctorParameters=(()=>[]);