@mescius/wijmo.olap 5.20261.45-nightly.d20251218.t163151 → 5.20261.45-nightly.d20260105.t163143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015-commonjs.js +2 -2
- package/es2015-esm.js +2 -2
- package/es5-esm.js +2 -2
- package/index.d.ts +10 -12
- package/index.js +2 -2
- package/package.json +6 -6
package/es2015-commonjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.20261.45-nightly.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t163143
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
"use strict";var __importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@mescius/wijmo"),wijmo_grid_filter_1=require("@mescius/wijmo.grid.filter"),wijmo_input_1=require("@mescius/wijmo.input"),wijmo_grid_1=require("@mescius/wijmo.grid"),wijmo_chart_1=require("@mescius/wijmo.chart"),selfModule=__importStar(require("@mescius/wijmo.olap"));class _TextBuilder{constructor(){this._text=""}get length(){return this._text.length}toString(){return this._text}append(...e){this._text=this._text.concat(...e)}joinToList(e,...t){let i=t.join();this.length>0&&i.length>0?this._text=this._text.concat(e,...t):i.length>0&&(this._text=i)}joinItemToList(e){this.joinToList(",",e)}wrap(e,t){this.length>0&&(this._text=e.concat(this._text,t))}static wrap(e,t,i){return t.length>0?e.concat(t,i):""}}exports._TextBuilder=_TextBuilder;exports.DetailDialogClsNames={dialogBody:"wj-dialog-body",dialogFooter:"wj-dialog-footer",dialogHeader:"wj-dialog-header",hostElement:"wj-detaildialog",summary:"wj-summary"};exports.PivotChartClsNames={hierarchicalAxesLine:"wj-hierarchicalaxes-line",hostElement:"wj-pivotchart"};exports.PivotFieldEditorClsNames={hostElement:"wj-pivotfieldeditor"};exports.PivotFilterEditorClsNames={hostElement:"wj-pivotfiltereditor"};exports.PivotGridClsNames={colFieldHdr:"wj-col-field-hdr",hostElement:"wj-pivotgrid",pivotCollapse:"wj-pivot-collapse",rowFieldHdr:"wj-row-field-hdr"};exports.PivotPanelClsNames={aggregate:"wj-aggregate",header:"wj-header",hostElement:"wj-pivotpanel"};exports.SlicerClsNames={header:"wj-header",hostElement:"wj-slicer",noCheck:"wj-nocheck"};exports._GridContextMenuClsNames={hostElement:"wj-olap-context-menu"};class _Tally{constructor(){this._cntAll=0;this._cnt=0;this._cntn=0;this._sum=0;this._sum2=0;this._min=null;this._max=null;this._first=null;this._last=null}add(e,t){if(e instanceof _Tally){this._sum+=e._sum;this._sum2+=e._sum2;this._max=this._max&&e._max?Math.max(this._max,e._max):this._max||e._max;this._min=this._min&&e._min?Math.min(this._min,e._min):this._min||e._min;this._cnt+=e._cnt;this._cntn+=e._cntn;this._cntAll+=e._cntAll}else{this._cntAll++;if(null!=e){this._cnt++;wijmo_1.isBoolean(e)&&(e=e?1:0);(null==this._min||e<this._min)&&(this._min=e);(null==this._max||e>this._max)&&(this._max=e);null==this._first&&(this._first=e);this._last=e;if(wijmo_1.isNumber(e)&&!isNaN(e)){wijmo_1.isNumber(t)&&(e*=t);this._cntn++;this._sum+=e;this._sum2+=e*e}}}}getAggregate(e){if(0==this._cnt)return null;let t=0==this._cntn?0:this._sum/this._cntn,i=wijmo_1.Aggregate;switch(e){case i.None:return null;case i.CntAll:return this._cntAll;case i.Avg:return t;case i.Cnt:return this._cnt;case i.Max:return this._max;case i.Min:return this._min;case i.Rng:return this._max-this._min;case i.Sum:return this._sum;case i.VarPop:return this._cntn<=1?0:this._sum2/this._cntn-t*t;case i.StdPop:return this._cntn<=1?0:Math.sqrt(this._sum2/this._cntn-t*t);case i.Var:return this._cntn<=1?0:(this._sum2/this._cntn-t*t)*this._cntn/(this._cntn-1);case i.Std:return this._cntn<=1?0:Math.sqrt((this._sum2/this._cntn-t*t)*this._cntn/(this._cntn-1));case i.First:return this._first;case i.Last:return this._last}throw"Invalid aggregate type."}}exports._Tally=_Tally;class _PivotKey{constructor(e,t,i,s,l){this._fields=e;this._fieldCount=t;this._valueFields=i;this._valueFieldIndex=s;this._item=l}get fields(){return this._fields}get valueFields(){return this._valueFields}get valueField(){return this._valueFields[this._valueFieldIndex]}get values(){if(null==this._vals){this._vals=new Array(this._fieldCount);for(let e=0;e<this._fieldCount;e++){let t=this._fields[e];this._vals[e]=t._getValue(this._item,!1)}}return this._vals}get fieldNames(){if(!this._names){this._names=[];for(let e=0;e<this.fields.length;e++){let t=this._fields[e];this._names.push(t._getName())}}return this._names}get aggregate(){let e=this._valueFields,t=this._valueFieldIndex;wijmo_1.assert(e&&t>-1&&t<e.length,"aggregate not available for this key");return e[t].aggregate}getValue(e,t){if(0==this.values.length)return wijmo_1.culture.olap.PivotEngine.grandTotal;if(e>this.values.length-1)return wijmo_1.culture.olap.PivotEngine.subTotal;let i=this.values[e];if(t&&!wijmo_1.isString(i)){let t=this.fields[e],s=t?t.format:"";i=wijmo_1.Globalize.format(this.values[e],s)}return i}get level(){return this._fieldCount==this._fields.length?-1:this._fieldCount}compareTo(e){let t=0;if(null!=e&&e._fields==this._fields){let i=this.values,s=e.values,l=Math.min(i.length,s.length);for(let o=0;o<l;o++){let l=null!=i[o]?wijmo_1.getType(i[o]):null,r=i[o],n=s[o],a=this._fields[o];if(a.sortComparer){t=a.sortComparer(r,n);if(wijmo_1.isNumber(t)){if(0!=t)return a.descending?-t:t;continue}}if(l==wijmo_1.DataType.Date){let t=a.format;if(t&&"d"!=t&&"D"!=t){let i=a._getValue(this._item,!0),s=a._getValue(e._item,!0),l=wijmo_1.Globalize.parseDate(i,t),o=wijmo_1.Globalize.parseDate(s,t);if(l&&o){r=l;n=o}else{r=i;n=s}}}if(!(r==n||wijmo_1.DateTime.equals(r,n))){if(null==r)return 1;if(null==n)return-1;t=r<n?-1:1;return a.descending?-t:t}}if(i.length==s.length){t=this._valueFieldIndex-e._valueFieldIndex;if(0!=t)return t}t=s.length-i.length;if(0!=t)return t*(this.fields.engine.totalsBeforeData?-1:1)}return 0}matchesItem(e){for(let t=0;t<this._vals.length;t++){if(this.getValue(t,!0)!=this._fields[t]._getValue(e,!0))return!1}return!0}toString(e){if(!this._key||e){let t="";for(let e=0;e<this._fieldCount;e++){let i=this._fields[e];t+=i._getName()+":"+i._getValue(this._item,!0)+";"}if(this._valueFields){t+=this._valueFields[this._valueFieldIndex]._getName()+":0;"}else t+="{total}";if(e)return t+e.toString();this._key=t}return this._key}}_PivotKey._ROW_KEY_NAME="$rowKey";exports._PivotKey=_PivotKey;const _NOT_EDITABLE="This collection is not editable.";class PivotCollectionView extends wijmo_1.CollectionView{constructor(e){super();this.canAddNew=this.canRemove=!1;this._ng=wijmo_1.asType(e,PivotEngine,!1)}get engine(){return this._ng}implementsInterface(e){return"IEditableCollectionView"!=e&&super.implementsInterface(e)}editItem(e){wijmo_1.assert(!1,_NOT_EDITABLE)}addNew(){wijmo_1.assert(!1,_NOT_EDITABLE)}_performSort(e){let t=this._ng;if(t.sortableGroups&&t._getShowRowTotals()==ShowTotals.Subtotals){let t=0,i=e.length-1;0==this._getItemLevel(e[t])&&t++;0==this._getItemLevel(e[i])&&i--;this._sortGroups(e,1,t,i)}else this._sortData(e)}_performFilter(e){return this._ng&&0==this._ng.valueFields.length&&0==this._ng.rowFields.length?[]:this.canFilter&&this._filter?e.filter(this._filter,this):e}_getGroupRange(e,t){let i=this._ng,s=e.indexOf(t),l=s,o=this._getItemLevel(e[s]);if(i.totalsBeforeData)for(l=s;l<e.length-1;l++){let t=this._getItemLevel(e[l+1]);if(t>-1&&t<=o)break}else for(s=l;s;s--){let t=this._getItemLevel(e[s-1]);if(t>-1&&t<=o)break}return[s,l]}_sortGroups(e,t,i,s){let l=[];for(let o=i;o<=s;o++)this._getItemLevel(e[o])==t&&l.push(e[o]);if(!l.length){this._sortData(e);return}super._performSort(l);let o=[];for(let s=0;s<l.length;s++){var r=this._getGroupRange(e,l[s]),n=o.length;for(let t=r[0];t<=r[1];t++)o.push(e[t]);const a=o.length-1;if(t<this._ng.rowFields.length-1)this._sortGroups(o,t+1,i+n,a);else{const e=this._ng.totalsBeforeData?1:0;this._sortSegment(o,n+e,a+e)}}for(let t=0;t<o.length;t++)e[i+t]=o[t]}_sortSegment(e,t,i){let s=e.slice(t,i);super._performSort(s);for(let i=0;i<s.length;i++)e[t+i]=s[i]}_sortData(e){for(let t=0;t<e.length;t++){if(this._getItemLevel(e[t])>-1)continue;let i=t;for(;i<e.length-1&&!(this._getItemLevel(e[i+1])>-1);i++);if(i>t){let s=e.slice(t,i+1);super._performSort(s);for(let i=0;i<s.length;i++)e[t+i]=s[i]}t=i}}_getItemLevel(e){return e[_PivotKey._ROW_KEY_NAME].level}}exports.PivotCollectionView=PivotCollectionView;class PivotField{constructor(e,t,i,s){this._isExplicitAggregate=!1;this.propertyChanged=new wijmo_1.Event;this._ng=e;this._binding=new PivotFieldBinding(this,t);this._header=i||wijmo_1.toHeaderCase(t);this._showAs=ShowAs.NoCalculation;this._isContentHtml=!1;this._visible=!0;this._format="";this._filter=new PivotFilter(this);wijmo_1.copy(this,s);null==this._dataType&&this._updateDataTypeByBinding();this._isExplicitAggregate||this._updateAggregateByDataType()}get binding(){return this._binding?this._binding.path:null}set binding(e){if(e!=this.binding){let t=this.binding,i=wijmo_1.asString(e);this._binding=i?new PivotFieldBinding(this,i):null;if(null==this._dataType){this._updateDataTypeByBinding();this._isExplicitAggregate||this._updateAggregateByDataType()}let s=new wijmo_1.PropertyChangedEventArgs("binding",t,e);this.onPropertyChanged(s)}}get getValue(){return this._getValueFn}set getValue(e){this._getValueFn=wijmo_1.asFunction(e,!0)}get getAggregateValue(){return this._getAggValueFn}set getAggregateValue(e){this._getAggValueFn=wijmo_1.asFunction(e,!0)}get header(){return this._header}set header(e){e=wijmo_1.asString(e,!1);let t=this._ng.fields.getField(e);!e||t&&t!=this?wijmo_1.assert(!1,"field headers must be unique and non-empty."):this._setProp("_header",wijmo_1.asString(e))}get filter(){return this._filter}get aggregate(){return this._aggregate}set aggregate(e){this._isExplicitAggregate=!0;this._setProp("_aggregate",wijmo_1.asEnum(e,wijmo_1.Aggregate))}get showAs(){return this._showAs}set showAs(e){this._setProp("_showAs",wijmo_1.asEnum(e,ShowAs))}get weightField(){return this._weightField}set weightField(e){this._setProp("_weightField",wijmo_1.asType(e,PivotField,!0))}get dataType(){return this._dataType}set dataType(e){this._setProp("_dataType",wijmo_1.asEnum(e,wijmo_1.DataType))}get isMeasure(){return this._dataType==wijmo_1.DataType.Number}get subFields(){return this._subFields}get format(){return this._format}set format(e){this._setProp("_format",wijmo_1.asString(e))}get align(){return this._align}set align(e){this._setProp("_align",wijmo_1.asString(e))}get width(){return this._width}set width(e){this._setProp("_width",wijmo_1.asNumber(e,!0,!0))}get wordWrap(){return this._wordWrap}set wordWrap(e){this._setProp("_wordWrap",wijmo_1.asBoolean(e))}get descending(){return!!this._descending}set descending(e){this._setProp("_descending",wijmo_1.asBoolean(e))}get isContentHtml(){return this._isContentHtml}set isContentHtml(e){this._setProp("_isContentHtml",wijmo_1.asBoolean(e))}get visible(){return this._visible}set visible(e){this._setProp("_visible",wijmo_1.asBoolean(e))}get sortComparer(){return this._srtCmp}set sortComparer(e){e!=this.sortComparer&&(this._srtCmp=wijmo_1.asFunction(e))}get engine(){return this._ng}get collectionView(){return this.engine?this.engine.collectionView:null}get isActive(){return this._getIsActive()}set isActive(e){this._setIsActive(e)}get parentField(){return this._parent}get key(){return this.header}onPropertyChanged(e){this.propertyChanged.raise(this,e);this._ng._fieldPropertyChanged(this,e)}_updateDataTypeByBinding(){if(this._ng&&this._binding){const e=this._ng.collectionView,t=e?e.items.length:0;for(let i=0;i<t;i++){const t=e.items[i];if(null!=t){this._dataType=wijmo_1.getType(this._binding.getValue(t));break}}}}_updateAggregateByDataType(){this._aggregate=this.dataType==wijmo_1.DataType.Number?wijmo_1.Aggregate.Sum:wijmo_1.Aggregate.Cnt}_copy(e,t){if("subFields"==e){this._subFields?this._subFields.splice(0,this._subFields.length):this._subFields=[];t&&t.length&&t.forEach(e=>{let t=this.engine._createField(e,this._autoGenerated);this._subFields.push(t)});return!0}if("filter"==e){this._setFilterProxy(t);return!0}return!1}_getFilterProxy(){let e=this.filter;if(e.conditionFilter.isActive){let t=e.conditionFilter,i={condition1:{operator:t.condition1.operator,value:t.condition1.value},and:t.and,condition2:{operator:t.condition2.operator,value:t.condition2.value}};t.condition1.isActive||delete i.condition1;t.condition2.isActive||delete i.condition2;return i}if(e.valueFilter.isActive){let t=e.valueFilter;return{filterText:t.filterText,showValues:t.showValues}}wijmo_1.assert(!1,"inactive filters shouldn't be persisted.");return null}_setFilterProxy(e){let t=this.filter,i=t.conditionFilter,s=t.valueFilter;t.clear();e.conditionFilter?e=e.conditionFilter:e.valueFilter&&(e=e.valueFilter);if(e.condition1){let t=e.condition1,s=wijmo_1.changeType(t.value,this.dataType);i.condition1.value=s||t.value;i.condition1.operator=t.operator;let l=e.condition2;if(l){let e=wijmo_1.changeType(l.value,this.dataType);i.condition2.value=e||l.value;i.condition2.operator=l.operator}wijmo_1.isBoolean(e.and)&&(i.and=e.and)}if(e.showValues){s.filterText=e.filterText;s.showValues=e.showValues}}_getIsActive(){if(this._ng&&!this._hasSubFields()){let e=this._ng._viewLists;for(let t=0;t<e.length;t++)if(e[t].indexOf(this)>-1)return!0}return!1}_setIsActive(e){if(this._ng&&!this._hasSubFields()){let t=this.isActive;if((e=wijmo_1.asBoolean(e))!=t)if(e)this.isMeasure?this._ng.valueFields.push(this):this._ng.rowFields.push(this);else{let e=this._ng._viewLists;for(let t=0;t<e.length;t++){let i=e[t];for(let e=0;e<i.length;e++){let t=i[e];if(t==this||t.parentField==this){i.removeAt(e);e--}}}let t=this._ng.fields;for(let e=t.length-1;e>=0;e--){if(t[e].parentField==this){t.removeAt(e);e--}}}}}_hasSubFields(){return null!=this._subFields&&this._subFields.length>0}_clone(){let e=new PivotField(this._ng,this.binding);this._ng._copyProps(e,this,PivotField._props);e._autoGenerated=!0;e._parent=this;let t=this.header.replace(/\d+$/,"");for(let i=2;;i++){let s=t+i.toString();if(null==this._ng.fields.getField(s)){e._header=s;break}}return e}_setProp(e,t,i){let s=this[e];if(t!=s){this[e]=t;let i=new wijmo_1.PropertyChangedEventArgs(e.substr(1),s,t);this.onPropertyChanged(i)}}_getName(){return this.header||this.binding}_getValue(e,t){let i=this._binding,s=null;e&&(s=wijmo_1.isFunction(this._getValueFn)?this._getValueFn.call(this,e):this._ng.isServer?e[this.key]:i._key?e[i._key]:i.getValue(e));return t&&"string"!=typeof s?wijmo_1.Globalize.format(s,this._format):s}_getWeight(e){let t=this._weightField?this._weightField._getValue(e,!1):null;return wijmo_1.isNumber(t)?t:null}}PivotField._props=["dataType","format","width","wordWrap","aggregate","showAs","descending","isContentHtml","visible"];exports.PivotField=PivotField;class CubePivotField extends PivotField{constructor(e,t,i,s){super(e,t,i,s);wijmo_1.assert(null!=this.dimensionType,"CubePivotField objects must specify the field's dimensionType")}get header(){return this._header}set header(e){this._setProp("_header",wijmo_1.asString(e))}get dimensionType(){return this._dimensionType}set dimensionType(e){this._setProp("_dimensionType",wijmo_1.asEnum(e,DimensionType,!1))}get isMeasure(){switch(this._dimensionType){case 1:case 2:case 8:return!0}return!1}get key(){return this.binding}_clone(){throw"CubePivotField objects cannot be cloned"}}exports.CubePivotField=CubePivotField;var DimensionType,ShowTotals,ShowAs,PivotChartType,LegendVisibility;!function(e){e[e.Dimension=0]="Dimension";e[e.Measure=1]="Measure";e[e.Kpi=2]="Kpi";e[e.NameSet=3]="NameSet";e[e.Attribute=4]="Attribute";e[e.Folder=5]="Folder";e[e.Hierarchy=6]="Hierarchy";e[e.Date=7]="Date";e[e.Currency=8]="Currency"}(DimensionType=exports.DimensionType||(exports.DimensionType={}));class Slicer extends wijmo_1.Control{constructor(e,t){super(e,null,wijmo_1.isIE()&&!wijmo_1.isEdge());this._hdr=null;this._mSel=!1;this._updatingFilter=!1;this._propChanged=!1;this._fldPropChangeBnd=this._fldPropChange.bind(this);let i=this.getTemplate();this.applyTemplate(`${exports.SlicerClsNames.hostElement} ${exports.SlicerClsNames.noCheck} ${wijmo_1.ControlClsNames.hostElement} ${wijmo_1.ControlClsNames.content}`,i,{_root:"root",_divHdr:"div-hdr",_divHdrText:"div-hdr-text",_btnMSel:"btn-msel",_btnClear:"btn-clear"});let s=wijmo_1.culture.olap.Slicer;this._tt=new wijmo_1.Tooltip;wijmo_1.setAttribute(this._btnMSel,"aria-label",s.multiSelect);wijmo_1.setAttribute(this._btnClear,"aria-label",s.clearFilter);this._tt.setTooltip(this._btnMSel,s.multiSelect);this._tt.setTooltip(this._btnClear,s.clearFilter);this.addEventListener(this._btnClear,"click",e=>{this._clear()});this.addEventListener(this._btnMSel,"click",e=>{this.multiSelect=!this.multiSelect});this.initialize(t)}static get controlTemplate(){Slicer._ctrlTemplate||(Slicer._ctrlTemplate=`<div wj-part="root"><div wj-part="div-hdr" class="${exports.SlicerClsNames.header}"><div wj-part="div-hdr-text"></div><button wj-part="btn-msel" class="${wijmo_1.InputFormElementsClsNames.btn} btn-msel" tabindex="-1"><span class=${wijmo_1.GlyphClsNames.glyph}>≡</span></button><button wj-part="btn-clear" class="${wijmo_1.InputFormElementsClsNames.btn} btn-clear" tabindex="-1"><span class=${wijmo_1.GlyphClsNames.glyph}>×</span></button></div></div>`);return Slicer._ctrlTemplate}static set controlTemplate(e){Slicer._ctrlTemplate=e}get field(){return this._fld}set field(e){if(e!=this._fld){if(this._divListBox){wijmo_1.removeChild(this._divListBox);this._divListBox=null;this._lbx.dispose();this._lbx=null}if(this._edt){this._clear();this._edt.dispose()}let t=this._fld;if(t){t.filter.filterType=this._originalFilterType;t.filter.valueFilter.uniqueValues=this._uniqueValues;t.propertyChanged.removeHandler(this._fldPropChangeBnd)}t=this._fld=wijmo_1.asType(e,PivotField,!0);if(t){this._originalFilterType=t.filter.filterType;t.filter.filterType=wijmo_grid_filter_1.FilterType.Value;let e=t.engine;this._uniqueValues=t.filter.valueFilter.uniqueValues;if(e.isServer&&!this._uniqueValues){let i=e._getUniqueValues(t);t.filter.valueFilter.uniqueValues=i}t.propertyChanged.addHandler(this._fldPropChangeBnd);t.isActive||t.engine.filterFields.push(t);let i=document.createElement("div");this._edt=new wijmo_grid_filter_1.ValueFilterEditor(i,t.filter.valueFilter)}if(this._edt){this._divListBox=this._edt.hostElement.querySelector("."+wijmo_input_1.ListBoxClsNames.hostElement);this._root.appendChild(this._divListBox);this._lbx=wijmo_1.Control.getControl(this._divListBox);this._lbx.checkedItemsChanged.addHandler((e,i)=>{if(!this._propChanged){let e=this._lbx.selectedItem;if(!this.multiSelect&&e){this._mSel=!0;this._lbx.checkedItems=[e];this._mSel=!1}}if(this._edt&&t){this._updateFilter();t.engine.invalidate()}})}this._updateHeader();wijmo_1.isIE()&&!wijmo_1.isEdge()&&this.refresh()}}get header(){return this._hdr}set header(e){if(e!=this._hdr){this._hdr=wijmo_1.asString(e);this._updateHeader()}}get showHeader(){return"none"!=this._divHdr.style.display}set showHeader(e){this._divHdr.style.display=wijmo_1.asBoolean(e)?"":"none"}get showCheckboxes(){return!wijmo_1.hasClass(this.hostElement,exports.SlicerClsNames.noCheck)}set showCheckboxes(e){wijmo_1.toggleClass(this.hostElement,exports.SlicerClsNames.noCheck,!wijmo_1.asBoolean(e))}get multiSelect(){return this._mSel}set multiSelect(e){this._mSel=wijmo_1.asBoolean(e);wijmo_1.toggleClass(this._btnMSel,wijmo_1.ControlStateClsNames.active,this._mSel)}refresh(e=!0){wijmo_1.isIE()&&!wijmo_1.isEdge()&&this.hostElement&&(this._setCssTimer=setTimeout(()=>{wijmo_1.setCss(this._lbx.hostElement,{height:this.hostElement.clientHeight-this._divHdr.offsetHeight})}));super.refresh(e)}_fldPropChange(e,t){this._propChanged=!0;switch(t.propertyName){case"header":this._updateHeader();break;case"format":case"binding":e.filter.clear();this._edt.updateEditor();break;case"filter":this._updatingFilter||this._edt.updateEditor()}this._propChanged=!1}_updateHeader(){let e=this._hdr;e||null==this._fld||(e=this._fld.header);this._divHdrText.textContent=e}_clear(){if(this._edt){this._edt.clearEditor(!1);this._updateFilter();this._fld.engine.invalidate()}}_updateFilter(){this._updatingFilter=!0;this._edt.updateFilter();this._updatingFilter=!1}dispose(){if(this._tt){this._tt.dispose();this._tt=null}if(this._edt){this._edt.dispose();this._edt=null}if(this._lbx){this._lbx.dispose();this._lbx=null}if(this._setCssTimer){clearTimeout(this._setCssTimer);this._setCssTimer=null}this._fld&&this._fld.propertyChanged.removeHandler(this._fldPropChangeBnd);super.dispose()}}Slicer._ctrlTemplate="";exports.Slicer=Slicer;class _GridContextMenu extends wijmo_input_1.Menu{constructor(){super(document.createElement("div"),{header:"PivotGrid Context Menu",displayMemberPath:"text",commandParameterPath:"parm",command:{executeCommand:e=>{this._execute(e)},canExecuteCommand:e=>this._canExecute(e)}});this.itemsSource=this._getMenuItems();wijmo_1.addClass(this.dropDown,"context-menu "+exports._GridContextMenuClsNames.hostElement)}static get controlTemplate(){_GridContextMenu._ctrlTemplate||(_GridContextMenu._ctrlTemplate=wijmo_input_1.Menu.controlTemplate);return _GridContextMenu._ctrlTemplate}static set controlTemplate(e){_GridContextMenu._ctrlTemplate=e}refresh(e=!0){this.itemsSource=this._getMenuItems();super.refresh(e)}attach(e){wijmo_1.assert(e instanceof PivotGrid,"Expecting a PivotGrid control...");let t=e.hostElement;this._gridOwner=t;this._contextMenuHandler=i=>{if(e.customContextMenu){i.preventDefault();this.owner=t;if(this._selectField(i)){let e=this.dropDown;this.selectedIndex=-1;if(this.onIsDroppedDownChanging(new wijmo_1.CancelEventArgs)){wijmo_1.showPopup(e,i);this.onIsDroppedDownChanged();e.focus()}}}};this._gridOwner.addEventListener("contextmenu",this._contextMenuHandler)}_selectField(e){this._targetField=null;this._htDown=null;let t=wijmo_1.Control.getControl(this.owner),i=t.engine,s=i.valueFields,l=i.columnFields,o=t.hitTest(e),r=wijmo_grid_1.CellType;switch(o.cellType){case r.Cell:t.select(o.range);this._targetField=s[o.col%s.length];this._htDown=o;break;case r.ColumnHeader:this._targetField=o.row<l.length?l[o.row]:s[o.col%s.length];break;case r.RowHeader:this._targetField=t._colRowFields.get(o.getColumn());break;case r.TopLeft:o.row==o.panel.rows.length-1&&(this._targetField=t._colRowFields.get(o.getColumn()))}return null!=this._targetField}_getMenuItems(){let e=[{text:'<div class="menu-icon menu-icon-remove">✖</div>Remove Field',parm:"remove"},{text:'<div class="menu-icon">⛭</div>Field Settings...',parm:"edit"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:'<div class="menu-icon">⌕</div>Show Detail...',parm:"detail"}];for(let t=0;t<e.length;t++){let i=e[t];if(i.parm){let e=wijmo_1.culture.olap._ListContextMenu[i.parm];wijmo_1.assert(e,"missing localized text for item "+i.parm);i.text=i.text.replace(/([^>]+$)/,e)}}return e}_execute(e){let t=this._targetField,i=wijmo_1.Control.getControl(this.owner),s=i?i.engine:null,l=this._htDown;switch(e){case"remove":s.removeField(t);break;case"edit":s.editField(t);break;case"detail":i.showDetail(l.row,l.col)}}_canExecute(e){let t=this._targetField,i=wijmo_1.Control.getControl(this.owner),s=i?i.engine:null,l=this._htDown;if(null==t||null==s)return!1;switch(e){case"remove":return!0;case"edit":return s.allowFieldEditing;case"detail":return null!=l&&!(t instanceof CubePivotField)&&s.valueFields.length>0}return!0}dispose(){if(this._gridOwner){this._gridOwner.removeEventListener("contextmenu",this._contextMenuHandler);this._contextMenuHandler=null;this._gridOwner=null}this._targetField=null;this._htDown=null;this.command=null;this.itemsSource=null;super.dispose()}}_GridContextMenu._ctrlTemplate="";exports._GridContextMenu=_GridContextMenu;class PivotFieldCollection extends wijmo_1.ObservableArray{constructor(e){super();this._ng=e}get maxItems(){return this._maxItems}set maxItems(e){this._maxItems=wijmo_1.asInt(e,!0,!0)}get engine(){return this._ng}getField(e){return this._getField(this,e)}_getField(e,t){for(let i=0;i<e.length;i++){let s=e[i];if(s.key==t)return s;if(s._hasSubFields()){s=this._getField(s.subFields,t);if(s)return s}}return null}push(...e){let t=this._ng;for(let i=0;e&&i<e.length;i++){let s=e[i];wijmo_1.isString(s)&&(s=this==t.fields?new PivotField(t,s):t.fields.getField(s));wijmo_1.assert(s instanceof PivotField,"This collection must contain PivotField objects only.");if(s.key&&this.getField(s.key)){wijmo_1.assert(!1,"PivotField keys must be unique.");return-1}if(null!=this._maxItems&&this.length>=this._maxItems)break;super.push(s)}return this.length}}exports.PivotFieldCollection=PivotFieldCollection;class _PivotNode{constructor(e,t,i,s,l,o){this._key=new _PivotKey(e,t,i,s,l);this._nodes={};this._parent=o}getNode(e,t,i,s,l){let o=this;for(let r=0;r<t;r++){let t=e[r]._getValue(l,!0),n=o._nodes[t];if(!n){n=new _PivotNode(e,r+1,i,s,l,o);o._nodes[t]=n}o=n}if(i&&s>-1){let r=i[s].header,n=o._nodes[r];if(!n){n=new _PivotNode(e,t,i,s,l,o);o._nodes[r]=n}o=n}return o}get key(){return this._key}get parent(){return this._parent}get tree(){this._tree||(this._tree=new _PivotNode(null,0,null,-1,null));return this._tree}}exports._PivotNode=_PivotNode;class _ServerConnection{constructor(e,t){this._ng=wijmo_1.asType(e,PivotEngine);wijmo_1.assert(this._isValidUrl(t),"Invalid service Url: "+t+")")}getFields(){let e=null;wijmo_1.httpRequest(this._getUrl("Fields"),{async:!1,success:t=>{e=JSON.parse(t.responseText);wijmo_1.isArray(e)||console.error("Failed to get fields from server: "+t.responseText)},error:e=>{this._handleError("Getting Fields",e)}});return e}getUniqueValues(e){let t=null;wijmo_1.httpRequest(this._getUrl("UniqueValues",null,e.header),{method:"POST",async:!1,data:{view:this._ng.viewDefinition},success:e=>{t=JSON.parse(e.responseText);wijmo_1.isArray(t)||console.error("Failed to get unique field values from server: "+e.responseText)},error:e=>{this._handleError("Getting Unique Field Values",e)}});return t}getOutputView(e){this.clearPendingRequests();this._sendHttpRequest("Analyses",{method:"POST",data:{view:this._ng.viewDefinition},success:t=>{let i=JSON.parse(t.responseText);this._token=i.token;this._start=Date.now();this._handleResult(i.status,e)},error:e=>{this._handleError("Analyses",e)}})}getDetail(e,t){let i,s=[],l=this._ng.rowFields.length,o=e?e.values.length:0;for(let t=0;t<l;t++)t<o?s.push(_ServerConnection._getRequestedValue(e.values[t])):s.push(null);l=this._ng.columnFields.length;o=t?t.values.length:0;for(let e=0;e<l;e++)e<o?s.push(_ServerConnection._getRequestedValue(t.values[e])):s.push(null);i=new wijmo_1.ObservableArray;this._loadArray("Detail",i,{method:"POST",view:this._ng.viewDefinition,keys:s,max:this._ng.serverMaxDetail});return i}getSortedKeys(e,t){let i=Object.keys(e);if(this._ng.sortOnServer){if(i.length>1){let e={},s=[],l=[];i.forEach(i=>{this._insertKey(e,i,t)});this._reorderKeys(e,null,null,s,t);if(!t&&this._ng.valueFields.length>1){let e=s.length/this._ng.valueFields.length,t=s.length/e;for(let i=0;i<e;i++)for(let o=0;o<t;o++)l.push(s[i+o*e]);return l}return s}}else i.sort((e,t)=>this._ng._keys[e].compareTo(this._ng._keys[t]));return i}static _getRequestedValue(e){if(wijmo_1.isDate(e)){let t=e;return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()))}return e}clearPendingRequests(){this._clearRequest();this._clearTimeout();this._clearToken()}updateTallies(e){let t=this._ng,i=t.rowFields.length,s=t.columnFields.length,l=t.valueFields.length,o=new _PivotNode(t.rowFields,0,null,-1,null);e.forEach((e,r,n)=>{let a=this._getAggregatedFieldCount(e,t.rowFields),h=o.getNode(t.rowFields,i-a,null,-1,e),d=h.key,_=d.toString(null),u=t._tallies[_];if(!u){t._keys[_]=d;t._tallies[_]=u={}}a=this._getAggregatedFieldCount(e,t.columnFields);for(let i=0;i<l;i++){let l=h.tree.getNode(t.columnFields,s-a,t.valueFields,i,e).key,o=l.toString(),r=t.valueFields[i],n=u[o];if(!n){t._keys[o]=l;n=u[o]=new _ServerTally;n.add(this._getFieldValue(r,e,!1))}}})}_getFieldValue(e,t,i){let s=t[e.key];return i&&"string"!=typeof s?wijmo_1.Globalize.format(s,e.format):s}_getKeyLength(e,t){return e.split(";").length-(t?1:2)}_insertKey(e,t,i){let s=t.split(";");i||s.pop();if(1==s.length)e[s.pop()]={};else{let t=s.pop(),i=e[t];i||(e[t]=i={});for(;s.length>0;){let e=s.shift();i[e]||(i[e]={});i=i[e]}}}_joinKeys(e,t,i){return t&&i?[t,e,i].join(";"):i?[e,i].join(";"):e}_reorderKeys(e,t,i,s,l){Object.keys(e).forEach(o=>{let r=this._joinKeys(o,t,i),n=l?this._ng.showRowTotals:this._ng.showColumnTotals,a=Object.keys(e[o]).length,h=!t&&!i&&n!==ShowTotals.None||!t&&!a||t||n===ShowTotals.Subtotals;l||(r+=";");this._ng.totalsBeforeData&&h&&s.push(r);i?t?this._reorderKeys(e[o],[t,o].join(";"),i,s,l):this._reorderKeys(e[o],o,i,s,l):this._reorderKeys(e[o],null,o,s,l);!this._ng.totalsBeforeData&&h&&s.push(r)})}_getParentKey(e,t){let i=e.split(";");t?i.splice(i.length-2,1):i.splice(0,i.length-2);return i.join(";")}_getAggregatedFieldCount(e,t){let i=t.length,s=0;for(let l=0;l<i;l++){let i=t[l];null==this._getFieldValue(i,e,!1)&&s++}return s}_loadArray(e,t,i){i||(i={});null==i.skip&&(i.skip=0);null==i.top&&(i.top=100);let s=wijmo_1.isNumber(i.max)?i.max:1e6;this._request=wijmo_1.httpRequest(this._getUrl(e),{data:i,method:i.method||"GET",success:l=>{let o=JSON.parse(l.responseText);t.deferUpdate(()=>{o.value.forEach(e=>{t.push(e)})});if(o.value.length==i.top&&t.length<s){i.skip+=i.top;this._loadArray(e,t,i)}},error:t=>{this._handleError(e,t)}})}_getUrl(e,t=this._token,i){let s=this._ng.itemsSource.toString(),l=s.lastIndexOf("/");s.substr(0,l);switch(e=e.toLowerCase()){case"rawdata":case"detail":return s;case"fields":case"analyses":return s+"/"+e;case"clear":return s+"/analyses/"+t+"/";case"result":case"status":return s+"/analyses/"+t+"/"+e;case"uniquevalues":return s+"/fields/"+i+"/"+e}wijmo_1.assert(!1,"Unrecognized command")}_isValidUrl(e){let t=document.createElement("a");t.href=wijmo_1.asString(e);t.href=t.href;return t.protocol&&t.hostname&&t.pathname&&"/"!=e[e.length-1]}_handleResult(e,t){switch(e.executingStatus.toLowerCase()){case"executing":case"notset":if(Date.now()-this._start>this._ng.serverTimeout){this._handleError("Analyses",{status:500,statusText:"Analysis timed out"});return}this._progress=e.progress;this._ng.onUpdatingView(new ProgressEventArgs(this._progress));this._clearTimeout();this._toGetStatus=setTimeout(()=>{this._waitUntilComplete(t)},this._ng.serverPollInterval);break;case"completed":this._progress=100;this._ng.onUpdatingView(new ProgressEventArgs(this._progress));this._getResults(t);break;case"exception":this._getResults(t);break;default:this._handleError("Analyses",{status:500,statusText:"Unexpected result..."})}}_waitUntilComplete(e){this._sendHttpRequest("Status",{success:t=>{let i=JSON.parse(t.responseText);this._handleResult(i,e)},error:e=>{this._handleError("Status",e)}})}_getResults(e){this._sendHttpRequest("Result",{success:t=>{this._clearToken();let i=JSON.parse(t.responseText);wijmo_1.assert(wijmo_1.isArray(i),"Result array Expected.");let s=[];this._ng._viewLists.forEach(e=>{s=s.concat(e.filter(e=>e.dataType==wijmo_1.DataType.Date))});s.length>0&&i.forEach(e=>{s.forEach(t=>{let i=t._binding,s=i.getValue(e);wijmo_1.isString(s)&&i.setValue(e,new Date(s))})});wijmo_1.asFunction(e)(i)},error:e=>{this._handleError("Result",e)}})}_handleError(e,t){this.clearPendingRequests();e='** HttpRequest error on command "'+e+'"';this._ng.onError(new wijmo_1.RequestErrorEventArgs(t,e))&&this._throwResponseError(e,t)}_sendHttpRequest(e,t){let i=this._getUrl(e);this._request=wijmo_1.httpRequest(i,t)}_throwResponseError(e,t){e=e+"\r\n"+t.status+"\r\n";let i=t.responseText||"";if(500==t.status&&t.responseText){i=JSON.parse(t.responseText).ExceptionMessage}throw e+=i||t.statusText}_clearToken(){if(this._token){this._clearRequest();this._clearTimeout();this._sendHttpRequest("Clear",{method:"DELETE"});this._token=null}}_clearRequest(){if(this._request&&4!=this._request.readyState){this._request.abort();this._request=null}}_clearTimeout(){if(this._toGetStatus){clearTimeout(this._toGetStatus);this._toGetStatus=null}}}_ServerConnection._TIMEOUT=6e4;_ServerConnection._POLL_INTERVAL=500;_ServerConnection._MAXDETAIL=1e3;exports._ServerConnection=_ServerConnection;class _ServerTally extends _Tally{add(e,t){wijmo_1.assert(0==this._cnt,"Server tallies have a single value.");this._aggregatedValue=e}getAggregate(e){return this._aggregatedValue}}wijmo_1._addCultureInfo("olap",{PivotEngine:{grandTotal:"Grand Total",subTotal:"Subtotal"},PivotPanel:{fields:"Choose fields to add to report:",drag:"Drag fields between areas below:",filters:"Filters",cols:"Columns",rows:"Rows",vals:"Values",defer:"Defer Updates",update:"Update"},PivotFieldEditor:{dialogHeader:"Field settings:",header:"Header:",summary:"Summary:",showAs:"Show As:",weighBy:"Weigh by:",sort:"Sort:",filter:"Filter:",format:"Format:",sample:"Sample:",edit:"Edit...",clear:"Clear",ok:"OK",cancel:"Cancel",none:"(none)",sorts:{asc:"Ascending",desc:"Descending"},aggs:{sum:"Sum",cnt:"Count",avg:"Average",max:"Max",min:"Min",rng:"Range",std:"StdDev",var:"Var",stdp:"StdDevPop",varp:"VarPop",first:"First",last:"Last"},calcs:{noCalc:"No calculation",dRow:"Difference from previous row",dRowPct:"% Difference from previous row",dCol:"Difference from previous column",dColPct:"% Difference from previous column",dPctGrand:"% of grand total",dPctRow:"% of row total",dPrevRow:"% of value in the previous row",dPctCol:"% of column total",dPrevCol:"% of value in the previous column",dRunTot:"Running total",dRunTotPct:"% running total"},formats:{n0:"Integer (n0)",n2:"Float (n2)",c:"Currency (c)",p0:"Percentage (p0)",p2:"Percentage (p2)",n2c:"Thousands (n2,)",n2cc:"Millions (n2,,)",n2ccc:"Billions (n2,,,)",d:"Date (d)",MMMMddyyyy:"Month Day Year (MMMM dd, yyyy)",dMyy:"Day Month Year (d/M/yy)",ddMyy:"Day Month Year (dd/M/yy)",dMyyyy:"Day Month Year (dd/M/yyyy)",MMMyyyy:"Month Year (MMM yyyy)",MMMMyyyy:"Month Year (MMMM yyyy)",yyyy:"Year (yyyy)",yyyyQq:'Year Quarter (yyyy "Q"q)',FYEEEEQU:'Fiscal Year Quarter ("FY"EEEE "Q"U)'}},_ListContextMenu:{up:"Move Up",down:"Move Down",first:"Move to Beginning",last:"Move to End",filter:"Move to Report Filter",rows:"Move to Row Labels",cols:"Move to Column Labels",vals:"Move to Values",remove:"Remove Field",edit:"Field Settings...",detail:"Show Detail..."},DetailDialog:{header:"Detail View:",ok:"OK",items:"{cnt:n0} items",item:"{cnt} item",row:"Row",col:"Column"},PivotChart:{by:"by",and:"and"},Slicer:{multiSelect:"Multi-Select",clearFilter:"Clear Filter"}});!function(e){e[e.None=0]="None";e[e.GrandTotals=1]="GrandTotals";e[e.Subtotals=2]="Subtotals"}(ShowTotals=exports.ShowTotals||(exports.ShowTotals={}));!function(e){e[e.NoCalculation=0]="NoCalculation";e[e.DiffRow=1]="DiffRow";e[e.DiffRowPct=2]="DiffRowPct";e[e.DiffCol=3]="DiffCol";e[e.DiffColPct=4]="DiffColPct";e[e.PctGrand=5]="PctGrand";e[e.PctRow=6]="PctRow";e[e.PctCol=7]="PctCol";e[e.RunTot=8]="RunTot";e[e.RunTotPct=9]="RunTotPct";e[e.PctPrevRow=10]="PctPrevRow";e[e.PctPrevCol=11]="PctPrevCol"}(ShowAs=exports.ShowAs||(exports.ShowAs={}));class PivotEngine{constructor(e){this._autoGenFields=!0;this._allowFieldEditing=!0;this._showRowTotals=ShowTotals.GrandTotals;this._showColTotals=ShowTotals.GrandTotals;this._totalsBefore=!1;this._sortableGroups=!0;this._showZeros=!1;this._updating=0;this._xValueSearch=!0;this._async=!0;this._sortOnServer=!1;this._cntTotal=0;this._cntFiltered=0;this._serverParms={timeout:_ServerConnection._TIMEOUT,pollInterval:_ServerConnection._POLL_INTERVAL,maxDetail:_ServerConnection._MAXDETAIL};this.itemsSourceChanged=new wijmo_1.Event;this.viewDefinitionChanged=new wijmo_1.Event;this.updatingView=new wijmo_1.Event;this.updatedView=new wijmo_1.Event;this.error=new wijmo_1.Event;this._isUpdatingChanged=new wijmo_1.Event;this._hasDeferredUpdatesChanged=new wijmo_1.Event;this._pivotView=new PivotCollectionView(this);this._fields=new PivotFieldCollection(this);this._rowFields=new PivotFieldCollection(this);this._columnFields=new PivotFieldCollection(this);this._valueFields=new PivotFieldCollection(this);this._filterFields=new PivotFieldCollection(this);this._viewLists=[this._rowFields,this._columnFields,this._valueFields,this._filterFields];let t=this._fieldListChanged.bind(this);this._fields.collectionChanged.addHandler(t);this._viewLists.forEach(e=>{e.collectionChanged.addHandler(t)});this._defaultFilterType=null;wijmo_1.copy(this,e)}get itemsSource(){return this._items}set itemsSource(e){if(this._items!=e){if(this._cv){this._cv.collectionChanged.removeHandler(this._cvCollectionChanged,this);this._cv=null}if(this._server){this._server.clearPendingRequests();this._server=null}this._items=e;wijmo_1.isString(e)?this._server=new _ServerConnection(this,e):wijmo_1.isObject(e)&&!wijmo_1.tryCast(e,"ICollectionView")?this._server=new _SqlServerConnection(this,e):this._cv=wijmo_1.asCollectionView(e);null!=this._cv&&this._cv.collectionChanged.addHandler(this._cvCollectionChanged,this);this.deferUpdate(()=>{this.autoGenerateFields&&this._generateFields();this._updateFieldTypes()});this.onItemsSourceChanged()}}get isServer(){return null!=this._server}get collectionView(){return this._cv}get pivotView(){return this._pivotView}get showRowTotals(){return this._showRowTotals}set showRowTotals(e){if((e=wijmo_1.asEnum(e,ShowTotals))!=this.showRowTotals){this._showRowTotals=e;this.onViewDefinitionChanged();this.invalidate()}}get showColumnTotals(){return this._showColTotals}set showColumnTotals(e){if((e=wijmo_1.asEnum(e,ShowTotals))!=this.showColumnTotals){this._showColTotals=e;this.onViewDefinitionChanged();this.invalidate()}}get totalsBeforeData(){return this._totalsBefore}set totalsBeforeData(e){if(e!=this._totalsBefore){this._totalsBefore=wijmo_1.asBoolean(e);this.onViewDefinitionChanged();this._updatePivotView()}}get sortableGroups(){return this._sortableGroups}set sortableGroups(e){if(e!=this._sortableGroups){this._sortableGroups=wijmo_1.asBoolean(e);this.onViewDefinitionChanged()}}get sortOnServer(){return this._sortOnServer}set sortOnServer(e){this._sortOnServer=wijmo_1.asBoolean(e)}get showZeros(){return this._showZeros}set showZeros(e){if(e!=this._showZeros){this._showZeros=wijmo_1.asBoolean(e);this.onViewDefinitionChanged();this._updatePivotView()}}get defaultFilterType(){return null!=this._defaultFilterType?this._defaultFilterType:this._server?wijmo_grid_filter_1.FilterType.Condition:wijmo_grid_filter_1.FilterType.Both}set defaultFilterType(e){this._defaultFilterType=wijmo_1.asEnum(e,wijmo_grid_filter_1.FilterType,!0)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){this._xValueSearch=wijmo_1.asBoolean(e)}get autoGenerateFields(){return this._autoGenFields}set autoGenerateFields(e){this._autoGenFields=wijmo_1.asBoolean(e)}get allowFieldEditing(){return this._allowFieldEditing}set allowFieldEditing(e){this._allowFieldEditing=wijmo_1.asBoolean(e)}get fields(){return this._fields}get rowFields(){return this._rowFields}get columnFields(){return this._columnFields}get filterFields(){return this._filterFields}get valueFields(){return this._valueFields}get viewDefinition(){let e={showZeros:this.showZeros,showColumnTotals:this.showColumnTotals,showRowTotals:this.showRowTotals,defaultFilterType:this.defaultFilterType,totalsBeforeData:this.totalsBeforeData,sortableGroups:this.sortableGroups,fields:[],rowFields:this._getFieldCollectionProxy(this.rowFields),columnFields:this._getFieldCollectionProxy(this.columnFields),filterFields:this._getFieldCollectionProxy(this.filterFields),valueFields:this._getFieldCollectionProxy(this.valueFields)};this.fields.forEach(t=>{let i=this._getFieldDefinition(t);e.fields.push(i)});return JSON.stringify(e)}set viewDefinition(e){let t=JSON.parse(e);t&&this.deferUpdate(()=>{this._copyProps(this,t,PivotEngine._props);this.fields.clear();t.fields.forEach(e=>{let t=this._getFieldFromDefinition(e);this.fields.push(t)});t.fields.forEach((e,t)=>{wijmo_1.isString(e.weightField)&&(this.fields[t].weightField=this.fields.getField(e.weightField))});this._setFieldCollectionProxy(this.rowFields,t.rowFields);this._setFieldCollectionProxy(this.columnFields,t.columnFields);this._setFieldCollectionProxy(this.filterFields,t.filterFields);this._setFieldCollectionProxy(this.valueFields,t.valueFields)})}get isViewDefined(){let e=this._valueFields.length,t=this._rowFields.length,i=this._columnFields.length;return this._server?e>0&&(t>0||i>0):e>0||t>0||i>0}beginUpdate(){this.cancelPendingUpdates();this._updating++;1===this._updating&&this._onIsUpdatingChanged()}endUpdate(){this._updating--;if(this._updating<=0){if(this._viewDefinitionChanged){this._viewDefinitionChanged=!1;this.onViewDefinitionChanged();this._setHasDeferredUpdates(!1)}this._onIsUpdatingChanged();this.refresh()}}get isUpdating(){return this._updating>0}get hasDeferredUpdates(){return this._hasDeferredUpdates}_setHasDeferredUpdates(e){if(this._hasDeferredUpdates!==e){this._hasDeferredUpdates=e;this._onHasDeferredUpdatesChanged()}}deferUpdate(e){try{this.beginUpdate();e()}finally{this.endUpdate()}}refresh(e=!1){this._updateView(e)}invalidate(){this._toInv&&(this._toInv=clearTimeout(this._toInv));this.isUpdating||this.isDisposed||(this._toInv=setTimeout(()=>{this.refresh()},wijmo_1.Control._REFRESH_INTERVAL))}get async(){return this._async}set async(e){if(e!=this._async){this.cancelPendingUpdates();this._async=wijmo_1.asBoolean(e)}}get serverTimeout(){return this._serverParms.timeout}set serverTimeout(e){this._serverParms.timeout=wijmo_1.asNumber(e,!1,!0)}get serverPollInterval(){return this._serverParms.pollInterval}set serverPollInterval(e){this._serverParms.pollInterval=wijmo_1.asNumber(e,!1,!0)}get serverMaxDetail(){return this._serverParms.maxDetail}set serverMaxDetail(e){this._serverParms.maxDetail=wijmo_1.asNumber(e,!1,!0)}cancelPendingUpdates(){if(this._toUpdateTallies){clearTimeout(this._toUpdateTallies);this._toUpdateTallies=null}}getDetail(e,t){let i=e?e[_PivotKey._ROW_KEY_NAME]:null,s=this._getKey(t);if(this._server)return this._server.getDetail(i,s);let l=this.collectionView.items,o=[];l.forEach(e=>{!this._applyFilter(e)||null!=i&&!i.matchesItem(e)||null!=s&&!s.matchesItem(e)||o.push(e)});return o}getDetailView(e,t){let i=this.getDetail(e,t);return new wijmo_1.CollectionView(i)}getKeys(e,t){let i=e?e[_PivotKey._ROW_KEY_NAME]:null,s=this._getKey(t);return{rowKey:{fields:i?i.fieldNames:[],values:i?i.values:[]},colKey:{fields:s?s.fieldNames:[],values:s?s.values:[]}}}editField(e){if(this.allowFieldEditing){this.edt=new PivotFieldEditor(document.createElement("div"),{field:e});this._dlg=new wijmo_input_1.Popup(document.createElement("div"),{content:this.edt.hostElement});this._dlg.show(!0)}}removeField(e){for(let t=0;t<this._viewLists.length;t++){let i=this._viewLists[t],s=i.indexOf(e);if(s>-1){i.removeAt(s);return}}}onItemsSourceChanged(e){this.itemsSourceChanged.raise(this,e)}onViewDefinitionChanged(e){if(this._updating<=0){this.viewDefinitionChanged.raise(this,e);this._viewDefinitionChanged=!1;this._setHasDeferredUpdates(!1)}else{this._viewDefinitionChanged=!0;this._setHasDeferredUpdates(!0)}}onUpdatingView(e){this.updatingView.raise(this,e)}onUpdatedView(e){this.updatedView.raise(this,e)}onError(e){this.error.raise(this,e);return!e.cancel}_onIsUpdatingChanged(e){this._isUpdatingChanged.raise(this,e)}_onHasDeferredUpdatesChanged(e){this._hasDeferredUpdatesChanged.raise(this,e)}_copy(e,t){let i;switch(e){case"fields":this.fields.clear();this._viewLists.forEach(e=>{e.clear()});i=wijmo_1.asArray(t);i.forEach(e=>{let t=this._createField(e,!1);this.fields.push(t)});this._updateFieldTypes();return!0;case"rowFields":case"columnFields":case"valueFields":case"filterFields":this[e].clear();if(!wijmo_1.isArray(t)){this[e].maxItems=t.maxItems;t=t.items}i=wijmo_1.asArray(t);i.forEach(t=>{let i=this.fields.getField(t);this[e].push(i)});return!0}return!1}_getKey(e){return this._keys[e]}_getRowKey(e){let t=e;if(wijmo_1.isNumber(e)){let i=this._pivotView;t=(i.items.length?i.items:i.sourceCollection)[e]}return t?t[_PivotKey._ROW_KEY_NAME]:null}_getRowLevel(e){let t=this._getRowKey(e);return t?t.level:-1}_getColKey(e){wijmo_1.isNumber(e)&&(e=this._colBindings[e]);if(wijmo_1.isString(e))return this._getKey(e);wijmo_1.assert(null==e||e instanceof _PivotKey,"invalid parameter in call to _getColLevel");return e}_getColLevel(e){return(e=this._getColKey(e))?e.level:-1}_getFieldByColKey(e){const t=this._getColKey(e);return t&&t.valueField}_applyFilter(e){let t=this._activeFilterFields;for(let i=0;i<t.length;i++){if(!t[i].filter.apply(e))return!1}return!0}_updateView(e=!1){if(!this.isUpdating||e){this.cancelPendingUpdates();this._cntTotal=this._cntFiltered=0;this._tallies={};this._keys={};this._activeFilterFields=[];if(this._server&&this.isViewDefined){this._server.getOutputView(t=>{if(this.isViewDefined){this._server.updateTallies(t);this._updatePivotView(e)}});return}this._viewLists.forEach(e=>{e.forEach(e=>{e.filter.isActive&&this._activeFilterFields.push(e)})});if(this.isViewDefined&&wijmo_1.hasItems(this._cv)){this._batchStart=Date.now();this._updateTallies(this._cv.items,0,e)}else this._updatePivotView(e);this._setHasDeferredUpdates(!1)}}_updateTallies(e,t,i=!1){let s=e.length,l=new _PivotNode(this._rowFields,0,null,-1,null),o=this.valueFields;if(0==o.length&&this.columnFields.length>0){o=new PivotFieldCollection(this);o.push(new PivotField(this,"","",{aggregate:wijmo_1.Aggregate.Sum}))}let r=ShowTotals,n=this._rowFields.length,a=this._getShowRowTotals(),h=a==r.None?n:0,d=a==r.GrandTotals?Math.max(1,n):1,_=this._columnFields.length,u=this._getShowColTotals(),g=u==r.None?_:0,c=u==r.GrandTotals?Math.max(1,_):1,m=o.length;for(let r=t;r<s;r++){if(this._async&&r-t>=PivotEngine._BATCH_SIZE&&Date.now()-this._batchStart>PivotEngine._BATCH_DELAY){this._toUpdateTallies=setTimeout(()=>{this.onUpdatingView(new ProgressEventArgs(Math.round(r/e.length*100)));this._batchStart=Date.now();this._updateTallies(e,r,i)},PivotEngine._BATCH_TIMEOUT);return}this._cntTotal++;let s=e[r];if(!this._activeFilterFields.length||this._applyFilter(s)){this._cntFiltered++;for(let e=h;e<=n;e+=d){let t=l.getNode(this._rowFields,e,null,-1,s),i=t.key,r=i.toString(),n=this._tallies[r];if(!n){this._keys[r]=i;this._tallies[r]=n={}}for(let e=g;e<=_;e+=c)for(let i=0;i<m;i++){let l=t.tree.getNode(this._columnFields,e,o,i,s).key,r=l.toString(),a=n[r];if(!a){this._keys[r]=l;a=n[r]=new _Tally}let h=o[i],d=h._getValue(s,!1),_=h.weightField?h._getWeight(s):null;a.add(d,_)}}}}this._toUpdateTallies=null;this._updatePivotView(i)}_updatePivotView(e=!1){if(!this.isUpdating||e){let e=this._pivotView;e.deferUpdate(()=>{this.onUpdatingView(new ProgressEventArgs(100));e.cancelEdit();e.cancelNew();let t=e.sourceCollection;t.length=0;let i={};for(let e in this._tallies)i[e]=!0;let s={};for(let e in this._tallies){let t=this._tallies[e];for(let e in t)s[e]=!0}let l=[],o=[];if(this._server)l=this._server.getSortedKeys(i,!0),o=this._server.getSortedKeys(s,!1);else{l=this._getSortedKeys(i);o=this._getSortedKeys(s)}for(let e=0;e<l.length;e++){let i=l[e],s=this._tallies[i],r={};r[_PivotKey._ROW_KEY_NAME]=this._getKey(i);for(let e=0;e<o.length;e++){let t=o[e],i=s[t],l=this._getKey(t),n=i?i.getAggregate(l.aggregate):null;null==n&&this._showZeros&&(n=0);r[t]=n}t.push(r)}this._colBindings=o;this._updateFieldValues(t);e.sortDescriptions.clear();e.refresh()});this.onUpdatedView()}}_getSortedKeys(e){let t=Object.keys(e);t.sort((e,t)=>this._keys[e].compareTo(this._keys[t]));return t}_updateFieldValues(e){let t=this.valueFields.length;for(let i=0;i<t;i++){let s=this.valueFields[i];if(wijmo_1.isFunction(s.getAggregateValue))for(let l=i;l<this._colBindings.length;l+=t)for(let t=0;t<e.length;t++){let i=e[t],o=this._colBindings[l],r=this._getAggregateObject(i,o);i[o]=s.getAggregateValue.call(this,r)}}for(let i=0;i<t;i++){let s=this.valueFields[i];switch(s.showAs){case ShowAs.RunTot:case ShowAs.RunTotPct:for(let l=i;l<this._colBindings.length;l+=t){for(let t=0;t<e.length;t++){e[t][this._colBindings[l]]=this._getRunningTotal(e,t,l)}if(s.showAs==ShowAs.RunTotPct)for(let t=0;t<e.length;t++){let i=e[t],s=this._colBindings[l],o=i[s];if(wijmo_1.isNumber(o)){let r=this._getLastValueInRowGroup(e,t,l);0!=r&&(i[s]=o/r)}}}break;case ShowAs.PctGrand:case ShowAs.PctCol:let l=0;if(s.showAs==ShowAs.PctGrand)for(let s=i;s<this._colBindings.length;s+=t)-1==this._getColLevel(s)&&(l+=this._getColTotal(e,s));for(let o=i;o<this._colBindings.length;o+=t){s.showAs==ShowAs.PctCol&&(l=this._getColTotal(e,o));let t=this._colBindings[o];e.forEach(e=>{let i=e[t];wijmo_1.isNumber(i)&&(e[t]=0!=l?i/l:null)})}break;case ShowAs.PctRow:for(let s=0;s<e.length;s++){let l=e[s],o=0;for(let e=i;e<this._colBindings.length;e+=t)if(-1==this._getColLevel(e)){let t=l[this._colBindings[e]];wijmo_1.isNumber(t)&&(o+=t)}for(let e=i;e<this._colBindings.length;e+=t){let t=this._colBindings[e],i=l[t];wijmo_1.isNumber(i)&&(l[t]=0!=o?i/o:null)}}break;case ShowAs.DiffRow:case ShowAs.DiffRowPct:case ShowAs.PctPrevRow:for(let l=i;l<this._colBindings.length;l+=t)for(let t=e.length-1;t>=0;t--){e[t][this._colBindings[l]]=this._getRowDifference(e,t,l,s.showAs)}break;case ShowAs.DiffCol:case ShowAs.DiffColPct:case ShowAs.PctPrevCol:for(let l=0;l<e.length;l++)for(let o=this._colBindings.length-t+i;o>=0;o-=t){e[l][this._colBindings[o]]=this._getColDifference(e,l,o,s.showAs)}}}}_getAggregateObject(e,t){let i={},s=/(.+:.+;)*((.+):.+;)/,l=t.match(s);for(let t in e){let o=t.match(s);o&&o[1]==l[1]&&(i[o[3]]=e[t])}return i}_getColTotal(e,t){let i=this._colBindings[t],s=0;e.forEach(e=>{if(-1==this._getRowLevel(e)){let t=e[i];wijmo_1.isNumber(t)&&(s+=t)}});return s}_getRunningTotal(e,t,i){let s=this._getRowLevel(e[t]);if(0==s)return null;let l=this._colBindings[i],o=e[t][l],r=this._getShowRowTotals(),n=this.rowFields.length-2;for(let i=t-1;i>=0;i--){let a=this._getRowLevel(e[i]);if(a==s){if(n>-1&&s<0&&r!=ShowTotals.Subtotals){let s=e[t].$rowKey,l=e[i].$rowKey;if(s.values[n]!=l.values[n])return null}o+=e[i][l];break}if(a>s)break}return o}_getLastValueInRowGroup(e,t,i){let s=this._colBindings[i],l=e[t][s],o=this._getRowLevel(e[t]),r=this.rowFields.length-2,n=this._getShowRowTotals();for(let i=t+1;i<e.length;i++){let a=this._getRowLevel(e[i]);if(a==o){if(r>-1&&o<0&&n!=ShowTotals.Subtotals){let s=e[t].$rowKey,o=e[i].$rowKey;if(s.values[r]!=o.values[r])return l}l=e[i][s]}if(a>o)break}return l}_getRowDifference(e,t,i,s){let l=this._getRowLevel(e[t]);if(0==l)return null;let o=this._colBindings[i],r=e[t][o],n=this.rowFields.length-2,a=this._getShowRowTotals();for(let i=t-1;i>=0;i--){let h=this._getRowLevel(e[i]);if(h==l){if(n>-1&&l<0&&a!=ShowTotals.Subtotals){let s=e[t].$rowKey,l=e[i].$rowKey;if(s.values[n]!=l.values[n])return null}let h=e[i][o];switch(s){case ShowAs.DiffRow:r-=h;break;case ShowAs.DiffRowPct:r=(r-h)/h;break;case ShowAs.PctPrevRow:r/=h}return r}if(h>l)break}return s==ShowAs.PctPrevRow?1:null}_getColDifference(e,t,i,s){let l=this._getColLevel(i);if(0==l)return null;let o=e[t],r=o[this._colBindings[i]],n=this.valueFields.length,a=this.columnFields.length-2,h=this._getShowColTotals();for(let e=i-n;e>=0;e-=n){let t=this._getColLevel(e);if(t==l){if(a>-1&&l<0&&h!=ShowTotals.Subtotals){let t=this._getKey(this._colBindings[i]),s=this._getKey(this._colBindings[e]);if(t.values[a]!=s.values[a])return null}let t=o[this._colBindings[e]];switch(s){case ShowAs.DiffCol:r-=t;break;case ShowAs.DiffColPct:r=(r-t)/t;break;case ShowAs.PctPrevCol:r/=t}return r}if(t>l)break}return s==ShowAs.PctPrevCol?1:null}_getShowRowTotals(){return this._valueFields.length?this._showRowTotals:ShowTotals.None}_getShowColTotals(){return this._valueFields.length?this._showColTotals:ShowTotals.None}_getUniqueValues(e){return this._server?this._server.getUniqueValues(e):null}_generateFields(){this._viewLists.forEach(e=>{e.clear()});for(let e=0;e<this.fields.length;e++){if(this.fields[e]._autoGenerated){this.fields.removeAt(e);e--}}if(this._server){this._server.getFields().forEach(e=>{let t=this._createField(e,!0);this.fields.getField(t.header)||this.fields.push(t)});return}let e=this.collectionView,t=e?e.items:null;t&&t.length&&this.autoGenerateFields&&wijmo_1.getTypes(t,0).forEach(e=>{let t=this._createField({binding:e.binding,header:wijmo_1.toHeaderCase(e.binding),dataType:e.dataType},!0);this.fields.getField(t.header)||this.fields.push(t)})}_updateFieldTypes(){let e=this.collectionView,t=e?e.sourceCollection:null;t&&t.length&&this.fields.forEach(e=>{this._updateFieldType(e,t)})}_updateFieldType(e,t){if(e._hasSubFields())e.subFields.forEach(e=>{this._updateFieldType(e,t)});else{if(null==e.dataType&&e.binding)for(let i=0;i<t.length;i++){let s=e._binding.getValue(t[i]);if(null!=s){e.dataType=wijmo_1.isPrimitive(s)?wijmo_1.getType(s):null;break}}if(null!=e.dataType){e.format||(e.format=e.dataType==wijmo_1.DataType.Date?"d":"n0");e.aggregate==wijmo_1.Aggregate.Sum&&e.dataType!=wijmo_1.DataType.Number&&(e.aggregate=wijmo_1.Aggregate.Cnt)}}}_createField(e,t){let i;if(wijmo_1.isString(e))i=new PivotField(this,e);else if(e){e.key&&delete e.key;i=null!=e.dimensionType?new CubePivotField(this,e.binding,e.header,e):new PivotField(this,e.binding,e.header,e);null!=e.dataType&&(i.dataType=e.dataType)}i._autoGenerated=t;if(t||wijmo_1.isString(e)){i.format=i.dataType==wijmo_1.DataType.Date?"d":"n0";i.aggregate=i.dataType==wijmo_1.DataType.Number?wijmo_1.Aggregate.Sum:wijmo_1.Aggregate.Cnt}e&&!wijmo_1.isString(e)&&wijmo_1.copy(i,e);return i}_cvCollectionChanged(e,t){this.invalidate()}_fieldListChanged(e,t){if(t.action==wijmo_1.NotifyCollectionChangedAction.Add){let i=e;for(let e=0;e<i.length-1;e++)if(i[e].key)for(let t=e+1;t<i.length;t++)if(i[e].key==i[t].key){i.removeAt(t);t--}if(i!=this._fields)if(this._fields.getField(t.item.key)){for(let e=0;e<this._viewLists.length;e++)if(this._viewLists[e]!=i){let i=this._viewLists[e],s=i.indexOf(t.item);s>-1&&i.removeAt(s)}}else i.removeAt(t.index);if(wijmo_1.isNumber(i.maxItems)&&i.maxItems>-1)for(;i.length>i.maxItems;){let e=i.length-1;i[e]==t.item&&e>0&&e--;i.removeAt(e)}}this.onViewDefinitionChanged();this.invalidate()}_fieldPropertyChanged(e,t){this.onViewDefinitionChanged();if(!e.isActive)return;let i=t.propertyName;"visible"!=i&&("width"!=i&&"wordWrap"!=i&&"isContentHtml"!=i?"format"==i&&this.valueFields.indexOf(e)>-1?this._pivotView.refresh():"showAs"!=i?"descending"!=i?"aggregate"!=i?this.invalidate():this.valueFields.indexOf(e)>-1&&!this.isUpdating&&(this._server?this._updateView():this._updatePivotView()):this._updatePivotView():this.valueFields.indexOf(e)>-1&&!this.isUpdating&&this._updatePivotView():this._pivotView.refresh())}_copyProps(e,t,i){for(let s=0;s<i.length;s++){let l=i[s];null!=t[l]&&(e[l]=t[l])}}_getFieldFromDefinition(e){let t=e.filter;e.filter&&delete e.filter;let i=this._createField(e,!0);if(t){i._setFilterProxy(t);e.filter=t}return i}_getFieldDefinition(e){let t={binding:e.binding,header:e.header,dataType:e.dataType,aggregate:e.aggregate,showAs:e.showAs,descending:e.descending,format:e.format,align:e.align,wordWrap:e.wordWrap,width:e.width,isContentHtml:e.isContentHtml};e.weightField&&(t.weightField=e.weightField._getName());e.key&&(t.key=e.key);e.filter.isActive&&(t.filter=e._getFilterProxy());if(e._hasSubFields()){t.subFields=[];e.subFields.forEach(e=>{t.subFields.push(this._getFieldDefinition(e))})}e instanceof CubePivotField&&(t.dimensionType=e.dimensionType);return t}_getFieldCollectionProxy(e){let t={items:[]};wijmo_1.isNumber(e.maxItems)&&e.maxItems>-1&&(t.maxItems=e.maxItems);for(let i=0;i<e.length;i++){let s=e[i];t.items.push(s.key)}return t}_setFieldCollectionProxy(e,t){e.clear();e.maxItems=wijmo_1.isNumber(t.maxItems)?t.maxItems:null;for(let i=0;i<t.items.length;i++)e.push(t.items[i])}dispose(){this.isDisposed=!0;if(this._cv){this._cv.collectionChanged.removeHandler(this._cvCollectionChanged,this);this._cv=null}if(this._server){this._server.clearPendingRequests();this._server=null}this._fields&&this._fields.collectionChanged&&this._fields.collectionChanged.removeHandler(this._fieldListChanged,this);this._viewLists.forEach(e=>{e.collectionChanged&&e.collectionChanged.removeHandler(this._fieldListChanged,this)});this._tallies=null;this._keys=null;this._activeFilterFields=null;if(this._toInv){clearTimeout(this._toInv);this._toInv=null}if(this._toUpdateTallies){clearTimeout(this._toUpdateTallies);this._toUpdateTallies=null}if(this.edt){this.edt.dispose();this.edt=null}if(this._dlg){this._dlg.dispose();this._dlg=null}this._items=null;if(this._fields){this._fields.clear();this._fields=null}if(this._rowFields){this._rowFields.clear();this._rowFields=null}if(this._columnFields){this._columnFields.clear();this._columnFields=null}if(this._valueFields){this._valueFields.clear();this._valueFields=null}if(this._filterFields){this._filterFields.clear();this._filterFields=null}this._serverParms=null;this._colBindings=null;delete this.isDisposed}}PivotEngine._BATCH_SIZE=1e4;PivotEngine._BATCH_TIMEOUT=0;PivotEngine._BATCH_DELAY=100;PivotEngine._props=["showZeros","showRowTotals","showColumnTotals","totalsBeforeData","sortableGroups","defaultFilterType"];exports.PivotEngine=PivotEngine;class ProgressEventArgs extends wijmo_1.EventArgs{constructor(e){super();this._progress=wijmo_1.asNumber(e)}get progress(){return this._progress}}exports.ProgressEventArgs=ProgressEventArgs;class _ListContextMenu extends wijmo_input_1.Menu{constructor(e){super(document.createElement("div"),{header:"Field Context Menu",displayMemberPath:"text",commandParameterPath:"parm",command:{executeCommand:e=>{this._execute(e)},canExecuteCommand:e=>this._canExecute(e)}});this._full=e;this.itemsSource=this._getMenuItems(e);wijmo_1.addClass(this.dropDown,"context-menu "+exports._GridContextMenuClsNames.hostElement)}static get controlTemplate(){_ListContextMenu._ctrlTemplate||(_ListContextMenu._ctrlTemplate=wijmo_input_1.Menu.controlTemplate);return _ListContextMenu._ctrlTemplate}static set controlTemplate(e){_ListContextMenu._ctrlTemplate=e}refresh(e=!0){this.itemsSource=this._getMenuItems(this._full);super.refresh(e)}attach(e){wijmo_1.assert(e instanceof wijmo_grid_1.FlexGrid,"Expecting a FlexGrid control...");let t=e.hostElement;this._contextMenuHandler=i=>{if(this._selectField(e,i)){i.preventDefault();this.owner=t;this.show(i)}};t.addEventListener("contextmenu",this._contextMenuHandler)}_selectField(e,t){let i=e.hitTest(t);if(i.panel!=e.cells||!i.range.isValid)return!1;let s=e.rows[i.row].dataItem;if(s instanceof CubePivotField&&s.subFields&&s.subFields.length)return!1;e.select(i.range,!0);return!0}_getMenuItems(e){let t;t=e?[{text:'<div class="menu-icon"></div>*',parm:"up"},{text:'<div class="menu-icon"></div>*',parm:"down"},{text:'<div class="menu-icon"></div>*',parm:"first"},{text:'<div class="menu-icon"></div>*',parm:"last"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:`<div class="menu-icon"><span class=${wijmo_1.GlyphClsNames.filter}></span></div>*`,parm:"filter"},{text:'<div class="menu-icon">≡</div>*',parm:"rows"},{text:'<div class="menu-icon">⫴</div>*',parm:"cols"},{text:'<div class="menu-icon">Σ</div>*',parm:"vals"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:'<div class="menu-icon menu-icon-remove">✖</div>*',parm:"remove"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:'<div class="menu-icon">⛭</div>*',parm:"edit"}]:[{text:`<div class="menu-icon"><span class=${wijmo_1.GlyphClsNames.filter}></span></div>*`,parm:"filter"},{text:'<div class="menu-icon">≡</div>*',parm:"rows"},{text:'<div class="menu-icon">⫴</div>*',parm:"cols"},{text:'<div class="menu-icon">Σ</div>*',parm:"vals"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:'<div class="menu-icon">⛭</div>*',parm:"edit"}];for(let e=0;e<t.length;e++){let i=t[e];if(i.parm){let e=wijmo_1.culture.olap._ListContextMenu[i.parm];wijmo_1.assert(e,"missing localized text for item "+i.parm);i.text=i.text.replace(/([^>]+$)/,e)}}return t}_execute(e){let t=wijmo_1.Control.getControl(this.owner),i=t.itemsSource,s=t.selection.row,l=t.rows[s].dataItem,o=l?l.engine:null,r=this._getTargetList(o,e);switch(e){case"up":case"first":case"down":case"last":if(o){let t=i.indexOf(l),s="up"==e?t-1:"first"==e?0:"down"==e?t+1:"last"==e?i.length:-1;o.deferUpdate(()=>{i.removeAt(t);i.insert(s,l)})}break;case"filter":case"rows":case"cols":case"vals":r&&l&&r.push(l);break;case"remove":l&&o.removeField(l);break;case"edit":l&&o.editField(l)}}_canExecute(e){let t=wijmo_1.Control.getControl(this.owner);if(!t)return!1;let i=t.selection.row,s=i>-1?t.rows[i].dataItem:null,l=s?s.engine:null,o=this._getTargetList(l,e),r=!!s&&s instanceof CubePivotField,n=!!s&&s.isMeasure;switch(e){case"up":case"first":return i>0;case"down":case"last":return i<t.rows.length-1;case"filter":case"rows":case"cols":return!n&&o&&o.indexOf(s)<0;case"vals":return(!r||n)&&o&&o.indexOf(s)<0;case"edit":return l&&l.allowFieldEditing;case"detail":return s&&!r}return!0}_getTargetList(e,t){if(e)switch(t){case"filter":return e.filterFields;case"rows":return e.rowFields;case"cols":return e.columnFields;case"vals":return e.valueFields}return null}dispose(){if(this.owner instanceof HTMLElement){this.owner.removeEventListener("contextmenu",this._contextMenuHandler);this._contextMenuHandler=null;this._owner=null}this.itemsSource=null;super.dispose()}}_ListContextMenu._ctrlTemplate="";exports._ListContextMenu=_ListContextMenu;class PivotPanel extends wijmo_1.Control{constructor(e,t){super(e,null,!0);this._showIcons=!0;this._restrictDrag=null;this.deferredUpdateChanged=new wijmo_1.Event;this.itemsSourceChanged=new wijmo_1.Event;this.viewDefinitionChanged=new wijmo_1.Event;this.updatingView=new wijmo_1.Event;this.updatedView=new wijmo_1.Event;this._isUpdatingChangedBnd=this._isUpdatingChanged.bind(this);let i=this.getTemplate();this.applyTemplate(`${wijmo_1.ControlClsNames.hostElement} ${wijmo_1.ControlClsNames.content} ${exports.PivotPanelClsNames.hostElement}`,i,{_dFields:"d-fields",_dFilters:"d-filters",_dRows:"d-rows",_dCols:"d-cols",_dVals:"d-vals",_dProgress:"d-prog",_btnUpdate:"btn-update",_chkDefer:"chk-defer",_gFlds:"g-flds",_gDrag:"g-drag",_gFlt:"g-flt",_gCols:"g-cols",_gRows:"g-rows",_gVals:"g-vals",_gDefer:"g-defer"});this._globalize();let s=this.hostElement;this.addEventListener(s,"dragstart",this._dragstart.bind(this));this.addEventListener(s,"dragover",this._dragover.bind(this));this.addEventListener(s,"dragleave",this._dragover.bind(this));this.addEventListener(s,"drop",this._drop.bind(this));this.addEventListener(s,"dragend",this._dragend.bind(this));this._lbFields=this._createFieldGrid(this._dFields);this._lbFilters=this._createFieldGrid(this._dFilters);this._lbRows=this._createFieldGrid(this._dRows);this._lbCols=this._createFieldGrid(this._dCols);this._lbVals=this._createFieldGrid(this._dVals);let l=this._ctxMenuShort=new _ListContextMenu(!1);l.attach(this._lbFields);l=this._ctxMenuFull=new _ListContextMenu(!0);l.attach(this._lbFilters);l.attach(this._lbRows);l.attach(this._lbCols);l.attach(this._lbVals);this._dMarker=wijmo_1.createElement(`<div class="${wijmo_grid_1.FlexGridClsNames.marker}" style="display:none"> </div>`);this.hostElement.appendChild(this._dMarker);this.addEventListener(this._btnUpdate,"click",e=>{this._ng.refresh(!0);this.refresh();e.preventDefault()});this.addEventListener(this._chkDefer,"click",e=>{this.deferredUpdate=this._chkDefer.checked;this._updateDeferredUpdateElements()});this.engine=new PivotEngine;this.initialize(t)}static get controlTemplate(){PivotPanel._ctrlTemplate||(PivotPanel._ctrlTemplate=`<div><label wj-part="g-flds"></label><div wj-part="d-fields"></div><label wj-part="g-drag"></label><table><tr><td width="50%"><label><span class="${wijmo_1.GlyphClsNames.glyph} ${wijmo_1.GlyphClsNames.filter}"></span> <span wj-part="g-flt"></span></label><div wj-part="d-filters"></div></td><td width= "50%" style="border-left-style:solid"><label><span class=${wijmo_1.GlyphClsNames.glyph}>⫴</span> <span wj-part="g-cols"></span></label><div wj-part="d-cols"></div></td></tr><tr style="border-top-style:solid"><td width="50%"><label><span class=${wijmo_1.GlyphClsNames.glyph}>≡</span> <span wj-part="g-rows"></span></label><div wj-part="d-rows"></div></td><td width= "50%" style="border-left-style:solid"><label><span class=${wijmo_1.GlyphClsNames.glyph}>Σ</span> <span wj-part="g-vals"></span></label><div wj-part="d-vals"></div></td></tr></table><div wj-part="d-prog" class=${wijmo_1.ControlStateClsNames.selected} style="width:0px;height:3px"></div><div style="display:table"><label style="display:table-cell;vertical-align:middle"><input wj-part="chk-defer" type="checkbox"/> <span wj-part="g-defer"></span></label><button wj-part="btn-update" class="${wijmo_1.InputFormElementsClsNames.btn} ${wijmo_1.ControlStateClsNames.disabled}" style="float:right;margin:6px" disabled></button></div></div>`);return PivotPanel._ctrlTemplate}static set controlTemplate(e){PivotPanel._ctrlTemplate=e}_getProductInfo(){return"D6F4,PivotPanel"}get engine(){return this._ng}set engine(e){let t,i=this._ng;if(i){i.itemsSourceChanged.removeHandler(this._itemsSourceChanged);i.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged);i.updatingView.removeHandler(this._updatingView);i.updatedView.removeHandler(this._updatedView);i.error.removeHandler(this._requestError);i._isUpdatingChanged.removeHandler(this._isUpdatingChangedBnd);t=this.deferredUpdate}e=wijmo_1.asType(e,PivotEngine,!1);i=this._ng=e;i.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);i.viewDefinitionChanged.addHandler(this._viewDefinitionChanged,this);i.updatingView.addHandler(this._updatingView,this);i.updatedView.addHandler(this._updatedView,this);i.error.addHandler(this._requestError,this);i._isUpdatingChanged.addHandler(this._isUpdatingChangedBnd);t!==this.deferredUpdate&&this.onDeferredUpdateChanged();this._lbFields.itemsSource=e.fields;this._lbFilters.itemsSource=e.filterFields;this._lbRows.itemsSource=e.rowFields;this._lbCols.itemsSource=e.columnFields;this._lbVals.itemsSource=e.valueFields;this._filterFieldVisibleWithRoot=e=>e.visible&&null==e.parentField;this._filterFieldVisibleOnly=e=>e.visible;this._lbFields.collectionView.filter=this._filterFieldVisibleWithRoot;"Filters,Rows,Cols,Vals".split(",").forEach(e=>{this["_lb"+e].collectionView.filter=this._filterFieldVisibleOnly});this._updateDeferredUpdateElements()}get itemsSource(){return this._ng.itemsSource}set itemsSource(e){e instanceof PivotEngine?this.engine=e:this._ng.itemsSource=e}get collectionView(){return this._ng.collectionView}get pivotView(){return this._ng.pivotView}get autoGenerateFields(){return this.engine.autoGenerateFields}set autoGenerateFields(e){this._ng.autoGenerateFields=e}get fields(){return this._ng.fields}get rowFields(){return this._ng.rowFields}get columnFields(){return this._ng.columnFields}get valueFields(){return this._ng.valueFields}get filterFields(){return this._ng.filterFields}get viewDefinition(){return this._ng.viewDefinition}set viewDefinition(e){this._ng.viewDefinition=e}get isViewDefined(){return this._ng.isViewDefined}get showFieldIcons(){return this._showIcons}set showFieldIcons(e){if(e!=this._showIcons){this._showIcons=wijmo_1.asBoolean(e);this.invalidate()}}get restrictDragging(){return this._restrictDrag}set restrictDragging(e){this._restrictDrag=wijmo_1.asBoolean(e,!0)}get deferredUpdate(){return this.engine.isUpdating}set deferredUpdate(e){this.deferredUpdate!=e&&(e?this._ng.beginUpdate():this._ng.endUpdate())}onDeferredUpdateChanged(e){this.deferredUpdateChanged.raise(this,e)}onItemsSourceChanged(e){this.itemsSourceChanged.raise(this,e)}onViewDefinitionChanged(e){this.viewDefinitionChanged.raise(this,e)}onUpdatingView(e){this.updatingView.raise(this,e)}onUpdatedView(e){this.updatedView.raise(this,e)}refresh(e=!0){if(this.hostElement){["Fields","Filters","Rows","Cols","Vals"].forEach(e=>{let t=this["_lb"+e],i=t?t.collectionView:null;if(t&&i){t.refresh();i.refresh()}});if(e){this._globalize();this._ctxMenuShort.refresh();this._ctxMenuFull.refresh()}}super.refresh(e)}_copy(e,t){switch(e){case"engine":this.engine=t;return!0}return!1}_globalize(){let e=wijmo_1.culture.olap.PivotPanel;wijmo_1.setText(this._gFlds,e.fields);wijmo_1.setText(this._gDrag,e.drag);wijmo_1.setText(this._gFlt,e.filters);wijmo_1.setText(this._gCols,e.cols);wijmo_1.setText(this._gRows,e.rows);wijmo_1.setText(this._gVals,e.vals);wijmo_1.setText(this._gDefer,e.defer);wijmo_1.setText(this._btnUpdate,e.update)}_itemsSourceChanged(e,t){this.onItemsSourceChanged(t)}_viewDefinitionChanged(e,t){this.invalidate();this.onViewDefinitionChanged(t)}_updatingView(e,t){let i=wijmo_1.clamp(t.progress,5,100)%100;this._dProgress.style.width=i+"%";this.onUpdatingView(t)}_updatedView(e,t){this.onUpdatedView(t)}_requestError(e,t){this._dProgress.style.width="0"}_isUpdatingChanged(){this._updateDeferredUpdateElements();this.onDeferredUpdateChanged()}_updateDeferredUpdateElements(){const e=this.deferredUpdate;this._chkDefer.checked=e;wijmo_1.enable(this._btnUpdate,e)}_createFieldGrid(e){let t=new wijmo_grid_1.FlexGrid(e,{autoGenerateColumns:!1,childItemsPath:"subFields",columns:[{binding:"header",width:"*"}],headersVisibility:"None",selectionMode:"Cell",alternatingRowStep:0});t.cells.hostElement.parentElement.style.overflowX="hidden";t.formatItem.addHandler((e,t)=>{let i=e.rows[t.row].dataItem;wijmo_1.assert(i instanceof PivotField,"PivotField expected...");let s=i._hasSubFields();wijmo_1.toggleClass(t.cell,exports.PivotPanelClsNames.header,s);t.cell.setAttribute("draggable",(!s).toString());let l=t.cell.innerHTML;i.filter.isActive&&(l+=` <span class=${wijmo_1.GlyphClsNames.filter}></span>`);e!=this._lbVals||wijmo_1.isFunction(i.getAggregateValue)||(l+=` <span class="${exports.PivotPanelClsNames.aggregate}">(`+wijmo_1.Aggregate[i.aggregate]+")</span>");if(e==this._lbFields&&!s){if(this._showIcons){let e=i.isMeasure?"measure":"dimension";l=`<span class="${wijmo_1.GlyphClsNames.glyph}-`+e+'"></span> '+l}l='<label><input type="checkbox"'+(i.isActive?" checked":"")+"> "+l+"</label>"}t.cell.innerHTML=l});t.addEventListener(e,"click",e=>{let i=e.target;if(i instanceof HTMLInputElement&&"checkbox"==i.type){let s=this._hitTestField(t,e);s instanceof PivotField&&(s.isActive=i.checked)}});return t}_dragstart(e){let t=this._getFlexGridTarget(e);if(t){this._dragField=this._hitTestField(t,e);this._dragSource=this._dragField instanceof PivotField?t.hostElement:null;if(this._dragSource&&e.dataTransfer){wijmo_1._startDrag(e.dataTransfer,"copyMove");e.stopPropagation()}}}_dragover(e){let t=!1,i=this._getFlexGridTarget(e);if(i&&this._dragField){if(this._dragSource==this._dFields&&i!=this._lbFields){let e=i.itemsSource;if(null==e.maxItems||e.length<e.maxItems){let e=this._dragField;i.itemsSource.indexOf(e)<0?t=!0:i==this._lbVals&&(t=!(e instanceof CubePivotField))}}this._dragSource&&this._dragSource!=this._dFields&&(t=!0)}if(t&&this._getRestrictDrag()&&this._dragSource!=i.hostElement){let e=this._dragField.isMeasure;i==this._lbVals?t=e:i!=this._lbRows&&i!=this._lbCols||(t=!e)}if(t){this._updateDropMarker(i,e);e.dataTransfer.dropEffect=this._dragSource==this._dFields?"copy":"move";e.preventDefault();e.stopPropagation()}else this._updateDropMarker()}_drop(e){let t=this._getFlexGridTarget(e);if(t&&this._dragField){let e=wijmo_1.Control.getControl(this._dragSource),i=this._dragField;if(e==this._lbFields&&t==this._lbVals&&t.itemsSource.indexOf(i)>-1){i=i._clone();this.engine.fields.push(i)}t==this._lbFields?i.isActive=!1:this._ng.deferUpdate(()=>{let e=t.itemsSource,s=e.indexOf(i);if(s!=this._dropIndex){if(s>-1){e.removeAt(s);s<this._dropIndex&&this._dropIndex--}e.insert(this._dropIndex,i)}})}this._resetMouseState()}_dragend(e){this._resetMouseState()}_hitTestField(e,t){let i=e.hitTest(t.target);if(i.panel==e.cells&&i.range.isValid){e.select(i.range,!0);return e.rows[i.row].dataItem}return null}_getRestrictDrag(){let e=this._restrictDrag;null==e&&this.fields.length&&(e=this.fields[0]instanceof CubePivotField);return e}_resetMouseState(){this._dragSource=null;this._updateDropMarker()}_getFlexGridTarget(e){let t=wijmo_1.Control.getControl(wijmo_1.closest(e.target,"."+wijmo_grid_1.FlexGridClsNames.hostElement));return t instanceof wijmo_grid_1.FlexGrid?t:null}_updateDropMarker(e,t){if(!t){this._dMarker.style.display="none";return}let i,s=this.hostElement,l=s.getBoundingClientRect();if(e.rows.length){let l=e.hitTest(t).row;if(l>-1){i=e.getCellBoundingRect(l,0);if(t.clientY>s.scrollTop+i.top+i.height/2&&l<e.rows.length){i.top+=i.height;l++}this._dropIndex=l}else{l=e.viewRange.bottomRow;i=e.getCellBoundingRect(l,0);i.top+=i.height;this._dropIndex=l+1}}else{i=wijmo_1.Rect.fromBoundingRect(e.hostElement.getBoundingClientRect());i.top+=4;this._dropIndex=0}wijmo_1.setCss(this._dMarker,{left:Math.round(i.left-l.left)+s.scrollLeft,top:Math.round(i.top-l.top-2)+s.scrollTop,width:Math.round(i.width),height:4,display:""})}dispose(){this._lbFields&&this._lbFields.collectionView&&(this._lbFields.collectionView.filter=null);["Filters","Rows","Cols","Vals"].forEach(e=>{const t=this["_lb"+e];t&&t.collectionView&&(t.collectionView.filter=null)});if(this._ctxMenuShort){this._ctxMenuShort.dispose();this._ctxMenuShort=null}if(this._ctxMenuFull){this._ctxMenuFull.dispose();this._ctxMenuFull=null}if(this._lbFields){this._lbFields.dispose();this._lbFields=null}if(this._lbFilters){this._lbFilters.dispose();this._lbFilters=null}if(this._lbRows){this._lbRows.dispose();this._lbRows=null}if(this._lbCols){this._lbCols.dispose();this._lbCols=null}if(this._lbVals){this._lbVals.dispose();this._lbVals=null}if(this._ng){this._ng.itemsSourceChanged.removeHandler(this._itemsSourceChanged);this._ng.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged);this._ng.updatingView.removeHandler(this._updatingView);this._ng.updatedView.removeHandler(this._updatedView);this._ng.error.removeHandler(this._requestError);this._ng._isUpdatingChanged.removeHandler(this._isUpdatingChangedBnd)}this.engine.dispose();super.dispose()}}PivotPanel._ctrlTemplate="";exports.PivotPanel=PivotPanel;class PivotGrid extends wijmo_grid_1.FlexGrid{constructor(e,t){super(e);this._showDetailOnDoubleClick=!0;this._collapsibleSubtotals=!0;this._customCtxMenu=!0;this._ctxMenu=new _GridContextMenu;this._showRowFldSort=!1;this._showRowFldHdrs=!0;this._showColFldHdrs=!0;this._showValFldHdrs=!1;this._centerVert=!0;this._collapsedKeys={};this._resizingColumn=!1;this._outlineMode=!1;this._ignoreClick=!1;this._colRowFields=new Map;this._prevCulture=wijmo_1.culture.Globalize.name;this._hdrCols._setDefaultSize(this._cols.defaultSize);wijmo_1.addClass(this.hostElement,exports.PivotGridClsNames.hostElement);this.isReadOnly=!0;this.copyHeaders=wijmo_grid_1.HeadersVisibility.All;this.deferResizing=!0;this.alternatingRowStep=0;this.autoGenerateColumns=!1;this.allowDragging=wijmo_grid_1.AllowDragging.None;this.allowMerging=wijmo_grid_1.AllowMerging.All;this.mergeManager=new _PivotMergeManager;this.customContextMenu=!0;this.treeIndent=32;this.initialize(t);this.formatItem.addHandler(this._formatItem,this);var i=this.hostElement;this.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);this.addEventListener(i,"mouseup",this._mouseup.bind(this),!0);this.addEventListener(i,"dblclick",this._dblclick.bind(this),!0);this.addEventListener(i,"click",this._click.bind(this),!0);this.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._ctxMenu.attach(this)}static get controlTemplate(){PivotGrid._ctrlTemplate||(PivotGrid._ctrlTemplate=wijmo_grid_1.FlexGrid.controlTemplate);return PivotGrid._ctrlTemplate}static set controlTemplate(e){PivotGrid._ctrlTemplate=e}_getProductInfo(){return"D6F4,PivotGrid"}get engine(){return this._ng}get showDetailOnDoubleClick(){return this._showDetailOnDoubleClick}set showDetailOnDoubleClick(e){this._showDetailOnDoubleClick=wijmo_1.asBoolean(e)}get detailDialog(){this._dlgDetail||(this._dlgDetail=new DetailDialog(document.createElement("div")));return this._dlgDetail}get showRowFieldHeaders(){return this._showRowFldHdrs}set showRowFieldHeaders(e){if(e!=this._showRowFldHdrs){this._showRowFldHdrs=wijmo_1.asBoolean(e);this._updateFixedContent()}}get showColumnFieldHeaders(){return this._showColFldHdrs}set showColumnFieldHeaders(e){if(e!=this._showColFldHdrs){this._showColFldHdrs=wijmo_1.asBoolean(e);this._updateFixedContent()}}get showValueFieldHeaders(){return this._showValFldHdrs}set showValueFieldHeaders(e){if(e!=this._showValFldHdrs){this._showValFldHdrs=wijmo_1.asBoolean(e);this._updateFixedCounts();this._updateFixedContent()}}get showRowFieldSort(){return this._showRowFldSort}set showRowFieldSort(e){if(e!=this._showRowFldSort){this._showRowFldSort=wijmo_1.asBoolean(e);this._updateFixedContent()}}get customContextMenu(){return this._customCtxMenu}set customContextMenu(e){this._customCtxMenu=wijmo_1.asBoolean(e)}get collapsibleSubtotals(){return this._collapsibleSubtotals}set collapsibleSubtotals(e){if(e!=this._collapsibleSubtotals){this._collapsibleSubtotals=wijmo_1.asBoolean(e);this.invalidate()}}get centerHeadersVertically(){return this._centerVert}set centerHeadersVertically(e){if(e!=this._centerVert){this._centerVert=wijmo_1.asBoolean(e);this.invalidate()}}get outlineMode(){return this._outlineMode}set outlineMode(e){if(e!=this._outlineMode){this._outlineMode=wijmo_1.asBoolean(e);this._bindGrid(!0)}}getKeys(e,t){let i=this.rows[wijmo_1.asInt(e)],s=this.columns[wijmo_1.asInt(t)],l=i?i.dataItem:null,o=s?s.binding:null;return this._ng.getKeys(l,o)}getDetail(e,t){let i=this.rows[wijmo_1.asInt(e)].dataItem,s=this.columns[wijmo_1.asInt(t)].binding;return this._ng.getDetail(i,s)}getDetailView(e,t){let i=this.rows[wijmo_1.asInt(e)].dataItem,s=this.columns[wijmo_1.asInt(t)].binding;return this._ng.getDetailView(i,s)}showDetail(e,t){if(this._ng.valueFields.length){let i=this.detailDialog;i.showDetail(this,new wijmo_grid_1.CellRange(e,t));i.show(!0)}}collapseRowsToLevel(e){this._collapseRowsToLevel(e)}collapseColumnsToLevel(e){this._collapseColsToLevel(e)}_getQuickAutoSize(){return wijmo_1.isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter}_bindGrid(e){this.deferUpdate(()=>{let t=this.preserveOutlineState||this._resizingColumn,i=this._collapsedKeys,s=this.rows,l=this.columns;t||(i=this._collapsedKeys={});super._bindGrid(e);if(this._ng&&t&&!wijmo_1.isEmpty(i)){let e=this._ng.totalsBeforeData,t=e?s.length-1:0,o=e?-1:s.length,r=e?-1:1;for(let e=t;e!=o;e+=r){let t=s[e].dataItem,l=t?t[_PivotKey._ROW_KEY_NAME]:null;l&&l.level>=0&&i[l.toString()]&&this._setRowCollapsed(new wijmo_grid_1.CellRange(e,l.level-1),!0)}t=e?l.length-1:0;o=e?-1:l.length;r=e?-1:1;for(let e=t;e!=o;e+=r){let t=l[e].binding,s=this._ng._getKey(t);s&&s.level>0&&i[s.toString()]&&this._setColCollapsed(new wijmo_grid_1.CellRange(s.level-1,e),!0)}}})}_getCollectionView(e){e instanceof PivotPanel?e=e.engine.pivotView:e instanceof PivotEngine&&(e=e.pivotView);return wijmo_1.asCollectionView(e)}refresh(e=!0){this._ctxMenu.refresh();const t=wijmo_1.culture.Globalize.name;if(this._prevCulture!==t){this._prevCulture=t;this._updateFixedContent()}super.refresh(e)}onItemsSourceChanged(e){if(this._ng){this._ng.updatingView.removeHandler(this._updatingView,this);this._ng.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged,this);this._ng._hasDeferredUpdatesChanged.removeHandler(this._hasDeferredUpdatesChanged,this)}this._collapsedKeys={};let t=this.collectionView;this._ng=t instanceof PivotCollectionView?t.engine:null;if(this._ng){this._ng.updatingView.addHandler(this._updatingView,this);this._ng.viewDefinitionChanged.addHandler(this._viewDefinitionChanged,this);this._ng._hasDeferredUpdatesChanged.addHandler(this._hasDeferredUpdatesChanged,this)}this._updatingView();this._bindGrid(!0);super.onItemsSourceChanged(e)}onResizedColumn(e){let t=this._ng;if(t){this._resizingColumn=!0;if(e.panel.columns==this.rowHeaders.columns){let t=this._colRowFields.get(e.getColumn());t instanceof PivotField&&(t.width=e.panel.columns[e.col].renderWidth)}if(e.panel.columns==this.columnHeaders.columns){let i=t.valueFields;if(i.length>0){i[e.col%i.length].width=e.panel.columns[e.col].renderWidth}}this._resizingColumn=!1}super.onResizedColumn(e)}onSortingColumn(e){let t=this._ng;return(!t||!t.isUpdating)&&super.onSortingColumn(e)}onDraggingColumn(e){let t=this._ng;return(!t||!t.isUpdating)&&super.onDraggingColumn(e)}onDraggedColumn(e){let t=this._ng;if(t&&e.panel.columns==this.topLeftCells.columns){let i=t.rowFields,s=i[e.data.col];t.deferUpdate(()=>{i.removeAt(e.data.col);i.insert(e.col,s)})}super.onDraggedColumn(e)}_updatingView(){this._updateFixedCounts();this.columns.clear();this.rows.clear()}_viewDefinitionChanged(){this._resizingColumn||(this._collapsedKeys={})}_hasDeferredUpdatesChanged(){const e=this.engine,t=e&&e.hasDeferredUpdates,i=this.hostElement.querySelectorAll("."+PivotGrid._WJC_COLLAPSE);for(let e=0;e<i.length;e++)s=i[e],wijmo_1.toggleClass(s,PivotGrid._WJC_DISABLED,t);var s}onLoadedRows(e){0==this.columns.length&&this._generateColumns();this._updateFixedCounts();this._updateFixedContent();super.onLoadedRows(e)}_generateColumns(){let e=this.collectionView,t=e?e.sourceCollection:null,i=t&&t.length,s=this.engine;if(s&&i){const e=Object.keys(t[0]).filter(e=>e!=_PivotKey._ROW_KEY_NAME),i=[wijmo_1.Aggregate.Cnt,wijmo_1.Aggregate.CntAll];for(let t=0;t<e.length;t++){const l=s._getFieldByColKey(e[t]);this.columns.push(new wijmo_grid_1.Column({binding:e[t],dataType:l&&-1===i.indexOf(l.aggregate)?l.dataType:wijmo_1.DataType.Number,allowMerging:!0}))}}}_updateFixedCounts(){let e,t=this._ng,i=t&&t.isViewDefined;e=Math.max(1,i?t.rowFields.length:1);let s=this.topLeftCells.columns;s.clear();this._colRowFields.clear();for(let l=0;l<e;l++){let e=new wijmo_grid_1.Column({allowMerging:!0});s.push(e);i&&this._colRowFields.set(e,t.rowFields[l])}e=Math.max(1,i?t.columnFields.length:1);t&&t.columnFields.length&&(t.valueFields.length>1||this.showValueFieldHeaders)&&e++;let l=this.topLeftCells.rows;l.clear();for(let t=0;t<e;t++)l.push(new wijmo_grid_1.Row)}_updateFixedContent(){let e=this._ng;if(!e||!e.isViewDefined){this.topLeftCells.setCellData(0,0,null);return}let t=e.rowFields,i=e.columnFields,s=e.valueFields,l=this.outlineMode?t.map(e=>e.header).join(" / "):"",o=this.topLeftCells;for(let e=0;e<o.rows.length;e++)for(let s=0;s<o.columns.length;s++){let r="";this.showRowFieldHeaders&&s<t.length&&e==o.rows.length-1&&(r=this.outlineMode?l:t[s].header);this.showColumnFieldHeaders&&!r&&e<i.length&&0==s&&(r=i[e].header+":");o.setCellData(e,s,r,!1,!1)}o=this.rowHeaders;for(let e=0;e<o.rows.length;e++){let t=o.rows[e].dataItem[_PivotKey._ROW_KEY_NAME];wijmo_1.assert(t instanceof _PivotKey,"missing PivotKey for row...");for(let i=0;i<o.columns.length;i++){let s=t.getValue(i,!0);o.setCellData(e,i,s,!1,!1)}}o=this.columnHeaders;for(let t=0;t<o.columns.length;t++){let l=e._getKey(o.columns[t].binding);wijmo_1.assert(l instanceof _PivotKey,"missing PivotKey for column...");for(let e=0;e<o.rows.length;e++){let r=l.getValue(e,!0);e==o.rows.length-1&&s.length&&(s.length>1||0==i.length||l.level>-1||this.showValueFieldHeaders)&&(r=s[t%s.length].header);o.setCellData(e,t,r,!1,!1)}}o=this.topLeftCells;for(let e=0;e<o.columns.length;e++){let i=o.columns[e],s=e<t.length?t[e]:null;i.wordWrap=s?s.wordWrap:null;i.align=s?s.align:null;if(this.outlineMode&&e<o.columns.length-1){i.width=this.treeIndent;i.allowResizing=!1}else{i.allowResizing=!0;i.width=s&&wijmo_1.isNumber(s.width)?s.width:null}}o=this.cells;for(let e=0;e<o.columns.length;e++){let t=o.columns[e],i=s.length?s[e%s.length]:null;t.width=i&&wijmo_1.isNumber(i.width)?i.width:null;t.wordWrap=i?i.wordWrap:null;t.format=i?i.format:null;t.align=i?i.align:null}this.invalidate()}_updateDefaultSizes(){const e=super._updateDefaultSizes();this._hdrCols._setDefaultSize(4*e);return e}_formatItem(e,t){let i=this._ng,s=t.panel,l=t.cell;if(!i)return;if(s==this.topLeftCells){let e=0==i.rowFields.length||t.row<s.rows.length-1||t.row==s.rows.length-1&&!this.showRowFieldHeaders;wijmo_1.toggleClass(l,exports.PivotGridClsNames.colFieldHdr,e);wijmo_1.toggleClass(l,exports.PivotGridClsNames.rowFieldHdr,!e)}let o,r=null;s==this.topLeftCells&&t.row==s.rows.length-1&&this.allowDragging&wijmo_grid_1.AllowDragging.Columns&&(r=!0);wijmo_1.setAttribute(l,"draggable",r);switch(s){case this.rowHeaders:o=i.rowFields[t.col%i.rowFields.length];break;case this.columnHeaders:o=i.columnFields[t.row];break;case this.cells:o=i.valueFields[t.col]}o&&o.isContentHtml&&(l.innerHTML=l.textContent);let n=s.columns[t.col].binding,a=s.rows==this.rows?i._getRowLevel(t.row):-1,h=s.columns==this.columns?i._getColLevel(n):-1;wijmo_1.toggleClass(l,exports.PivotPanelClsNames.aggregate,a>-1||h>-1);if(this._collapsibleSubtotals){if(s==this.rowHeaders&&i._getShowRowTotals()==ShowTotals.Subtotals)if(this.outlineMode){let e=this._getGroupedRows(t.range);if(t.col<i.rowFields.length-1){if(!e.containsRow(t.row)){let e=this._getRowCollapsed(t.range);l.innerHTML=this._getCollapsedGlyph(e)+l.innerHTML}}}else{let e=this.getMergedRange(s,t.row,t.col,!1)||t.range;if(t.col<i.rowFields.length-1&&e.rowSpan>1){let t=this._getRowCollapsed(e);l.innerHTML=this._getCollapsedGlyph(t)+l.innerHTML}}this.outlineMode&&s==this.rowHeaders&&t.range.rightCol<s.columns.length-1&&(l.innerHTML="");if(s==this.columnHeaders&&i._getShowColTotals()==ShowTotals.Subtotals){let e=this.getMergedRange(s,t.row,t.col,!1)||t.range;if(t.row<i.columnFields.length-1&&e.columnSpan>1){let t=this._getColCollapsed(e);l.innerHTML=this._getCollapsedGlyph(t)+l.innerHTML}}}if(s==this.topLeftCells&&this.showRowFieldSort&&t.col<i.rowFields.length&&t.row==this._getSortRowIndex()){o=i.rowFields[t.col];wijmo_1.toggleClass(l,wijmo_grid_1.FlexGridClsNames.sortAsc,!o.descending);wijmo_1.toggleClass(l,wijmo_grid_1.FlexGridClsNames.sortDesc,o.descending);l.innerHTML+=` <span class="${wijmo_1.GlyphClsNames.glyph}-`+(o.descending?"down":"up")+'"></span>'}s!=this.cells&&wijmo_1.toggleClass(l,wijmo_1.UtilitesClsNames.alignVCenter,this._centerVert)}_getCollapsedGlyph(e){const t=this.engine,i=t&&t.hasDeferredUpdates;return'<div class="'+(PivotGrid._WJC_COLLAPSE+(i?" "+PivotGrid._WJC_DISABLED:""))+'">'+`<span class="${wijmo_1.GlyphClsNames.glyph}-`+(e?"plus":"minus")+'"></span></div>'}_mousedown(e){if(e.defaultPrevented||0!=e.button){this._htDown=null;return}const t=this._htDown=this.hitTest(e),i=t.panel;this._ignoreClick=!1;const s=this.engine,l=s&&s.hasDeferredUpdates;let o=wijmo_1.closestClass(e.target,PivotGrid._WJC_COLLAPSE);if(!l&&null!=o&&null!=i){let s,l=t.range;switch(i.cellType){case wijmo_grid_1.CellType.RowHeader:const t=this.getMergedRange(i,l.row,l.col);t&&l.copy(t);s=this._getRowCollapsed(l);e.shiftKey||e.ctrlKey?this._collapseRowsToLevel(l.col+(s?2:1)):this._setRowCollapsed(l,!s);break;case wijmo_grid_1.CellType.ColumnHeader:s=this._getColCollapsed(l);e.shiftKey||e.ctrlKey?this._collapseColsToLevel(l.row+(s?2:1)):this._setColCollapsed(l,!s)}e.preventDefault();this._ignoreClick=!0;this._htDown=null;this.focus()}}_mouseup(e){if(!this._htDown||e.defaultPrevented)return;if(this._mouseHdl._szRowCol)return;let t=this.hitTest(e);if(this._htDown.panel!=t.panel||!t.range.equals(this._htDown.range))return;let i=this._ng,s=this.topLeftCells;if(t.panel==s&&t.row==s.rows.length-1&&t.col>-1){let s=t.getColumn();if(this.allowSorting&&s.allowSorting&&!t.edgeRight){let e=this._colRowFields.get(s);if(e&&!i.isUpdating){let s=new wijmo_grid_1.CellRangeEventArgs(t.panel,t.range);if(this.onSortingColumn(s)){i.pivotView.sortDescriptions.clear();e.descending=!e.descending;this.onSortedColumn(s)}}}e.preventDefault();this._ignoreClick=!0}}_click(e){this._ignoreClick&&e.preventDefault()}_dblclick(e){if(!e.defaultPrevented&&this._showDetailOnDoubleClick){let e=this._htDown;if(e&&e.panel==this.cells){let t=this._ng;t&&t.fields.length>0&&(t.fields[0]instanceof CubePivotField||this.showDetail(e.row,e.col))}}}_keydown(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&this.collapsibleSubtotals){let t=this.selection;if(t.isValid){let i=this._getRowLevel(t.topRow);i<0&&(i=this.rowHeaders.columns.length-1);let s=this._getKeyCode(e);switch(s){case wijmo_1.Key.Left:case wijmo_1.Key.Right:let l=new wijmo_grid_1.CellRange(t.row,i-1);this._setRowCollapsed(l,s==wijmo_1.Key.Left);e.preventDefault()}}}}_getRowLevel(e){return this._ng._getRowLevel(e)}_getGroupedRows(e){let t,i=this._getRowLevel.bind(this),s=e.col+1,l=this.rows.length,o=this._ng.totalsBeforeData,r=e.row;if(0==i(r)){r=o?1:0;t=o?l-1:l-2}else{if(o)for(;r<l&&!(i(r)<0);r++);else for(;r>=0&&!(i(r)<0);r--);for(;r>0;r--){let e=i(r-1);if(e>=0&&e<=s)break}for(t=r;t<l-1;t++){let e=i(t+1);if(e>=0&&e<=s)break}}wijmo_1.assert(t>=r,"group end < start?");return t>=r?new wijmo_grid_1.CellRange(r,e.col,t,e.col2):e}_toggleRowCollapsed(e){this._setRowCollapsed(e,!this._getRowCollapsed(e))}_getRowCollapsed(e){e=this._getGroupedRows(e);let t=this._ng.totalsBeforeData?e.row-1:e.row2+1,i=this.rows[t]||this.rows[e.row],s=i?i.dataItem[_PivotKey._ROW_KEY_NAME]:null;return!!s&&this._collapsedKeys[s.toString()]}_setRowCollapsed(e,t){e=this._getGroupedRows(e);let i=this._ng.totalsBeforeData?e.row-1:e.row2+1,s=this.rows[i]||this.rows[e.row],l=s?s.dataItem[_PivotKey._ROW_KEY_NAME]:null;l&&(this._collapsedKeys[l.toString()]=t);this.deferUpdate(()=>{for(let i=e.row;i<=e.row2;i++)this.rows[i].visible=!t;s&&(s.visible=!0);if(!t){let t=this._getRowLevel(i),s=[];for(let i=e.row;i<=e.row2;i++)if(this._getRowLevel(i)>-1){let l=this._getGroupedRows(new wijmo_grid_1.CellRange(i,t));wijmo_1.assert(l.row>=e.row&&l.row2<=e.row2,"child range overflow");s.push(l);i++}s.forEach(e=>{let t=this._getRowCollapsed(e);this._setRowCollapsed(e,t)})}})}_collapseRowsToLevel(e){e>=this._ng.rowFields.length&&(e=-1);this.deferUpdate(()=>{for(let t=0;t<this.rows.length;t++){let i=this._getRowLevel(t);if(i>0){let s=this.rows[t].dataItem[_PivotKey._ROW_KEY_NAME];this._collapsedKeys[s.toString()]=e>0&&i>=e}if(e<0)this.rows[t].visible=!0;else{let s=i>-1&&i<=e;s||(this._ng.totalsBeforeData?0==t&&(s=!0):t==this.rows.length-1&&(s=!0));this.rows[t].visible=s}}})}_getColLevel(e){return this._ng._getColLevel(this.columns[e].binding)}_getGroupedCols(e){let t,i=this._getColLevel.bind(this),s=e.row+1,l=this.columns.length,o=this._ng.totalsBeforeData,r=e.col;if(0==i(r)){r=o?1:0;t=o?l-1:l-2}else{if(this._ng.totalsBeforeData)for(r=e.col;r<l&&!(i(r)<0);r++);else for(r=e.col;r>=0&&!(i(r)<0);r--);for(;r>0;r--){let e=i(r-1);if(e>=0&&e<=s)break}for(t=r;t<l-1;t++){let e=i(t+1);if(e>=0&&e<=s)break}}wijmo_1.assert(t>=r,"group end < start?");return t>=r?new wijmo_grid_1.CellRange(e.row,r,e.row2,t):e}_toggleColCollapsed(e){this._setColCollapsed(e,!this._getColCollapsed(e))}_getColCollapsed(e){e=this._getGroupedCols(e);let t=this._ng,i=t.totalsBeforeData?e.col-t.valueFields.length:e.col2+1,s=this.columns[i],l=s?s.binding:null;return!!l&&this._collapsedKeys[l.toString()]}_setColCollapsed(e,t){e=this._getGroupedCols(e);let i=this._ng,s=i.totalsBeforeData?e.col-i.valueFields.length:e.col2+1,l=this.columns[s],o=l?l.binding:null;o&&(this._collapsedKeys[o.toString()]=t);this.deferUpdate(()=>{for(let t=1;t<=i.valueFields.length;t++)this.columns[i.totalsBeforeData?e.col-t:e.col2+t].visible=!0;for(let i=e.col;i<=e.col2;i++)this.columns[i].visible=!t;if(!t){let t=this._getColLevel(s),l=[];for(let s=e.col;s<=e.col2;s++)if(this._getColLevel(s)>-1){let o=this._getGroupedCols(new wijmo_grid_1.CellRange(t,s));wijmo_1.assert(o.col>=e.col&&o.col2<=e.col2,"child range overflow");l.push(o);s+=i.valueFields.length-1}l.forEach(e=>{let t=this._getColCollapsed(e);this._setColCollapsed(e,t)})}})}_collapseColsToLevel(e){e>=this._ng.columnFields.length&&(e=-1);this.deferUpdate(()=>{for(let t=0;t<this.columns.length;t++){let i=this._getColLevel(t);if(i>0){let s=this._ng._getKey(this.columns[t].binding);this._collapsedKeys[s.toString()]=e>0&&i>=e}if(e<0)this.columns[t].visible=!0;else{let s=i>-1&&i<=e;this.columns[t].visible=s}}})}dispose(){if(this._ctxMenu){this._ctxMenu.dispose();this._ctxMenu=null}if(this._dlgDetail){this._dlgDetail.dispose();this._dlgDetail=null}if(this._ng){this._ng.updatingView.removeHandler(this._updatingView,this);this._ng.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged,this);this._ng._hasDeferredUpdatesChanged.removeHandler(this._hasDeferredUpdatesChanged,this)}super.dispose()}}PivotGrid._WJC_COLLAPSE=exports.PivotGridClsNames.pivotCollapse;PivotGrid._WJC_DISABLED=wijmo_1.ControlStateClsNames.disabled;PivotGrid._ctrlTemplate="";exports.PivotGrid=PivotGrid;class DetailDialog extends wijmo_input_1.Popup{constructor(e,t){super(e,null);let i=this.getTemplate();this.applyTemplate(`${wijmo_1.ControlClsNames.hostElement} ${exports.DetailDialogClsNames.hostElement}`,i,{_sCnt:"sp-cnt",_dSummary:"div-summary",_dGrid:"div-grid",_btnOK:"btn-ok",_gHdr:"g-hdr"});this._g=new wijmo_grid_1.FlexGrid(this._dGrid,{isReadOnly:!0});this.initialize(t)}static get controlTemplate(){DetailDialog._ctrlTemplate||(DetailDialog._ctrlTemplate=`<div><div class="${exports.DetailDialogClsNames.dialogHeader}"><span wj-part="g-hdr">Detail View:</span> <span wj-part="sp-cnt"></span></div><div class="${exports.DetailDialogClsNames.dialogBody}"><div wj-part="div-summary" class="${exports.DetailDialogClsNames.summary}"></div><div wj-part="div-grid"></div></div><div class="${exports.DetailDialogClsNames.dialogFooter}"><button wj-part="btn-ok"class="${wijmo_1.UtilitesClsNames.hide} ${wijmo_1.InputFormElementsClsNames.btn}">OK</button> </div></div>`);return DetailDialog._ctrlTemplate}static set controlTemplate(e){DetailDialog._ctrlTemplate=e}showDetail(e,t){let i=e.getDetailView(t.row,t.col);this._g.itemsSource=i;let s=wijmo_1.tryCast(i,"IPagedCollectionView");this._updateDetailCount(s?s.totalItemCount:i.items.length);i.collectionChanged.addHandler(()=>{this._updateDetailCount(i.items.length)});let l=e.engine,o=wijmo_1.culture.olap.DetailDialog,r="";this._gHdr.textContent=o.header;this._btnOK.textContent=o.ok;let n=e.rows[t.row].dataItem[_PivotKey._ROW_KEY_NAME];this._rowHdr=wijmo_1.escapeHtml(this._getHeader(n));this._rowHdr&&(r+=o.row+": <b>"+this._rowHdr+"</b><br>");let a=l._getKey(e.columns[t.col].binding);this._colHdr=wijmo_1.escapeHtml(this._getHeader(a));this._colHdr&&(r+=o.col+": <b>"+this._colHdr+"</b><br>");let h=l.valueFields,d=h[t.col%h.length],_=e.getCellData(t.row,t.col,!0);this._cellHdr=wijmo_1.escapeHtml(d.header);this._cellValue=wijmo_1.escapeHtml(_);r+=this._cellHdr+": <b>"+this._cellValue+"</b>";this._dSummary.innerHTML=r}get rowHeader(){return this._rowHdr}get columnHeader(){return this._colHdr}get cellHeader(){return this._cellHdr}get cellValue(){return this._cellValue}get detailCount(){return this._detailCount}_updateDetailCount(e){let t=wijmo_1.culture.olap.DetailDialog;this._sCnt.textContent=wijmo_1.format(1==e?t.item:t.items,{cnt:e});this._detailCount=e}_getHeader(e){if(e&&e.values&&e.values.length){let t=[];for(let i=0;i<e.values.length;i++)t.push(e.getValue(i,!0));return t.join(" - ")}return null}}DetailDialog._ctrlTemplate="";exports.DetailDialog=DetailDialog;class _PivotMergeManager extends wijmo_grid_1.MergeManager{getMergedRange(e,t,i,s=!0){return this._getMergedRange(e,t,i,s)}_getMergedRange(e,t,i,s=!0,l=!0){let o=e.grid.collectionView;this._ng=o instanceof PivotCollectionView?o.engine:null;if(!this._ng)return super._getMergedRange(e,t,i,s,l);if(t<0||t>=e.rows.length||i<0||i>=e.columns.length)return null;let r=e.grid.allowMerging,n=wijmo_grid_1.AllowMerging;switch(e.cellType){case wijmo_grid_1.CellType.TopLeft:return 0!=(r&n.AllHeaders)?this._getMergedTopLeftRange(e,t,i):null;case wijmo_grid_1.CellType.RowHeader:return 0!=(r&n.RowHeaders)?this._getMergedRowHeaderRange(e,t,i,s?e.viewRange:null):null;case wijmo_grid_1.CellType.ColumnHeader:return 0!=(r&n.ColumnHeaders)?this._getMergedColumnHeaderRange(e,t,i,s?e.viewRange:null):null}return null}_getMergedTopLeftRange(e,t,i){let s=new wijmo_grid_1.CellRange(t,i),l=e.grid;if(l.outlineMode&&l.showRowFieldHeaders&&s.row==e.rows.length-1){s.col=0;s.col2=e.columns.length-1;return s}for(;s.col>0&&!e.getCellData(t,s.col,!0);)s.col--;for(;s.col2<e.columns.length-1&&!e.getCellData(t,s.col2+1,!0);)s.col2++;return s.isSingleCell?null:s}_getMergedRowHeaderRange(e,t,i,s){let l=e.grid,o=e.columns[i],r=e.columns,n=e.rows;if(!o.allowMerging)return null;if(l.outlineMode){if(this._isSubtotal(e,t,i)||this._isSubtotal(e,t,i+1)){let s=this._getOutlineRange(e,t,i);return s.isSingleCell?null:s}if(i<e.columns.length-1){let e=l._getGroupedRows(new wijmo_grid_1.CellRange(t,i));return e.isSingleCell?null:e}return null}let a=this._ng._getRowLevel(t);if(a>-1&&i>=a){let o,n,a=e.getCellData(t,i,!1),h=0,d=r.length-1;if(i>=r._frozenInternal&&l._vtCols<r.length&&s){h=s.col;d=s.col2}for(o=i;o>h&&e.getCellData(t,o-1,!1)==a;o--);for(n=i;n<d&&e.getCellData(t,n+1,!1)==a;n++);return o!=n?new wijmo_grid_1.CellRange(t,o,t,n):null}let h,d,_=0,u=n.length-1;if(i>=n._frozenInternal&&l._vtRows<n.length&&s){_=s.row;u=s.row2}for(h=t;h>_&&this._sameColumnValues(e,t,h-1,i);h--);for(d=t;d<u&&this._sameColumnValues(e,t,d+1,i);d++);return h!=d?new wijmo_grid_1.CellRange(h,i,d,i):null}_sameColumnValues(e,t,i,s){for(;s>=0;s--){if(e.getCellData(t,s,!1)!=e.getCellData(i,s,!1))return!1}return!0}_isSubtotal(e,t,i){let s=e.rows[t].dataItem,l=s?s[_PivotKey._ROW_KEY_NAME]:null;return s&&i>l.values.length-1&&i<e.columns.length}_getOutlineRange(e,t,i){let s=new wijmo_grid_1.CellRange(t,i);s.col2=e.columns.length-1;for(;s.col&&this._isSubtotal(e,t,s.col);)s.col--;return s}_getMergedColumnHeaderRange(e,t,i,s){let l=e.columns[i],o=this._ng._getKey(l.binding),r=e.getCellData(t,i,!1),n=e.grid,a=e.columns,h=e.rows,d=this._ng._getColLevel(o);if(d>-1&&t>=d){let l,o,a=0,d=h.length-1;if(i>=h._frozenInternal&&n._vtRows<h.length&&s){a=s.row;d=s.row2}for(l=t;l>a&&e.getCellData(l-1,i,!1)==r;l--);for(o=t;o<d&&e.getCellData(o+1,i,!1)==r;o++);if(l!=o)return new wijmo_grid_1.CellRange(l,i,o,i)}if(s){i<e.columns._frozenInternal&&(s.col=s.col2=0);t<e.rows._frozenInternal&&(s.row=s.row2=0)}let _,u,g=0,c=a.length-1;if(i>=a._frozenInternal&&n._vtCols<a.length&&s){g=s.col;c=s.col2}for(_=i;_>g&&this._sameRowValues(e,t,i,_-1);_--);for(u=i;u<c&&this._sameRowValues(e,t,i,u+1);u++);return _!=u?new wijmo_grid_1.CellRange(t,_,t,u):null}_sameRowValues(e,t,i,s){for(;t>=0;t--){if(e.getCellData(t,i,!1)!=e.getCellData(t,s,!1))return!1}return!0}}exports._PivotMergeManager=_PivotMergeManager;!function(e){e[e.Column=0]="Column";e[e.Bar=1]="Bar";e[e.Scatter=2]="Scatter";e[e.Line=3]="Line";e[e.Area=4]="Area";e[e.Pie=5]="Pie"}(PivotChartType=exports.PivotChartType||(exports.PivotChartType={}));!function(e){e[e.Always=0]="Always";e[e.Never=1]="Never";e[e.Auto=2]="Auto"}(LegendVisibility=exports.LegendVisibility||(exports.LegendVisibility={}));class PivotChart extends wijmo_1.Control{constructor(e,t){super(e);this._chartType=PivotChartType.Column;this._showHierarchicalAxes=!0;this._showTotals=!1;this._showTitle=!0;this._showLegend=LegendVisibility.Always;this._legendPosition=wijmo_chart_1.Position.Right;this._maxSeries=PivotChart.MAX_SERIES;this._maxPoints=PivotChart.MAX_POINTS;this._stacking=wijmo_chart_1.Stacking.None;this._colItms=[];this._dataItms=[];this._lblsSrc=[];this._grpLblsSrc=[];wijmo_1.addClass(this.hostElement,exports.PivotChartClsNames.hostElement);this._isPieChart()?this._createFlexPie():this._createFlexChart();super.initialize(t)}_getProductInfo(){return"D6F4,PivotChart"}get engine(){return this._ng}get itemsSource(){return this._itemsSource}set itemsSource(e){if(e&&this._itemsSource!==e){let t=this._itemsSource;e instanceof PivotPanel?e=e.engine.pivotView:e instanceof PivotEngine&&(e=e.pivotView);this._itemsSource=wijmo_1.asCollectionView(e);this._onItemsSourceChanged(t)}}get chartType(){return this._chartType}set chartType(e){if((e=wijmo_1.asEnum(e,PivotChartType))!=this._chartType){var t=this._chartType;this._chartType=e;this._changeChartType();e!==PivotChartType.Bar&&t!==PivotChartType.Bar||this._updatePivotChart()}}get showHierarchicalAxes(){return this._showHierarchicalAxes}set showHierarchicalAxes(e){if(e!=this._showHierarchicalAxes){this._showHierarchicalAxes=wijmo_1.asBoolean(e,!0);!this._isPieChart()&&this._flexChart&&this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc)}}get showTotals(){return this._showTotals}set showTotals(e){if(e!=this._showTotals){this._showTotals=wijmo_1.asBoolean(e,!0);this._updatePivotChart()}}get showTitle(){return this._showTitle}set showTitle(e){if(e!=this._showTitle){this._showTitle=wijmo_1.asBoolean(e,!0);this._updatePivotChart()}}get showLegend(){return this._showLegend}set showLegend(e){if((e=wijmo_1.asEnum(e,LegendVisibility))!=this.showLegend){this._showLegend=e;this._updatePivotChart()}}get legendPosition(){return this._legendPosition}set legendPosition(e){if((e=wijmo_1.asEnum(e,wijmo_chart_1.Position))!=this.legendPosition){this._legendPosition=e;this._updatePivotChart()}}get stacking(){return this._stacking}set stacking(e){if((e=wijmo_1.asEnum(e,wijmo_chart_1.Stacking))!=this._stacking){this._stacking=e;if(this._flexChart){this._flexChart.stacking=this._stacking;this._updatePivotChart()}}}get maxSeries(){return this._maxSeries}set maxSeries(e){if(e!=this._maxSeries){this._maxSeries=wijmo_1.asNumber(e);this._updatePivotChart()}}get maxPoints(){return this._maxPoints}set maxPoints(e){if(e!=this._maxPoints){this._maxPoints=wijmo_1.asNumber(e);this._updatePivotChart()}}get flexChart(){return this._flexChart}get flexPie(){return this._flexPie}get header(){return this._header}set header(e){if(e!=this._header){this._header=wijmo_1.asString(e,!0);this.invalidate()}}get footer(){return this._footer}set footer(e){if(e!=this._footer){this._footer=wijmo_1.asString(e,!0);this.invalidate()}}get headerStyle(){return this._headerStyle}set headerStyle(e){if(e!=this._headerStyle){this._headerStyle=e;this.invalidate()}}get footerStyle(){return this._footerStyle}set footerStyle(e){if(e!=this._footerStyle){this._footerStyle=e;this.invalidate()}}refresh(e=!0){super.refresh(e);this._isPieChart()?this._flexPie&&this._flexPie.refresh(e):this._flexChart&&this._flexChart.refresh(e);this._updatePivotChart()}saveImageToDataUrl(e,t){this._isPieChart()?this._flexPie&&this._flexPie.saveImageToDataUrl(e,t):this._flexChart&&this._flexChart.saveImageToDataUrl(e,t)}saveImageToFile(e){this._isPieChart()?this._flexPie&&this._flexPie.saveImageToFile(e):this._flexChart&&this._flexChart.saveImageToFile(e)}_onItemsSourceChanged(e){this._ng&&this._ng.updatedView.removeHandler(this._updatePivotChart,this);e&&e.collectionChanged.removeHandler(this._updatePivotChart,this);let t=this._itemsSource;this._ng=t instanceof PivotCollectionView?t.engine:null;this._ng&&this._ng.updatedView.addHandler(this._updatePivotChart,this);this._itemsSource&&this._itemsSource.collectionChanged.addHandler(this._updatePivotChart,this);this._updatePivotChart()}_createFlexChart(){let e=document.createElement("div");this.hostElement.appendChild(e);this._flexChart=new wijmo_chart_1.FlexChart(e);this._flexChart._bindingSeparator=null;this._flexChart.legend.position=wijmo_chart_1.Position.Right;this._flexChart.bindingX=_PivotKey._ROW_KEY_NAME;this._flexChart.stacking=this._stacking;this._flexChart.tooltip.content=e=>{let t=e.name?"<b>"+e.name+"</b> <br/>":"";t+=this._getLabel(e.x)+" "+this._getValue(e);return t};this._flexChart.hostElement.style.visibility="hidden"}_createFlexPie(){let e=document.createElement("div");this.hostElement.appendChild(e);this._colMenu=new wijmo_input_1.MultiSelect(e,{displayMemberPath:"text",placeholder:wijmo_1.culture.olap.PivotPanel.cols,selectedValuePath:"prop",showSelectAllCheckbox:!0,keyActionPrintCharacters:0,keyActionTab:0});this._colMenu.hostElement.style.visibility="hidden";this._colMenu.checkedItemsChanged.addHandler((e,t)=>this._updateFlexPieBinding());let t=document.createElement("div");this.hostElement.appendChild(t);this._flexPie=new wijmo_chart_1.FlexPie(t);this._flexPie.bindingName=_PivotKey._ROW_KEY_NAME;this._flexPie.tooltip.content=e=>"<b>"+this._getLabel(this._dataItms[e.pointIndex][_PivotKey._ROW_KEY_NAME])+"</b> <br/>"+this._getValue(e);this._flexPie.rendering.addHandler(this._updatePieInfo,this)}_updatePivotChart(){if(!this._ng||!this._ng.pivotView)return;let e,t=[],i=[],s=[],l=0,o=this._ng.pivotView,r=this._ng.rowFields;for(let n=0;n<o.items.length;n++){let a=o.items[n],h=a.$rowKey;0==n&&this._getColumns(a);if(t.length>=this._maxPoints)break;if(!this._isTotalRow(a[_PivotKey._ROW_KEY_NAME])){t.push(a);i.push({value:t.length-1,text:this._getLabel(a[_PivotKey._ROW_KEY_NAME])});for(let i=0;i<r.length;i++){s.length<=i&&s.push([]);if(this._getMergeIndex(h,e)<i){l=s[i].length-1;let e=s[i][l];0===l&&i<r.length-1&&(e.value=(e.width-1)/2);if(l>0&&i<r.length-1){let t=this._getOffsetWidth(s[i]);e.value=t+(e.width-1)/2}s[i].push({value:t.length-1,text:h.getValue(i,!0),width:1})}else{l=s[i].length-1;s[i][l].width++}}e=h}}for(let e=0;e<r.length;e++)if(e<s.length){l=s[e].length-1;s[e][l].value=this._getOffsetWidth(s[e])+(s[e][l].width-1)/2}this._dataItms=t;this._lblsSrc=i;this._grpLblsSrc=s;this._updateFlexChartOrPie()}_updateFlexChartOrPie(){let e=this._isPieChart();!e&&this._flexChart?this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc):e&&this._flexPie&&this._updateFlexPie(this._dataItms,this._lblsSrc)}_updateFlexChart(e,t,i){let s,l=this._flexChart,o=l?l.hostElement:null;if(this._ng&&l&&o){l.beginUpdate();l.itemsSource=e;this._createSeries();l.series&&l.series.length>0&&e.length>0?o.style.visibility="visible":o.style.visibility="hidden";l.header=this.header||this._getChartTitle();this.headerStyle&&(l.headerStyle=this.headerStyle);this.footer&&(l.footer=this.footer);this.footerStyle&&(l.footerStyle=this.footerStyle);if(this._isRotatedChart()){if(this._showHierarchicalAxes&&i.length>0){l.axisY.itemsSource=i[i.length-1];l.axisX.labelAngle=void 0;if(i.length>=2)for(let e=i.length-2;e>=0;e--)this._createGroupAxes(i[e])}else{l.axisY.labelAngle=void 0;l.axisY.itemsSource=t}l.axisX.itemsSource=void 0}else{if(this._showHierarchicalAxes&&i.length>0){l.axisX.itemsSource=i[i.length-1];if(i.length>=2)for(let e=i.length-2;e>=0;e--)this._createGroupAxes(i[e])}else{l.axisX.labelAngle=void 0;l.axisX.itemsSource=t}l.axisY.itemsSource=void 0}l.axisX.labelPadding=6;l.axisY.labelPadding=6;if(this._isRotatedChart()){s=l.axisX;l.axisY.reversed=!0}else{s=l.axisY;l.axisY.reversed=!1}l.stacking!==wijmo_chart_1.Stacking.Stacked100pc&&this._ng.valueFields.length>0&&this._ng.valueFields[0].format?s.format=this._ng.valueFields[0].format:s.format="";l.legend.position=this._getLegendPosition();l.endUpdate()}}_updateFlexPie(e,t){let i=this._flexPie,s=i?i.hostElement:null,l=this._colMenu;if(!this._ng||!i||!s)return;this._colItms.length>0&&e.length>0?s.style.visibility="visible":s.style.visibility="hidden";i.beginUpdate();i.itemsSource=e;i.bindingName=_PivotKey._ROW_KEY_NAME;this._colItms&&this._colItms.length>0&&(i.binding=this._colItms[0].prop);i.header=this.header||this._getChartTitle();this.headerStyle&&(i.headerStyle=this.headerStyle);this.footer&&(i.footer=this.footer);this.footerStyle&&(i.footerStyle=this.footerStyle);i.legend.position=this._getLegendPosition();i.endUpdate();let o=this._getTitle(this._ng.columnFields);""!==o&&(o="<b>"+o+": </b>");if(this._colItms&&this._colItms.length>1&&e.length>0){l.hostElement.style.visibility="visible";l.itemsSource=this._colItms;l.checkedItems=[this._colItms[0]];l.invalidate()}else l.hostElement.style.visibility="hidden"}_getLegendPosition(){let e=this.legendPosition;if(this.showLegend==LegendVisibility.Never)e=wijmo_chart_1.Position.None;else if(this.showLegend==LegendVisibility.Auto&&this.flexChart&&this.flexChart.series){let t=0;this.flexChart.series.forEach(e=>{let i=e.visibility;e.name&&i!=wijmo_chart_1.SeriesVisibility.Hidden&&i!=wijmo_chart_1.SeriesVisibility.Plot&&t++});t<2&&(e=wijmo_chart_1.Position.None)}return e}_createSeries(){this._flexChart&&(this._flexChart.series.length=0);let e=1==this._ng.valueFields.length;for(let t=0;t<this._colItms.length;t++){let i=new wijmo_chart_1.Series,s=this._colItms[t].prop,l=this._colItms[t].text;if(e){let e=l.lastIndexOf(";");e>-1&&(l=l.substr(0,e))}i.binding=s;i.name=l;this._flexChart.series.push(i)}}_getColumns(e){let t,i,s=0;if(e){this._colItms=[];for(let l in e)if(e.hasOwnProperty(l)&&l!==_PivotKey._ROW_KEY_NAME&&s<this._maxSeries&&this._isValidColumn(l)){t=this._ng._getKey(l);i=this._getLabel(t);this._colItms.push({prop:l,text:this._getLabel(t)});s++}}}_createGroupAxes(e){let t,i=this._flexChart,s=this._isRotatedChart()?i.axisY:i.axisX;if(!e)return;t=new wijmo_chart_1.Axis;t.labelAngle=0;t.labelPadding=6;t.position=this._isRotatedChart()?wijmo_chart_1.Position.Left:wijmo_chart_1.Position.Bottom;t.majorTickMarks=wijmo_chart_1.TickMark.None;t.itemsSource=e;t.reversed=s.reversed;t.axisLine=!1;t.itemFormatter=(i,s)=>{if(t._axrect){let l=.5*e.filter((function(e){return e.value==s.val}))[0].width;if(this._isRotatedChart()){let e=t.reversed?-1:1,o=t.convert(s.val+l)+5*e,r=t.convert(s.val-l)-5*e,n=t._axrect.left+t._axrect.width-5;i.drawLine(n,o,n,r,PivotChart.HRHAXISCSS);i.drawLine(n,o,n+5,o,PivotChart.HRHAXISCSS);i.drawLine(n,r,n+5,r,PivotChart.HRHAXISCSS);i.drawLine(n,s.pos.y,n-5,s.pos.y,PivotChart.HRHAXISCSS)}else{let e=t.convert(s.val-l)+5,o=t.convert(s.val+l)-5,r=t._axrect.top;i.drawLine(e,r,o,r,PivotChart.HRHAXISCSS);i.drawLine(e,r,e,r-5,PivotChart.HRHAXISCSS);i.drawLine(o,r,o,r-5,PivotChart.HRHAXISCSS);i.drawLine(s.pos.x,r,s.pos.x,r+5,PivotChart.HRHAXISCSS)}}return s};t.min=s.actualMin;t.max=s.actualMax;s.rangeChanged.addHandler((function(){isNaN(t.min)&&isNaN(s.actualMin)||t.min==s.actualMin||(t.min=s.actualMin);isNaN(t.max)&&isNaN(s.actualMax)||t.max==s.actualMax||(t.max=s.actualMax)}));let l=new wijmo_chart_1.Series;l.visibility=wijmo_chart_1.SeriesVisibility.Hidden;this._isRotatedChart()?l.axisY=t:l.axisX=t;i.series.push(l)}_updateFlexPieBinding(){let e="",t=[];this._colMenu.checkedItems.forEach(i=>{e.length>0&&(e+=",");e+=i.prop;t.push(i.text)});this._flexPie.binding=e;this._flexPie.titles=t.length>1?t:null}_updatePieInfo(){this._flexPie&&(this._flexPie._labels=this._flexPie._labels.map((e,t)=>this._lblsSrc[t].text))}_changeChartType(){let e=null;if(this.chartType===PivotChartType.Pie){this._flexPie||this._createFlexPie();this._updateFlexPie(this._dataItms,this._lblsSrc);this._swapChartAndPie(!1)}else{switch(this.chartType){case PivotChartType.Column:e=wijmo_chart_1.ChartType.Column;break;case PivotChartType.Bar:e=wijmo_chart_1.ChartType.Bar;break;case PivotChartType.Scatter:e=wijmo_chart_1.ChartType.Scatter;break;case PivotChartType.Line:e=wijmo_chart_1.ChartType.Line;break;case PivotChartType.Area:e=wijmo_chart_1.ChartType.Area}if(this._flexChart)"none"!==this._flexChart.hostElement.style.display&&e!==PivotChartType.Bar&&this._flexChart.chartType!==wijmo_chart_1.ChartType.Bar||this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc);else{this._createFlexChart();this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc)}this._flexChart.chartType=e;this._swapChartAndPie(!0)}}_swapChartAndPie(e){this._flexChart&&(this._flexChart.hostElement.style.display=e?"block":"none");this._flexPie&&(this._flexPie.hostElement.style.display=e?"none":"block");if(this._colMenu&&this._colMenu.hostElement){this._colMenu.hostElement.style.display=e?"none":"block";this._colMenu.hostElement.style.top="0";this._clearStyleTopTimer=setTimeout(()=>{this._colMenu.hostElement.style.top=""},0)}}_getLabel(e){let t="";if(!e||!e.values)return t;let i=e.valueFields?e.valueField:null;switch(e.values.length){case 0:i&&(t+=i.header);break;case 1:t+=e.getValue(0,!0);i&&(t+="; "+i.header);break;default:for(let i=0;i<e.values.length;i++){i>0&&(t+="; ");t+=e.getValue(i,!0)}i&&(t+="; "+i.header)}return t}_getValue(e){let t=this._ng.valueFields,i=e.series?e.series.chart.series.indexOf(e.series):0,s=i<t.length?t[i].format:t.length?t[0].format:"";return s?wijmo_1.Globalize.format(e.y,s):e._yfmt}_getChartTitle(){if(!this.showTitle||!this._ng.valueFields.length)return null;let e=this._ng,t=this._getTitle(e.valueFields),i=this._getTitle(e.rowFields),s=this._getTitle(e.columnFields),l=t,o=wijmo_1.culture.olap.PivotChart;if(t&&this._dataItms.length>0){i&&(l+=wijmo_1.format(" {by} {rows}",{by:o.by,rows:i}));s&&(l+=wijmo_1.format(" {and} {cols}",{and:i?o.and:o.by,cols:s}))}return l}_getTitle(e){let t="";for(let i=0;i<e.length;i++){t.length>0&&(t+="; ");t+=e[i].header}return t}_isValidColumn(e){let t=e.split(";"),i=this._showTotals;return 0===this._ng.columnFields.length||(t&&2===t.length?i:!(!t||t.length-2!==this._ng.columnFields.length)&&!i)}_isTotalRow(e){return e.values.length<this._ng.rowFields.length}_isPieChart(){return this._chartType==PivotChartType.Pie}_isRotatedChart(){return!this._isPieChart()&&this._chartType==PivotChartType.Bar!==this._flexChart.rotated}_getMergeIndex(e,t){let i=-1;if(null!=e&&null!=t&&e.values.length==t.values.length&&e.values.length==e.fields.length&&t.values.length==t.fields.length)for(let s=0;s<e.values.length;s++){if(e.getValue(s,!0)!=t.getValue(s,!0))return i;i=s}return i}_getOffsetWidth(e){let t=0;if(e.length<=1)return t;for(let i=0;i<e.length-1;i++)t+=e[i].width;return t}dispose(){if(this._flexChart){this._flexChart.dispose();this._flexChart=null}if(this._flexPie){this._flexPie.dispose();this._flexPie=null}if(this._colMenu){this._colMenu.dispose();this._colMenu=null}if(this._clearStyleTopTimer){clearTimeout(this._clearStyleTopTimer);this._clearStyleTopTimer=null}this._ng&&this._ng.updatedView.removeHandler(this._updatePivotChart,this);this._itemsSource&&this._itemsSource.collectionChanged.removeHandler(this._updatePivotChart,this);super.dispose()}}PivotChart.MAX_SERIES=100;PivotChart.MAX_POINTS=100;PivotChart.HRHAXISCSS=exports.PivotChartClsNames.hierarchicalAxesLine;exports.PivotChart=PivotChart;class _MdxQueryBuilder{constructor(e,t){this._ng=null;this._cubeName=null;this._ng=e;this._cubeName=t}buildQuery(){let e=new _TextBuilder,t=this.buildWhereSection(this._ng.valueFields);e.append("SELECT ",this.buildAxes()," FROM ",this.buildCubeName(),t);e.append(" CELL PROPERTIES VALUE, FORMAT_STRING");return e.toString()}buildWhereSection(e){let t=new _TextBuilder;if(1==e.length){t.append(this.buildSetForMeasuresShelf(e));t.wrap(" WHERE ","")}return t.toString()}buildCubeName(){let e=new _TextBuilder;e.append(this.buildSubcubeExpression());let t=e.length>0;t&&e.wrap("SELECT "," FROM ");e.append("[",this._cubeName,"]");t&&e.wrap("(",")");return e.toString()}buildSubcubeExpression(){let e=new _TextBuilder,t=this.getMeasureFilterExpressions(this._ng.valueFields),i=this.buildFilterAttributeSet(this._ng.filterFields),s=this.buildFilterAttributeSet(this._ng.rowFields,t),l=this.buildFilterAttributeSet(this._ng.columnFields,0==s.length?t:null);e.joinItemToList(i);e.joinItemToList(s);e.joinItemToList(l);if(e.length>0){e.wrap("(",")");e.append(" ON COLUMNS")}return e.toString()}buildFilterAttributeSet(e,t){let i=new _TextBuilder;for(let s=0;s<e.length;s++){let l=e[s],o=this.buildFilterString(l,0==s?t:null);i.joinItemToList(o)}return i.toString()}buildFilterString(e,t){let i=new _TextBuilder;e.filter.isActive?e.filter.conditionFilter.isActive?i.append(this.getConditionFilterString(e,t)):e.filter.valueFilter.isActive&&i.append(this.getValueFilterString(e)):t&&i.append(this.getConditionFilterString(e,t));return i.toString()}getValueFilterString(e){let t=new _TextBuilder,i=e.filter.valueFilter,s=Object.keys(i.showValues).map(t=>e.key+".["+t+"]");t.append(s.join(","));t.length>0&&t.wrap("{","}");return t.toString()}getConditionFilterString(e,t){let i=new _TextBuilder,s=e.key+".LEVELS(1).ALLMEMBERS",l=e.filter.conditionFilter.condition1,o=e.filter.conditionFilter.condition2;if(l.isActive){i.append(this.getConditionFilterExpression(e,l));o.isActive&&i.append(e.filter.conditionFilter.and?" AND ":" OR ")}o.isActive&&i.append(this.getConditionFilterExpression(e,o));if(t&&t.length>0){i.length>0&&i.append(" AND ");i.append(t.join(" AND "))}i.length>0&&i.wrap("Filter("+s+",(","))");return i.toString()}getMeasureFilterExpressions(e){let t=[];for(let i=0;i<e.length;i++){let s=new _TextBuilder,l=e[i],o=(l.dimensionType,DimensionType.Measure,l.filter.conditionFilter.condition1),r=l.filter.conditionFilter.condition2;if(o.isActive){s.append(this.getConditionFilterExpression(l,o));r.isActive&&s.append(l.filter.conditionFilter.and?" AND ":" OR ")}r.isActive&&s.append(this.getConditionFilterExpression(l,r));if(s.length>0){s.wrap("(",")");t.push(s.toString())}}return t}getConditionFilterExpression(e,t){if(!t.isActive)return"";let i=e.dimensionType==DimensionType.Measure,s=e.dataType==wijmo_1.DataType.Number,l=e.dataType==wijmo_1.DataType.Date,o=s||l?"member_value":"member_caption",r=i?e.key:e.key+".CurrentMember."+o,n=l?"CDate('"+wijmo_1.Globalize.formatDate(t.value,"d")+"')":t.value.toString(),a=new _TextBuilder;switch(t.operator){case wijmo_grid_filter_1.Operator.BW:a.append("(Left(",r,",",n.length.toString(),')="',n,'")');break;case wijmo_grid_filter_1.Operator.NBW:a.append("(Left(",r,",",n.length.toString(),')<>"',n,'")');break;case wijmo_grid_filter_1.Operator.EW:a.append("(Right(",r,",",n.length.toString(),')="',n,'")');break;case wijmo_grid_filter_1.Operator.NEW:a.append("(Right(",r,",",n.length.toString(),')<>"',n,'")');break;case wijmo_grid_filter_1.Operator.EQ:i||s||l?a.append("(",r,")=",n):a.append("(",r,')="',n,'"');break;case wijmo_grid_filter_1.Operator.NE:i||s||l?a.append("(",r,")<>",n):a.append("(",r,')<>"',n,'"');break;case wijmo_grid_filter_1.Operator.CT:a.append("(InStr(1,",r,',"',n,'")>0)');break;case wijmo_grid_filter_1.Operator.NC:a.append("(InStr(1,",r,',"',n,'")=0))');break;case wijmo_grid_filter_1.Operator.GT:a.append("(",r,")>",n);break;case wijmo_grid_filter_1.Operator.LT:a.append("(",r,")<",n);break;case wijmo_grid_filter_1.Operator.GE:a.append("(",r,")>=",n);break;case wijmo_grid_filter_1.Operator.LE:a.append("(",r,")<=",n)}return a.toString()}buildAxes(){let e=new _TextBuilder,t=this.buildSetForAttributesShelf(this._ng.rowFields);e.joinItemToList(t);this._ng.rowFields.length>0&&(this._ng.columnFields.length>0||this._ng.valueFields.length>1?e.append(" ON ROWS"):e.append(" ON COLUMNS"));t=this.buildSetForAttributesColumnShelf(this._ng.columnFields);e.joinItemToList(t);this._ng.columnFields.length>0&&e.append(" ON COLUMNS");if(this._ng.valueFields.length>1&&0==this._ng.columnFields.length){t=this.buildSetForMeasuresShelf(this._ng.valueFields);e.joinItemToList(t);e.append(" ON COLUMNS")}return e.toString()}buildSetForAttributesShelf(e){let t=new _TextBuilder;for(let s=0;s<e.length;s++){var i=e[s];i.dimensionType!=DimensionType.Attribute&&i.dimensionType!=DimensionType.Hierarchy||t.joinItemToList(this.buildAttributeSetForAxis(i));s>0&&t.wrap("CrossJoin(",")")}t.wrap("NON EMPTY ","");return t.toString()}buildSetForAttributesColumnShelf(e){let t=new _TextBuilder;for(let s=0;s<e.length;s++){var i=e[s];i.dimensionType!=DimensionType.Attribute&&i.dimensionType!=DimensionType.Hierarchy||t.joinItemToList(this.buildAttributeSetForAxis(i))}this._ng.valueFields.length>1&&e.length>0&&t.joinItemToList(this.buildSetForMeasuresShelf(this._ng.valueFields));(this._ng.valueFields.length>1&&e.length>0||e.length>1)&&t.wrap("CrossJoin(",")");t.wrap("NON EMPTY ","");return t.toString()}buildSetForMeasuresShelf(e){let t=new _TextBuilder;for(let s=0;s<e.length;s++){var i=e[s];i.dimensionType!=DimensionType.Measure&&i.dimensionType!=DimensionType.Kpi||t.joinItemToList(this.buildMeasureSetForAxis(i))}t.wrap("{","}");return t.toString()}buildAttributeSetForAxis(e){let t=new _TextBuilder;if(e.dimensionType==DimensionType.Hierarchy){t.append(e.key);t.append(".ALLMEMBERS");t.wrap("{","}");t.wrap("HIERARCHIZE(",")")}return t.toString()}buildMeasureSetForAxis(e){let t=new _TextBuilder;e.dimensionType!=DimensionType.Measure&&e.dimensionType!=DimensionType.Kpi||t.append(e.key);return t.toString()}}exports._MdxQueryBuilder=_MdxQueryBuilder;class _SqlServerConnection extends _ServerConnection{constructor(e,t){super(e,t.url);this._jsonResult=null;this._dataTypes=null;this._debug=!1;e.sortOnServer=!0;wijmo_1.assert(wijmo_1.isString(t.cube)&&!wijmo_1.isNullOrWhiteSpace(t.cube),"Cube name required.");this._cubeName=t.cube;this._catalogName=wijmo_1.isString(t.catalog)&&!wijmo_1.isNullOrWhiteSpace(t.catalog)?t.catalog:"";this._url=t.url;this._user=t.user;this._password=t.password}getFields(){this._getSession();this._jsonResult=null;this._dataTypes=null;this._getProperties(this._token);this._getDimensions(this._token);this._endSession();return this._jsonResult}getOutputView(e){this._ng.onUpdatingView(new ProgressEventArgs(0));let t=new _MdxQueryBuilder(this._ng,this._cubeName).buildQuery();this._jsonResult=[];this._getSession();this._execQuery(this._token,t,t=>{wijmo_1.asFunction(e)(this._jsonResult);this._ng.onUpdatedView(new ProgressEventArgs(100))})}getDetail(e,t){throw"getDetail method not supported"}getSortedKeys(e,t){let i=Object.keys(e);if(this._ng.sortOnServer){if(i.length>1){let e=t?this._ng.showRowTotals:this._ng.showColumnTotals,s=t?this._ng.rowFields.length:this._ng.columnFields.length,l=this._ng.valueFields.length;if(!this._ng.totalsBeforeData&&e!==ShowTotals.None){let e=-1,o=[],r=[];i.forEach(i=>{let n=this._getKeyLength(i,t);if(n===s)r.push(i);else if(n>=e)o.push(i);else{if(o.length>=l)for(var a=0;a<l;a++)r.push(o.pop());o.push(i)}e=n});if(o.length>0){o.reverse();r=r.concat(o)}return r}}}else i.sort((e,t)=>this._ng._keys[e].compareTo(this._ng._keys[t]));return i}_getSession(){let e=this._url;return wijmo_1.httpRequest(e,{async:!1,data:_ENV_SESSION,method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{let t=e.responseXML.getElementsByTagName("Session");this._token=t[0].getAttribute("SessionId")},error:e=>{this._handleError("Begin Session",e)}})}_endSession(){let e=this._url;return wijmo_1.httpRequest(e,{async:!1,data:_ENV_ENDSESSION(this._token),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},error:e=>{this._handleError("End Session",e)},complete:e=>{this._token=void 0}})}_getProperties(e){let t=this._url;return wijmo_1.httpRequest(t,{async:!1,data:_ENV_PROPERTIES(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{for(var t={},i=e.responseXML.getElementsByTagName("row"),s=0;s<i.length;s++){var l=_getTagValue(i[s],"HIERARCHY_UNIQUE_NAME");switch(Number(_getTagValue(i[s],"DATA_TYPE"))){case 2:case 3:case 4:case 5:case 6:t[l]=wijmo_1.DataType.Number;break;case 7:t[l]=wijmo_1.DataType.Date}}this._dataTypes=t},error:e=>{this._handleError("Get Properties",e)}})}_getDimensions(e){let t=this._url;return wijmo_1.httpRequest(t,{async:!1,data:_ENV_DIMENSIONS(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:t=>{for(var i=[],s=t.responseXML.getElementsByTagName("row"),l=0;l<s.length;l++){if("2"!==_getTagValue(s[l],"DIMENSION_TYPE")){var o=_getTagValue(s[l],"DIMENSION_UNIQUE_NAME"),r={header:_getTagValue(s[l],"DIMENSION_CAPTION"),dataType:wijmo_1.DataType.Object,dimensionType:DimensionType.Dimension,subFields:[]};this._getSubFolders(e,o,r);i.push(r)}else this._getMeasures(e,i)}var n={header:"KPIs",dataType:wijmo_1.DataType.Object,dimensionType:DimensionType.Kpi,subFields:[]};this._getKPIs(e,n);i.push(n);this._jsonResult=i},error:e=>{this._handleError("Get Dimensions",e)}})}_getSubFolders(e,t,i){let s=this._url;wijmo_1.httpRequest(s,{async:!1,data:_ENV_HIERARCHIES(e,this._catalogName,this._cubeName,t),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{for(var t=e.responseXML.getElementsByTagName("row"),s=0;s<t.length;s++){var l={header:_getTagValue(t[s],"HIERARCHY_NAME"),binding:_getTagValue(t[s],"HIERARCHY_UNIQUE_NAME"),dataType:wijmo_1.DataType.String,dimensionType:DimensionType.Hierarchy};this._dataTypes[l.binding]&&(l.dataType=this._dataTypes[l.binding]);for(var o=_getTagValue(t[s],"HIERARCHY_DISPLAY_FOLDER").split("\\"),r=i,n=0;n<o.length;n++)if(""!=o[n]){var a={header:o[n],dataType:wijmo_1.DataType.Object,dimensionType:DimensionType.Folder,subFields:[]};if(_containsFolder(r,o[n]))r=_findSubFieldByName(r,o[n]);else{r.subFields.push(a);r=a}}r.subFields.push(l)}},error:e=>{this._handleError("Get Hierarchies",e)}})}_getMeasures(e,t){let i=this._url;return wijmo_1.httpRequest(i,{async:!1,data:_ENV_MEASURES(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{for(var i=e.responseXML.getElementsByTagName("row"),s={},l=0;l<i.length;l++){var o=_getTagValue(i[l],"MEASUREGROUP_NAME"),r={header:_getTagValue(i[l],"MEASURE_CAPTION"),binding:_getTagValue(i[l],"MEASURE_UNIQUE_NAME"),dataType:wijmo_1.DataType.Number,dimensionType:DimensionType.Measure};if(Object.keys(s).indexOf(o)<0){var n={header:o,dataType:wijmo_1.DataType.Number,dimensionType:DimensionType.Measure,subFields:[]};n.subFields.push(r);t.push(n);s[o]=n}else s[o].subFields.push(r)}},error:e=>{this._handleError("Get Measures",e)}})}_getKPIs(e,t){let i=this._url;return wijmo_1.httpRequest(i,{async:!1,data:_ENV_KPIS(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{for(var i=e.responseXML.getElementsByTagName("row"),s=0;s<i.length;s++){for(var l=_getTagValue(i[s],"KPI_DISPLAY_FOLDER").split("\\"),o=t,r=0;r<l.length;r++){var n={header:l[r],dataType:wijmo_1.DataType.Object,dimensionType:DimensionType.Folder,subFields:[]};if(_containsFolder(o,l[r]))o=_findSubFieldByName(o,l[r]);else{o.subFields.push(n);o=n}}var a={header:_getTagValue(i[s],"KPI_CAPTION"),binding:_getTagValue(i[s],"KPI_VALUE"),dataType:wijmo_1.DataType.Number,dimensionType:DimensionType.Kpi};o.subFields.push(a)}},error:e=>{this._handleError("Get KPIs",e)}})}_execQuery(e,t,i){let s=this._url;return wijmo_1.httpRequest(s,{async:!0,data:_ENV_QUERY(e,this._catalogName,t),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{let s=e.responseXML,l=s.querySelector("Error");if(l){throw"SSAS Error\r\n"+l.getAttribute("Description")+"\r\n"+t}this._createPivotKeys(s);wijmo_1.asFunction(i)(e)},error:e=>{this._handleError("Execute Query",e)},complete:()=>{this._endSession()}})}_createPivotKeys(e){let t=null,i=null,s=e.querySelector("CellData");if(this._ng.columnFields.length>0||this._ng.valueFields.length>1){i=e.querySelector("Axis[name='Axis0']");this._ng.rowFields.length>0&&(t=e.querySelector("Axis[name='Axis1']"))}else this._ng.rowFields.length>0&&(t=e.querySelector("Axis[name='Axis0']"));let l=t&&this._ng.rowFields.length>0,o=i&&this._ng.columnFields.length>0;l&&o?this._createRowKeys(s,t,i):l?this._createRowOnlyKeys(s,t):o&&this._createColumnOnlyKeys(s,i)}_createRowKeys(e,t,i){let s=t.getElementsByTagName("Tuple"),l=i.getElementsByTagName("Tuple"),o=this._ng.showRowTotals!==ShowTotals.None?0:1,r=this._ng.showColumnTotals!==ShowTotals.None?0:this._ng.valueFields.length;for(let t=o;t<s.length;t++){let i=t*l.length,o=s[t],n=this._validateTuple(o,this._ng.showRowTotals);if(n)for(let t=r;t<l.length;t++){let s=l[t],o=this._validateTuple(s,this._ng.showColumnTotals);if(o){for(let e in n)o[e]=n[e];for(let s=0;s<this._ng.valueFields.length;s++){o[this._ng.valueFields[s].key]=_getCellValue(e,i+t+s)}this._jsonResult.push(o)}}}}_createRowOnlyKeys(e,t){let i=t.getElementsByTagName("Tuple"),s=this._ng.valueFields.length,l=this._ng.showRowTotals!==ShowTotals.None?0:1,o=l*s;for(let t=l;t<i.length;t++){let s=i[t],l=this._validateTuple(s,this._ng.showRowTotals);if(l){for(let t=0;t<this._ng.valueFields.length;t++){l[this._ng.valueFields[t].key]=_getCellValue(e,o++)}this._jsonResult.push(l)}else o++}}_createColumnOnlyKeys(e,t){let i=t.getElementsByTagName("Tuple"),s=this._ng.valueFields.length,l=this._ng.showColumnTotals!==ShowTotals.None?0:1;for(let t=l;t<i.length;t+=s){let s=i[t],o=this._validateTuple(s,this._ng.showColumnTotals);if(o){for(let i=0;i<this._ng.valueFields.length;i++){o[this._ng.valueFields[i].key]=_getCellValue(e,t-l+i)}this._jsonResult.push(o)}}}_validateTuple(e,t){let i=e.getElementsByTagName("Member"),s=void 0,l={};for(let e=0;e<i.length;e++){let o=i[e],r=_getLevelNumber(o),n=o.getAttribute("Hierarchy"),a=_getCaptionValue(o);if(0==e)s=r;else{if(r>s)return null;if(t!==ShowTotals.Subtotals&&r!==s&&"[Measures]"!==n)return null;s=r}n.indexOf(".")>=0?l[n]=a:null!==a&&(l[a]=null)}return l}}exports._SqlServerConnection=_SqlServerConnection;function _getTagValue(e,t){let i=e.querySelector(t);return i?i.innerHTML||i.textContent:null}function _getLevelNumber(e){return Number(_getTagValue(e,"LNum"))}function _getCaptionValue(e){return _getLevelNumber(e)>0?_getTagValue(e,"Caption"):null}function _getCellValue(e,t){let i="Cell[CellOrdinal='"+t.toString()+"']",s=e.querySelector(i);if(s){let e=_getTagValue(s,"Value");if(e)return Number(e)}return null}function _findSubFieldByName(e,t){if(e.subFields)for(var i=0;i<e.subFields.length;i++){var s=e.subFields[i];if(s.header==t)return s}return e}function _containsFolder(e,t){if(e.subFields)for(var i=0;i<e.subFields.length;i++){if(e.subFields[i].header==t)return!0}return!1}const _ENV_SESSION='\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <BeginSession soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">\n <Command>\n <Statement />\n </Command>\n <Properties>\n </Properties>\n </Execute>\n </Body>\n </Envelope>',_ENV_ENDSESSION=e=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:EndSession soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">\n <Command>\n <Statement />\n </Command>\n <Properties>\n </Properties>\n </Execute>\n </Body>\n </Envelope>`,_ENV_DIMENSIONS=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_DIMENSIONS</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_HIERARCHIES=(e,t,i,s)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_HIERARCHIES</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n <DIMENSION_UNIQUE_NAME>${s}</DIMENSION_UNIQUE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_MEASURES=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_MEASURES</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_KPIS=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_KPIS</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_LEVELS=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_LEVELS</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_PROPERTIES=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_PROPERTIES</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n <PROPERTY_NAME>MEMBER_VALUE</PROPERTY_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_QUERY=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">\n <Command>\n <Statement>\n <![CDATA[\n ${i}\n ]]>\n </Statement>\n </Command>\n <Properties>\n <PropertyList>\n <Catalog>${t}</Catalog>\n <Content>Data</Content>\n </PropertyList>\n </Properties>\n </Execute>\n </Body>\n </Envelope>`;class PivotFilter{constructor(e){this._fld=e;let t=e;this._valueFilter=new wijmo_grid_filter_1.ValueFilter(t);this._valueFilter.exclusiveValueSearch=this._fld.engine.exclusiveValueSearch;this._conditionFilter=new wijmo_grid_filter_1.ConditionFilter(t)}get filterType(){return null!=this._filterType?this._filterType:this._fld.engine.defaultFilterType}set filterType(e){if((e=wijmo_1.asEnum(e,wijmo_grid_filter_1.FilterType,!0))!=this._filterType){this._filterType=e;this.clear()}}apply(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)}get isActive(){return this._conditionFilter.isActive||this._valueFilter.isActive}clear(){let e=!1;if(this._valueFilter.isActive){this._valueFilter.clear();e=!0}if(this._conditionFilter.isActive){this._valueFilter.clear();e=!0}e&&this._fld.onPropertyChanged(new wijmo_1.PropertyChangedEventArgs("filter",null,null))}get valueFilter(){return this._valueFilter}get conditionFilter(){return this._conditionFilter}}exports.PivotFilter=PivotFilter;class PivotFilterEditor extends wijmo_1.Control{constructor(e,t,i){super(e);this.finishEditing=new wijmo_1.Event;this.hostElement.tabIndex=-1;let s=this.getTemplate();this.applyTemplate(`${wijmo_1.ControlClsNames.hostElement} ${wijmo_1.ControlClsNames.content} ${exports.PivotFilterEditorClsNames.hostElement}`,s,{_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnOk:"btn-ok"});wijmo_1.setText(this._aVal,wijmo_1.culture.FlexGridFilter.values);wijmo_1.setText(this._aCnd,wijmo_1.culture.FlexGridFilter.conditions);wijmo_1.setText(this._btnOk,wijmo_1.culture.olap.PivotFieldEditor.ok);let l=this._btnClicked.bind(this);this.addEventListener(this._btnOk,"click",l);this.addEventListener(this._aVal,"click",l);this.addEventListener(this._aCnd,"click",l);this.addEventListener(this.hostElement,"keydown",e=>{switch(e.keyCode){case wijmo_1.Key.Enter:switch(e.target.tagName){case"A":case"BUTTON":this._btnClicked(e);break;default:this.onFinishEditing(new wijmo_1.CancelEventArgs)}e.preventDefault();break;case wijmo_1.Key.Escape:this.onFinishEditing(new wijmo_1.CancelEventArgs);e.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(this.hostElement,e.shiftKey?-1:1);e.preventDefault()}});this._fld=t;this._uniqueValues=t.filter.valueFilter.uniqueValues;this.initialize(i);this.updateEditor()}static get controlTemplate(){PivotFilterEditor._ctrlTemplate||(PivotFilterEditor._ctrlTemplate=`<div><div wj-part="div-type" style="text-align:center;margin-bottom:12px;font-size:80%"><a wj-part="a-cnd" href="" tabindex="-1" draggable="false"></a> | <a wj-part="a-val" href="" tabindex="-1" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-ok" class="${wijmo_1.InputFormElementsClsNames.btn}"></button></div></div>`);return PivotFilterEditor._ctrlTemplate}static set controlTemplate(e){PivotFilterEditor._ctrlTemplate=e}get field(){return this._fld}get filter(){return this._fld?this._fld.filter:null}get isEditorClear(){switch(this._getFilterType()){case wijmo_grid_filter_1.FilterType.Value:return!this._edtVal||this._edtVal.isEditorClear;case wijmo_grid_filter_1.FilterType.Condition:return!this._edtCnd||this._edtCnd.isEditorClear}wijmo_1.assert(!1,"unknown filter type?");return!1}updateEditor(){let e=wijmo_grid_filter_1.FilterType,t=e.None;if(this.filter){t=this.filter.conditionFilter.isActive||0==(this.filter.filterType&e.Value)?e.Condition:e.Value;this._showFilter(t)}if(this._edtVal){let e=this._fld,t=e.engine;if(t.isServer&&!this._uniqueValues){let i=t._getUniqueValues(e);e.filter.valueFilter.uniqueValues=i}this._edtVal.updateEditor()}this._edtCnd&&this._edtCnd.updateEditor()}updateFilter(){switch(this._getFilterType()){case wijmo_grid_filter_1.FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case wijmo_grid_filter_1.FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}this.field.onPropertyChanged(new wijmo_1.PropertyChangedEventArgs("filter",null,null))}clearEditor(){this._edtVal&&this._edtVal.clearEditor();this._edtCnd&&this._edtCnd.clearEditor()}onFinishEditing(e){this.finishEditing.raise(this,e);return!e.cancel}_showFilter(e){e==wijmo_grid_filter_1.FilterType.Value&&null==this._edtVal&&(this._edtVal=new wijmo_grid_filter_1.ValueFilterEditor(this._divEdtVal,this.filter.valueFilter));e==wijmo_grid_filter_1.FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new wijmo_grid_filter_1.ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter));if(0!=(e&this.filter.filterType))if(e==wijmo_grid_filter_1.FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1)}switch(this.filter.filterType){case wijmo_grid_filter_1.FilterType.None:case wijmo_grid_filter_1.FilterType.Condition:case wijmo_grid_filter_1.FilterType.Value:this._divType.style.display="none";break;default:this._divType.style.display=""}}_enableLink(e,t){e.style.textDecoration=t?"":"none";e.style.fontWeight=t?"":"bold";wijmo_1.setAttribute(e,"href",t?"":null)}_getFilterType(){let e=wijmo_grid_filter_1.FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition}_btnClicked(e){e.preventDefault();e.stopPropagation();if(!wijmo_1.hasClass(e.target,wijmo_1.ControlStateClsNames.disabled))if(e.target!=this._aVal)if(e.target!=this._aCnd)this.onFinishEditing(new wijmo_1.CancelEventArgs);else{this._showFilter(wijmo_grid_filter_1.FilterType.Condition);wijmo_1.moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(wijmo_grid_filter_1.FilterType.Value);wijmo_1.moveFocus(this._edtVal.hostElement,0)}}}PivotFilterEditor._ctrlTemplate="";exports.PivotFilterEditor=PivotFilterEditor;class PivotFieldEditor extends wijmo_1.Control{constructor(e,t){super(e,null,!0);this.hostElement.tabIndex=-1;let i=this.getTemplate();this.applyTemplate(`${wijmo_1.ControlClsNames.hostElement} ${exports.PivotFieldEditorClsNames.hostElement}`,i,{_dBnd:"sp-bnd",_dHdr:"div-hdr",_dAgg:"div-agg",_dShw:"div-shw",_dWFl:"div-wfl",_dSrt:"div-srt",_btnFltEdt:"btn-flt-edt",_btnFltClr:"btn-flt-clr",_dFmt:"div-fmt",_dSmp:"div-smp",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_gDlg:"g-dlg",_gHdr:"g-hdr",_gAgg:"g-agg",_gShw:"g-shw",_gWfl:"g-wfl",_gSrt:"g-srt",_gFlt:"g-flt",_gFmt:"g-fmt",_gSmp:"g-smp"});this._pvDate=new Date;let s=wijmo_1.culture.olap.PivotFieldEditor;wijmo_1.setText(this._gDlg,s.dialogHeader);wijmo_1.setText(this._gHdr,s.header);wijmo_1.setText(this._gAgg,s.summary);wijmo_1.setText(this._gShw,s.showAs);wijmo_1.setText(this._gWfl,s.weighBy);wijmo_1.setText(this._gSrt,s.sort);wijmo_1.setText(this._gFlt,s.filter);wijmo_1.setText(this._gFmt,s.format);wijmo_1.setText(this._gSmp,s.sample);wijmo_1.setText(this._btnFltEdt,s.edit);wijmo_1.setText(this._btnFltClr,s.clear);wijmo_1.setText(this._btnApply,s.ok);wijmo_1.setText(this._btnCancel,s.cancel);this._cmbHdr=new wijmo_input_1.ComboBox(this._dHdr,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbAgg=new wijmo_input_1.ComboBox(this._dAgg,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbShw=new wijmo_input_1.ComboBox(this._dShw,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbWFl=new wijmo_input_1.ComboBox(this._dWFl,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbSrt=new wijmo_input_1.ComboBox(this._dSrt,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbFmt=new wijmo_input_1.ComboBox(this._dFmt,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbSmp=new wijmo_input_1.ComboBox(this._dSmp,{keyActionPrintCharacters:0,keyActionTab:0});this._initAggregateOptions();this._initShowAsOptions();this._initFormatOptions();this._initSortOptions();this._updatePreview();this._cmbShw.textChanged.addHandler(this._updateFormat,this);this._cmbFmt.textChanged.addHandler(this._updatePreview,this);this.addEventListener(this._btnFltEdt,"click",e=>{this._editFilter();e.preventDefault()});this.addEventListener(this._btnFltClr,"click",e=>{this._createFilterEditor();this._closeAndFocusTimer=setTimeout(()=>{this._eFlt.clearEditor();this._btnFltEdt.focus();wijmo_1.enable(this._btnFltClr,!1)});e.preventDefault()});this.addEventListener(this._btnApply,"click",e=>{this.updateField()});this.initialize(t)}static get controlTemplate(){PivotFieldEditor._ctrlTemplate||(PivotFieldEditor._ctrlTemplate=`<div><div class="${exports.DetailDialogClsNames.dialogHeader}" tabindex="-1"><span wj-part="g-dlg"></span> <span wj-part="sp-bnd"></span></div><div class="${exports.DetailDialogClsNames.dialogBody}"><table style="table-layout:fixed"><tr><td wj-part="g-hdr"></td><td><div wj-part="div-hdr"></div></td></tr><tr class="${wijmo_1.UtilitesClsNames.separator}"><td wj-part="g-agg"></td><td><div wj-part="div-agg"></div></td></tr><tr class="${wijmo_1.UtilitesClsNames.separator}"><td wj-part="g-shw"></td><td><div wj-part="div-shw"></div></td></tr><tr><td wj-part="g-wfl"></td><td><div wj-part="div-wfl"></div></td></tr><tr><td wj-part="g-srt"></td><td><div wj-part="div-srt"></div></td></tr><tr class="${wijmo_1.UtilitesClsNames.separator}"><td wj-part="g-flt"></td><td><div><button wj-part="btn-flt-edt" class="${wijmo_1.InputFormElementsClsNames.btn}"></button> <button wj-part="btn-flt-clr" class="${wijmo_1.InputFormElementsClsNames.btn}"></button></div></td></tr><tr class="${wijmo_1.UtilitesClsNames.separator}"><td wj-part="g-fmt"></td><td><div wj-part="div-fmt"></div></td></tr><tr><td wj-part="g-smp"></td><td><div wj-part="div-smp" readonly tabindex="-1"></div></td></tr></table></div><div class="${exports.DetailDialogClsNames.dialogFooter}"><button wj-part="btn-apply" class="${wijmo_1.InputFormElementsClsNames.btn} ${wijmo_1.UtilitesClsNames.hide}"></button> <button wj-part="btn-cancel" class="${wijmo_1.InputFormElementsClsNames.btn} ${wijmo_1.UtilitesClsNames.hide}"></button></div></div>`);return PivotFieldEditor._ctrlTemplate}static set controlTemplate(e){PivotFieldEditor._ctrlTemplate=e}get field(){return this._fld}set field(e){if(e!=this._fld){this._fld=wijmo_1.asType(e,PivotField);this.updateEditor()}}updateEditor(){let e=this._fld;if(e&&e.engine){this._dBnd.textContent=e.binding;this._cmbHdr.text=e.header;this._cmbAgg.collectionView.refresh();this._cmbAgg.selectedValue=e.aggregate;this._cmbSrt.selectedValue=e.descending;this._cmbShw.selectedValue=e.showAs;this._initWeighByOptions();let t=e.engine.defaultFilterType!=wijmo_grid_filter_1.FilterType.None&&(null!=e.binding||wijmo_1.isFunction(e.getValue));wijmo_1.enable(this._btnFltEdt,t);wijmo_1.enable(this._btnFltClr,t&&e.filter.isActive);this._cmbFmt.collectionView.refresh();this._cmbFmt.selectedValue=e.format;this._cmbFmt.selectedValue||(this._cmbFmt.text=e.format);let i=e instanceof CubePivotField;this._cmbAgg.isDisabled=i||!!e.getAggregateValue;this._cmbWFl.isDisabled=i}}updateField(){let e=this._fld;if(e){let t=this._cmbHdr.text.trim();e.header=t||wijmo_1.toHeaderCase(e.binding);e.aggregate=this._cmbAgg.selectedValue;e.showAs=this._cmbShw.selectedValue;e.weightField=this._cmbWFl.selectedValue;e.descending=this._cmbSrt.selectedValue;let i=e.format;e.format=this._cmbFmt.selectedValue||this._cmbFmt.text;let s=this._eFlt;if(s){s.updateFilter();const t=e.dataType==wijmo_1.DataType.Number,l=e.dataType==wijmo_1.DataType.Date;if(i!=e.format&&(t||l)){let s=e.filter.valueFilter;if(s&&s.isActive&&!s.dataMap){let o={};if(t)for(let t in s.showValues){let i=wijmo_1.Globalize.parseFloat(t);o[wijmo_1.Globalize.format(i,e.format)]=!0}else if(l)for(let t in s.showValues){let s=wijmo_1.Globalize.parseDate(t,i);o[wijmo_1.Globalize.format(s,e.format)]=!0}s.showValues=o}}}}}_initAggregateOptions(){let e=wijmo_1.culture.olap.PivotFieldEditor.aggs,t=wijmo_1.Aggregate,i=[{key:e.sum,val:t.Sum,all:!1},{key:e.cnt,val:t.Cnt,all:!0},{key:e.avg,val:t.Avg,all:!1},{key:e.max,val:t.Max,all:!0},{key:e.min,val:t.Min,all:!0},{key:e.rng,val:t.Rng,all:!1},{key:e.std,val:t.Std,all:!1},{key:e.var,val:t.Var,all:!1},{key:e.stdp,val:t.StdPop,all:!1},{key:e.varp,val:t.VarPop,all:!1},{key:e.first,val:t.First,all:!0},{key:e.last,val:t.Last,all:!0}];this._cmbAgg.itemsSource=i;this._cmbAgg.collectionView.filter=e=>{if(e&&e.all)return!0;if(this._fld){let e=this._fld.dataType;return e==wijmo_1.DataType.Number||e==wijmo_1.DataType.Boolean}return!1};this._cmbAgg.initialize({displayMemberPath:"key",selectedValuePath:"val"})}_initShowAsOptions(){let e=wijmo_1.culture.olap.PivotFieldEditor.calcs,t=[{key:e.noCalc,val:ShowAs.NoCalculation},{key:e.dRow,val:ShowAs.DiffRow},{key:e.dRowPct,val:ShowAs.DiffRowPct},{key:e.dCol,val:ShowAs.DiffCol},{key:e.dColPct,val:ShowAs.DiffColPct},{key:e.dPctGrand,val:ShowAs.PctGrand},{key:e.dPctRow,val:ShowAs.PctRow},{key:e.dPrevRow,val:ShowAs.PctPrevRow},{key:e.dPctCol,val:ShowAs.PctCol},{key:e.dPrevCol,val:ShowAs.PctPrevCol},{key:e.dRunTot,val:ShowAs.RunTot},{key:e.dRunTotPct,val:ShowAs.RunTotPct}];this._cmbShw.itemsSource=t;this._cmbShw.initialize({displayMemberPath:"key",selectedValuePath:"val"})}_initFormatOptions(){let e=wijmo_1.culture.olap.PivotFieldEditor.formats,t=[{key:e.n0,val:"n0",all:!0},{key:e.n2,val:"n2",all:!0},{key:e.c,val:"c",all:!0},{key:e.p0,val:"p0",all:!0},{key:e.p2,val:"p2",all:!0},{key:e.n2c,val:"n2,",all:!0},{key:e.n2cc,val:"n2,,",all:!0},{key:e.n2ccc,val:"n2,,,",all:!0},{key:e.d,val:"d",all:!1},{key:e.MMMMddyyyy,val:"MMMM dd, yyyy",all:!1},{key:e.dMyy,val:"d/M/yy",all:!1},{key:e.ddMyy,val:"dd/M/yy",all:!1},{key:e.dMyyyy,val:"dd/M/yyyy",all:!1},{key:e.MMMyyyy,val:"MMM yyyy",all:!1},{key:e.MMMMyyyy,val:"MMMM yyyy",all:!1},{key:e.yyyy,val:"yyyy",all:!1},{key:e.yyyyQq,val:'yyyy "Q"q',all:!1},{key:e.FYEEEEQU,val:'"FY"EEEE "Q"U',all:!1}];this._cmbFmt.itemsSource=t;this._cmbFmt.isEditable=!0;this._cmbFmt.isRequired=!1;this._cmbFmt.collectionView.filter=e=>!(!e||!e.all)||!!this._fld&&this._fld.dataType==wijmo_1.DataType.Date;this._cmbFmt.initialize({displayMemberPath:"key",selectedValuePath:"val"})}_initWeighByOptions(){let e=this._fld;if(e){let t=[{key:wijmo_1.culture.olap.PivotFieldEditor.none,val:null}];e.engine.fields.forEach(i=>{i!=e&&i.dataType==wijmo_1.DataType.Number&&t.push({key:i.header,val:i})});this._cmbWFl.initialize({displayMemberPath:"key",selectedValuePath:"val",itemsSource:t,selectedValue:e.weightField})}}_initSortOptions(){let e=wijmo_1.culture.olap.PivotFieldEditor.sorts,t=[{key:e.asc,val:!1},{key:e.desc,val:!0}];this._cmbSrt.itemsSource=t;this._cmbSrt.initialize({displayMemberPath:"key",selectedValuePath:"val"})}_updateFormat(){let e=ShowAs[this._cmbShw.selectedValue];this._cmbFmt.selectedValue=e.indexOf("Pct")>-1?"p0":"n0"}_updatePreview(){let e=this._cmbFmt.selectedValue||this._cmbFmt.text,t=wijmo_1.Globalize.format,i="";if(e){let s=e[0].toLowerCase();i="nfgxc".indexOf(s)>-1?t(1234.5678,e):t("p"==s?.12345678:this._pvDate,e)}this._cmbSmp.text=i}_editFilter(){this._createFilterEditor();wijmo_1.showPopup(this._dFlt,this._btnFltEdt,!1,!1,!1);wijmo_1.moveFocus(this._dFlt,0)}_createFilterEditor(){if(!this._dFlt){this._dFlt=document.createElement("div");this._eFlt=new PivotFilterEditor(this._dFlt,this._fld);wijmo_1.addClass(this._dFlt,wijmo_input_1.DropDownClsNames.dropDownPanel);this._lostFocusHandler=()=>{this._closeFilterTimer=setTimeout(()=>{let e=wijmo_1.Control.getControl(this._dFlt);e&&!e.containsFocus()&&this._closeFilter()},10)};this._eFlt.lostFocus.addHandler(this._lostFocusHandler);this._eFlt.finishEditing.addHandler(()=>{this._closeFilter();wijmo_1.enable(this._btnFltClr,!this._eFlt.isEditorClear)})}}_closeFilter(){if(this._dFlt){wijmo_1.hidePopup(this._dFlt,!0);this.focus()}}dispose(){if(this._closeFilterTimer){clearTimeout(this._closeFilterTimer);this._closeFilterTimer=null}this._cmbShw&&this._cmbShw.textChanged.removeHandler(this._updateFormat,this);this._cmbFmt&&this._cmbFmt.textChanged.removeHandler(this._updatePreview,this);if(this._eFlt){this._eFlt.dispose();this._eFlt=null}if(this._dFlt){this._dFlt.innerHTML="";this._dFlt=null}if(this._closeFilterTimer){clearTimeout(this._closeFilterTimer);this._closeFilterTimer=null}if(this._closeAndFocusTimer){clearTimeout(this._closeAndFocusTimer);this._closeAndFocusTimer=null}this.hostElement&&(this.hostElement[wijmo_1.Control._CTRL_KEY]=null);super.dispose()}}PivotFieldEditor._ctrlTemplate="";exports.PivotFieldEditor=PivotFieldEditor;wijmo_1._registerModule("wijmo.olap",selfModule);class PivotFieldBinding extends wijmo_1.Binding{constructor(e,t){super(t);this._fld=e}getValue(e){const t=this._fld;return wijmo_1.isFunction(t.getValue)?t._getValue(e,!1):super.getValue(e)}}exports.PivotFieldBinding=PivotFieldBinding;
|
|
14
|
+
"use strict";var __importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@mescius/wijmo"),wijmo_grid_filter_1=require("@mescius/wijmo.grid.filter"),wijmo_input_1=require("@mescius/wijmo.input"),wijmo_grid_1=require("@mescius/wijmo.grid"),wijmo_chart_1=require("@mescius/wijmo.chart"),selfModule=__importStar(require("@mescius/wijmo.olap"));class _TextBuilder{constructor(){this._text=""}get length(){return this._text.length}toString(){return this._text}append(...e){this._text=this._text.concat(...e)}joinToList(e,...t){const i=t.join();this.length>0&&i.length>0?this._text=this._text.concat(e,...t):i.length>0&&(this._text=i)}joinItemToList(e){this.joinToList(",",e)}wrap(e,t){this.length>0&&(this._text=e.concat(this._text,t))}static wrap(e,t,i){return t.length>0?e.concat(t,i):""}}exports._TextBuilder=_TextBuilder;exports.DetailDialogClsNames={dialogBody:"wj-dialog-body",dialogFooter:"wj-dialog-footer",dialogHeader:"wj-dialog-header",hostElement:"wj-detaildialog",summary:"wj-summary"};exports.PivotChartClsNames={hierarchicalAxesLine:"wj-hierarchicalaxes-line",hostElement:"wj-pivotchart"};exports.PivotFieldEditorClsNames={hostElement:"wj-pivotfieldeditor"};exports.PivotFilterEditorClsNames={hostElement:"wj-pivotfiltereditor"};exports.PivotGridClsNames={colFieldHdr:"wj-col-field-hdr",hostElement:"wj-pivotgrid",pivotCollapse:"wj-pivot-collapse",rowFieldHdr:"wj-row-field-hdr"};exports.PivotPanelClsNames={aggregate:"wj-aggregate",header:"wj-header",hostElement:"wj-pivotpanel"};exports.SlicerClsNames={header:"wj-header",hostElement:"wj-slicer",noCheck:"wj-nocheck"};exports._GridContextMenuClsNames={hostElement:"wj-olap-context-menu"};class _Tally{constructor(){this._cntAll=0;this._cnt=0;this._cntn=0;this._sum=0;this._sum2=0;this._min=null;this._max=null;this._first=null;this._last=null}add(e,t){if(e instanceof _Tally){this._sum+=e._sum;this._sum2+=e._sum2;this._max=this._max&&e._max?Math.max(this._max,e._max):this._max||e._max;this._min=this._min&&e._min?Math.min(this._min,e._min):this._min||e._min;this._cnt+=e._cnt;this._cntn+=e._cntn;this._cntAll+=e._cntAll}else{this._cntAll++;if(null!=e){this._cnt++;wijmo_1.isBoolean(e)&&(e=e?1:0);(null==this._min||e<this._min)&&(this._min=e);(null==this._max||e>this._max)&&(this._max=e);null==this._first&&(this._first=e);this._last=e;if(wijmo_1.isNumber(e)&&!isNaN(e)){wijmo_1.isNumber(t)&&(e*=t);this._cntn++;this._sum+=e;this._sum2+=e*e}}}}getAggregate(e){if(0==this._cnt)return null;const t=0==this._cntn?0:this._sum/this._cntn,i=wijmo_1.Aggregate;switch(e){case i.None:return null;case i.CntAll:return this._cntAll;case i.Avg:return t;case i.Cnt:return this._cnt;case i.Max:return this._max;case i.Min:return this._min;case i.Rng:return this._max-this._min;case i.Sum:return this._sum;case i.VarPop:return this._cntn<=1?0:this._sum2/this._cntn-t*t;case i.StdPop:return this._cntn<=1?0:Math.sqrt(this._sum2/this._cntn-t*t);case i.Var:return this._cntn<=1?0:(this._sum2/this._cntn-t*t)*this._cntn/(this._cntn-1);case i.Std:return this._cntn<=1?0:Math.sqrt((this._sum2/this._cntn-t*t)*this._cntn/(this._cntn-1));case i.First:return this._first;case i.Last:return this._last}throw"Invalid aggregate type."}}exports._Tally=_Tally;class _PivotKey{constructor(e,t,i,s,l){this._fields=e;this._fieldCount=t;this._valueFields=i;this._valueFieldIndex=s;this._item=l}get fields(){return this._fields}get valueFields(){return this._valueFields}get valueField(){return this._valueFields[this._valueFieldIndex]}get values(){if(null==this._vals){this._vals=new Array(this._fieldCount);for(let e=0;e<this._fieldCount;e++){const t=this._fields[e];this._vals[e]=t._getValue(this._item,!1)}}return this._vals}get fieldNames(){if(!this._names){this._names=[];for(let e=0;e<this.fields.length;e++){const t=this._fields[e];this._names.push(t._getName())}}return this._names}get aggregate(){const e=this._valueFields,t=this._valueFieldIndex;wijmo_1.assert(e&&t>-1&&t<e.length,"aggregate not available for this key");return e[t].aggregate}getValue(e,t){if(0==this.values.length)return wijmo_1.culture.olap.PivotEngine.grandTotal;if(e>this.values.length-1)return wijmo_1.culture.olap.PivotEngine.subTotal;let i=this.values[e];if(t&&!wijmo_1.isString(i)){const t=this.fields[e],s=t?t.format:"";i=wijmo_1.Globalize.format(this.values[e],s)}return i}get level(){return this._fieldCount==this._fields.length?-1:this._fieldCount}compareTo(e){let t=0;if(null!=e&&e._fields==this._fields){const i=this.values,s=e.values,l=Math.min(i.length,s.length);for(let o=0;o<l;o++){let l=null!=i[o]?wijmo_1.getType(i[o]):null,n=i[o],r=s[o];const a=this._fields[o];if(a.sortComparer){t=a.sortComparer(n,r);if(wijmo_1.isNumber(t)){if(0!=t)return a.descending?-t:t;continue}}if(l==wijmo_1.DataType.Date){const t=a.format;if(t&&"d"!=t&&"D"!=t){const i=a._getValue(this._item,!0),s=a._getValue(e._item,!0),l=wijmo_1.Globalize.parseDate(i,t),o=wijmo_1.Globalize.parseDate(s,t);if(l&&o){n=l;r=o}else{n=i;r=s}}}if(!(n==r||wijmo_1.DateTime.equals(n,r))){if(null==n)return 1;if(null==r)return-1;t=n<r?-1:1;return a.descending?-t:t}}if(i.length==s.length){t=this._valueFieldIndex-e._valueFieldIndex;if(0!=t)return t}t=s.length-i.length;if(0!=t)return t*(this.fields.engine.totalsBeforeData?-1:1)}return 0}matchesItem(e){for(let t=0;t<this._vals.length;t++){if(this.getValue(t,!0)!=this._fields[t]._getValue(e,!0))return!1}return!0}toString(e){if(!this._key||e){let t="";for(let e=0;e<this._fieldCount;e++){const i=this._fields[e];t+=`${i._getName()}:${i._getValue(this._item,!0)};`}if(this._valueFields){t+=this._valueFields[this._valueFieldIndex]._getName()+":0;"}else t+="{total}";if(e)return t+e.toString();this._key=t}return this._key}}_PivotKey._ROW_KEY_NAME="$rowKey";exports._PivotKey=_PivotKey;const _NOT_EDITABLE="This collection is not editable.";class PivotCollectionView extends wijmo_1.CollectionView{constructor(e){super();this.canAddNew=this.canRemove=!1;this._ng=wijmo_1.asType(e,PivotEngine,!1)}get engine(){return this._ng}implementsInterface(e){return"IEditableCollectionView"!=e&&super.implementsInterface(e)}editItem(e){wijmo_1.assert(!1,_NOT_EDITABLE)}addNew(){wijmo_1.assert(!1,_NOT_EDITABLE)}_performSort(e){const t=this._ng;if(t.sortableGroups&&t._getShowRowTotals()==ShowTotals.Subtotals){let t=0,i=e.length-1;0==this._getItemLevel(e[t])&&t++;0==this._getItemLevel(e[i])&&i--;this._sortGroups(e,1,t,i)}else this._sortData(e)}_performFilter(e){return this._ng&&0==this._ng.valueFields.length&&0==this._ng.rowFields.length?[]:this.canFilter&&this._filter?e.filter(this._filter,this):e}_getGroupRange(e,t){let i=this._ng,s=e.indexOf(t),l=s,o=this._getItemLevel(e[s]);if(i.totalsBeforeData)for(l=s;l<e.length-1;l++){const t=this._getItemLevel(e[l+1]);if(t>-1&&t<=o)break}else for(s=l;s;s--){const t=this._getItemLevel(e[s-1]);if(t>-1&&t<=o)break}return[s,l]}_sortGroups(e,t,i,s){const l=[];for(let o=i;o<=s;o++)this._getItemLevel(e[o])==t&&l.push(e[o]);if(!l.length){this._sortData(e);return}super._performSort(l);const o=[];for(let s=0;s<l.length;s++){const n=this._getGroupRange(e,l[s]),r=o.length;for(let t=n[0];t<=n[1];t++)o.push(e[t]);const a=o.length-1;if(t<this._ng.rowFields.length-1)this._sortGroups(o,t+1,i+r,a);else{const e=this._ng.totalsBeforeData?1:0;this._sortSegment(o,r+e,a+e)}}for(let t=0;t<o.length;t++)e[i+t]=o[t]}_sortSegment(e,t,i){const s=e.slice(t,i);super._performSort(s);for(let i=0;i<s.length;i++)e[t+i]=s[i]}_sortData(e){for(let t=0;t<e.length;t++){if(this._getItemLevel(e[t])>-1)continue;let i=t;for(;i<e.length-1&&!(this._getItemLevel(e[i+1])>-1);i++);if(i>t){const s=e.slice(t,i+1);super._performSort(s);for(let i=0;i<s.length;i++)e[t+i]=s[i]}t=i}}_getItemLevel(e){return e[_PivotKey._ROW_KEY_NAME].level}}exports.PivotCollectionView=PivotCollectionView;class PivotField{constructor(e,t,i,s){this._isExplicitAggregate=!1;this.propertyChanged=new wijmo_1.Event;this._ng=e;this._binding=new PivotFieldBinding(this,t);this._header=i||wijmo_1.toHeaderCase(t);this._showAs=ShowAs.NoCalculation;this._isContentHtml=!1;this._visible=!0;this._format="";this._filter=new PivotFilter(this);wijmo_1.copy(this,s);null==this._dataType&&this._updateDataTypeByBinding();this._isExplicitAggregate||this._updateAggregateByDataType()}get binding(){return this._binding?this._binding.path:null}set binding(e){if(e!=this.binding){const t=this.binding,i=wijmo_1.asString(e);this._binding=i?new PivotFieldBinding(this,i):null;if(null==this._dataType){this._updateDataTypeByBinding();this._isExplicitAggregate||this._updateAggregateByDataType()}const s=new wijmo_1.PropertyChangedEventArgs("binding",t,e);this.onPropertyChanged(s)}}get getValue(){return this._getValueFn}set getValue(e){this._getValueFn=wijmo_1.asFunction(e,!0)}get getAggregateValue(){return this._getAggValueFn}set getAggregateValue(e){this._getAggValueFn=wijmo_1.asFunction(e,!0)}get header(){return this._header}set header(e){e=wijmo_1.asString(e,!1);const t=this._ng.fields.getField(e);!e||t&&t!=this?wijmo_1.assert(!1,"field headers must be unique and non-empty."):this._setProp("_header",wijmo_1.asString(e))}get filter(){return this._filter}get aggregate(){return this._aggregate}set aggregate(e){this._isExplicitAggregate=!0;this._setProp("_aggregate",wijmo_1.asEnum(e,wijmo_1.Aggregate))}get showAs(){return this._showAs}set showAs(e){this._setProp("_showAs",wijmo_1.asEnum(e,ShowAs))}get weightField(){return this._weightField}set weightField(e){this._setProp("_weightField",wijmo_1.asType(e,PivotField,!0))}get dataType(){return this._dataType}set dataType(e){this._setProp("_dataType",wijmo_1.asEnum(e,wijmo_1.DataType))}get isMeasure(){return this._dataType==wijmo_1.DataType.Number}get subFields(){return this._subFields}get format(){return this._format}set format(e){this._setProp("_format",wijmo_1.asString(e))}get align(){return this._align}set align(e){this._setProp("_align",wijmo_1.asString(e))}get width(){return this._width}set width(e){this._setProp("_width",wijmo_1.asNumber(e,!0,!0))}get wordWrap(){return this._wordWrap}set wordWrap(e){this._setProp("_wordWrap",wijmo_1.asBoolean(e))}get descending(){return!!this._descending}set descending(e){this._setProp("_descending",wijmo_1.asBoolean(e))}get isContentHtml(){return this._isContentHtml}set isContentHtml(e){this._setProp("_isContentHtml",wijmo_1.asBoolean(e))}get visible(){return this._visible}set visible(e){this._setProp("_visible",wijmo_1.asBoolean(e))}get sortComparer(){return this._srtCmp}set sortComparer(e){e!=this.sortComparer&&(this._srtCmp=wijmo_1.asFunction(e))}get engine(){return this._ng}get collectionView(){return this.engine?this.engine.collectionView:null}get isActive(){return this._getIsActive()}set isActive(e){this._setIsActive(e)}get parentField(){return this._parent}get key(){return this.header}onPropertyChanged(e){this.propertyChanged.raise(this,e);this._ng._fieldPropertyChanged(this,e)}_updateDataTypeByBinding(){if(this._ng&&this._binding){const e=this._ng.collectionView,t=e?e.items.length:0;for(let i=0;i<t;i++){const t=e.items[i];if(null!=t){this._dataType=wijmo_1.getType(this._binding.getValue(t));break}}}}_updateAggregateByDataType(){this._aggregate=this.dataType==wijmo_1.DataType.Number?wijmo_1.Aggregate.Sum:wijmo_1.Aggregate.Cnt}_copy(e,t){if("subFields"==e){this._subFields?this._subFields.splice(0,this._subFields.length):this._subFields=[];t&&t.length&&t.forEach(e=>{const t=this.engine._createField(e,this._autoGenerated);this._subFields.push(t)});return!0}if("filter"==e){this._setFilterProxy(t);return!0}return!1}_getFilterProxy(){const e=this.filter;if(e.conditionFilter.isActive){const t=e.conditionFilter,i={condition1:{operator:t.condition1.operator,value:t.condition1.value},and:t.and,condition2:{operator:t.condition2.operator,value:t.condition2.value}};t.condition1.isActive||delete i.condition1;t.condition2.isActive||delete i.condition2;return i}if(e.valueFilter.isActive){const t=e.valueFilter;return{filterText:t.filterText,showValues:t.showValues}}wijmo_1.assert(!1,"inactive filters shouldn't be persisted.");return null}_setFilterProxy(e){const t=this.filter,i=t.conditionFilter,s=t.valueFilter;t.clear();e.conditionFilter?e=e.conditionFilter:e.valueFilter&&(e=e.valueFilter);if(e.condition1){const t=e.condition1,s=wijmo_1.changeType(t.value,this.dataType);i.condition1.value=s||t.value;i.condition1.operator=t.operator;const l=e.condition2;if(l){const e=wijmo_1.changeType(l.value,this.dataType);i.condition2.value=e||l.value;i.condition2.operator=l.operator}wijmo_1.isBoolean(e.and)&&(i.and=e.and)}if(e.showValues){s.filterText=e.filterText;s.showValues=e.showValues}}_getIsActive(){if(this._ng&&!this._hasSubFields()){const e=this._ng._viewLists;for(let t=0;t<e.length;t++)if(e[t].indexOf(this)>-1)return!0}return!1}_setIsActive(e){if(this._ng&&!this._hasSubFields()){const t=this.isActive;if((e=wijmo_1.asBoolean(e))!=t)if(e)this.isMeasure?this._ng.valueFields.push(this):this._ng.rowFields.push(this);else{const e=this._ng._viewLists;for(let t=0;t<e.length;t++){const i=e[t];for(let e=0;e<i.length;e++){const t=i[e];if(t==this||t.parentField==this){i.removeAt(e);e--}}}const t=this._ng.fields;for(let e=t.length-1;e>=0;e--){if(t[e].parentField==this){t.removeAt(e);e--}}}}}_hasSubFields(){return null!=this._subFields&&this._subFields.length>0}_clone(){const e=new PivotField(this._ng,this.binding);this._ng._copyProps(e,this,PivotField._props);e._autoGenerated=!0;e._parent=this;const t=this.header.replace(/\d+$/,"");for(let i=2;;i++){const s=t+i.toString();if(null==this._ng.fields.getField(s)){e._header=s;break}}return e}_setProp(e,t,i){const s=this[e];if(t!=s){this[e]=t;const i=new wijmo_1.PropertyChangedEventArgs(e.substr(1),s,t);this.onPropertyChanged(i)}}_getName(){return this.header||this.binding}_getValue(e,t){let i=this._binding,s=null;e&&(s=wijmo_1.isFunction(this._getValueFn)?this._getValueFn.call(this,e):this._ng.isServer?e[this.key]:i._key?e[i._key]:i.getValue(e));return t&&"string"!=typeof s?wijmo_1.Globalize.format(s,this._format):s}_getWeight(e){const t=this._weightField?this._weightField._getValue(e,!1):null;return wijmo_1.isNumber(t)?t:null}}PivotField._props=["dataType","format","width","wordWrap","aggregate","showAs","descending","isContentHtml","visible"];exports.PivotField=PivotField;class CubePivotField extends PivotField{constructor(e,t,i,s){super(e,t,i,s);wijmo_1.assert(null!=this.dimensionType,"CubePivotField objects must specify the field's dimensionType")}get header(){return this._header}set header(e){this._setProp("_header",wijmo_1.asString(e))}get dimensionType(){return this._dimensionType}set dimensionType(e){this._setProp("_dimensionType",wijmo_1.asEnum(e,DimensionType,!1))}get isMeasure(){switch(this._dimensionType){case 1:case 2:case 8:return!0}return!1}get key(){return this.binding}_clone(){throw"CubePivotField objects cannot be cloned"}}exports.CubePivotField=CubePivotField;var DimensionType,ShowTotals,ShowAs,PivotChartType,LegendVisibility;!function(e){e[e.Dimension=0]="Dimension";e[e.Measure=1]="Measure";e[e.Kpi=2]="Kpi";e[e.NameSet=3]="NameSet";e[e.Attribute=4]="Attribute";e[e.Folder=5]="Folder";e[e.Hierarchy=6]="Hierarchy";e[e.Date=7]="Date";e[e.Currency=8]="Currency"}(DimensionType=exports.DimensionType||(exports.DimensionType={}));class Slicer extends wijmo_1.Control{constructor(e,t){super(e,null,wijmo_1.isIE()&&!wijmo_1.isEdge());this._hdr=null;this._mSel=!1;this._updatingFilter=!1;this._propChanged=!1;this._fldPropChangeBnd=this._fldPropChange.bind(this);const i=this.getTemplate();this.applyTemplate(`${exports.SlicerClsNames.hostElement} ${exports.SlicerClsNames.noCheck} ${wijmo_1.ControlClsNames.hostElement} ${wijmo_1.ControlClsNames.content}`,i,{_root:"root",_divHdr:"div-hdr",_divHdrText:"div-hdr-text",_btnMSel:"btn-msel",_btnClear:"btn-clear"});const s=wijmo_1.culture.olap.Slicer;this._tt=new wijmo_1.Tooltip;wijmo_1.setAttribute(this._btnMSel,"aria-label",s.multiSelect);wijmo_1.setAttribute(this._btnClear,"aria-label",s.clearFilter);this._tt.setTooltip(this._btnMSel,s.multiSelect);this._tt.setTooltip(this._btnClear,s.clearFilter);this.addEventListener(this._btnClear,"click",e=>{this._clear()});this.addEventListener(this._btnMSel,"click",e=>{this.multiSelect=!this.multiSelect});this.initialize(t)}static get controlTemplate(){Slicer._ctrlTemplate||(Slicer._ctrlTemplate=`<div wj-part="root"><div wj-part="div-hdr" class="${exports.SlicerClsNames.header}"><div wj-part="div-hdr-text"></div><button wj-part="btn-msel" class="${wijmo_1.InputFormElementsClsNames.btn} btn-msel" tabindex="-1"><span class=${wijmo_1.GlyphClsNames.glyph}>≡</span></button><button wj-part="btn-clear" class="${wijmo_1.InputFormElementsClsNames.btn} btn-clear" tabindex="-1"><span class=${wijmo_1.GlyphClsNames.glyph}>×</span></button></div></div>`);return Slicer._ctrlTemplate}static set controlTemplate(e){Slicer._ctrlTemplate=e}get field(){return this._fld}set field(e){if(e!=this._fld){if(this._divListBox){wijmo_1.removeChild(this._divListBox);this._divListBox=null;this._lbx.dispose();this._lbx=null}if(this._edt){this._clear();this._edt.dispose()}let t=this._fld;if(t){t.filter.filterType=this._originalFilterType;t.filter.valueFilter.uniqueValues=this._uniqueValues;t.propertyChanged.removeHandler(this._fldPropChangeBnd)}t=this._fld=wijmo_1.asType(e,PivotField,!0);if(t){this._originalFilterType=t.filter.filterType;t.filter.filterType=wijmo_grid_filter_1.FilterType.Value;const e=t.engine;this._uniqueValues=t.filter.valueFilter.uniqueValues;if(e.isServer&&!this._uniqueValues){const i=e._getUniqueValues(t);t.filter.valueFilter.uniqueValues=i}t.propertyChanged.addHandler(this._fldPropChangeBnd);t.isActive||t.engine.filterFields.push(t);const i=document.createElement("div");this._edt=new wijmo_grid_filter_1.ValueFilterEditor(i,t.filter.valueFilter)}if(this._edt){this._divListBox=this._edt.hostElement.querySelector("."+wijmo_input_1.ListBoxClsNames.hostElement);this._root.appendChild(this._divListBox);this._lbx=wijmo_1.Control.getControl(this._divListBox);this._lbx.checkedItemsChanged.addHandler((e,i)=>{if(!this._propChanged){const e=this._lbx.selectedItem;if(!this.multiSelect&&e){this._mSel=!0;this._lbx.checkedItems=[e];this._mSel=!1}}if(this._edt&&t){this._updateFilter();t.engine.invalidate()}})}this._updateHeader();wijmo_1.isIE()&&!wijmo_1.isEdge()&&this.refresh()}}get header(){return this._hdr}set header(e){if(e!=this._hdr){this._hdr=wijmo_1.asString(e);this._updateHeader()}}get showHeader(){return"none"!=this._divHdr.style.display}set showHeader(e){this._divHdr.style.display=wijmo_1.asBoolean(e)?"":"none"}get showCheckboxes(){return!wijmo_1.hasClass(this.hostElement,exports.SlicerClsNames.noCheck)}set showCheckboxes(e){wijmo_1.toggleClass(this.hostElement,exports.SlicerClsNames.noCheck,!wijmo_1.asBoolean(e))}get multiSelect(){return this._mSel}set multiSelect(e){this._mSel=wijmo_1.asBoolean(e);wijmo_1.toggleClass(this._btnMSel,wijmo_1.ControlStateClsNames.active,this._mSel)}refresh(e=!0){wijmo_1.isIE()&&!wijmo_1.isEdge()&&this.hostElement&&(this._setCssTimer=setTimeout(()=>{wijmo_1.setCss(this._lbx.hostElement,{height:this.hostElement.clientHeight-this._divHdr.offsetHeight})}));super.refresh(e)}_fldPropChange(e,t){this._propChanged=!0;switch(t.propertyName){case"header":this._updateHeader();break;case"format":case"binding":e.filter.clear();this._edt.updateEditor();break;case"filter":this._updatingFilter||this._edt.updateEditor()}this._propChanged=!1}_updateHeader(){let e=this._hdr;e||null==this._fld||(e=this._fld.header);this._divHdrText.textContent=e}_clear(){if(this._edt){this._edt.clearEditor(!1);this._updateFilter();this._fld.engine.invalidate()}}_updateFilter(){this._updatingFilter=!0;this._edt.updateFilter();this._updatingFilter=!1}dispose(){if(this._tt){this._tt.dispose();this._tt=null}if(this._edt){this._edt.dispose();this._edt=null}if(this._lbx){this._lbx.dispose();this._lbx=null}if(this._setCssTimer){clearTimeout(this._setCssTimer);this._setCssTimer=null}this._fld&&this._fld.propertyChanged.removeHandler(this._fldPropChangeBnd);super.dispose()}}Slicer._ctrlTemplate="";exports.Slicer=Slicer;class _GridContextMenu extends wijmo_input_1.Menu{constructor(){super(document.createElement("div"),{header:"PivotGrid Context Menu",displayMemberPath:"text",commandParameterPath:"parm",command:{executeCommand:e=>{this._execute(e)},canExecuteCommand:e=>this._canExecute(e)}});this.itemsSource=this._getMenuItems();wijmo_1.addClass(this.dropDown,"context-menu "+exports._GridContextMenuClsNames.hostElement)}static get controlTemplate(){_GridContextMenu._ctrlTemplate||(_GridContextMenu._ctrlTemplate=wijmo_input_1.Menu.controlTemplate);return _GridContextMenu._ctrlTemplate}static set controlTemplate(e){_GridContextMenu._ctrlTemplate=e}refresh(e=!0){this.itemsSource=this._getMenuItems();super.refresh(e)}attach(e){wijmo_1.assert(e instanceof PivotGrid,"Expecting a PivotGrid control...");const t=e.hostElement;this._gridOwner=t;this._contextMenuHandler=i=>{if(e.customContextMenu){i.preventDefault();this.owner=t;if(this._selectField(i)){const e=this.dropDown;this.selectedIndex=-1;if(this.onIsDroppedDownChanging(new wijmo_1.CancelEventArgs)){wijmo_1.showPopup(e,i);this.onIsDroppedDownChanged();e.focus()}}}};this._gridOwner.addEventListener("contextmenu",this._contextMenuHandler)}_selectField(e){this._targetField=null;this._htDown=null;const t=wijmo_1.Control.getControl(this.owner),i=t.engine,s=i.valueFields,l=i.columnFields,o=t.hitTest(e),n=wijmo_grid_1.CellType;switch(o.cellType){case n.Cell:t.select(o.range);this._targetField=s[o.col%s.length];this._htDown=o;break;case n.ColumnHeader:this._targetField=o.row<l.length?l[o.row]:s[o.col%s.length];break;case n.RowHeader:this._targetField=t._colRowFields.get(o.getColumn());break;case n.TopLeft:o.row==o.panel.rows.length-1&&(this._targetField=t._colRowFields.get(o.getColumn()))}return null!=this._targetField}_getMenuItems(){const e=[{text:'<div class="menu-icon menu-icon-remove">✖</div>Remove Field',parm:"remove"},{text:'<div class="menu-icon">⛭</div>Field Settings...',parm:"edit"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:'<div class="menu-icon">⌕</div>Show Detail...',parm:"detail"}];for(let t=0;t<e.length;t++){const i=e[t];if(i.parm){const e=wijmo_1.culture.olap._ListContextMenu[i.parm];wijmo_1.assert(e,"missing localized text for item "+i.parm);i.text=i.text.replace(/([^>]+$)/,e)}}return e}_execute(e){const t=this._targetField,i=wijmo_1.Control.getControl(this.owner),s=i?i.engine:null,l=this._htDown;switch(e){case"remove":s.removeField(t);break;case"edit":s.editField(t);break;case"detail":i.showDetail(l.row,l.col)}}_canExecute(e){const t=this._targetField,i=wijmo_1.Control.getControl(this.owner),s=i?i.engine:null,l=this._htDown;if(null==t||null==s)return!1;switch(e){case"remove":return!0;case"edit":return s.allowFieldEditing;case"detail":return null!=l&&!(t instanceof CubePivotField)&&s.valueFields.length>0}return!0}dispose(){if(this._gridOwner){this._gridOwner.removeEventListener("contextmenu",this._contextMenuHandler);this._contextMenuHandler=null;this._gridOwner=null}this._targetField=null;this._htDown=null;this.command=null;this.itemsSource=null;super.dispose()}}_GridContextMenu._ctrlTemplate="";exports._GridContextMenu=_GridContextMenu;class PivotFieldCollection extends wijmo_1.ObservableArray{constructor(e){super();this._ng=e}get maxItems(){return this._maxItems}set maxItems(e){this._maxItems=wijmo_1.asInt(e,!0,!0)}get engine(){return this._ng}getField(e){return this._getField(this,e)}_getField(e,t){for(let i=0;i<e.length;i++){let s=e[i];if(s.key==t)return s;if(s._hasSubFields()){s=this._getField(s.subFields,t);if(s)return s}}return null}push(...e){const t=this._ng;for(let i=0;e&&i<e.length;i++){let s=e[i];wijmo_1.isString(s)&&(s=this==t.fields?new PivotField(t,s):t.fields.getField(s));wijmo_1.assert(s instanceof PivotField,"This collection must contain PivotField objects only.");if(s.key&&this.getField(s.key)){wijmo_1.assert(!1,"PivotField keys must be unique.");return-1}if(null!=this._maxItems&&this.length>=this._maxItems)break;super.push(s)}return this.length}}exports.PivotFieldCollection=PivotFieldCollection;class _PivotNode{constructor(e,t,i,s,l,o){this._key=new _PivotKey(e,t,i,s,l);this._nodes={};this._parent=o}getNode(e,t,i,s,l){let o=this;for(let n=0;n<t;n++){let t=e[n]._getValue(l,!0),r=o._nodes[t];if(!r){r=new _PivotNode(e,n+1,i,s,l,o);o._nodes[t]=r}o=r}if(i&&s>-1){let n=i[s].header,r=o._nodes[n];if(!r){r=new _PivotNode(e,t,i,s,l,o);o._nodes[n]=r}o=r}return o}get key(){return this._key}get parent(){return this._parent}get tree(){this._tree||(this._tree=new _PivotNode(null,0,null,-1,null));return this._tree}}exports._PivotNode=_PivotNode;class _ServerConnection{constructor(e,t){this._ng=wijmo_1.asType(e,PivotEngine);wijmo_1.assert(this._isValidUrl(t),`Invalid service Url: ${t})`)}getFields(){let e=null;wijmo_1.httpRequest(this._getUrl("Fields"),{async:!1,success:t=>{e=JSON.parse(t.responseText);wijmo_1.isArray(e)||console.error("Failed to get fields from server: "+t.responseText)},error:e=>{this._handleError("Getting Fields",e)}});return e}getUniqueValues(e){let t=null;wijmo_1.httpRequest(this._getUrl("UniqueValues",null,e.header),{method:"POST",async:!1,data:{view:this._ng.viewDefinition},success:e=>{t=JSON.parse(e.responseText);wijmo_1.isArray(t)||console.error("Failed to get unique field values from server: "+e.responseText)},error:e=>{this._handleError("Getting Unique Field Values",e)}});return t}getOutputView(e){this.clearPendingRequests();this._sendHttpRequest("Analyses",{method:"POST",data:{view:this._ng.viewDefinition},success:t=>{const i=JSON.parse(t.responseText);this._token=i.token;this._start=Date.now();this._handleResult(i.status,e)},error:e=>{this._handleError("Analyses",e)}})}getDetail(e,t){let i,s=[],l=this._ng.rowFields.length,o=e?e.values.length:0;for(let t=0;t<l;t++)t<o?s.push(_ServerConnection._getRequestedValue(e.values[t])):s.push(null);l=this._ng.columnFields.length;o=t?t.values.length:0;for(let e=0;e<l;e++)e<o?s.push(_ServerConnection._getRequestedValue(t.values[e])):s.push(null);i=new wijmo_1.ObservableArray;this._loadArray("Detail",i,{method:"POST",view:this._ng.viewDefinition,keys:s,max:this._ng.serverMaxDetail});return i}getSortedKeys(e,t){const i=Object.keys(e);if(this._ng.sortOnServer){if(i.length>1){const e={},s=[],l=[];i.forEach(i=>{this._insertKey(e,i,t)});this._reorderKeys(e,null,null,s,t);if(!t&&this._ng.valueFields.length>1){const e=s.length/this._ng.valueFields.length,t=s.length/e;for(let i=0;i<e;i++)for(let o=0;o<t;o++)l.push(s[i+o*e]);return l}return s}}else i.sort((e,t)=>this._ng._keys[e].compareTo(this._ng._keys[t]));return i}static _getRequestedValue(e){if(wijmo_1.isDate(e)){const t=e;return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()))}return e}clearPendingRequests(){this._clearRequest();this._clearTimeout();this._clearToken()}updateTallies(e){const t=this._ng,i=t.rowFields.length,s=t.columnFields.length,l=t.valueFields.length,o=new _PivotNode(t.rowFields,0,null,-1,null);e.forEach((e,n,r)=>{let a=this._getAggregatedFieldCount(e,t.rowFields),h=o.getNode(t.rowFields,i-a,null,-1,e),d=h.key,_=d.toString(null),c=t._tallies[_];if(!c){t._keys[_]=d;t._tallies[_]=c={}}a=this._getAggregatedFieldCount(e,t.columnFields);for(let i=0;i<l;i++){const l=h.tree.getNode(t.columnFields,s-a,t.valueFields,i,e).key,o=l.toString(),n=t.valueFields[i];let r=c[o];if(!r){t._keys[o]=l;r=c[o]=new _ServerTally;r.add(this._getFieldValue(n,e,!1))}}})}_getFieldValue(e,t,i){const s=t[e.key];return i&&"string"!=typeof s?wijmo_1.Globalize.format(s,e.format):s}_getKeyLength(e,t){return e.split(";").length-(t?1:2)}_insertKey(e,t,i){const s=t.split(";");i||s.pop();if(1==s.length)e[s.pop()]={};else{const t=s.pop();let i=e[t];i||(e[t]=i={});for(;s.length>0;){const e=s.shift();i[e]||(i[e]={});i=i[e]}}}_joinKeys(e,t,i){return t&&i?[t,e,i].join(";"):i?[e,i].join(";"):e}_reorderKeys(e,t,i,s,l){Object.keys(e).forEach(o=>{let n=this._joinKeys(o,t,i);const r=l?this._ng.showRowTotals:this._ng.showColumnTotals,a=Object.keys(e[o]).length,h=!t&&!i&&r!==ShowTotals.None||!t&&!a||t||r===ShowTotals.Subtotals;l||(n+=";");this._ng.totalsBeforeData&&h&&s.push(n);i?t?this._reorderKeys(e[o],[t,o].join(";"),i,s,l):this._reorderKeys(e[o],o,i,s,l):this._reorderKeys(e[o],null,o,s,l);!this._ng.totalsBeforeData&&h&&s.push(n)})}_getAggregatedFieldCount(e,t){let i=t.length,s=0;for(let l=0;l<i;l++){const i=t[l];null==this._getFieldValue(i,e,!1)&&s++}return s}_loadArray(e,t,i){i||(i={});null==i.skip&&(i.skip=0);null==i.top&&(i.top=100);const s=wijmo_1.isNumber(i.max)?i.max:1e6;this._request=wijmo_1.httpRequest(this._getUrl(e),{data:i,method:i.method||"GET",success:l=>{const o=JSON.parse(l.responseText);t.deferUpdate(()=>{o.value.forEach(e=>{t.push(e)})});if(o.value.length==i.top&&t.length<s){i.skip+=i.top;this._loadArray(e,t,i)}},error:t=>{this._handleError(e,t)}})}_getUrl(e,t=this._token,i){const s=this._ng.itemsSource.toString(),l=s.lastIndexOf("/");s.substr(0,l);switch(e=e.toLowerCase()){case"rawdata":case"detail":return s;case"fields":case"analyses":return`${s}/${e}`;case"clear":return`${s}/analyses/${t}/`;case"result":case"status":return`${s}/analyses/${t}/${e}`;case"uniquevalues":return`${s}/fields/${i}/${e}`}wijmo_1.assert(!1,"Unrecognized command")}_isValidUrl(e){const t=document.createElement("a");t.href=wijmo_1.asString(e);const i=t.href;t.href=i;return t.protocol&&t.hostname&&t.pathname&&"/"!=e[e.length-1]}_handleResult(e,t){switch(e.executingStatus.toLowerCase()){case"executing":case"notset":if(Date.now()-this._start>this._ng.serverTimeout){this._handleError("Analyses",{status:500,statusText:"Analysis timed out"});return}this._progress=e.progress;this._ng.onUpdatingView(new ProgressEventArgs(this._progress));this._clearTimeout();this._toGetStatus=setTimeout(()=>{this._waitUntilComplete(t)},this._ng.serverPollInterval);break;case"completed":this._progress=100;this._ng.onUpdatingView(new ProgressEventArgs(this._progress));this._getResults(t);break;case"exception":this._getResults(t);break;default:this._handleError("Analyses",{status:500,statusText:"Unexpected result..."})}}_waitUntilComplete(e){this._sendHttpRequest("Status",{success:t=>{const i=JSON.parse(t.responseText);this._handleResult(i,e)},error:e=>{this._handleError("Status",e)}})}_getResults(e){this._sendHttpRequest("Result",{success:t=>{this._clearToken();const i=JSON.parse(t.responseText);wijmo_1.assert(wijmo_1.isArray(i),"Result array Expected.");let s=[];this._ng._viewLists.forEach(e=>{s=s.concat(e.filter(e=>e.dataType==wijmo_1.DataType.Date))});s.length>0&&i.forEach(e=>{s.forEach(t=>{const i=t._binding,s=i.getValue(e);wijmo_1.isString(s)&&i.setValue(e,new Date(s))})});wijmo_1.asFunction(e)(i)},error:e=>{this._handleError("Result",e)}})}_handleError(e,t){this.clearPendingRequests();e=`** HttpRequest error on command "${e}"`;this._ng.onError(new wijmo_1.RequestErrorEventArgs(t,e))&&this._throwResponseError(e,t)}_sendHttpRequest(e,t){const i=this._getUrl(e);this._request=wijmo_1.httpRequest(i,t)}_throwResponseError(e,t){e=`${e}\r\n${t.status}\r\n`;let i=t.responseText||"";if(500==t.status&&t.responseText){i=JSON.parse(t.responseText).ExceptionMessage}throw e+=i||t.statusText}_clearToken(){if(this._token){this._clearRequest();this._clearTimeout();this._sendHttpRequest("Clear",{method:"DELETE"});this._token=null}}_clearRequest(){if(this._request&&4!=this._request.readyState){this._request.abort();this._request=null}}_clearTimeout(){if(this._toGetStatus){clearTimeout(this._toGetStatus);this._toGetStatus=null}}}_ServerConnection._TIMEOUT=6e4;_ServerConnection._POLL_INTERVAL=500;_ServerConnection._MAXDETAIL=1e3;exports._ServerConnection=_ServerConnection;class _ServerTally extends _Tally{add(e,t){wijmo_1.assert(0==this._cnt,"Server tallies have a single value.");this._aggregatedValue=e}getAggregate(e){return this._aggregatedValue}}wijmo_1._addCultureInfo("olap",{PivotEngine:{grandTotal:"Grand Total",subTotal:"Subtotal"},PivotPanel:{fields:"Choose fields to add to report:",drag:"Drag fields between areas below:",filters:"Filters",cols:"Columns",rows:"Rows",vals:"Values",defer:"Defer Updates",update:"Update"},PivotFieldEditor:{dialogHeader:"Field settings:",header:"Header:",summary:"Summary:",showAs:"Show As:",weighBy:"Weigh by:",sort:"Sort:",filter:"Filter:",format:"Format:",sample:"Sample:",edit:"Edit...",clear:"Clear",ok:"OK",cancel:"Cancel",none:"(none)",sorts:{asc:"Ascending",desc:"Descending"},aggs:{sum:"Sum",cnt:"Count",avg:"Average",max:"Max",min:"Min",rng:"Range",std:"StdDev",var:"Var",stdp:"StdDevPop",varp:"VarPop",first:"First",last:"Last"},calcs:{noCalc:"No calculation",dRow:"Difference from previous row",dRowPct:"% Difference from previous row",dCol:"Difference from previous column",dColPct:"% Difference from previous column",dPctGrand:"% of grand total",dPctRow:"% of row total",dPrevRow:"% of value in the previous row",dPctCol:"% of column total",dPrevCol:"% of value in the previous column",dRunTot:"Running total",dRunTotPct:"% running total"},formats:{n0:"Integer (n0)",n2:"Float (n2)",c:"Currency (c)",p0:"Percentage (p0)",p2:"Percentage (p2)",n2c:"Thousands (n2,)",n2cc:"Millions (n2,,)",n2ccc:"Billions (n2,,,)",d:"Date (d)",MMMMddyyyy:"Month Day Year (MMMM dd, yyyy)",dMyy:"Day Month Year (d/M/yy)",ddMyy:"Day Month Year (dd/M/yy)",dMyyyy:"Day Month Year (dd/M/yyyy)",MMMyyyy:"Month Year (MMM yyyy)",MMMMyyyy:"Month Year (MMMM yyyy)",yyyy:"Year (yyyy)",yyyyQq:'Year Quarter (yyyy "Q"q)',FYEEEEQU:'Fiscal Year Quarter ("FY"EEEE "Q"U)'}},_ListContextMenu:{up:"Move Up",down:"Move Down",first:"Move to Beginning",last:"Move to End",filter:"Move to Report Filter",rows:"Move to Row Labels",cols:"Move to Column Labels",vals:"Move to Values",remove:"Remove Field",edit:"Field Settings...",detail:"Show Detail..."},DetailDialog:{header:"Detail View:",ok:"OK",items:"{cnt:n0} items",item:"{cnt} item",row:"Row",col:"Column"},PivotChart:{by:"by",and:"and"},Slicer:{multiSelect:"Multi-Select",clearFilter:"Clear Filter"}});!function(e){e[e.None=0]="None";e[e.GrandTotals=1]="GrandTotals";e[e.Subtotals=2]="Subtotals"}(ShowTotals=exports.ShowTotals||(exports.ShowTotals={}));!function(e){e[e.NoCalculation=0]="NoCalculation";e[e.DiffRow=1]="DiffRow";e[e.DiffRowPct=2]="DiffRowPct";e[e.DiffCol=3]="DiffCol";e[e.DiffColPct=4]="DiffColPct";e[e.PctGrand=5]="PctGrand";e[e.PctRow=6]="PctRow";e[e.PctCol=7]="PctCol";e[e.RunTot=8]="RunTot";e[e.RunTotPct=9]="RunTotPct";e[e.PctPrevRow=10]="PctPrevRow";e[e.PctPrevCol=11]="PctPrevCol"}(ShowAs=exports.ShowAs||(exports.ShowAs={}));class PivotEngine{constructor(e){this._autoGenFields=!0;this._allowFieldEditing=!0;this._showRowTotals=ShowTotals.GrandTotals;this._showColTotals=ShowTotals.GrandTotals;this._totalsBefore=!1;this._sortableGroups=!0;this._showZeros=!1;this._updating=0;this._xValueSearch=!0;this._async=!0;this._sortOnServer=!1;this._cntTotal=0;this._cntFiltered=0;this._serverParms={timeout:_ServerConnection._TIMEOUT,pollInterval:_ServerConnection._POLL_INTERVAL,maxDetail:_ServerConnection._MAXDETAIL};this.itemsSourceChanged=new wijmo_1.Event;this.viewDefinitionChanged=new wijmo_1.Event;this.updatingView=new wijmo_1.Event;this.updatedView=new wijmo_1.Event;this.error=new wijmo_1.Event;this._isUpdatingChanged=new wijmo_1.Event;this._hasDeferredUpdatesChanged=new wijmo_1.Event;this._pivotView=new PivotCollectionView(this);this._fields=new PivotFieldCollection(this);this._rowFields=new PivotFieldCollection(this);this._columnFields=new PivotFieldCollection(this);this._valueFields=new PivotFieldCollection(this);this._filterFields=new PivotFieldCollection(this);this._viewLists=[this._rowFields,this._columnFields,this._valueFields,this._filterFields];const t=this._fieldListChanged.bind(this);this._fields.collectionChanged.addHandler(t);this._viewLists.forEach(e=>{e.collectionChanged.addHandler(t)});this._defaultFilterType=null;wijmo_1.copy(this,e)}get itemsSource(){return this._items}set itemsSource(e){if(this._items!=e){if(this._cv){this._cv.collectionChanged.removeHandler(this._cvCollectionChanged,this);this._cv=null}if(this._server){this._server.clearPendingRequests();this._server=null}this._items=e;wijmo_1.isString(e)?this._server=new _ServerConnection(this,e):wijmo_1.isObject(e)&&!wijmo_1.tryCast(e,"ICollectionView")?this._server=new _SqlServerConnection(this,e):this._cv=wijmo_1.asCollectionView(e);null!=this._cv&&this._cv.collectionChanged.addHandler(this._cvCollectionChanged,this);this.deferUpdate(()=>{this.autoGenerateFields&&this._generateFields();this._updateFieldTypes()});this.onItemsSourceChanged()}}get isServer(){return null!=this._server}get collectionView(){return this._cv}get pivotView(){return this._pivotView}get showRowTotals(){return this._showRowTotals}set showRowTotals(e){if((e=wijmo_1.asEnum(e,ShowTotals))!=this.showRowTotals){this._showRowTotals=e;this.onViewDefinitionChanged();this.invalidate()}}get showColumnTotals(){return this._showColTotals}set showColumnTotals(e){if((e=wijmo_1.asEnum(e,ShowTotals))!=this.showColumnTotals){this._showColTotals=e;this.onViewDefinitionChanged();this.invalidate()}}get totalsBeforeData(){return this._totalsBefore}set totalsBeforeData(e){if(e!=this._totalsBefore){this._totalsBefore=wijmo_1.asBoolean(e);this.onViewDefinitionChanged();this._updatePivotView()}}get sortableGroups(){return this._sortableGroups}set sortableGroups(e){if(e!=this._sortableGroups){this._sortableGroups=wijmo_1.asBoolean(e);this.onViewDefinitionChanged()}}get sortOnServer(){return this._sortOnServer}set sortOnServer(e){this._sortOnServer=wijmo_1.asBoolean(e)}get showZeros(){return this._showZeros}set showZeros(e){if(e!=this._showZeros){this._showZeros=wijmo_1.asBoolean(e);this.onViewDefinitionChanged();this._updatePivotView()}}get defaultFilterType(){return null!=this._defaultFilterType?this._defaultFilterType:this._server?wijmo_grid_filter_1.FilterType.Condition:wijmo_grid_filter_1.FilterType.Both}set defaultFilterType(e){this._defaultFilterType=wijmo_1.asEnum(e,wijmo_grid_filter_1.FilterType,!0)}get exclusiveValueSearch(){return this._xValueSearch}set exclusiveValueSearch(e){this._xValueSearch=wijmo_1.asBoolean(e)}get autoGenerateFields(){return this._autoGenFields}set autoGenerateFields(e){this._autoGenFields=wijmo_1.asBoolean(e)}get allowFieldEditing(){return this._allowFieldEditing}set allowFieldEditing(e){this._allowFieldEditing=wijmo_1.asBoolean(e)}get fields(){return this._fields}get rowFields(){return this._rowFields}get columnFields(){return this._columnFields}get filterFields(){return this._filterFields}get valueFields(){return this._valueFields}get viewDefinition(){const e={showZeros:this.showZeros,showColumnTotals:this.showColumnTotals,showRowTotals:this.showRowTotals,defaultFilterType:this.defaultFilterType,totalsBeforeData:this.totalsBeforeData,sortableGroups:this.sortableGroups,fields:[],rowFields:this._getFieldCollectionProxy(this.rowFields),columnFields:this._getFieldCollectionProxy(this.columnFields),filterFields:this._getFieldCollectionProxy(this.filterFields),valueFields:this._getFieldCollectionProxy(this.valueFields)};this.fields.forEach(t=>{const i=this._getFieldDefinition(t);e.fields.push(i)});return JSON.stringify(e)}set viewDefinition(e){const t=JSON.parse(e);t&&this.deferUpdate(()=>{this._copyProps(this,t,PivotEngine._props);this.fields.clear();t.fields.forEach(e=>{const t=this._getFieldFromDefinition(e);this.fields.push(t)});t.fields.forEach((e,t)=>{wijmo_1.isString(e.weightField)&&(this.fields[t].weightField=this.fields.getField(e.weightField))});this._setFieldCollectionProxy(this.rowFields,t.rowFields);this._setFieldCollectionProxy(this.columnFields,t.columnFields);this._setFieldCollectionProxy(this.filterFields,t.filterFields);this._setFieldCollectionProxy(this.valueFields,t.valueFields)})}get isViewDefined(){const e=this._valueFields.length,t=this._rowFields.length,i=this._columnFields.length;return this._server?e>0&&(t>0||i>0):e>0||t>0||i>0}beginUpdate(){this.cancelPendingUpdates();this._updating++;1===this._updating&&this._onIsUpdatingChanged()}endUpdate(){this._updating--;if(this._updating<=0){if(this._viewDefinitionChanged){this._viewDefinitionChanged=!1;this.onViewDefinitionChanged();this._setHasDeferredUpdates(!1)}this._onIsUpdatingChanged();this.refresh()}}get isUpdating(){return this._updating>0}get hasDeferredUpdates(){return this._hasDeferredUpdates}_setHasDeferredUpdates(e){if(this._hasDeferredUpdates!==e){this._hasDeferredUpdates=e;this._onHasDeferredUpdatesChanged()}}deferUpdate(e){try{this.beginUpdate();e()}finally{this.endUpdate()}}refresh(e=!1){this._updateView(e)}invalidate(){this._toInv&&(this._toInv=clearTimeout(this._toInv));this.isUpdating||this.isDisposed||(this._toInv=setTimeout(()=>{this.refresh()},wijmo_1.Control._REFRESH_INTERVAL))}get async(){return this._async}set async(e){if(e!=this._async){this.cancelPendingUpdates();this._async=wijmo_1.asBoolean(e)}}get serverTimeout(){return this._serverParms.timeout}set serverTimeout(e){this._serverParms.timeout=wijmo_1.asNumber(e,!1,!0)}get serverPollInterval(){return this._serverParms.pollInterval}set serverPollInterval(e){this._serverParms.pollInterval=wijmo_1.asNumber(e,!1,!0)}get serverMaxDetail(){return this._serverParms.maxDetail}set serverMaxDetail(e){this._serverParms.maxDetail=wijmo_1.asNumber(e,!1,!0)}cancelPendingUpdates(){if(this._toUpdateTallies){clearTimeout(this._toUpdateTallies);this._toUpdateTallies=null}}getDetail(e,t){const i=e?e[_PivotKey._ROW_KEY_NAME]:null,s=this._getKey(t);if(this._server)return this._server.getDetail(i,s);const l=this.collectionView.items,o=[];l.forEach(e=>{!this._applyFilter(e)||null!=i&&!i.matchesItem(e)||null!=s&&!s.matchesItem(e)||o.push(e)});return o}getDetailView(e,t){const i=this.getDetail(e,t);return new wijmo_1.CollectionView(i)}getKeys(e,t){const i=e?e[_PivotKey._ROW_KEY_NAME]:null,s=this._getKey(t);return{rowKey:{fields:i?i.fieldNames:[],values:i?i.values:[]},colKey:{fields:s?s.fieldNames:[],values:s?s.values:[]}}}editField(e){if(this.allowFieldEditing){this.edt=new PivotFieldEditor(document.createElement("div"),{field:e});this._dlg=new wijmo_input_1.Popup(document.createElement("div"),{content:this.edt.hostElement});this._dlg.show(!0)}}removeField(e){for(let t=0;t<this._viewLists.length;t++){const i=this._viewLists[t],s=i.indexOf(e);if(s>-1){i.removeAt(s);return}}}onItemsSourceChanged(e){this.itemsSourceChanged.raise(this,e)}onViewDefinitionChanged(e){if(this._updating<=0){this.viewDefinitionChanged.raise(this,e);this._viewDefinitionChanged=!1;this._setHasDeferredUpdates(!1)}else{this._viewDefinitionChanged=!0;this._setHasDeferredUpdates(!0)}}onUpdatingView(e){this.updatingView.raise(this,e)}onUpdatedView(e){this.updatedView.raise(this,e)}onError(e){this.error.raise(this,e);return!e.cancel}_onIsUpdatingChanged(e){this._isUpdatingChanged.raise(this,e)}_onHasDeferredUpdatesChanged(e){this._hasDeferredUpdatesChanged.raise(this,e)}_copy(e,t){let i;switch(e){case"fields":this.fields.clear();this._viewLists.forEach(e=>{e.clear()});i=wijmo_1.asArray(t);i.forEach(e=>{const t=this._createField(e,!1);this.fields.push(t)});this._updateFieldTypes();return!0;case"rowFields":case"columnFields":case"valueFields":case"filterFields":this[e].clear();if(!wijmo_1.isArray(t)){this[e].maxItems=t.maxItems;t=t.items}i=wijmo_1.asArray(t);i.forEach(t=>{const i=this.fields.getField(t);this[e].push(i)});return!0}return!1}_getKey(e){return this._keys[e]}_getRowKey(e){let t=e;if(wijmo_1.isNumber(e)){const i=this._pivotView;t=(i.items.length?i.items:i.sourceCollection)[e]}return t?t[_PivotKey._ROW_KEY_NAME]:null}_getRowLevel(e){const t=this._getRowKey(e);return t?t.level:-1}_getColKey(e){wijmo_1.isNumber(e)&&(e=this._colBindings[e]);if(wijmo_1.isString(e))return this._getKey(e);wijmo_1.assert(null==e||e instanceof _PivotKey,"invalid parameter in call to _getColLevel");return e}_getColLevel(e){return(e=this._getColKey(e))?e.level:-1}_getFieldByColKey(e){const t=this._getColKey(e);return t&&t.valueField}_applyFilter(e){const t=this._activeFilterFields;for(let i=0;i<t.length;i++){if(!t[i].filter.apply(e))return!1}return!0}_updateView(e=!1){if(!this.isUpdating||e){this.cancelPendingUpdates();this._cntTotal=this._cntFiltered=0;this._tallies={};this._keys={};this._activeFilterFields=[];if(this._server&&this.isViewDefined){this._server.getOutputView(t=>{if(this.isViewDefined){this._server.updateTallies(t);this._updatePivotView(e)}});return}this._viewLists.forEach(e=>{e.forEach(e=>{e.filter.isActive&&this._activeFilterFields.push(e)})});if(this.isViewDefined&&wijmo_1.hasItems(this._cv)){this._batchStart=Date.now();this._updateTallies(this._cv.items,0,e)}else this._updatePivotView(e);this._setHasDeferredUpdates(!1)}}_updateTallies(e,t,i=!1){const s=e.length,l=new _PivotNode(this._rowFields,0,null,-1,null);let o=this.valueFields;if(0==o.length&&this.columnFields.length>0){o=new PivotFieldCollection(this);o.push(new PivotField(this,"","",{aggregate:wijmo_1.Aggregate.Sum}))}const n=ShowTotals,r=this._rowFields.length,a=this._getShowRowTotals(),h=a==n.None?r:0,d=a==n.GrandTotals?Math.max(1,r):1,_=this._columnFields.length,c=this._getShowColTotals(),u=c==n.None?_:0,g=c==n.GrandTotals?Math.max(1,_):1,m=o.length;for(let n=t;n<s;n++){if(this._async&&n-t>=PivotEngine._BATCH_SIZE&&Date.now()-this._batchStart>PivotEngine._BATCH_DELAY){this._toUpdateTallies=setTimeout(()=>{this.onUpdatingView(new ProgressEventArgs(Math.round(n/e.length*100)));this._batchStart=Date.now();this._updateTallies(e,n,i)},PivotEngine._BATCH_TIMEOUT);return}this._cntTotal++;const s=e[n];if(!this._activeFilterFields.length||this._applyFilter(s)){this._cntFiltered++;for(let e=h;e<=r;e+=d){let t=l.getNode(this._rowFields,e,null,-1,s),i=t.key,n=i.toString(),r=this._tallies[n];if(!r){this._keys[n]=i;this._tallies[n]=r={}}for(let e=u;e<=_;e+=g)for(let i=0;i<m;i++){let l=t.tree.getNode(this._columnFields,e,o,i,s).key,n=l.toString(),a=r[n];if(!a){this._keys[n]=l;a=r[n]=new _Tally}const h=o[i],d=h._getValue(s,!1),_=h.weightField?h._getWeight(s):null;a.add(d,_)}}}}this._toUpdateTallies=null;this._updatePivotView(i)}_updatePivotView(e=!1){if(!this.isUpdating||e){const e=this._pivotView;e.deferUpdate(()=>{this.onUpdatingView(new ProgressEventArgs(100));e.cancelEdit();e.cancelNew();const t=e.sourceCollection;t.length=0;const i={};for(const e in this._tallies)i[e]=!0;const s={};for(const e in this._tallies){const t=this._tallies[e];for(const e in t)s[e]=!0}let l=[],o=[];if(this._server){l=this._server.getSortedKeys(i,!0);o=this._server.getSortedKeys(s,!1)}else{l=this._getSortedKeys(i);o=this._getSortedKeys(s)}for(let e=0;e<l.length;e++){const i=l[e],s=this._tallies[i],n={};n[_PivotKey._ROW_KEY_NAME]=this._getKey(i);for(let e=0;e<o.length;e++){let t=o[e],i=s[t],l=this._getKey(t),r=i?i.getAggregate(l.aggregate):null;null==r&&this._showZeros&&(r=0);n[t]=r}t.push(n)}this._colBindings=o;this._updateFieldValues(t);e.sortDescriptions.clear();e.refresh()});this.onUpdatedView()}}_getSortedKeys(e){const t=Object.keys(e);t.sort((e,t)=>this._keys[e].compareTo(this._keys[t]));return t}_updateFieldValues(e){const t=this.valueFields.length;for(let i=0;i<t;i++){const s=this.valueFields[i];if(wijmo_1.isFunction(s.getAggregateValue))for(let l=i;l<this._colBindings.length;l+=t)for(let t=0;t<e.length;t++){const i=e[t],o=this._colBindings[l],n=this._getAggregateObject(i,o);i[o]=s.getAggregateValue.call(this,n)}}for(let i=0;i<t;i++){const s=this.valueFields[i];switch(s.showAs){case ShowAs.RunTot:case ShowAs.RunTotPct:for(let l=i;l<this._colBindings.length;l+=t){for(let t=0;t<e.length;t++){e[t][this._colBindings[l]]=this._getRunningTotal(e,t,l)}if(s.showAs==ShowAs.RunTotPct)for(let t=0;t<e.length;t++){const i=e[t],s=this._colBindings[l],o=i[s];if(wijmo_1.isNumber(o)){const n=this._getLastValueInRowGroup(e,t,l);0!=n&&(i[s]=o/n)}}}break;case ShowAs.PctGrand:case ShowAs.PctCol:{let l=0;if(s.showAs==ShowAs.PctGrand)for(let s=i;s<this._colBindings.length;s+=t)-1==this._getColLevel(s)&&(l+=this._getColTotal(e,s));for(let o=i;o<this._colBindings.length;o+=t){s.showAs==ShowAs.PctCol&&(l=this._getColTotal(e,o));const t=this._colBindings[o];e.forEach(e=>{const i=e[t];wijmo_1.isNumber(i)&&(e[t]=0!=l?i/l:null)})}break}case ShowAs.PctRow:for(let s=0;s<e.length;s++){let l=e[s],o=0;for(let e=i;e<this._colBindings.length;e+=t)if(-1==this._getColLevel(e)){const t=l[this._colBindings[e]];wijmo_1.isNumber(t)&&(o+=t)}for(let e=i;e<this._colBindings.length;e+=t){const t=this._colBindings[e],i=l[t];wijmo_1.isNumber(i)&&(l[t]=0!=o?i/o:null)}}break;case ShowAs.DiffRow:case ShowAs.DiffRowPct:case ShowAs.PctPrevRow:for(let l=i;l<this._colBindings.length;l+=t)for(let t=e.length-1;t>=0;t--){e[t][this._colBindings[l]]=this._getRowDifference(e,t,l,s.showAs)}break;case ShowAs.DiffCol:case ShowAs.DiffColPct:case ShowAs.PctPrevCol:for(let l=0;l<e.length;l++)for(let o=this._colBindings.length-t+i;o>=0;o-=t){e[l][this._colBindings[o]]=this._getColDifference(e,l,o,s.showAs)}}}}_getAggregateObject(e,t){const i={},s=/(.+:.+;)*((.+):.+;)/,l=t.match(s);for(const t in e){const o=t.match(s);o&&o[1]==l[1]&&(i[o[3]]=e[t])}return i}_getColTotal(e,t){let i=this._colBindings[t],s=0;e.forEach(e=>{if(-1==this._getRowLevel(e)){const t=e[i];wijmo_1.isNumber(t)&&(s+=t)}});return s}_getRunningTotal(e,t,i){const s=this._getRowLevel(e[t]);if(0==s)return null;let l=this._colBindings[i],o=e[t][l],n=this._getShowRowTotals();const r=this.rowFields.length-2;for(let i=t-1;i>=0;i--){const a=this._getRowLevel(e[i]);if(a==s){if(r>-1&&s<0&&n!=ShowTotals.Subtotals){const s=e[t].$rowKey,l=e[i].$rowKey;if(s.values[r]!=l.values[r])return null}o+=e[i][l];break}if(a>s)break}return o}_getLastValueInRowGroup(e,t,i){let s=this._colBindings[i],l=e[t][s];const o=this._getRowLevel(e[t]),n=this.rowFields.length-2,r=this._getShowRowTotals();for(let i=t+1;i<e.length;i++){const a=this._getRowLevel(e[i]);if(a==o){if(n>-1&&o<0&&r!=ShowTotals.Subtotals){const s=e[t].$rowKey,o=e[i].$rowKey;if(s.values[n]!=o.values[n])return l}l=e[i][s]}if(a>o)break}return l}_getRowDifference(e,t,i,s){const l=this._getRowLevel(e[t]);if(0==l)return null;let o=this._colBindings[i],n=e[t][o],r=this.rowFields.length-2,a=this._getShowRowTotals();for(let i=t-1;i>=0;i--){const h=this._getRowLevel(e[i]);if(h==l){if(r>-1&&l<0&&a!=ShowTotals.Subtotals){const s=e[t].$rowKey,l=e[i].$rowKey;if(s.values[r]!=l.values[r])return null}const h=e[i][o];switch(s){case ShowAs.DiffRow:n-=h;break;case ShowAs.DiffRowPct:n=(n-h)/h;break;case ShowAs.PctPrevRow:n/=h}return n}if(h>l)break}return s==ShowAs.PctPrevRow?1:null}_getColDifference(e,t,i,s){const l=this._getColLevel(i);if(0==l)return null;let o=e[t],n=o[this._colBindings[i]],r=this.valueFields.length,a=this.columnFields.length-2,h=this._getShowColTotals();for(let e=i-r;e>=0;e-=r){const t=this._getColLevel(e);if(t==l){if(a>-1&&l<0&&h!=ShowTotals.Subtotals){const t=this._getKey(this._colBindings[i]),s=this._getKey(this._colBindings[e]);if(t.values[a]!=s.values[a])return null}const t=o[this._colBindings[e]];switch(s){case ShowAs.DiffCol:n-=t;break;case ShowAs.DiffColPct:n=(n-t)/t;break;case ShowAs.PctPrevCol:n/=t}return n}if(t>l)break}return s==ShowAs.PctPrevCol?1:null}_getShowRowTotals(){return this._valueFields.length?this._showRowTotals:ShowTotals.None}_getShowColTotals(){return this._valueFields.length?this._showColTotals:ShowTotals.None}_getUniqueValues(e){return this._server?this._server.getUniqueValues(e):null}_generateFields(){this._viewLists.forEach(e=>{e.clear()});for(let e=0;e<this.fields.length;e++){if(this.fields[e]._autoGenerated){this.fields.removeAt(e);e--}}if(this._server){this._server.getFields().forEach(e=>{const t=this._createField(e,!0);this.fields.getField(t.header)||this.fields.push(t)});return}const e=this.collectionView,t=e?e.items:null;t&&t.length&&this.autoGenerateFields&&wijmo_1.getTypes(t,0).forEach(e=>{const t=this._createField({binding:e.binding,header:wijmo_1.toHeaderCase(e.binding),dataType:e.dataType},!0);this.fields.getField(t.header)||this.fields.push(t)})}_updateFieldTypes(){const e=this.collectionView,t=e?e.sourceCollection:null;t&&t.length&&this.fields.forEach(e=>{this._updateFieldType(e,t)})}_updateFieldType(e,t){if(e._hasSubFields())e.subFields.forEach(e=>{this._updateFieldType(e,t)});else{if(null==e.dataType&&e.binding)for(let i=0;i<t.length;i++){const s=e._binding.getValue(t[i]);if(null!=s){e.dataType=wijmo_1.isPrimitive(s)?wijmo_1.getType(s):null;break}}if(null!=e.dataType){e.format||(e.format=e.dataType==wijmo_1.DataType.Date?"d":"n0");e.aggregate==wijmo_1.Aggregate.Sum&&e.dataType!=wijmo_1.DataType.Number&&(e.aggregate=wijmo_1.Aggregate.Cnt)}}}_createField(e,t){let i;if(wijmo_1.isString(e))i=new PivotField(this,e);else if(e){e.key&&delete e.key;i=null!=e.dimensionType?new CubePivotField(this,e.binding,e.header,e):new PivotField(this,e.binding,e.header,e);null!=e.dataType&&(i.dataType=e.dataType)}i._autoGenerated=t;if(t||wijmo_1.isString(e)){i.format=i.dataType==wijmo_1.DataType.Date?"d":"n0";i.aggregate=i.dataType==wijmo_1.DataType.Number?wijmo_1.Aggregate.Sum:wijmo_1.Aggregate.Cnt}e&&!wijmo_1.isString(e)&&wijmo_1.copy(i,e);return i}_cvCollectionChanged(e,t){this.invalidate()}_fieldListChanged(e,t){if(t.action==wijmo_1.NotifyCollectionChangedAction.Add){const i=e;for(let e=0;e<i.length-1;e++)if(i[e].key)for(let t=e+1;t<i.length;t++)if(i[e].key==i[t].key){i.removeAt(t);t--}if(i!=this._fields)if(this._fields.getField(t.item.key)){for(let e=0;e<this._viewLists.length;e++)if(this._viewLists[e]!=i){const i=this._viewLists[e],s=i.indexOf(t.item);s>-1&&i.removeAt(s)}}else i.removeAt(t.index);if(wijmo_1.isNumber(i.maxItems)&&i.maxItems>-1)for(;i.length>i.maxItems;){let e=i.length-1;i[e]==t.item&&e>0&&e--;i.removeAt(e)}}this.onViewDefinitionChanged();this.invalidate()}_fieldPropertyChanged(e,t){this.onViewDefinitionChanged();if(!e.isActive)return;const i=t.propertyName;"visible"!=i&&("width"!=i&&"wordWrap"!=i&&"isContentHtml"!=i?"format"==i&&this.valueFields.indexOf(e)>-1?this._pivotView.refresh():"showAs"!=i?"descending"!=i?"aggregate"!=i?this.invalidate():this.valueFields.indexOf(e)>-1&&!this.isUpdating&&(this._server?this._updateView():this._updatePivotView()):this._updatePivotView():this.valueFields.indexOf(e)>-1&&!this.isUpdating&&this._updatePivotView():this._pivotView.refresh())}_copyProps(e,t,i){for(let s=0;s<i.length;s++){const l=i[s];null!=t[l]&&(e[l]=t[l])}}_getFieldFromDefinition(e){const t=e.filter;e.filter&&delete e.filter;const i=this._createField(e,!0);if(t){i._setFilterProxy(t);e.filter=t}return i}_getFieldDefinition(e){const t={binding:e.binding,header:e.header,dataType:e.dataType,aggregate:e.aggregate,showAs:e.showAs,descending:e.descending,format:e.format,align:e.align,wordWrap:e.wordWrap,width:e.width,isContentHtml:e.isContentHtml};e.weightField&&(t.weightField=e.weightField._getName());e.key&&(t.key=e.key);e.filter.isActive&&(t.filter=e._getFilterProxy());if(e._hasSubFields()){t.subFields=[];e.subFields.forEach(e=>{t.subFields.push(this._getFieldDefinition(e))})}e instanceof CubePivotField&&(t.dimensionType=e.dimensionType);return t}_getFieldCollectionProxy(e){const t={items:[]};wijmo_1.isNumber(e.maxItems)&&e.maxItems>-1&&(t.maxItems=e.maxItems);for(let i=0;i<e.length;i++){const s=e[i];t.items.push(s.key)}return t}_setFieldCollectionProxy(e,t){e.clear();e.maxItems=wijmo_1.isNumber(t.maxItems)?t.maxItems:null;for(let i=0;i<t.items.length;i++)e.push(t.items[i])}dispose(){this.isDisposed=!0;if(this._cv){this._cv.collectionChanged.removeHandler(this._cvCollectionChanged,this);this._cv=null}if(this._server){this._server.clearPendingRequests();this._server=null}this._fields&&this._fields.collectionChanged&&this._fields.collectionChanged.removeHandler(this._fieldListChanged,this);this._viewLists.forEach(e=>{e.collectionChanged&&e.collectionChanged.removeHandler(this._fieldListChanged,this)});this._tallies=null;this._keys=null;this._activeFilterFields=null;if(this._toInv){clearTimeout(this._toInv);this._toInv=null}if(this._toUpdateTallies){clearTimeout(this._toUpdateTallies);this._toUpdateTallies=null}if(this.edt){this.edt.dispose();this.edt=null}if(this._dlg){this._dlg.dispose();this._dlg=null}this._items=null;if(this._fields){this._fields.clear();this._fields=null}if(this._rowFields){this._rowFields.clear();this._rowFields=null}if(this._columnFields){this._columnFields.clear();this._columnFields=null}if(this._valueFields){this._valueFields.clear();this._valueFields=null}if(this._filterFields){this._filterFields.clear();this._filterFields=null}this._serverParms=null;this._colBindings=null;delete this.isDisposed}}PivotEngine._BATCH_SIZE=1e4;PivotEngine._BATCH_TIMEOUT=0;PivotEngine._BATCH_DELAY=100;PivotEngine._props=["showZeros","showRowTotals","showColumnTotals","totalsBeforeData","sortableGroups","defaultFilterType"];exports.PivotEngine=PivotEngine;class ProgressEventArgs extends wijmo_1.EventArgs{constructor(e){super();this._progress=wijmo_1.asNumber(e)}get progress(){return this._progress}}exports.ProgressEventArgs=ProgressEventArgs;class _ListContextMenu extends wijmo_input_1.Menu{constructor(e){super(document.createElement("div"),{header:"Field Context Menu",displayMemberPath:"text",commandParameterPath:"parm",command:{executeCommand:e=>{this._execute(e)},canExecuteCommand:e=>this._canExecute(e)}});this._full=e;this.itemsSource=this._getMenuItems(e);wijmo_1.addClass(this.dropDown,"context-menu "+exports._GridContextMenuClsNames.hostElement)}static get controlTemplate(){_ListContextMenu._ctrlTemplate||(_ListContextMenu._ctrlTemplate=wijmo_input_1.Menu.controlTemplate);return _ListContextMenu._ctrlTemplate}static set controlTemplate(e){_ListContextMenu._ctrlTemplate=e}refresh(e=!0){this.itemsSource=this._getMenuItems(this._full);super.refresh(e)}attach(e){wijmo_1.assert(e instanceof wijmo_grid_1.FlexGrid,"Expecting a FlexGrid control...");const t=e.hostElement;this._contextMenuHandler=i=>{if(this._selectField(e,i)){i.preventDefault();this.owner=t;this.show(i)}};t.addEventListener("contextmenu",this._contextMenuHandler)}_selectField(e,t){const i=e.hitTest(t);if(i.panel!=e.cells||!i.range.isValid)return!1;const s=e.rows[i.row].dataItem;if(s instanceof CubePivotField&&s.subFields&&s.subFields.length)return!1;e.select(i.range,!0);return!0}_getMenuItems(e){let t;t=e?[{text:'<div class="menu-icon"></div>*',parm:"up"},{text:'<div class="menu-icon"></div>*',parm:"down"},{text:'<div class="menu-icon"></div>*',parm:"first"},{text:'<div class="menu-icon"></div>*',parm:"last"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:`<div class="menu-icon"><span class=${wijmo_1.GlyphClsNames.filter}></span></div>*`,parm:"filter"},{text:'<div class="menu-icon">≡</div>*',parm:"rows"},{text:'<div class="menu-icon">⫴</div>*',parm:"cols"},{text:'<div class="menu-icon">Σ</div>*',parm:"vals"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:'<div class="menu-icon menu-icon-remove">✖</div>*',parm:"remove"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:'<div class="menu-icon">⛭</div>*',parm:"edit"}]:[{text:`<div class="menu-icon"><span class=${wijmo_1.GlyphClsNames.filter}></span></div>*`,parm:"filter"},{text:'<div class="menu-icon">≡</div>*',parm:"rows"},{text:'<div class="menu-icon">⫴</div>*',parm:"cols"},{text:'<div class="menu-icon">Σ</div>*',parm:"vals"},{text:`<div class="${wijmo_1.UtilitesClsNames.separator}"></div>`},{text:'<div class="menu-icon">⛭</div>*',parm:"edit"}];for(let e=0;e<t.length;e++){const i=t[e];if(i.parm){const e=wijmo_1.culture.olap._ListContextMenu[i.parm];wijmo_1.assert(e,"missing localized text for item "+i.parm);i.text=i.text.replace(/([^>]+$)/,e)}}return t}_execute(e){const t=wijmo_1.Control.getControl(this.owner),i=t.itemsSource,s=t.selection.row,l=t.rows[s].dataItem,o=l?l.engine:null,n=this._getTargetList(o,e);switch(e){case"up":case"first":case"down":case"last":if(o){const t=i.indexOf(l),s="up"==e?t-1:"first"==e?0:"down"==e?t+1:"last"==e?i.length:-1;o.deferUpdate(()=>{i.removeAt(t);i.insert(s,l)})}break;case"filter":case"rows":case"cols":case"vals":n&&l&&n.push(l);break;case"remove":l&&o.removeField(l);break;case"edit":l&&o.editField(l)}}_canExecute(e){const t=wijmo_1.Control.getControl(this.owner);if(!t)return!1;const i=t.selection.row,s=i>-1?t.rows[i].dataItem:null,l=s?s.engine:null,o=this._getTargetList(l,e),n=!!s&&s instanceof CubePivotField,r=!!s&&s.isMeasure;switch(e){case"up":case"first":return i>0;case"down":case"last":return i<t.rows.length-1;case"filter":case"rows":case"cols":return!r&&o&&o.indexOf(s)<0;case"vals":return(!n||r)&&o&&o.indexOf(s)<0;case"edit":return l&&l.allowFieldEditing;case"detail":return s&&!n}return!0}_getTargetList(e,t){if(e)switch(t){case"filter":return e.filterFields;case"rows":return e.rowFields;case"cols":return e.columnFields;case"vals":return e.valueFields}return null}dispose(){if(this.owner instanceof HTMLElement){this.owner.removeEventListener("contextmenu",this._contextMenuHandler);this._contextMenuHandler=null;this._owner=null}this.itemsSource=null;super.dispose()}}_ListContextMenu._ctrlTemplate="";exports._ListContextMenu=_ListContextMenu;class PivotPanel extends wijmo_1.Control{constructor(e,t){super(e,null,!0);this._showIcons=!0;this._restrictDrag=null;this.deferredUpdateChanged=new wijmo_1.Event;this.itemsSourceChanged=new wijmo_1.Event;this.viewDefinitionChanged=new wijmo_1.Event;this.updatingView=new wijmo_1.Event;this.updatedView=new wijmo_1.Event;this._isUpdatingChangedBnd=this._isUpdatingChanged.bind(this);const i=this.getTemplate();this.applyTemplate(`${wijmo_1.ControlClsNames.hostElement} ${wijmo_1.ControlClsNames.content} ${exports.PivotPanelClsNames.hostElement}`,i,{_dFields:"d-fields",_dFilters:"d-filters",_dRows:"d-rows",_dCols:"d-cols",_dVals:"d-vals",_dProgress:"d-prog",_btnUpdate:"btn-update",_chkDefer:"chk-defer",_gFlds:"g-flds",_gDrag:"g-drag",_gFlt:"g-flt",_gCols:"g-cols",_gRows:"g-rows",_gVals:"g-vals",_gDefer:"g-defer"});this._globalize();const s=this.hostElement;this.addEventListener(s,"dragstart",this._dragstart.bind(this));this.addEventListener(s,"dragover",this._dragover.bind(this));this.addEventListener(s,"dragleave",this._dragover.bind(this));this.addEventListener(s,"drop",this._drop.bind(this));this.addEventListener(s,"dragend",this._dragend.bind(this));this._lbFields=this._createFieldGrid(this._dFields);this._lbFilters=this._createFieldGrid(this._dFilters);this._lbRows=this._createFieldGrid(this._dRows);this._lbCols=this._createFieldGrid(this._dCols);this._lbVals=this._createFieldGrid(this._dVals);this._ctxMenuShort=new _ListContextMenu(!1);let l=this._ctxMenuShort;l.attach(this._lbFields);l=this._ctxMenuFull=new _ListContextMenu(!0);l.attach(this._lbFilters);l.attach(this._lbRows);l.attach(this._lbCols);l.attach(this._lbVals);this._dMarker=wijmo_1.createElement(`<div class="${wijmo_grid_1.FlexGridClsNames.marker}" style="display:none"> </div>`);this.hostElement.appendChild(this._dMarker);this.addEventListener(this._btnUpdate,"click",e=>{this._ng.refresh(!0);this.refresh();e.preventDefault()});this.addEventListener(this._chkDefer,"click",e=>{this.deferredUpdate=this._chkDefer.checked;this._updateDeferredUpdateElements()});this.engine=new PivotEngine;this.initialize(t)}static get controlTemplate(){PivotPanel._ctrlTemplate||(PivotPanel._ctrlTemplate=`<div><label wj-part="g-flds"></label><div wj-part="d-fields"></div><label wj-part="g-drag"></label><table><tr><td width="50%"><label><span class="${wijmo_1.GlyphClsNames.glyph} ${wijmo_1.GlyphClsNames.filter}"></span> <span wj-part="g-flt"></span></label><div wj-part="d-filters"></div></td><td width= "50%" style="border-left-style:solid"><label><span class=${wijmo_1.GlyphClsNames.glyph}>⫴</span> <span wj-part="g-cols"></span></label><div wj-part="d-cols"></div></td></tr><tr style="border-top-style:solid"><td width="50%"><label><span class=${wijmo_1.GlyphClsNames.glyph}>≡</span> <span wj-part="g-rows"></span></label><div wj-part="d-rows"></div></td><td width= "50%" style="border-left-style:solid"><label><span class=${wijmo_1.GlyphClsNames.glyph}>Σ</span> <span wj-part="g-vals"></span></label><div wj-part="d-vals"></div></td></tr></table><div wj-part="d-prog" class=${wijmo_1.ControlStateClsNames.selected} style="width:0px;height:3px"></div><div style="display:table"><label style="display:table-cell;vertical-align:middle"><input wj-part="chk-defer" type="checkbox"/> <span wj-part="g-defer"></span></label><button wj-part="btn-update" class="${wijmo_1.InputFormElementsClsNames.btn} ${wijmo_1.ControlStateClsNames.disabled}" style="float:right;margin:6px" disabled></button></div></div>`);return PivotPanel._ctrlTemplate}static set controlTemplate(e){PivotPanel._ctrlTemplate=e}_getProductInfo(){return"D6F4,PivotPanel"}get engine(){return this._ng}set engine(e){let t,i=this._ng;if(i){i.itemsSourceChanged.removeHandler(this._itemsSourceChanged);i.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged);i.updatingView.removeHandler(this._updatingView);i.updatedView.removeHandler(this._updatedView);i.error.removeHandler(this._requestError);i._isUpdatingChanged.removeHandler(this._isUpdatingChangedBnd);t=this.deferredUpdate}e=wijmo_1.asType(e,PivotEngine,!1);i=this._ng=e;i.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);i.viewDefinitionChanged.addHandler(this._viewDefinitionChanged,this);i.updatingView.addHandler(this._updatingView,this);i.updatedView.addHandler(this._updatedView,this);i.error.addHandler(this._requestError,this);i._isUpdatingChanged.addHandler(this._isUpdatingChangedBnd);t!==this.deferredUpdate&&this.onDeferredUpdateChanged();this._lbFields.itemsSource=e.fields;this._lbFilters.itemsSource=e.filterFields;this._lbRows.itemsSource=e.rowFields;this._lbCols.itemsSource=e.columnFields;this._lbVals.itemsSource=e.valueFields;this._filterFieldVisibleWithRoot=e=>e.visible&&null==e.parentField;this._filterFieldVisibleOnly=e=>e.visible;this._lbFields.collectionView.filter=this._filterFieldVisibleWithRoot;"Filters,Rows,Cols,Vals".split(",").forEach(e=>{this["_lb"+e].collectionView.filter=this._filterFieldVisibleOnly});this._updateDeferredUpdateElements()}get itemsSource(){return this._ng.itemsSource}set itemsSource(e){e instanceof PivotEngine?this.engine=e:this._ng.itemsSource=e}get collectionView(){return this._ng.collectionView}get pivotView(){return this._ng.pivotView}get autoGenerateFields(){return this.engine.autoGenerateFields}set autoGenerateFields(e){this._ng.autoGenerateFields=e}get fields(){return this._ng.fields}get rowFields(){return this._ng.rowFields}get columnFields(){return this._ng.columnFields}get valueFields(){return this._ng.valueFields}get filterFields(){return this._ng.filterFields}get viewDefinition(){return this._ng.viewDefinition}set viewDefinition(e){this._ng.viewDefinition=e}get isViewDefined(){return this._ng.isViewDefined}get showFieldIcons(){return this._showIcons}set showFieldIcons(e){if(e!=this._showIcons){this._showIcons=wijmo_1.asBoolean(e);this.invalidate()}}get restrictDragging(){return this._restrictDrag}set restrictDragging(e){this._restrictDrag=wijmo_1.asBoolean(e,!0)}get deferredUpdate(){return this.engine.isUpdating}set deferredUpdate(e){this.deferredUpdate!=e&&(e?this._ng.beginUpdate():this._ng.endUpdate())}onDeferredUpdateChanged(e){this.deferredUpdateChanged.raise(this,e)}onItemsSourceChanged(e){this.itemsSourceChanged.raise(this,e)}onViewDefinitionChanged(e){this.viewDefinitionChanged.raise(this,e)}onUpdatingView(e){this.updatingView.raise(this,e)}onUpdatedView(e){this.updatedView.raise(this,e)}refresh(e=!0){if(this.hostElement){["Fields","Filters","Rows","Cols","Vals"].forEach(e=>{const t=this["_lb"+e],i=t?t.collectionView:null;if(t&&i){t.refresh();i.refresh()}});if(e){this._globalize();this._ctxMenuShort.refresh();this._ctxMenuFull.refresh()}}super.refresh(e)}_copy(e,t){switch(e){case"engine":this.engine=t;return!0}return!1}_globalize(){const e=wijmo_1.culture.olap.PivotPanel;wijmo_1.setText(this._gFlds,e.fields);wijmo_1.setText(this._gDrag,e.drag);wijmo_1.setText(this._gFlt,e.filters);wijmo_1.setText(this._gCols,e.cols);wijmo_1.setText(this._gRows,e.rows);wijmo_1.setText(this._gVals,e.vals);wijmo_1.setText(this._gDefer,e.defer);wijmo_1.setText(this._btnUpdate,e.update)}_itemsSourceChanged(e,t){this.onItemsSourceChanged(t)}_viewDefinitionChanged(e,t){this.invalidate();this.onViewDefinitionChanged(t)}_updatingView(e,t){const i=wijmo_1.clamp(t.progress,5,100)%100;this._dProgress.style.width=i+"%";this.onUpdatingView(t)}_updatedView(e,t){this.onUpdatedView(t)}_requestError(e,t){this._dProgress.style.width="0"}_isUpdatingChanged(){this._updateDeferredUpdateElements();this.onDeferredUpdateChanged()}_updateDeferredUpdateElements(){const e=this.deferredUpdate;this._chkDefer.checked=e;wijmo_1.enable(this._btnUpdate,e)}_createFieldGrid(e){const t=new wijmo_grid_1.FlexGrid(e,{autoGenerateColumns:!1,childItemsPath:"subFields",columns:[{binding:"header",width:"*"}],headersVisibility:"None",selectionMode:"Cell",alternatingRowStep:0});t.cells.hostElement.parentElement.style.overflowX="hidden";t.formatItem.addHandler((e,t)=>{const i=e.rows[t.row].dataItem;wijmo_1.assert(i instanceof PivotField,"PivotField expected...");const s=i._hasSubFields();wijmo_1.toggleClass(t.cell,exports.PivotPanelClsNames.header,s);t.cell.setAttribute("draggable",(!s).toString());let l=t.cell.innerHTML;i.filter.isActive&&(l+=` <span class=${wijmo_1.GlyphClsNames.filter}></span>`);e!=this._lbVals||wijmo_1.isFunction(i.getAggregateValue)||(l+=` <span class="${exports.PivotPanelClsNames.aggregate}">(${wijmo_1.Aggregate[i.aggregate]})</span>`);if(e==this._lbFields&&!s){if(this._showIcons){const e=i.isMeasure?"measure":"dimension";l=`<span class="${wijmo_1.GlyphClsNames.glyph}-${e}"></span> ${l}`}l=`<label><input type="checkbox"${i.isActive?" checked":""}> ${l}</label>`}t.cell.innerHTML=l});t.addEventListener(e,"click",e=>{const i=e.target;if(i instanceof HTMLInputElement&&"checkbox"==i.type){const s=this._hitTestField(t,e);s instanceof PivotField&&(s.isActive=i.checked)}});return t}_dragstart(e){const t=this._getFlexGridTarget(e);if(t){this._dragField=this._hitTestField(t,e);this._dragSource=this._dragField instanceof PivotField?t.hostElement:null;if(this._dragSource&&e.dataTransfer){wijmo_1._startDrag(e.dataTransfer,"copyMove");e.stopPropagation()}}}_dragover(e){let t=!1;const i=this._getFlexGridTarget(e);if(i&&this._dragField){if(this._dragSource==this._dFields&&i!=this._lbFields){const e=i.itemsSource;if(null==e.maxItems||e.length<e.maxItems){const e=this._dragField;i.itemsSource.indexOf(e)<0?t=!0:i==this._lbVals&&(t=!(e instanceof CubePivotField))}}this._dragSource&&this._dragSource!=this._dFields&&(t=!0)}if(t&&this._getRestrictDrag()&&this._dragSource!=i.hostElement){const e=this._dragField.isMeasure;i==this._lbVals?t=e:i!=this._lbRows&&i!=this._lbCols||(t=!e)}if(t){this._updateDropMarker(i,e);e.dataTransfer.dropEffect=this._dragSource==this._dFields?"copy":"move";e.preventDefault();e.stopPropagation()}else this._updateDropMarker()}_drop(e){const t=this._getFlexGridTarget(e);if(t&&this._dragField){let e=wijmo_1.Control.getControl(this._dragSource),i=this._dragField;if(e==this._lbFields&&t==this._lbVals&&t.itemsSource.indexOf(i)>-1){i=i._clone();this.engine.fields.push(i)}t==this._lbFields?i.isActive=!1:this._ng.deferUpdate(()=>{const e=t.itemsSource,s=e.indexOf(i);if(s!=this._dropIndex){if(s>-1){e.removeAt(s);s<this._dropIndex&&this._dropIndex--}e.insert(this._dropIndex,i)}})}this._resetMouseState()}_dragend(e){this._resetMouseState()}_hitTestField(e,t){const i=e.hitTest(t.target);if(i.panel==e.cells&&i.range.isValid){e.select(i.range,!0);return e.rows[i.row].dataItem}return null}_getRestrictDrag(){let e=this._restrictDrag;null==e&&this.fields.length&&(e=this.fields[0]instanceof CubePivotField);return e}_resetMouseState(){this._dragSource=null;this._updateDropMarker()}_getFlexGridTarget(e){const t=wijmo_1.Control.getControl(wijmo_1.closest(e.target,"."+wijmo_grid_1.FlexGridClsNames.hostElement));return t instanceof wijmo_grid_1.FlexGrid?t:null}_updateDropMarker(e,t){if(!t){this._dMarker.style.display="none";return}let i,s=this.hostElement,l=s.getBoundingClientRect();if(e.rows.length){let l=e.hitTest(t).row;if(l>-1){i=e.getCellBoundingRect(l,0);if(t.clientY>s.scrollTop+i.top+i.height/2&&l<e.rows.length){i.top+=i.height;l++}this._dropIndex=l}else{l=e.viewRange.bottomRow;i=e.getCellBoundingRect(l,0);i.top+=i.height;this._dropIndex=l+1}}else{i=wijmo_1.Rect.fromBoundingRect(e.hostElement.getBoundingClientRect());i.top+=4;this._dropIndex=0}wijmo_1.setCss(this._dMarker,{left:Math.round(i.left-l.left)+s.scrollLeft,top:Math.round(i.top-l.top-2)+s.scrollTop,width:Math.round(i.width),height:4,display:""})}dispose(){this._lbFields&&this._lbFields.collectionView&&(this._lbFields.collectionView.filter=null);["Filters","Rows","Cols","Vals"].forEach(e=>{const t=this["_lb"+e];t&&t.collectionView&&(t.collectionView.filter=null)});if(this._ctxMenuShort){this._ctxMenuShort.dispose();this._ctxMenuShort=null}if(this._ctxMenuFull){this._ctxMenuFull.dispose();this._ctxMenuFull=null}if(this._lbFields){this._lbFields.dispose();this._lbFields=null}if(this._lbFilters){this._lbFilters.dispose();this._lbFilters=null}if(this._lbRows){this._lbRows.dispose();this._lbRows=null}if(this._lbCols){this._lbCols.dispose();this._lbCols=null}if(this._lbVals){this._lbVals.dispose();this._lbVals=null}if(this._ng){this._ng.itemsSourceChanged.removeHandler(this._itemsSourceChanged);this._ng.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged);this._ng.updatingView.removeHandler(this._updatingView);this._ng.updatedView.removeHandler(this._updatedView);this._ng.error.removeHandler(this._requestError);this._ng._isUpdatingChanged.removeHandler(this._isUpdatingChangedBnd)}this.engine.dispose();super.dispose()}}PivotPanel._ctrlTemplate="";exports.PivotPanel=PivotPanel;class PivotGrid extends wijmo_grid_1.FlexGrid{constructor(e,t){super(e);this._showDetailOnDoubleClick=!0;this._collapsibleSubtotals=!0;this._customCtxMenu=!0;this._ctxMenu=new _GridContextMenu;this._showRowFldSort=!1;this._showRowFldHdrs=!0;this._showColFldHdrs=!0;this._showValFldHdrs=!1;this._centerVert=!0;this._collapsedKeys={};this._resizingColumn=!1;this._outlineMode=!1;this._ignoreClick=!1;this._colRowFields=new Map;this._prevCulture=wijmo_1.culture.Globalize.name;this._hdrCols._setDefaultSize(this._cols.defaultSize);wijmo_1.addClass(this.hostElement,exports.PivotGridClsNames.hostElement);this.isReadOnly=!0;this.copyHeaders=wijmo_grid_1.HeadersVisibility.All;this.deferResizing=!0;this.alternatingRowStep=0;this.autoGenerateColumns=!1;this.allowDragging=wijmo_grid_1.AllowDragging.None;this.allowMerging=wijmo_grid_1.AllowMerging.All;this.mergeManager=new _PivotMergeManager;this.customContextMenu=!0;this.treeIndent=32;this.initialize(t);this.formatItem.addHandler(this._formatItem,this);var i=this.hostElement;this.addEventListener(i,"mousedown",this._mousedown.bind(this),!0);this.addEventListener(i,"mouseup",this._mouseup.bind(this),!0);this.addEventListener(i,"dblclick",this._dblclick.bind(this),!0);this.addEventListener(i,"click",this._click.bind(this),!0);this.addEventListener(i,"keydown",this._keydown.bind(this),!0);this._ctxMenu.attach(this)}static get controlTemplate(){PivotGrid._ctrlTemplate||(PivotGrid._ctrlTemplate=wijmo_grid_1.FlexGrid.controlTemplate);return PivotGrid._ctrlTemplate}static set controlTemplate(e){PivotGrid._ctrlTemplate=e}_getProductInfo(){return"D6F4,PivotGrid"}get engine(){return this._ng}get showDetailOnDoubleClick(){return this._showDetailOnDoubleClick}set showDetailOnDoubleClick(e){this._showDetailOnDoubleClick=wijmo_1.asBoolean(e)}get detailDialog(){this._dlgDetail||(this._dlgDetail=new DetailDialog(document.createElement("div")));return this._dlgDetail}get showRowFieldHeaders(){return this._showRowFldHdrs}set showRowFieldHeaders(e){if(e!=this._showRowFldHdrs){this._showRowFldHdrs=wijmo_1.asBoolean(e);this._updateFixedContent()}}get showColumnFieldHeaders(){return this._showColFldHdrs}set showColumnFieldHeaders(e){if(e!=this._showColFldHdrs){this._showColFldHdrs=wijmo_1.asBoolean(e);this._updateFixedContent()}}get showValueFieldHeaders(){return this._showValFldHdrs}set showValueFieldHeaders(e){if(e!=this._showValFldHdrs){this._showValFldHdrs=wijmo_1.asBoolean(e);this._updateFixedCounts();this._updateFixedContent()}}get showRowFieldSort(){return this._showRowFldSort}set showRowFieldSort(e){if(e!=this._showRowFldSort){this._showRowFldSort=wijmo_1.asBoolean(e);this._updateFixedContent()}}get customContextMenu(){return this._customCtxMenu}set customContextMenu(e){this._customCtxMenu=wijmo_1.asBoolean(e)}get collapsibleSubtotals(){return this._collapsibleSubtotals}set collapsibleSubtotals(e){if(e!=this._collapsibleSubtotals){this._collapsibleSubtotals=wijmo_1.asBoolean(e);this.invalidate()}}get centerHeadersVertically(){return this._centerVert}set centerHeadersVertically(e){if(e!=this._centerVert){this._centerVert=wijmo_1.asBoolean(e);this.invalidate()}}get outlineMode(){return this._outlineMode}set outlineMode(e){if(e!=this._outlineMode){this._outlineMode=wijmo_1.asBoolean(e);this._bindGrid(!0)}}getKeys(e,t){const i=this.rows[wijmo_1.asInt(e)],s=this.columns[wijmo_1.asInt(t)],l=i?i.dataItem:null,o=s?s.binding:null;return this._ng.getKeys(l,o)}getDetail(e,t){const i=this.rows[wijmo_1.asInt(e)].dataItem,s=this.columns[wijmo_1.asInt(t)].binding;return this._ng.getDetail(i,s)}getDetailView(e,t){const i=this.rows[wijmo_1.asInt(e)].dataItem,s=this.columns[wijmo_1.asInt(t)].binding;return this._ng.getDetailView(i,s)}showDetail(e,t){if(this._ng.valueFields.length){const i=this.detailDialog;i.showDetail(this,new wijmo_grid_1.CellRange(e,t));i.show(!0)}}collapseRowsToLevel(e){this._collapseRowsToLevel(e)}collapseColumnsToLevel(e){this._collapseColsToLevel(e)}_getQuickAutoSize(){return wijmo_1.isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter}_bindGrid(e){this.deferUpdate(()=>{let t=this.preserveOutlineState||this._resizingColumn,i=this._collapsedKeys,s=this.rows,l=this.columns;t||(i=this._collapsedKeys={});super._bindGrid(e);if(this._ng&&t&&!wijmo_1.isEmpty(i)){let e=this._ng.totalsBeforeData,t=e?s.length-1:0,o=e?-1:s.length,n=e?-1:1;for(let e=t;e!=o;e+=n){const t=s[e].dataItem,l=t?t[_PivotKey._ROW_KEY_NAME]:null;l&&l.level>=0&&i[l.toString()]&&this._setRowCollapsed(new wijmo_grid_1.CellRange(e,l.level-1),!0)}t=e?l.length-1:0;o=e?-1:l.length;n=e?-1:1;for(let e=t;e!=o;e+=n){const t=l[e].binding,s=this._ng._getKey(t);s&&s.level>0&&i[s.toString()]&&this._setColCollapsed(new wijmo_grid_1.CellRange(s.level-1,e),!0)}}})}_getCollectionView(e){e instanceof PivotPanel?e=e.engine.pivotView:e instanceof PivotEngine&&(e=e.pivotView);return wijmo_1.asCollectionView(e)}refresh(e=!0){this._ctxMenu.refresh();const t=wijmo_1.culture.Globalize.name;if(this._prevCulture!==t){this._prevCulture=t;this._updateFixedContent()}super.refresh(e)}onItemsSourceChanged(e){if(this._ng){this._ng.updatingView.removeHandler(this._updatingView,this);this._ng.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged,this);this._ng._hasDeferredUpdatesChanged.removeHandler(this._hasDeferredUpdatesChanged,this)}this._collapsedKeys={};const t=this.collectionView;this._ng=t instanceof PivotCollectionView?t.engine:null;if(this._ng){this._ng.updatingView.addHandler(this._updatingView,this);this._ng.viewDefinitionChanged.addHandler(this._viewDefinitionChanged,this);this._ng._hasDeferredUpdatesChanged.addHandler(this._hasDeferredUpdatesChanged,this)}this._updatingView();this._bindGrid(!0);super.onItemsSourceChanged(e)}onResizedColumn(e){const t=this._ng;if(t){this._resizingColumn=!0;if(e.panel.columns==this.rowHeaders.columns){const t=this._colRowFields.get(e.getColumn());t instanceof PivotField&&(t.width=e.panel.columns[e.col].renderWidth)}if(e.panel.columns==this.columnHeaders.columns){const i=t.valueFields;if(i.length>0){i[e.col%i.length].width=e.panel.columns[e.col].renderWidth}}this._resizingColumn=!1}super.onResizedColumn(e)}onSortingColumn(e){const t=this._ng;return(!t||!t.isUpdating)&&super.onSortingColumn(e)}onDraggingColumn(e){const t=this._ng;return(!t||!t.isUpdating)&&super.onDraggingColumn(e)}onDraggedColumn(e){const t=this._ng;if(t&&e.panel.columns==this.topLeftCells.columns){const i=t.rowFields,s=i[e.data.col];t.deferUpdate(()=>{i.removeAt(e.data.col);i.insert(e.col,s)})}super.onDraggedColumn(e)}_updatingView(){this._updateFixedCounts();this.columns.clear();this.rows.clear()}_viewDefinitionChanged(){this._resizingColumn||(this._collapsedKeys={})}_hasDeferredUpdatesChanged(){const e=this.engine,t=e&&e.hasDeferredUpdates,i=this.hostElement.querySelectorAll("."+PivotGrid._WJC_COLLAPSE);for(let e=0;e<i.length;e++)s=i[e],wijmo_1.toggleClass(s,PivotGrid._WJC_DISABLED,t);var s}onLoadedRows(e){0==this.columns.length&&this._generateColumns();this._updateFixedCounts();this._updateFixedContent();super.onLoadedRows(e)}_generateColumns(){const e=this.collectionView,t=e?e.sourceCollection:null,i=t&&t.length,s=this.engine;if(s&&i){const e=Object.keys(t[0]).filter(e=>e!=_PivotKey._ROW_KEY_NAME),i=[wijmo_1.Aggregate.Cnt,wijmo_1.Aggregate.CntAll];for(let t=0;t<e.length;t++){const l=s._getFieldByColKey(e[t]);this.columns.push(new wijmo_grid_1.Column({binding:e[t],dataType:l&&-1===i.indexOf(l.aggregate)?l.dataType:wijmo_1.DataType.Number,allowMerging:!0}))}}}_updateFixedCounts(){let e,t=this._ng,i=t&&t.isViewDefined;e=Math.max(1,i?t.rowFields.length:1);const s=this.topLeftCells.columns;s.clear();this._colRowFields.clear();for(let l=0;l<e;l++){const e=new wijmo_grid_1.Column({allowMerging:!0});s.push(e);i&&this._colRowFields.set(e,t.rowFields[l])}e=Math.max(1,i?t.columnFields.length:1);t&&t.columnFields.length&&(t.valueFields.length>1||this.showValueFieldHeaders)&&e++;const l=this.topLeftCells.rows;l.clear();for(let t=0;t<e;t++)l.push(new wijmo_grid_1.Row)}_updateFixedContent(){const e=this._ng;if(!e||!e.isViewDefined){this.topLeftCells.setCellData(0,0,null);return}const t=e.rowFields,i=e.columnFields,s=e.valueFields,l=this.outlineMode?t.map(e=>e.header).join(" / "):"";let o=this.topLeftCells;for(let e=0;e<o.rows.length;e++)for(let s=0;s<o.columns.length;s++){let n="";this.showRowFieldHeaders&&s<t.length&&e==o.rows.length-1&&(n=this.outlineMode?l:t[s].header);this.showColumnFieldHeaders&&!n&&e<i.length&&0==s&&(n=i[e].header+":");o.setCellData(e,s,n,!1,!1)}o=this.rowHeaders;for(let e=0;e<o.rows.length;e++){const t=o.rows[e].dataItem[_PivotKey._ROW_KEY_NAME];wijmo_1.assert(t instanceof _PivotKey,"missing PivotKey for row...");for(let i=0;i<o.columns.length;i++){const s=t.getValue(i,!0);o.setCellData(e,i,s,!1,!1)}}o=this.columnHeaders;for(let t=0;t<o.columns.length;t++){const l=e._getKey(o.columns[t].binding);wijmo_1.assert(l instanceof _PivotKey,"missing PivotKey for column...");for(let e=0;e<o.rows.length;e++){let n=l.getValue(e,!0);e==o.rows.length-1&&s.length&&(s.length>1||0==i.length||l.level>-1||this.showValueFieldHeaders)&&(n=s[t%s.length].header);o.setCellData(e,t,n,!1,!1)}}o=this.topLeftCells;for(let e=0;e<o.columns.length;e++){const i=o.columns[e],s=e<t.length?t[e]:null;i.wordWrap=s?s.wordWrap:null;i.align=s?s.align:null;if(this.outlineMode&&e<o.columns.length-1){i.width=this.treeIndent;i.allowResizing=!1}else{i.allowResizing=!0;i.width=s&&wijmo_1.isNumber(s.width)?s.width:null}}o=this.cells;for(let e=0;e<o.columns.length;e++){const t=o.columns[e],i=s.length?s[e%s.length]:null;t.width=i&&wijmo_1.isNumber(i.width)?i.width:null;t.wordWrap=i?i.wordWrap:null;t.format=i?i.format:null;t.align=i?i.align:null}this.invalidate()}_updateDefaultSizes(){const e=super._updateDefaultSizes();this._hdrCols._setDefaultSize(4*e);return e}_formatItem(e,t){const i=this._ng,s=t.panel,l=t.cell;if(!i)return;if(s==this.topLeftCells){const e=0==i.rowFields.length||t.row<s.rows.length-1||t.row==s.rows.length-1&&!this.showRowFieldHeaders;wijmo_1.toggleClass(l,exports.PivotGridClsNames.colFieldHdr,e);wijmo_1.toggleClass(l,exports.PivotGridClsNames.rowFieldHdr,!e)}let o,n=null;s==this.topLeftCells&&t.row==s.rows.length-1&&this.allowDragging&wijmo_grid_1.AllowDragging.Columns&&(n=!0);wijmo_1.setAttribute(l,"draggable",n);switch(s){case this.rowHeaders:o=i.rowFields[t.col%i.rowFields.length];break;case this.columnHeaders:o=i.columnFields[t.row];break;case this.cells:o=i.valueFields[t.col]}o&&o.isContentHtml&&(l.innerHTML=l.textContent);const r=s.columns[t.col].binding,a=s.rows==this.rows?i._getRowLevel(t.row):-1,h=s.columns==this.columns?i._getColLevel(r):-1;wijmo_1.toggleClass(l,exports.PivotPanelClsNames.aggregate,a>-1||h>-1);if(this._collapsibleSubtotals){if(s==this.rowHeaders&&i._getShowRowTotals()==ShowTotals.Subtotals)if(this.outlineMode){const e=this._getGroupedRows(t.range);if(t.col<i.rowFields.length-1){if(!e.containsRow(t.row)){const e=this._getRowCollapsed(t.range);l.innerHTML=this._getCollapsedGlyph(e)+l.innerHTML}}}else{const e=this.getMergedRange(s,t.row,t.col,!1)||t.range;if(t.col<i.rowFields.length-1&&e.rowSpan>1){const t=this._getRowCollapsed(e);l.innerHTML=this._getCollapsedGlyph(t)+l.innerHTML}}this.outlineMode&&s==this.rowHeaders&&t.range.rightCol<s.columns.length-1&&(l.innerHTML="");if(s==this.columnHeaders&&i._getShowColTotals()==ShowTotals.Subtotals){const e=this.getMergedRange(s,t.row,t.col,!1)||t.range;if(t.row<i.columnFields.length-1&&e.columnSpan>1){const t=this._getColCollapsed(e);l.innerHTML=this._getCollapsedGlyph(t)+l.innerHTML}}}if(s==this.topLeftCells&&this.showRowFieldSort&&t.col<i.rowFields.length&&t.row==this._getSortRowIndex()){o=i.rowFields[t.col];wijmo_1.toggleClass(l,wijmo_grid_1.FlexGridClsNames.sortAsc,!o.descending);wijmo_1.toggleClass(l,wijmo_grid_1.FlexGridClsNames.sortDesc,o.descending);l.innerHTML+=` <span class="${wijmo_1.GlyphClsNames.glyph}-${o.descending?"down":"up"}"></span>`}s!=this.cells&&wijmo_1.toggleClass(l,wijmo_1.UtilitesClsNames.alignVCenter,this._centerVert)}_getCollapsedGlyph(e){const t=this.engine,i=t&&t.hasDeferredUpdates;return`<div class="${PivotGrid._WJC_COLLAPSE+(i?" "+PivotGrid._WJC_DISABLED:"")}"><span class="${wijmo_1.GlyphClsNames.glyph}-${e?"plus":"minus"}"></span></div>`}_mousedown(e){if(e.defaultPrevented||0!=e.button){this._htDown=null;return}this._htDown=this.hitTest(e);const t=this._htDown,i=t.panel;this._ignoreClick=!1;const s=this.engine,l=s&&s.hasDeferredUpdates,o=wijmo_1.closestClass(e.target,PivotGrid._WJC_COLLAPSE);if(!l&&null!=o&&null!=i){let s,l=t.range;switch(i.cellType){case wijmo_grid_1.CellType.RowHeader:{const t=this.getMergedRange(i,l.row,l.col);t&&l.copy(t);s=this._getRowCollapsed(l);e.shiftKey||e.ctrlKey?this._collapseRowsToLevel(l.col+(s?2:1)):this._setRowCollapsed(l,!s);break}case wijmo_grid_1.CellType.ColumnHeader:s=this._getColCollapsed(l);e.shiftKey||e.ctrlKey?this._collapseColsToLevel(l.row+(s?2:1)):this._setColCollapsed(l,!s)}e.preventDefault();this._ignoreClick=!0;this._htDown=null;this.focus()}}_mouseup(e){if(!this._htDown||e.defaultPrevented)return;if(this._mouseHdl._szRowCol)return;const t=this.hitTest(e);if(this._htDown.panel!=t.panel||!t.range.equals(this._htDown.range))return;const i=this._ng,s=this.topLeftCells;if(t.panel==s&&t.row==s.rows.length-1&&t.col>-1){const s=t.getColumn();if(this.allowSorting&&s.allowSorting&&!t.edgeRight){const e=this._colRowFields.get(s);if(e&&!i.isUpdating){const s=new wijmo_grid_1.CellRangeEventArgs(t.panel,t.range);if(this.onSortingColumn(s)){i.pivotView.sortDescriptions.clear();e.descending=!e.descending;this.onSortedColumn(s)}}}e.preventDefault();this._ignoreClick=!0}}_click(e){this._ignoreClick&&e.preventDefault()}_dblclick(e){if(!e.defaultPrevented&&this._showDetailOnDoubleClick){const e=this._htDown;if(e&&e.panel==this.cells){const t=this._ng;t&&t.fields.length>0&&(t.fields[0]instanceof CubePivotField||this.showDetail(e.row,e.col))}}}_keydown(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&this.collapsibleSubtotals){const t=this.selection;if(t.isValid){let i=this._getRowLevel(t.topRow);i<0&&(i=this.rowHeaders.columns.length-1);const s=this._getKeyCode(e);switch(s){case wijmo_1.Key.Left:case wijmo_1.Key.Right:{const l=new wijmo_grid_1.CellRange(t.row,i-1);this._setRowCollapsed(l,s==wijmo_1.Key.Left);e.preventDefault();break}}}}}_getRowLevel(e){return this._ng._getRowLevel(e)}_getGroupedRows(e){let t,i=this._getRowLevel.bind(this),s=e.col+1,l=this.rows.length,o=this._ng.totalsBeforeData,n=e.row;if(0==i(n)){n=o?1:0;t=o?l-1:l-2}else{if(o)for(;n<l&&!(i(n)<0);n++);else for(;n>=0&&!(i(n)<0);n--);for(;n>0;n--){const e=i(n-1);if(e>=0&&e<=s)break}for(t=n;t<l-1;t++){const e=i(t+1);if(e>=0&&e<=s)break}}wijmo_1.assert(t>=n,"group end < start?");return t>=n?new wijmo_grid_1.CellRange(n,e.col,t,e.col2):e}_toggleRowCollapsed(e){this._setRowCollapsed(e,!this._getRowCollapsed(e))}_getRowCollapsed(e){e=this._getGroupedRows(e);const t=this._ng.totalsBeforeData?e.row-1:e.row2+1,i=this.rows[t]||this.rows[e.row],s=i?i.dataItem[_PivotKey._ROW_KEY_NAME]:null;return!!s&&this._collapsedKeys[s.toString()]}_setRowCollapsed(e,t){e=this._getGroupedRows(e);const i=this._ng.totalsBeforeData?e.row-1:e.row2+1,s=this.rows[i]||this.rows[e.row],l=s?s.dataItem[_PivotKey._ROW_KEY_NAME]:null;l&&(this._collapsedKeys[l.toString()]=t);this.deferUpdate(()=>{for(let i=e.row;i<=e.row2;i++)this.rows[i].visible=!t;s&&(s.visible=!0);if(!t){const t=this._getRowLevel(i),s=[];for(let i=e.row;i<=e.row2;i++)if(this._getRowLevel(i)>-1){const l=this._getGroupedRows(new wijmo_grid_1.CellRange(i,t));wijmo_1.assert(l.row>=e.row&&l.row2<=e.row2,"child range overflow");s.push(l);i++}s.forEach(e=>{const t=this._getRowCollapsed(e);this._setRowCollapsed(e,t)})}})}_collapseRowsToLevel(e){e>=this._ng.rowFields.length&&(e=-1);this.deferUpdate(()=>{for(let t=0;t<this.rows.length;t++){const i=this._getRowLevel(t);if(i>0){const s=this.rows[t].dataItem[_PivotKey._ROW_KEY_NAME];this._collapsedKeys[s.toString()]=e>0&&i>=e}if(e<0)this.rows[t].visible=!0;else{let s=i>-1&&i<=e;s||(this._ng.totalsBeforeData?0==t&&(s=!0):t==this.rows.length-1&&(s=!0));this.rows[t].visible=s}}})}_getColLevel(e){return this._ng._getColLevel(this.columns[e].binding)}_getGroupedCols(e){let t,i=this._getColLevel.bind(this),s=e.row+1,l=this.columns.length,o=this._ng.totalsBeforeData,n=e.col;if(0==i(n)){n=o?1:0;t=o?l-1:l-2}else{if(this._ng.totalsBeforeData)for(n=e.col;n<l&&!(i(n)<0);n++);else for(n=e.col;n>=0&&!(i(n)<0);n--);for(;n>0;n--){const e=i(n-1);if(e>=0&&e<=s)break}for(t=n;t<l-1;t++){const e=i(t+1);if(e>=0&&e<=s)break}}wijmo_1.assert(t>=n,"group end < start?");return t>=n?new wijmo_grid_1.CellRange(e.row,n,e.row2,t):e}_toggleColCollapsed(e){this._setColCollapsed(e,!this._getColCollapsed(e))}_getColCollapsed(e){e=this._getGroupedCols(e);const t=this._ng,i=t.totalsBeforeData?e.col-t.valueFields.length:e.col2+1,s=this.columns[i],l=s?s.binding:null;return!!l&&this._collapsedKeys[l.toString()]}_setColCollapsed(e,t){e=this._getGroupedCols(e);const i=this._ng,s=i.totalsBeforeData?e.col-i.valueFields.length:e.col2+1,l=this.columns[s],o=l?l.binding:null;o&&(this._collapsedKeys[o.toString()]=t);this.deferUpdate(()=>{for(let t=1;t<=i.valueFields.length;t++)this.columns[i.totalsBeforeData?e.col-t:e.col2+t].visible=!0;for(let i=e.col;i<=e.col2;i++)this.columns[i].visible=!t;if(!t){const t=this._getColLevel(s),l=[];for(let s=e.col;s<=e.col2;s++)if(this._getColLevel(s)>-1){const o=this._getGroupedCols(new wijmo_grid_1.CellRange(t,s));wijmo_1.assert(o.col>=e.col&&o.col2<=e.col2,"child range overflow");l.push(o);s+=i.valueFields.length-1}l.forEach(e=>{const t=this._getColCollapsed(e);this._setColCollapsed(e,t)})}})}_collapseColsToLevel(e){e>=this._ng.columnFields.length&&(e=-1);this.deferUpdate(()=>{for(let t=0;t<this.columns.length;t++){const i=this._getColLevel(t);if(i>0){const s=this._ng._getKey(this.columns[t].binding);this._collapsedKeys[s.toString()]=e>0&&i>=e}if(e<0)this.columns[t].visible=!0;else{const s=i>-1&&i<=e;this.columns[t].visible=s}}})}dispose(){if(this._ctxMenu){this._ctxMenu.dispose();this._ctxMenu=null}if(this._dlgDetail){this._dlgDetail.dispose();this._dlgDetail=null}if(this._ng){this._ng.updatingView.removeHandler(this._updatingView,this);this._ng.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged,this);this._ng._hasDeferredUpdatesChanged.removeHandler(this._hasDeferredUpdatesChanged,this)}super.dispose()}}PivotGrid._WJC_COLLAPSE=exports.PivotGridClsNames.pivotCollapse;PivotGrid._WJC_DISABLED=wijmo_1.ControlStateClsNames.disabled;PivotGrid._ctrlTemplate="";exports.PivotGrid=PivotGrid;class DetailDialog extends wijmo_input_1.Popup{constructor(e,t){super(e,null);const i=this.getTemplate();this.applyTemplate(`${wijmo_1.ControlClsNames.hostElement} ${exports.DetailDialogClsNames.hostElement}`,i,{_sCnt:"sp-cnt",_dSummary:"div-summary",_dGrid:"div-grid",_btnOK:"btn-ok",_gHdr:"g-hdr"});this._g=new wijmo_grid_1.FlexGrid(this._dGrid,{isReadOnly:!0});this.initialize(t)}static get controlTemplate(){DetailDialog._ctrlTemplate||(DetailDialog._ctrlTemplate=`<div><div class="${exports.DetailDialogClsNames.dialogHeader}"><span wj-part="g-hdr">Detail View:</span> <span wj-part="sp-cnt"></span></div><div class="${exports.DetailDialogClsNames.dialogBody}"><div wj-part="div-summary" class="${exports.DetailDialogClsNames.summary}"></div><div wj-part="div-grid"></div></div><div class="${exports.DetailDialogClsNames.dialogFooter}"><button wj-part="btn-ok"class="${wijmo_1.UtilitesClsNames.hide} ${wijmo_1.InputFormElementsClsNames.btn}">OK</button> </div></div>`);return DetailDialog._ctrlTemplate}static set controlTemplate(e){DetailDialog._ctrlTemplate=e}showDetail(e,t){const i=e.getDetailView(t.row,t.col);this._g.itemsSource=i;const s=wijmo_1.tryCast(i,"IPagedCollectionView");this._updateDetailCount(s?s.totalItemCount:i.items.length);i.collectionChanged.addHandler(()=>{this._updateDetailCount(i.items.length)});let l=e.engine,o=wijmo_1.culture.olap.DetailDialog,n="";this._gHdr.textContent=o.header;this._btnOK.textContent=o.ok;const r=e.rows[t.row].dataItem[_PivotKey._ROW_KEY_NAME];this._rowHdr=wijmo_1.escapeHtml(this._getHeader(r));this._rowHdr&&(n+=`${o.row}: <b>${this._rowHdr}</b><br>`);const a=l._getKey(e.columns[t.col].binding);this._colHdr=wijmo_1.escapeHtml(this._getHeader(a));this._colHdr&&(n+=`${o.col}: <b>${this._colHdr}</b><br>`);const h=l.valueFields,d=h[t.col%h.length],_=e.getCellData(t.row,t.col,!0);this._cellHdr=wijmo_1.escapeHtml(d.header);this._cellValue=wijmo_1.escapeHtml(_);n+=`${this._cellHdr}: <b>${this._cellValue}</b>`;this._dSummary.innerHTML=n}get rowHeader(){return this._rowHdr}get columnHeader(){return this._colHdr}get cellHeader(){return this._cellHdr}get cellValue(){return this._cellValue}get detailCount(){return this._detailCount}_updateDetailCount(e){const t=wijmo_1.culture.olap.DetailDialog;this._sCnt.textContent=wijmo_1.format(1==e?t.item:t.items,{cnt:e});this._detailCount=e}_getHeader(e){if(e&&e.values&&e.values.length){const t=[];for(let i=0;i<e.values.length;i++)t.push(e.getValue(i,!0));return t.join(" - ")}return null}}DetailDialog._ctrlTemplate="";exports.DetailDialog=DetailDialog;class _PivotMergeManager extends wijmo_grid_1.MergeManager{getMergedRange(e,t,i,s=!0){return this._getMergedRange(e,t,i,s)}_getMergedRange(e,t,i,s=!0,l=!0){const o=e.grid.collectionView;this._ng=o instanceof PivotCollectionView?o.engine:null;if(!this._ng)return super._getMergedRange(e,t,i,s,l);if(t<0||t>=e.rows.length||i<0||i>=e.columns.length)return null;const n=e.grid.allowMerging,r=wijmo_grid_1.AllowMerging;switch(e.cellType){case wijmo_grid_1.CellType.TopLeft:return 0!=(n&r.AllHeaders)?this._getMergedTopLeftRange(e,t,i):null;case wijmo_grid_1.CellType.RowHeader:return 0!=(n&r.RowHeaders)?this._getMergedRowHeaderRange(e,t,i,s?e.viewRange:null):null;case wijmo_grid_1.CellType.ColumnHeader:return 0!=(n&r.ColumnHeaders)?this._getMergedColumnHeaderRange(e,t,i,s?e.viewRange:null):null}return null}_getMergedTopLeftRange(e,t,i){const s=new wijmo_grid_1.CellRange(t,i),l=e.grid;if(l.outlineMode&&l.showRowFieldHeaders&&s.row==e.rows.length-1){s.col=0;s.col2=e.columns.length-1;return s}for(;s.col>0&&!e.getCellData(t,s.col,!0);)s.col--;for(;s.col2<e.columns.length-1&&!e.getCellData(t,s.col2+1,!0);)s.col2++;return s.isSingleCell?null:s}_getMergedRowHeaderRange(e,t,i,s){const l=e.grid,o=e.columns[i],n=e.columns,r=e.rows;if(!o.allowMerging)return null;if(l.outlineMode){if(this._isSubtotal(e,t,i)||this._isSubtotal(e,t,i+1)){const s=this._getOutlineRange(e,t,i);return s.isSingleCell?null:s}if(i<e.columns.length-1){const e=l._getGroupedRows(new wijmo_grid_1.CellRange(t,i));return e.isSingleCell?null:e}return null}const a=this._ng._getRowLevel(t);if(a>-1&&i>=a){let o,r,a=e.getCellData(t,i,!1),h=0,d=n.length-1;if(i>=n._frozenInternal&&l._vtCols<n.length&&s){h=s.col;d=s.col2}for(o=i;o>h&&e.getCellData(t,o-1,!1)==a;o--);for(r=i;r<d&&e.getCellData(t,r+1,!1)==a;r++);return o!=r?new wijmo_grid_1.CellRange(t,o,t,r):null}let h,d,_=0,c=r.length-1;if(i>=r._frozenInternal&&l._vtRows<r.length&&s){_=s.row;c=s.row2}for(h=t;h>_&&this._sameColumnValues(e,t,h-1,i);h--);for(d=t;d<c&&this._sameColumnValues(e,t,d+1,i);d++);return h!=d?new wijmo_grid_1.CellRange(h,i,d,i):null}_sameColumnValues(e,t,i,s){for(;s>=0;s--){if(e.getCellData(t,s,!1)!=e.getCellData(i,s,!1))return!1}return!0}_isSubtotal(e,t,i){const s=e.rows[t].dataItem,l=s?s[_PivotKey._ROW_KEY_NAME]:null;return s&&i>l.values.length-1&&i<e.columns.length}_getOutlineRange(e,t,i){const s=new wijmo_grid_1.CellRange(t,i);s.col2=e.columns.length-1;for(;s.col&&this._isSubtotal(e,t,s.col);)s.col--;return s}_getMergedColumnHeaderRange(e,t,i,s){const l=e.columns[i],o=this._ng._getKey(l.binding),n=e.getCellData(t,i,!1),r=e.grid,a=e.columns,h=e.rows,d=this._ng._getColLevel(o);if(d>-1&&t>=d){let l,o,a=0,d=h.length-1;if(i>=h._frozenInternal&&r._vtRows<h.length&&s){a=s.row;d=s.row2}for(l=t;l>a&&e.getCellData(l-1,i,!1)==n;l--);for(o=t;o<d&&e.getCellData(o+1,i,!1)==n;o++);if(l!=o)return new wijmo_grid_1.CellRange(l,i,o,i)}if(s){i<e.columns._frozenInternal&&(s.col=s.col2=0);t<e.rows._frozenInternal&&(s.row=s.row2=0)}let _,c,u=0,g=a.length-1;if(i>=a._frozenInternal&&r._vtCols<a.length&&s){u=s.col;g=s.col2}for(_=i;_>u&&this._sameRowValues(e,t,i,_-1);_--);for(c=i;c<g&&this._sameRowValues(e,t,i,c+1);c++);return _!=c?new wijmo_grid_1.CellRange(t,_,t,c):null}_sameRowValues(e,t,i,s){for(;t>=0;t--){if(e.getCellData(t,i,!1)!=e.getCellData(t,s,!1))return!1}return!0}}exports._PivotMergeManager=_PivotMergeManager;!function(e){e[e.Column=0]="Column";e[e.Bar=1]="Bar";e[e.Scatter=2]="Scatter";e[e.Line=3]="Line";e[e.Area=4]="Area";e[e.Pie=5]="Pie"}(PivotChartType=exports.PivotChartType||(exports.PivotChartType={}));!function(e){e[e.Always=0]="Always";e[e.Never=1]="Never";e[e.Auto=2]="Auto"}(LegendVisibility=exports.LegendVisibility||(exports.LegendVisibility={}));class PivotChart extends wijmo_1.Control{constructor(e,t){super(e);this._chartType=PivotChartType.Column;this._showHierarchicalAxes=!0;this._showTotals=!1;this._showTitle=!0;this._showLegend=LegendVisibility.Always;this._legendPosition=wijmo_chart_1.Position.Right;this._maxSeries=PivotChart.MAX_SERIES;this._maxPoints=PivotChart.MAX_POINTS;this._stacking=wijmo_chart_1.Stacking.None;this._colItms=[];this._dataItms=[];this._lblsSrc=[];this._grpLblsSrc=[];wijmo_1.addClass(this.hostElement,exports.PivotChartClsNames.hostElement);this._isPieChart()?this._createFlexPie():this._createFlexChart();super.initialize(t)}_getProductInfo(){return"D6F4,PivotChart"}get engine(){return this._ng}get itemsSource(){return this._itemsSource}set itemsSource(e){if(e&&this._itemsSource!==e){const t=this._itemsSource;e instanceof PivotPanel?e=e.engine.pivotView:e instanceof PivotEngine&&(e=e.pivotView);this._itemsSource=wijmo_1.asCollectionView(e);this._onItemsSourceChanged(t)}}get chartType(){return this._chartType}set chartType(e){if((e=wijmo_1.asEnum(e,PivotChartType))!=this._chartType){const t=this._chartType;this._chartType=e;this._changeChartType();e!==PivotChartType.Bar&&t!==PivotChartType.Bar||this._updatePivotChart()}}get showHierarchicalAxes(){return this._showHierarchicalAxes}set showHierarchicalAxes(e){if(e!=this._showHierarchicalAxes){this._showHierarchicalAxes=wijmo_1.asBoolean(e,!0);!this._isPieChart()&&this._flexChart&&this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc)}}get showTotals(){return this._showTotals}set showTotals(e){if(e!=this._showTotals){this._showTotals=wijmo_1.asBoolean(e,!0);this._updatePivotChart()}}get showTitle(){return this._showTitle}set showTitle(e){if(e!=this._showTitle){this._showTitle=wijmo_1.asBoolean(e,!0);this._updatePivotChart()}}get showLegend(){return this._showLegend}set showLegend(e){if((e=wijmo_1.asEnum(e,LegendVisibility))!=this.showLegend){this._showLegend=e;this._updatePivotChart()}}get legendPosition(){return this._legendPosition}set legendPosition(e){if((e=wijmo_1.asEnum(e,wijmo_chart_1.Position))!=this.legendPosition){this._legendPosition=e;this._updatePivotChart()}}get stacking(){return this._stacking}set stacking(e){if((e=wijmo_1.asEnum(e,wijmo_chart_1.Stacking))!=this._stacking){this._stacking=e;if(this._flexChart){this._flexChart.stacking=this._stacking;this._updatePivotChart()}}}get maxSeries(){return this._maxSeries}set maxSeries(e){if(e!=this._maxSeries){this._maxSeries=wijmo_1.asNumber(e);this._updatePivotChart()}}get maxPoints(){return this._maxPoints}set maxPoints(e){if(e!=this._maxPoints){this._maxPoints=wijmo_1.asNumber(e);this._updatePivotChart()}}get flexChart(){return this._flexChart}get flexPie(){return this._flexPie}get header(){return this._header}set header(e){if(e!=this._header){this._header=wijmo_1.asString(e,!0);this.invalidate()}}get footer(){return this._footer}set footer(e){if(e!=this._footer){this._footer=wijmo_1.asString(e,!0);this.invalidate()}}get headerStyle(){return this._headerStyle}set headerStyle(e){if(e!=this._headerStyle){this._headerStyle=e;this.invalidate()}}get footerStyle(){return this._footerStyle}set footerStyle(e){if(e!=this._footerStyle){this._footerStyle=e;this.invalidate()}}refresh(e=!0){super.refresh(e);this._isPieChart()?this._flexPie&&this._flexPie.refresh(e):this._flexChart&&this._flexChart.refresh(e);this._updatePivotChart()}saveImageToDataUrl(e,t){this._isPieChart()?this._flexPie&&this._flexPie.saveImageToDataUrl(e,t):this._flexChart&&this._flexChart.saveImageToDataUrl(e,t)}saveImageToFile(e){this._isPieChart()?this._flexPie&&this._flexPie.saveImageToFile(e):this._flexChart&&this._flexChart.saveImageToFile(e)}_onItemsSourceChanged(e){this._ng&&this._ng.updatedView.removeHandler(this._updatePivotChart,this);e&&e.collectionChanged.removeHandler(this._updatePivotChart,this);const t=this._itemsSource;this._ng=t instanceof PivotCollectionView?t.engine:null;this._ng&&this._ng.updatedView.addHandler(this._updatePivotChart,this);this._itemsSource&&this._itemsSource.collectionChanged.addHandler(this._updatePivotChart,this);this._updatePivotChart()}_createFlexChart(){const e=document.createElement("div");this.hostElement.appendChild(e);this._flexChart=new wijmo_chart_1.FlexChart(e);this._flexChart._bindingSeparator=null;this._flexChart.legend.position=wijmo_chart_1.Position.Right;this._flexChart.bindingX=_PivotKey._ROW_KEY_NAME;this._flexChart.stacking=this._stacking;this._flexChart.tooltip.content=e=>{let t=e.name?`<b>${e.name}</b> <br/>`:"";t+=`${this._getLabel(e.x)} ${this._getValue(e)}`;return t};this._flexChart.hostElement.style.visibility="hidden"}_createFlexPie(){const e=document.createElement("div");this.hostElement.appendChild(e);this._colMenu=new wijmo_input_1.MultiSelect(e,{displayMemberPath:"text",placeholder:wijmo_1.culture.olap.PivotPanel.cols,selectedValuePath:"prop",showSelectAllCheckbox:!0,keyActionPrintCharacters:0,keyActionTab:0});this._colMenu.hostElement.style.visibility="hidden";this._colMenu.checkedItemsChanged.addHandler((e,t)=>this._updateFlexPieBinding());const t=document.createElement("div");this.hostElement.appendChild(t);this._flexPie=new wijmo_chart_1.FlexPie(t);this._flexPie.bindingName=_PivotKey._ROW_KEY_NAME;this._flexPie.tooltip.content=e=>`<b>${this._getLabel(this._dataItms[e.pointIndex][_PivotKey._ROW_KEY_NAME])}</b> <br/>${this._getValue(e)}`;this._flexPie.rendering.addHandler(this._updatePieInfo,this)}_updatePivotChart(){if(!this._ng||!this._ng.pivotView)return;let e,t=[],i=[],s=[],l=0,o=this._ng.pivotView,n=this._ng.rowFields;for(let r=0;r<o.items.length;r++){const a=o.items[r],h=a.$rowKey;0==r&&this._getColumns(a);if(t.length>=this._maxPoints)break;if(!this._isTotalRow(a[_PivotKey._ROW_KEY_NAME])){t.push(a);i.push({value:t.length-1,text:this._getLabel(a[_PivotKey._ROW_KEY_NAME])});for(let i=0;i<n.length;i++){s.length<=i&&s.push([]);if(this._getMergeIndex(h,e)<i){l=s[i].length-1;const e=s[i][l];0===l&&i<n.length-1&&(e.value=(e.width-1)/2);if(l>0&&i<n.length-1){const t=this._getOffsetWidth(s[i]);e.value=t+(e.width-1)/2}s[i].push({value:t.length-1,text:h.getValue(i,!0),width:1})}else{l=s[i].length-1;s[i][l].width++}}e=h}}for(let e=0;e<n.length;e++)if(e<s.length){l=s[e].length-1;s[e][l].value=this._getOffsetWidth(s[e])+(s[e][l].width-1)/2}this._dataItms=t;this._lblsSrc=i;this._grpLblsSrc=s;this._updateFlexChartOrPie()}_updateFlexChartOrPie(){const e=this._isPieChart();!e&&this._flexChart?this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc):e&&this._flexPie&&this._updateFlexPie(this._dataItms,this._lblsSrc)}_updateFlexChart(e,t,i){let s,l=this._flexChart,o=l?l.hostElement:null;if(this._ng&&l&&o){l.beginUpdate();l.itemsSource=e;this._createSeries();l.series&&l.series.length>0&&e.length>0?o.style.visibility="visible":o.style.visibility="hidden";l.header=this.header||this._getChartTitle();this.headerStyle&&(l.headerStyle=this.headerStyle);this.footer&&(l.footer=this.footer);this.footerStyle&&(l.footerStyle=this.footerStyle);if(this._isRotatedChart()){if(this._showHierarchicalAxes&&i.length>0){l.axisY.itemsSource=i[i.length-1];l.axisX.labelAngle=void 0;if(i.length>=2)for(let e=i.length-2;e>=0;e--)this._createGroupAxes(i[e])}else{l.axisY.labelAngle=void 0;l.axisY.itemsSource=t}l.axisX.itemsSource=void 0}else{if(this._showHierarchicalAxes&&i.length>0){l.axisX.itemsSource=i[i.length-1];if(i.length>=2)for(let e=i.length-2;e>=0;e--)this._createGroupAxes(i[e])}else{l.axisX.labelAngle=void 0;l.axisX.itemsSource=t}l.axisY.itemsSource=void 0}l.axisX.labelPadding=6;l.axisY.labelPadding=6;if(this._isRotatedChart()){s=l.axisX;l.axisY.reversed=!0}else{s=l.axisY;l.axisY.reversed=!1}l.stacking!==wijmo_chart_1.Stacking.Stacked100pc&&this._ng.valueFields.length>0&&this._ng.valueFields[0].format?s.format=this._ng.valueFields[0].format:s.format="";l.legend.position=this._getLegendPosition();l.endUpdate()}}_updateFlexPie(e,t){const i=this._flexPie,s=i?i.hostElement:null,l=this._colMenu;if(!this._ng||!i||!s)return;this._colItms.length>0&&e.length>0?s.style.visibility="visible":s.style.visibility="hidden";i.beginUpdate();i.itemsSource=e;i.bindingName=_PivotKey._ROW_KEY_NAME;this._colItms&&this._colItms.length>0&&(i.binding=this._colItms[0].prop);i.header=this.header||this._getChartTitle();this.headerStyle&&(i.headerStyle=this.headerStyle);this.footer&&(i.footer=this.footer);this.footerStyle&&(i.footerStyle=this.footerStyle);i.legend.position=this._getLegendPosition();i.endUpdate();let o=this._getTitle(this._ng.columnFields);""!==o&&(o=`<b>${o}: </b>`);if(this._colItms&&this._colItms.length>1&&e.length>0){l.hostElement.style.visibility="visible";l.itemsSource=this._colItms;l.checkedItems=[this._colItms[0]];l.invalidate()}else l.hostElement.style.visibility="hidden"}_getLegendPosition(){let e=this.legendPosition;if(this.showLegend==LegendVisibility.Never)e=wijmo_chart_1.Position.None;else if(this.showLegend==LegendVisibility.Auto&&this.flexChart&&this.flexChart.series){let t=0;this.flexChart.series.forEach(e=>{const i=e.visibility;e.name&&i!=wijmo_chart_1.SeriesVisibility.Hidden&&i!=wijmo_chart_1.SeriesVisibility.Plot&&t++});t<2&&(e=wijmo_chart_1.Position.None)}return e}_createSeries(){this._flexChart&&(this._flexChart.series.length=0);const e=1==this._ng.valueFields.length;for(let t=0;t<this._colItms.length;t++){let i=new wijmo_chart_1.Series,s=this._colItms[t].prop,l=this._colItms[t].text;if(e){const e=l.lastIndexOf(";");e>-1&&(l=l.substr(0,e))}i.binding=s;i.name=l;this._flexChart.series.push(i)}}_getColumns(e){let t,i,s=0;if(e){this._colItms=[];for(const l in e)if(e.hasOwnProperty(l)&&l!==_PivotKey._ROW_KEY_NAME&&s<this._maxSeries&&this._isValidColumn(l)){t=this._ng._getKey(l);i=this._getLabel(t);this._colItms.push({prop:l,text:this._getLabel(t)});s++}}}_createGroupAxes(e){let t,i=this._flexChart,s=this._isRotatedChart()?i.axisY:i.axisX;if(!e)return;t=new wijmo_chart_1.Axis;t.labelAngle=0;t.labelPadding=6;t.position=this._isRotatedChart()?wijmo_chart_1.Position.Left:wijmo_chart_1.Position.Bottom;t.majorTickMarks=wijmo_chart_1.TickMark.None;t.itemsSource=e;t.reversed=s.reversed;t.axisLine=!1;t.itemFormatter=(i,s)=>{if(t._axrect){const l=.5*e.filter(e=>e.value==s.val)[0].width;if(this._isRotatedChart()){const e=t.reversed?-1:1,o=t.convert(s.val+l)+5*e,n=t.convert(s.val-l)-5*e,r=t._axrect.left+t._axrect.width-5;i.drawLine(r,o,r,n,PivotChart.HRHAXISCSS);i.drawLine(r,o,r+5,o,PivotChart.HRHAXISCSS);i.drawLine(r,n,r+5,n,PivotChart.HRHAXISCSS);i.drawLine(r,s.pos.y,r-5,s.pos.y,PivotChart.HRHAXISCSS)}else{const e=t.convert(s.val-l)+5,o=t.convert(s.val+l)-5,n=t._axrect.top;i.drawLine(e,n,o,n,PivotChart.HRHAXISCSS);i.drawLine(e,n,e,n-5,PivotChart.HRHAXISCSS);i.drawLine(o,n,o,n-5,PivotChart.HRHAXISCSS);i.drawLine(s.pos.x,n,s.pos.x,n+5,PivotChart.HRHAXISCSS)}}return s};t.min=s.actualMin;t.max=s.actualMax;s.rangeChanged.addHandler(()=>{isNaN(t.min)&&isNaN(s.actualMin)||t.min==s.actualMin||(t.min=s.actualMin);isNaN(t.max)&&isNaN(s.actualMax)||t.max==s.actualMax||(t.max=s.actualMax)});const l=new wijmo_chart_1.Series;l.visibility=wijmo_chart_1.SeriesVisibility.Hidden;this._isRotatedChart()?l.axisY=t:l.axisX=t;i.series.push(l)}_updateFlexPieBinding(){let e="";const t=[];this._colMenu.checkedItems.forEach(i=>{e.length>0&&(e+=",");e+=i.prop;t.push(i.text)});this._flexPie.binding=e;this._flexPie.titles=t.length>1?t:null}_updatePieInfo(){this._flexPie&&(this._flexPie._labels=this._flexPie._labels.map((e,t)=>this._lblsSrc[t].text))}_changeChartType(){let e=null;if(this.chartType===PivotChartType.Pie){this._flexPie||this._createFlexPie();this._updateFlexPie(this._dataItms,this._lblsSrc);this._swapChartAndPie(!1)}else{switch(this.chartType){case PivotChartType.Column:e=wijmo_chart_1.ChartType.Column;break;case PivotChartType.Bar:e=wijmo_chart_1.ChartType.Bar;break;case PivotChartType.Scatter:e=wijmo_chart_1.ChartType.Scatter;break;case PivotChartType.Line:e=wijmo_chart_1.ChartType.Line;break;case PivotChartType.Area:e=wijmo_chart_1.ChartType.Area}if(this._flexChart)"none"!==this._flexChart.hostElement.style.display&&e!==PivotChartType.Bar&&this._flexChart.chartType!==wijmo_chart_1.ChartType.Bar||this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc);else{this._createFlexChart();this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc)}this._flexChart.chartType=e;this._swapChartAndPie(!0)}}_swapChartAndPie(e){this._flexChart&&(this._flexChart.hostElement.style.display=e?"block":"none");this._flexPie&&(this._flexPie.hostElement.style.display=e?"none":"block");if(this._colMenu&&this._colMenu.hostElement){this._colMenu.hostElement.style.display=e?"none":"block";this._colMenu.hostElement.style.top="0";this._clearStyleTopTimer=setTimeout(()=>{this._colMenu.hostElement.style.top=""},0)}}_getLabel(e){let t="";if(!e||!e.values)return t;const i=e.valueFields?e.valueField:null;switch(e.values.length){case 0:i&&(t+=i.header);break;case 1:t+=e.getValue(0,!0);i&&(t+="; "+i.header);break;default:for(let i=0;i<e.values.length;i++){i>0&&(t+="; ");t+=e.getValue(i,!0)}i&&(t+="; "+i.header)}return t}_getValue(e){const t=this._ng.valueFields,i=e.series?e.series.chart.series.indexOf(e.series):0,s=i<t.length?t[i].format:t.length?t[0].format:"";return s?wijmo_1.Globalize.format(e.y,s):e._yfmt}_getChartTitle(){if(!this.showTitle||!this._ng.valueFields.length)return null;let e=this._ng,t=this._getTitle(e.valueFields),i=this._getTitle(e.rowFields),s=this._getTitle(e.columnFields),l=t,o=wijmo_1.culture.olap.PivotChart;if(t&&this._dataItms.length>0){i&&(l+=wijmo_1.format(" {by} {rows}",{by:o.by,rows:i}));s&&(l+=wijmo_1.format(" {and} {cols}",{and:i?o.and:o.by,cols:s}))}return l}_getTitle(e){let t="";for(let i=0;i<e.length;i++){t.length>0&&(t+="; ");t+=e[i].header}return t}_isValidColumn(e){const t=e.split(";"),i=this._showTotals;return 0===this._ng.columnFields.length||(t&&2===t.length?i:!(!t||t.length-2!==this._ng.columnFields.length)&&!i)}_isTotalRow(e){return e.values.length<this._ng.rowFields.length}_isPieChart(){return this._chartType==PivotChartType.Pie}_isRotatedChart(){return!this._isPieChart()&&this._chartType==PivotChartType.Bar!==this._flexChart.rotated}_getMergeIndex(e,t){let i=-1;if(null!=e&&null!=t&&e.values.length==t.values.length&&e.values.length==e.fields.length&&t.values.length==t.fields.length)for(let s=0;s<e.values.length;s++){if(e.getValue(s,!0)!=t.getValue(s,!0))return i;i=s}return i}_getOffsetWidth(e){let t=0;if(e.length<=1)return t;for(let i=0;i<e.length-1;i++)t+=e[i].width;return t}dispose(){if(this._flexChart){this._flexChart.dispose();this._flexChart=null}if(this._flexPie){this._flexPie.dispose();this._flexPie=null}if(this._colMenu){this._colMenu.dispose();this._colMenu=null}if(this._clearStyleTopTimer){clearTimeout(this._clearStyleTopTimer);this._clearStyleTopTimer=null}this._ng&&this._ng.updatedView.removeHandler(this._updatePivotChart,this);this._itemsSource&&this._itemsSource.collectionChanged.removeHandler(this._updatePivotChart,this);super.dispose()}}PivotChart.MAX_SERIES=100;PivotChart.MAX_POINTS=100;PivotChart.HRHAXISCSS=exports.PivotChartClsNames.hierarchicalAxesLine;exports.PivotChart=PivotChart;class _MdxQueryBuilder{constructor(e,t){this._ng=null;this._cubeName=null;this._ng=e;this._cubeName=t}buildQuery(){const e=new _TextBuilder,t=this.buildWhereSection(this._ng.valueFields);e.append("SELECT ",this.buildAxes()," FROM ",this.buildCubeName(),t);e.append(" CELL PROPERTIES VALUE, FORMAT_STRING");return e.toString()}buildWhereSection(e){const t=new _TextBuilder;if(1==e.length){t.append(this.buildSetForMeasuresShelf(e));t.wrap(" WHERE ","")}return t.toString()}buildCubeName(){const e=new _TextBuilder;e.append(this.buildSubcubeExpression());const t=e.length>0;t&&e.wrap("SELECT "," FROM ");e.append("[",this._cubeName,"]");t&&e.wrap("(",")");return e.toString()}buildSubcubeExpression(){const e=new _TextBuilder,t=this.getMeasureFilterExpressions(this._ng.valueFields),i=this.buildFilterAttributeSet(this._ng.filterFields),s=this.buildFilterAttributeSet(this._ng.rowFields,t),l=this.buildFilterAttributeSet(this._ng.columnFields,0==s.length?t:null);e.joinItemToList(i);e.joinItemToList(s);e.joinItemToList(l);if(e.length>0){e.wrap("(",")");e.append(" ON COLUMNS")}return e.toString()}buildFilterAttributeSet(e,t){const i=new _TextBuilder;for(let s=0;s<e.length;s++){const l=e[s],o=this.buildFilterString(l,0==s?t:null);i.joinItemToList(o)}return i.toString()}buildFilterString(e,t){const i=new _TextBuilder;e.filter.isActive?e.filter.conditionFilter.isActive?i.append(this.getConditionFilterString(e,t)):e.filter.valueFilter.isActive&&i.append(this.getValueFilterString(e)):t&&i.append(this.getConditionFilterString(e,t));return i.toString()}getValueFilterString(e){const t=new _TextBuilder,i=e.filter.valueFilter,s=Object.keys(i.showValues).map(t=>`${e.key}.[${t}]`);t.append(s.join(","));t.length>0&&t.wrap("{","}");return t.toString()}getConditionFilterString(e,t){const i=new _TextBuilder,s=e.key+".LEVELS(1).ALLMEMBERS",l=e.filter.conditionFilter.condition1,o=e.filter.conditionFilter.condition2;if(l.isActive){i.append(this.getConditionFilterExpression(e,l));o.isActive&&i.append(e.filter.conditionFilter.and?" AND ":" OR ")}o.isActive&&i.append(this.getConditionFilterExpression(e,o));if(t&&t.length>0){i.length>0&&i.append(" AND ");i.append(t.join(" AND "))}i.length>0&&i.wrap(`Filter(${s},(`,"))");return i.toString()}getMeasureFilterExpressions(e){const t=[];for(let i=0;i<e.length;i++){const s=new _TextBuilder,l=e[i],o=(l.dimensionType,DimensionType.Measure,l.filter.conditionFilter.condition1),n=l.filter.conditionFilter.condition2;if(o.isActive){s.append(this.getConditionFilterExpression(l,o));n.isActive&&s.append(l.filter.conditionFilter.and?" AND ":" OR ")}n.isActive&&s.append(this.getConditionFilterExpression(l,n));if(s.length>0){s.wrap("(",")");t.push(s.toString())}}return t}getConditionFilterExpression(e,t){if(!t.isActive)return"";const i=e.dimensionType==DimensionType.Measure,s=e.dataType==wijmo_1.DataType.Number,l=e.dataType==wijmo_1.DataType.Date,o=s||l?"member_value":"member_caption",n=i?e.key:`${e.key}.CurrentMember.${o}`,r=l?`CDate('${wijmo_1.Globalize.formatDate(t.value,"d")}')`:t.value.toString(),a=new _TextBuilder;switch(t.operator){case wijmo_grid_filter_1.Operator.BW:a.append("(Left(",n,",",r.length.toString(),')="',r,'")');break;case wijmo_grid_filter_1.Operator.NBW:a.append("(Left(",n,",",r.length.toString(),')<>"',r,'")');break;case wijmo_grid_filter_1.Operator.EW:a.append("(Right(",n,",",r.length.toString(),')="',r,'")');break;case wijmo_grid_filter_1.Operator.NEW:a.append("(Right(",n,",",r.length.toString(),')<>"',r,'")');break;case wijmo_grid_filter_1.Operator.EQ:i||s||l?a.append("(",n,")=",r):a.append("(",n,')="',r,'"');break;case wijmo_grid_filter_1.Operator.NE:i||s||l?a.append("(",n,")<>",r):a.append("(",n,')<>"',r,'"');break;case wijmo_grid_filter_1.Operator.CT:a.append("(InStr(1,",n,',"',r,'")>0)');break;case wijmo_grid_filter_1.Operator.NC:a.append("(InStr(1,",n,',"',r,'")=0))');break;case wijmo_grid_filter_1.Operator.GT:a.append("(",n,")>",r);break;case wijmo_grid_filter_1.Operator.LT:a.append("(",n,")<",r);break;case wijmo_grid_filter_1.Operator.GE:a.append("(",n,")>=",r);break;case wijmo_grid_filter_1.Operator.LE:a.append("(",n,")<=",r)}return a.toString()}buildAxes(){const e=new _TextBuilder;let t=this.buildSetForAttributesShelf(this._ng.rowFields);e.joinItemToList(t);this._ng.rowFields.length>0&&(this._ng.columnFields.length>0||this._ng.valueFields.length>1?e.append(" ON ROWS"):e.append(" ON COLUMNS"));t=this.buildSetForAttributesColumnShelf(this._ng.columnFields);e.joinItemToList(t);this._ng.columnFields.length>0&&e.append(" ON COLUMNS");if(this._ng.valueFields.length>1&&0==this._ng.columnFields.length){t=this.buildSetForMeasuresShelf(this._ng.valueFields);e.joinItemToList(t);e.append(" ON COLUMNS")}return e.toString()}buildSetForAttributesShelf(e){const t=new _TextBuilder;for(let i=0;i<e.length;i++){const s=e[i];s.dimensionType!=DimensionType.Attribute&&s.dimensionType!=DimensionType.Hierarchy||t.joinItemToList(this.buildAttributeSetForAxis(s));i>0&&t.wrap("CrossJoin(",")")}t.wrap("NON EMPTY ","");return t.toString()}buildSetForAttributesColumnShelf(e){const t=new _TextBuilder;for(let i=0;i<e.length;i++){const s=e[i];s.dimensionType!=DimensionType.Attribute&&s.dimensionType!=DimensionType.Hierarchy||t.joinItemToList(this.buildAttributeSetForAxis(s))}this._ng.valueFields.length>1&&e.length>0&&t.joinItemToList(this.buildSetForMeasuresShelf(this._ng.valueFields));(this._ng.valueFields.length>1&&e.length>0||e.length>1)&&t.wrap("CrossJoin(",")");t.wrap("NON EMPTY ","");return t.toString()}buildSetForMeasuresShelf(e){const t=new _TextBuilder;for(let i=0;i<e.length;i++){const s=e[i];s.dimensionType!=DimensionType.Measure&&s.dimensionType!=DimensionType.Kpi||t.joinItemToList(this.buildMeasureSetForAxis(s))}t.wrap("{","}");return t.toString()}buildAttributeSetForAxis(e){const t=new _TextBuilder;if(e.dimensionType==DimensionType.Hierarchy){t.append(e.key);t.append(".ALLMEMBERS");t.wrap("{","}");t.wrap("HIERARCHIZE(",")")}return t.toString()}buildMeasureSetForAxis(e){const t=new _TextBuilder;e.dimensionType!=DimensionType.Measure&&e.dimensionType!=DimensionType.Kpi||t.append(e.key);return t.toString()}}exports._MdxQueryBuilder=_MdxQueryBuilder;class _SqlServerConnection extends _ServerConnection{constructor(e,t){super(e,t.url);this._jsonResult=null;this._dataTypes=null;e.sortOnServer=!0;wijmo_1.assert(wijmo_1.isString(t.cube)&&!wijmo_1.isNullOrWhiteSpace(t.cube),"Cube name required.");this._cubeName=t.cube;this._catalogName=wijmo_1.isString(t.catalog)&&!wijmo_1.isNullOrWhiteSpace(t.catalog)?t.catalog:"";this._url=t.url;this._user=t.user;this._password=t.password}getFields(){this._getSession();this._jsonResult=null;this._dataTypes=null;this._getProperties(this._token);this._getDimensions(this._token);this._endSession();return this._jsonResult}getOutputView(e){this._ng.onUpdatingView(new ProgressEventArgs(0));const t=new _MdxQueryBuilder(this._ng,this._cubeName).buildQuery();this._jsonResult=[];this._getSession();this._execQuery(this._token,t,t=>{wijmo_1.asFunction(e)(this._jsonResult);this._ng.onUpdatedView(new ProgressEventArgs(100))})}getDetail(e,t){throw"getDetail method not supported"}getSortedKeys(e,t){const i=Object.keys(e);if(this._ng.sortOnServer){if(i.length>1){const e=t?this._ng.showRowTotals:this._ng.showColumnTotals,s=t?this._ng.rowFields.length:this._ng.columnFields.length,l=this._ng.valueFields.length;if(!this._ng.totalsBeforeData&&e!==ShowTotals.None){let e=-1,o=[],n=[];i.forEach(i=>{const r=this._getKeyLength(i,t);if(r===s)n.push(i);else if(r>=e)o.push(i);else{if(o.length>=l)for(let e=0;e<l;e++)n.push(o.pop());o.push(i)}e=r});if(o.length>0){o.reverse();n=n.concat(o)}return n}}}else i.sort((e,t)=>this._ng._keys[e].compareTo(this._ng._keys[t]));return i}_getSession(){const e=this._url;return wijmo_1.httpRequest(e,{async:!1,data:_ENV_SESSION,method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{const t=e.responseXML.getElementsByTagName("Session");this._token=t[0].getAttribute("SessionId")},error:e=>{this._handleError("Begin Session",e)}})}_endSession(){const e=this._url;return wijmo_1.httpRequest(e,{async:!1,data:_ENV_ENDSESSION(this._token),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},error:e=>{this._handleError("End Session",e)},complete:e=>{this._token=void 0}})}_getProperties(e){const t=this._url;return wijmo_1.httpRequest(t,{async:!1,data:_ENV_PROPERTIES(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{const t={},i=e.responseXML.getElementsByTagName("row");for(let e=0;e<i.length;e++){const s=_getTagValue(i[e],"HIERARCHY_UNIQUE_NAME");switch(Number(_getTagValue(i[e],"DATA_TYPE"))){case 2:case 3:case 4:case 5:case 6:t[s]=wijmo_1.DataType.Number;break;case 7:t[s]=wijmo_1.DataType.Date}}this._dataTypes=t},error:e=>{this._handleError("Get Properties",e)}})}_getDimensions(e){const t=this._url;return wijmo_1.httpRequest(t,{async:!1,data:_ENV_DIMENSIONS(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:t=>{const i=[],s=t.responseXML.getElementsByTagName("row");for(let t=0;t<s.length;t++){if("2"!==_getTagValue(s[t],"DIMENSION_TYPE")){const l=_getTagValue(s[t],"DIMENSION_UNIQUE_NAME"),o={header:_getTagValue(s[t],"DIMENSION_CAPTION"),dataType:wijmo_1.DataType.Object,dimensionType:DimensionType.Dimension,subFields:[]};this._getSubFolders(e,l,o);i.push(o)}else this._getMeasures(e,i)}const l={header:"KPIs",dataType:wijmo_1.DataType.Object,dimensionType:DimensionType.Kpi,subFields:[]};this._getKPIs(e,l);i.push(l);this._jsonResult=i},error:e=>{this._handleError("Get Dimensions",e)}})}_getSubFolders(e,t,i){const s=this._url;wijmo_1.httpRequest(s,{async:!1,data:_ENV_HIERARCHIES(e,this._catalogName,this._cubeName,t),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{const t=e.responseXML.getElementsByTagName("row");for(let e=0;e<t.length;e++){const s={header:_getTagValue(t[e],"HIERARCHY_NAME"),binding:_getTagValue(t[e],"HIERARCHY_UNIQUE_NAME"),dataType:wijmo_1.DataType.String,dimensionType:DimensionType.Hierarchy};this._dataTypes[s.binding]&&(s.dataType=this._dataTypes[s.binding]);const l=_getTagValue(t[e],"HIERARCHY_DISPLAY_FOLDER").split("\\");let o=i;for(let e=0;e<l.length;e++){if(""==l[e])continue;const t={header:l[e],dataType:wijmo_1.DataType.Object,dimensionType:DimensionType.Folder,subFields:[]};if(_containsFolder(o,l[e]))o=_findSubFieldByName(o,l[e]);else{o.subFields.push(t);o=t}}o.subFields.push(s)}},error:e=>{this._handleError("Get Hierarchies",e)}})}_getMeasures(e,t){const i=this._url;return wijmo_1.httpRequest(i,{async:!1,data:_ENV_MEASURES(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{const i=e.responseXML.getElementsByTagName("row"),s={};for(let e=0;e<i.length;e++){const l=_getTagValue(i[e],"MEASUREGROUP_NAME"),o={header:_getTagValue(i[e],"MEASURE_CAPTION"),binding:_getTagValue(i[e],"MEASURE_UNIQUE_NAME"),dataType:wijmo_1.DataType.Number,dimensionType:DimensionType.Measure};if(Object.keys(s).indexOf(l)<0){const e={header:l,dataType:wijmo_1.DataType.Number,dimensionType:DimensionType.Measure,subFields:[]};e.subFields.push(o);t.push(e);s[l]=e}else s[l].subFields.push(o)}},error:e=>{this._handleError("Get Measures",e)}})}_getKPIs(e,t){const i=this._url;return wijmo_1.httpRequest(i,{async:!1,data:_ENV_KPIS(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{const i=e.responseXML.getElementsByTagName("row");for(let e=0;e<i.length;e++){const s=_getTagValue(i[e],"KPI_DISPLAY_FOLDER").split("\\");let l=t;for(let e=0;e<s.length;e++){const t={header:s[e],dataType:wijmo_1.DataType.Object,dimensionType:DimensionType.Folder,subFields:[]};if(_containsFolder(l,s[e]))l=_findSubFieldByName(l,s[e]);else{l.subFields.push(t);l=t}}const o={header:_getTagValue(i[e],"KPI_CAPTION"),binding:_getTagValue(i[e],"KPI_VALUE"),dataType:wijmo_1.DataType.Number,dimensionType:DimensionType.Kpi};l.subFields.push(o)}},error:e=>{this._handleError("Get KPIs",e)}})}_execQuery(e,t,i){const s=this._url;return wijmo_1.httpRequest(s,{async:!0,data:_ENV_QUERY(e,this._catalogName,t),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:e=>{const s=e.responseXML,l=s.querySelector("Error");if(l){throw`SSAS Error\r\n${l.getAttribute("Description")}\r\n${t}`}this._createPivotKeys(s);wijmo_1.asFunction(i)(e)},error:e=>{this._handleError("Execute Query",e)},complete:()=>{this._endSession()}})}_createPivotKeys(e){let t=null,i=null;const s=e.querySelector("CellData");if(this._ng.columnFields.length>0||this._ng.valueFields.length>1){i=e.querySelector("Axis[name='Axis0']");this._ng.rowFields.length>0&&(t=e.querySelector("Axis[name='Axis1']"))}else this._ng.rowFields.length>0&&(t=e.querySelector("Axis[name='Axis0']"));const l=t&&this._ng.rowFields.length>0,o=i&&this._ng.columnFields.length>0;l&&o?this._createRowKeys(s,t,i):l?this._createRowOnlyKeys(s,t):o&&this._createColumnOnlyKeys(s,i)}_createRowKeys(e,t,i){const s=t.getElementsByTagName("Tuple"),l=i.getElementsByTagName("Tuple"),o=this._ng.showRowTotals!==ShowTotals.None?0:1,n=this._ng.showColumnTotals!==ShowTotals.None?0:this._ng.valueFields.length;for(let t=o;t<s.length;t++){const i=t*l.length,o=s[t],r=this._validateTuple(o,this._ng.showRowTotals);if(r)for(let t=n;t<l.length;t++){const s=l[t],o=this._validateTuple(s,this._ng.showColumnTotals);if(o){for(const e in r)o[e]=r[e];for(let s=0;s<this._ng.valueFields.length;s++){o[this._ng.valueFields[s].key]=_getCellValue(e,i+t+s)}this._jsonResult.push(o)}}}}_createRowOnlyKeys(e,t){const i=t.getElementsByTagName("Tuple"),s=this._ng.valueFields.length,l=this._ng.showRowTotals!==ShowTotals.None?0:1;let o=l*s;for(let t=l;t<i.length;t++){const s=i[t],l=this._validateTuple(s,this._ng.showRowTotals);if(l){for(let t=0;t<this._ng.valueFields.length;t++){l[this._ng.valueFields[t].key]=_getCellValue(e,o++)}this._jsonResult.push(l)}else o++}}_createColumnOnlyKeys(e,t){const i=t.getElementsByTagName("Tuple"),s=this._ng.valueFields.length,l=this._ng.showColumnTotals!==ShowTotals.None?0:1;for(let t=l;t<i.length;t+=s){const s=i[t],o=this._validateTuple(s,this._ng.showColumnTotals);if(o){for(let i=0;i<this._ng.valueFields.length;i++){o[this._ng.valueFields[i].key]=_getCellValue(e,t-l+i)}this._jsonResult.push(o)}}}_validateTuple(e,t){const i=e.getElementsByTagName("Member");let s;const l={};for(let e=0;e<i.length;e++){const o=i[e],n=_getLevelNumber(o),r=o.getAttribute("Hierarchy"),a=_getCaptionValue(o);if(0==e)s=n;else{if(n>s)return null;if(t!==ShowTotals.Subtotals&&n!==s&&"[Measures]"!==r)return null;s=n}r.indexOf(".")>=0?l[r]=a:null!==a&&(l[a]=null)}return l}}exports._SqlServerConnection=_SqlServerConnection;function _getTagValue(e,t){const i=e.querySelector(t);return i?i.innerHTML||i.textContent:null}function _getLevelNumber(e){return Number(_getTagValue(e,"LNum"))}function _getCaptionValue(e){return _getLevelNumber(e)>0?_getTagValue(e,"Caption"):null}function _getCellValue(e,t){const i=`Cell[CellOrdinal='${t.toString()}']`,s=e.querySelector(i);if(s){const e=_getTagValue(s,"Value");if(e)return Number(e)}return null}function _findSubFieldByName(e,t){if(e.subFields)for(let i=0;i<e.subFields.length;i++){const s=e.subFields[i];if(s.header==t)return s}return e}function _containsFolder(e,t){if(e.subFields)for(let i=0;i<e.subFields.length;i++){if(e.subFields[i].header==t)return!0}return!1}const _ENV_SESSION='\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <BeginSession soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">\n <Command>\n <Statement />\n </Command>\n <Properties>\n </Properties>\n </Execute>\n </Body>\n </Envelope>',_ENV_ENDSESSION=e=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:EndSession soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">\n <Command>\n <Statement />\n </Command>\n <Properties>\n </Properties>\n </Execute>\n </Body>\n </Envelope>`,_ENV_DIMENSIONS=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_DIMENSIONS</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_HIERARCHIES=(e,t,i,s)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_HIERARCHIES</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n <DIMENSION_UNIQUE_NAME>${s}</DIMENSION_UNIQUE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_MEASURES=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_MEASURES</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_KPIS=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_KPIS</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_LEVELS=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_LEVELS</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_PROPERTIES=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Discover xmlns="urn:schemas-microsoft-com:xml-analysis">\n <RequestType>MDSCHEMA_PROPERTIES</RequestType>\n <Restrictions>\n <RestrictionList>\n <CATALOG_NAME>${t}</CATALOG_NAME>\n <CUBE_NAME>${i}</CUBE_NAME>\n <PROPERTY_NAME>MEMBER_VALUE</PROPERTY_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>`,_ENV_QUERY=(e,t,i)=>`\n <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">\n <Header>\n <XA:Session soap:mustUnderstand="1" SessionId="${e}" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:XA="urn:schemas-microsoft-com:xml-analysis" />\n </Header>\n <Body>\n <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">\n <Command>\n <Statement>\n <![CDATA[\n ${i}\n ]]>\n </Statement>\n </Command>\n <Properties>\n <PropertyList>\n <Catalog>${t}</Catalog>\n <Content>Data</Content>\n </PropertyList>\n </Properties>\n </Execute>\n </Body>\n </Envelope>`;class PivotFilter{constructor(e){this._fld=e;const t=e;this._valueFilter=new wijmo_grid_filter_1.ValueFilter(t);this._valueFilter.exclusiveValueSearch=this._fld.engine.exclusiveValueSearch;this._conditionFilter=new wijmo_grid_filter_1.ConditionFilter(t)}get filterType(){return null!=this._filterType?this._filterType:this._fld.engine.defaultFilterType}set filterType(e){if((e=wijmo_1.asEnum(e,wijmo_grid_filter_1.FilterType,!0))!=this._filterType){this._filterType=e;this.clear()}}apply(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)}get isActive(){return this._conditionFilter.isActive||this._valueFilter.isActive}clear(){let e=!1;if(this._valueFilter.isActive){this._valueFilter.clear();e=!0}if(this._conditionFilter.isActive){this._valueFilter.clear();e=!0}e&&this._fld.onPropertyChanged(new wijmo_1.PropertyChangedEventArgs("filter",null,null))}get valueFilter(){return this._valueFilter}get conditionFilter(){return this._conditionFilter}}exports.PivotFilter=PivotFilter;class PivotFilterEditor extends wijmo_1.Control{constructor(e,t,i){super(e);this.finishEditing=new wijmo_1.Event;this.hostElement.tabIndex=-1;const s=this.getTemplate();this.applyTemplate(`${wijmo_1.ControlClsNames.hostElement} ${wijmo_1.ControlClsNames.content} ${exports.PivotFilterEditorClsNames.hostElement}`,s,{_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnOk:"btn-ok"});wijmo_1.setText(this._aVal,wijmo_1.culture.FlexGridFilter.values);wijmo_1.setText(this._aCnd,wijmo_1.culture.FlexGridFilter.conditions);wijmo_1.setText(this._btnOk,wijmo_1.culture.olap.PivotFieldEditor.ok);const l=this._btnClicked.bind(this);this.addEventListener(this._btnOk,"click",l);this.addEventListener(this._aVal,"click",l);this.addEventListener(this._aCnd,"click",l);this.addEventListener(this.hostElement,"keydown",e=>{switch(e.keyCode){case wijmo_1.Key.Enter:switch(e.target.tagName){case"A":case"BUTTON":this._btnClicked(e);break;default:this.onFinishEditing(new wijmo_1.CancelEventArgs)}e.preventDefault();break;case wijmo_1.Key.Escape:this.onFinishEditing(new wijmo_1.CancelEventArgs);e.preventDefault();break;case wijmo_1.Key.Tab:wijmo_1.moveFocus(this.hostElement,e.shiftKey?-1:1);e.preventDefault()}});this._fld=t;this._uniqueValues=t.filter.valueFilter.uniqueValues;this.initialize(i);this.updateEditor()}static get controlTemplate(){PivotFilterEditor._ctrlTemplate||(PivotFilterEditor._ctrlTemplate=`<div><div wj-part="div-type" style="text-align:center;margin-bottom:12px;font-size:80%"><a wj-part="a-cnd" href="" tabindex="-1" draggable="false"></a> | <a wj-part="a-val" href="" tabindex="-1" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-ok" class="${wijmo_1.InputFormElementsClsNames.btn}"></button></div></div>`);return PivotFilterEditor._ctrlTemplate}static set controlTemplate(e){PivotFilterEditor._ctrlTemplate=e}get field(){return this._fld}get filter(){return this._fld?this._fld.filter:null}get isEditorClear(){switch(this._getFilterType()){case wijmo_grid_filter_1.FilterType.Value:return!this._edtVal||this._edtVal.isEditorClear;case wijmo_grid_filter_1.FilterType.Condition:return!this._edtCnd||this._edtCnd.isEditorClear}wijmo_1.assert(!1,"unknown filter type?");return!1}updateEditor(){let e=wijmo_grid_filter_1.FilterType,t=e.None;if(this.filter){t=this.filter.conditionFilter.isActive||0==(this.filter.filterType&e.Value)?e.Condition:e.Value;this._showFilter(t)}if(this._edtVal){const e=this._fld,t=e.engine;if(t.isServer&&!this._uniqueValues){const i=t._getUniqueValues(e);e.filter.valueFilter.uniqueValues=i}this._edtVal.updateEditor()}this._edtCnd&&this._edtCnd.updateEditor()}updateFilter(){switch(this._getFilterType()){case wijmo_grid_filter_1.FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case wijmo_grid_filter_1.FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}this.field.onPropertyChanged(new wijmo_1.PropertyChangedEventArgs("filter",null,null))}clearEditor(){this._edtVal&&this._edtVal.clearEditor();this._edtCnd&&this._edtCnd.clearEditor()}onFinishEditing(e){this.finishEditing.raise(this,e);return!e.cancel}_showFilter(e){e==wijmo_grid_filter_1.FilterType.Value&&null==this._edtVal&&(this._edtVal=new wijmo_grid_filter_1.ValueFilterEditor(this._divEdtVal,this.filter.valueFilter));e==wijmo_grid_filter_1.FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new wijmo_grid_filter_1.ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter));if(0!=(e&this.filter.filterType))if(e==wijmo_grid_filter_1.FilterType.Value){this._divEdtVal.style.display="";this._divEdtCnd.style.display="none";this._enableLink(this._aVal,!1);this._enableLink(this._aCnd,!0)}else{this._divEdtVal.style.display="none";this._divEdtCnd.style.display="";this._enableLink(this._aVal,!0);this._enableLink(this._aCnd,!1)}switch(this.filter.filterType){case wijmo_grid_filter_1.FilterType.None:case wijmo_grid_filter_1.FilterType.Condition:case wijmo_grid_filter_1.FilterType.Value:this._divType.style.display="none";break;default:this._divType.style.display=""}}_enableLink(e,t){e.style.textDecoration=t?"":"none";e.style.fontWeight=t?"":"bold";wijmo_1.setAttribute(e,"href",t?"":null)}_getFilterType(){const e=wijmo_grid_filter_1.FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition}_btnClicked(e){e.preventDefault();e.stopPropagation();if(!wijmo_1.hasClass(e.target,wijmo_1.ControlStateClsNames.disabled))if(e.target!=this._aVal)if(e.target!=this._aCnd)this.onFinishEditing(new wijmo_1.CancelEventArgs);else{this._showFilter(wijmo_grid_filter_1.FilterType.Condition);wijmo_1.moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(wijmo_grid_filter_1.FilterType.Value);wijmo_1.moveFocus(this._edtVal.hostElement,0)}}}PivotFilterEditor._ctrlTemplate="";exports.PivotFilterEditor=PivotFilterEditor;class PivotFieldEditor extends wijmo_1.Control{constructor(e,t){super(e,null,!0);this.hostElement.tabIndex=-1;const i=this.getTemplate();this.applyTemplate(`${wijmo_1.ControlClsNames.hostElement} ${exports.PivotFieldEditorClsNames.hostElement}`,i,{_dBnd:"sp-bnd",_dHdr:"div-hdr",_dAgg:"div-agg",_dShw:"div-shw",_dWFl:"div-wfl",_dSrt:"div-srt",_btnFltEdt:"btn-flt-edt",_btnFltClr:"btn-flt-clr",_dFmt:"div-fmt",_dSmp:"div-smp",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_gDlg:"g-dlg",_gHdr:"g-hdr",_gAgg:"g-agg",_gShw:"g-shw",_gWfl:"g-wfl",_gSrt:"g-srt",_gFlt:"g-flt",_gFmt:"g-fmt",_gSmp:"g-smp"});this._pvDate=new Date;const s=wijmo_1.culture.olap.PivotFieldEditor;wijmo_1.setText(this._gDlg,s.dialogHeader);wijmo_1.setText(this._gHdr,s.header);wijmo_1.setText(this._gAgg,s.summary);wijmo_1.setText(this._gShw,s.showAs);wijmo_1.setText(this._gWfl,s.weighBy);wijmo_1.setText(this._gSrt,s.sort);wijmo_1.setText(this._gFlt,s.filter);wijmo_1.setText(this._gFmt,s.format);wijmo_1.setText(this._gSmp,s.sample);wijmo_1.setText(this._btnFltEdt,s.edit);wijmo_1.setText(this._btnFltClr,s.clear);wijmo_1.setText(this._btnApply,s.ok);wijmo_1.setText(this._btnCancel,s.cancel);this._cmbHdr=new wijmo_input_1.ComboBox(this._dHdr,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbAgg=new wijmo_input_1.ComboBox(this._dAgg,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbShw=new wijmo_input_1.ComboBox(this._dShw,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbWFl=new wijmo_input_1.ComboBox(this._dWFl,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbSrt=new wijmo_input_1.ComboBox(this._dSrt,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbFmt=new wijmo_input_1.ComboBox(this._dFmt,{keyActionPrintCharacters:0,keyActionTab:0});this._cmbSmp=new wijmo_input_1.ComboBox(this._dSmp,{keyActionPrintCharacters:0,keyActionTab:0});this._initAggregateOptions();this._initShowAsOptions();this._initFormatOptions();this._initSortOptions();this._updatePreview();this._cmbShw.textChanged.addHandler(this._updateFormat,this);this._cmbFmt.textChanged.addHandler(this._updatePreview,this);this.addEventListener(this._btnFltEdt,"click",e=>{this._editFilter();e.preventDefault()});this.addEventListener(this._btnFltClr,"click",e=>{this._createFilterEditor();this._closeAndFocusTimer=setTimeout(()=>{this._eFlt.clearEditor();this._btnFltEdt.focus();wijmo_1.enable(this._btnFltClr,!1)});e.preventDefault()});this.addEventListener(this._btnApply,"click",e=>{this.updateField()});this.initialize(t)}static get controlTemplate(){PivotFieldEditor._ctrlTemplate||(PivotFieldEditor._ctrlTemplate=`<div><div class="${exports.DetailDialogClsNames.dialogHeader}" tabindex="-1"><span wj-part="g-dlg"></span> <span wj-part="sp-bnd"></span></div><div class="${exports.DetailDialogClsNames.dialogBody}"><table style="table-layout:fixed"><tr><td wj-part="g-hdr"></td><td><div wj-part="div-hdr"></div></td></tr><tr class="${wijmo_1.UtilitesClsNames.separator}"><td wj-part="g-agg"></td><td><div wj-part="div-agg"></div></td></tr><tr class="${wijmo_1.UtilitesClsNames.separator}"><td wj-part="g-shw"></td><td><div wj-part="div-shw"></div></td></tr><tr><td wj-part="g-wfl"></td><td><div wj-part="div-wfl"></div></td></tr><tr><td wj-part="g-srt"></td><td><div wj-part="div-srt"></div></td></tr><tr class="${wijmo_1.UtilitesClsNames.separator}"><td wj-part="g-flt"></td><td><div><button wj-part="btn-flt-edt" class="${wijmo_1.InputFormElementsClsNames.btn}"></button> <button wj-part="btn-flt-clr" class="${wijmo_1.InputFormElementsClsNames.btn}"></button></div></td></tr><tr class="${wijmo_1.UtilitesClsNames.separator}"><td wj-part="g-fmt"></td><td><div wj-part="div-fmt"></div></td></tr><tr><td wj-part="g-smp"></td><td><div wj-part="div-smp" readonly tabindex="-1"></div></td></tr></table></div><div class="${exports.DetailDialogClsNames.dialogFooter}"><button wj-part="btn-apply" class="${wijmo_1.InputFormElementsClsNames.btn} ${wijmo_1.UtilitesClsNames.hide}"></button> <button wj-part="btn-cancel" class="${wijmo_1.InputFormElementsClsNames.btn} ${wijmo_1.UtilitesClsNames.hide}"></button></div></div>`);return PivotFieldEditor._ctrlTemplate}static set controlTemplate(e){PivotFieldEditor._ctrlTemplate=e}get field(){return this._fld}set field(e){if(e!=this._fld){this._fld=wijmo_1.asType(e,PivotField);this.updateEditor()}}updateEditor(){const e=this._fld;if(e&&e.engine){this._dBnd.textContent=e.binding;this._cmbHdr.text=e.header;this._cmbAgg.collectionView.refresh();this._cmbAgg.selectedValue=e.aggregate;this._cmbSrt.selectedValue=e.descending;this._cmbShw.selectedValue=e.showAs;this._initWeighByOptions();const t=e.engine.defaultFilterType!=wijmo_grid_filter_1.FilterType.None&&(null!=e.binding||wijmo_1.isFunction(e.getValue));wijmo_1.enable(this._btnFltEdt,t);wijmo_1.enable(this._btnFltClr,t&&e.filter.isActive);this._cmbFmt.collectionView.refresh();this._cmbFmt.selectedValue=e.format;this._cmbFmt.selectedValue||(this._cmbFmt.text=e.format);const i=e instanceof CubePivotField;this._cmbAgg.isDisabled=i||!!e.getAggregateValue;this._cmbWFl.isDisabled=i}}updateField(){const e=this._fld;if(e){const t=this._cmbHdr.text.trim();e.header=t||wijmo_1.toHeaderCase(e.binding);e.aggregate=this._cmbAgg.selectedValue;e.showAs=this._cmbShw.selectedValue;e.weightField=this._cmbWFl.selectedValue;e.descending=this._cmbSrt.selectedValue;const i=e.format;e.format=this._cmbFmt.selectedValue||this._cmbFmt.text;const s=this._eFlt;if(s){s.updateFilter();const t=e.dataType==wijmo_1.DataType.Number,l=e.dataType==wijmo_1.DataType.Date;if(i!=e.format&&(t||l)){const s=e.filter.valueFilter;if(s&&s.isActive&&!s.dataMap){const o={};if(t)for(const t in s.showValues){const i=wijmo_1.Globalize.parseFloat(t);o[wijmo_1.Globalize.format(i,e.format)]=!0}else if(l)for(const t in s.showValues){const s=wijmo_1.Globalize.parseDate(t,i);o[wijmo_1.Globalize.format(s,e.format)]=!0}s.showValues=o}}}}}_initAggregateOptions(){const e=wijmo_1.culture.olap.PivotFieldEditor.aggs,t=wijmo_1.Aggregate,i=[{key:e.sum,val:t.Sum,all:!1},{key:e.cnt,val:t.Cnt,all:!0},{key:e.avg,val:t.Avg,all:!1},{key:e.max,val:t.Max,all:!0},{key:e.min,val:t.Min,all:!0},{key:e.rng,val:t.Rng,all:!1},{key:e.std,val:t.Std,all:!1},{key:e.var,val:t.Var,all:!1},{key:e.stdp,val:t.StdPop,all:!1},{key:e.varp,val:t.VarPop,all:!1},{key:e.first,val:t.First,all:!0},{key:e.last,val:t.Last,all:!0}];this._cmbAgg.itemsSource=i;this._cmbAgg.collectionView.filter=e=>{if(e&&e.all)return!0;if(this._fld){const e=this._fld.dataType;return e==wijmo_1.DataType.Number||e==wijmo_1.DataType.Boolean}return!1};this._cmbAgg.initialize({displayMemberPath:"key",selectedValuePath:"val"})}_initShowAsOptions(){const e=wijmo_1.culture.olap.PivotFieldEditor.calcs,t=[{key:e.noCalc,val:ShowAs.NoCalculation},{key:e.dRow,val:ShowAs.DiffRow},{key:e.dRowPct,val:ShowAs.DiffRowPct},{key:e.dCol,val:ShowAs.DiffCol},{key:e.dColPct,val:ShowAs.DiffColPct},{key:e.dPctGrand,val:ShowAs.PctGrand},{key:e.dPctRow,val:ShowAs.PctRow},{key:e.dPrevRow,val:ShowAs.PctPrevRow},{key:e.dPctCol,val:ShowAs.PctCol},{key:e.dPrevCol,val:ShowAs.PctPrevCol},{key:e.dRunTot,val:ShowAs.RunTot},{key:e.dRunTotPct,val:ShowAs.RunTotPct}];this._cmbShw.itemsSource=t;this._cmbShw.initialize({displayMemberPath:"key",selectedValuePath:"val"})}_initFormatOptions(){const e=wijmo_1.culture.olap.PivotFieldEditor.formats,t=[{key:e.n0,val:"n0",all:!0},{key:e.n2,val:"n2",all:!0},{key:e.c,val:"c",all:!0},{key:e.p0,val:"p0",all:!0},{key:e.p2,val:"p2",all:!0},{key:e.n2c,val:"n2,",all:!0},{key:e.n2cc,val:"n2,,",all:!0},{key:e.n2ccc,val:"n2,,,",all:!0},{key:e.d,val:"d",all:!1},{key:e.MMMMddyyyy,val:"MMMM dd, yyyy",all:!1},{key:e.dMyy,val:"d/M/yy",all:!1},{key:e.ddMyy,val:"dd/M/yy",all:!1},{key:e.dMyyyy,val:"dd/M/yyyy",all:!1},{key:e.MMMyyyy,val:"MMM yyyy",all:!1},{key:e.MMMMyyyy,val:"MMMM yyyy",all:!1},{key:e.yyyy,val:"yyyy",all:!1},{key:e.yyyyQq,val:'yyyy "Q"q',all:!1},{key:e.FYEEEEQU,val:'"FY"EEEE "Q"U',all:!1}];this._cmbFmt.itemsSource=t;this._cmbFmt.isEditable=!0;this._cmbFmt.isRequired=!1;this._cmbFmt.collectionView.filter=e=>!(!e||!e.all)||!!this._fld&&this._fld.dataType==wijmo_1.DataType.Date;this._cmbFmt.initialize({displayMemberPath:"key",selectedValuePath:"val"})}_initWeighByOptions(){const e=this._fld;if(e){const t=[{key:wijmo_1.culture.olap.PivotFieldEditor.none,val:null}];e.engine.fields.forEach(i=>{i!=e&&i.dataType==wijmo_1.DataType.Number&&t.push({key:i.header,val:i})});this._cmbWFl.initialize({displayMemberPath:"key",selectedValuePath:"val",itemsSource:t,selectedValue:e.weightField})}}_initSortOptions(){const e=wijmo_1.culture.olap.PivotFieldEditor.sorts,t=[{key:e.asc,val:!1},{key:e.desc,val:!0}];this._cmbSrt.itemsSource=t;this._cmbSrt.initialize({displayMemberPath:"key",selectedValuePath:"val"})}_updateFormat(){const e=ShowAs[this._cmbShw.selectedValue];this._cmbFmt.selectedValue=e.indexOf("Pct")>-1?"p0":"n0"}_updatePreview(){let e=this._cmbFmt.selectedValue||this._cmbFmt.text,t=wijmo_1.Globalize.format,i="";if(e){const s=e[0].toLowerCase();i="nfgxc".indexOf(s)>-1?t(1234.5678,e):t("p"==s?.12345678:this._pvDate,e)}this._cmbSmp.text=i}_editFilter(){this._createFilterEditor();wijmo_1.showPopup(this._dFlt,this._btnFltEdt,!1,!1,!1);wijmo_1.moveFocus(this._dFlt,0)}_createFilterEditor(){if(!this._dFlt){this._dFlt=document.createElement("div");this._eFlt=new PivotFilterEditor(this._dFlt,this._fld);wijmo_1.addClass(this._dFlt,wijmo_input_1.DropDownClsNames.dropDownPanel);this._lostFocusHandler=()=>{this._closeFilterTimer=setTimeout(()=>{const e=wijmo_1.Control.getControl(this._dFlt);e&&!e.containsFocus()&&this._closeFilter()},10)};this._eFlt.lostFocus.addHandler(this._lostFocusHandler);this._eFlt.finishEditing.addHandler(()=>{this._closeFilter();wijmo_1.enable(this._btnFltClr,!this._eFlt.isEditorClear)})}}_closeFilter(){if(this._dFlt){wijmo_1.hidePopup(this._dFlt,!0);this.focus()}}dispose(){if(this._closeFilterTimer){clearTimeout(this._closeFilterTimer);this._closeFilterTimer=null}this._cmbShw&&this._cmbShw.textChanged.removeHandler(this._updateFormat,this);this._cmbFmt&&this._cmbFmt.textChanged.removeHandler(this._updatePreview,this);if(this._eFlt){this._eFlt.dispose();this._eFlt=null}if(this._dFlt){this._dFlt.innerHTML="";this._dFlt=null}if(this._closeFilterTimer){clearTimeout(this._closeFilterTimer);this._closeFilterTimer=null}if(this._closeAndFocusTimer){clearTimeout(this._closeAndFocusTimer);this._closeAndFocusTimer=null}this.hostElement&&(this.hostElement[wijmo_1.Control._CTRL_KEY]=null);super.dispose()}}PivotFieldEditor._ctrlTemplate="";exports.PivotFieldEditor=PivotFieldEditor;wijmo_1._registerModule("wijmo.olap",selfModule);class PivotFieldBinding extends wijmo_1.Binding{constructor(e,t){super(t);this._fld=e}getValue(e){const t=this._fld;return wijmo_1.isFunction(t.getValue)?t._getValue(e,!1):super.getValue(e)}}exports.PivotFieldBinding=PivotFieldBinding;
|