@mescius/wijmo.olap 5.20251.31-nightly.d20250124.t020131 → 5.20251.31-nightly.d20250128.t121156
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 -1
- package/index.js +2 -2
- package/package.json +6 -6
package/es5-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.20251.31-nightly.
|
|
3
|
+
* Wijmo Library 5.20251.31-nightly.d20250128.t121156
|
|
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
|
-
var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}();import{CollectionView,asType,assert,ObservableArray,asInt,isString,isBoolean,isNumber,Aggregate,httpRequest,isArray,isDate,Globalize,asString,DataType,asFunction,RequestErrorEventArgs,isNullOrWhiteSpace,PropertyChangedEventArgs,asEnum,Control,setText,culture,Key,CancelEventArgs,moveFocus,setAttribute,hasClass,Event,ControlStateClsNames,ControlClsNames,InputFormElementsClsNames,addClass,enable,showPopup,toHeaderCase,hidePopup,isFunction,UtilitesClsNames,EventArgs,NotifyCollectionChangedAction,_addCultureInfo,copy,tryCast,getType,getTypes,isObject,isPrimitive,asCollectionView,asBoolean,asNumber,asArray,hasItems,Binding,changeType,DateTime,GlyphClsNames,createElement,clamp,toggleClass,_startDrag,closest,Rect,setCss,format,isEmpty,closestClass,escapeHtml,isIE,isEdge,Tooltip,removeChild,_registerModule}from"@mescius/wijmo";import{FilterType,Operator,ValueFilter,ConditionFilter,ValueFilterEditor,ConditionFilterEditor}from"@mescius/wijmo.grid.filter";import{ComboBox,DropDownClsNames,Popup,Menu,MultiSelect,ListBoxClsNames}from"@mescius/wijmo.input";import{FlexGrid,FlexGridClsNames,CellType,AllowMerging,MergeManager,CellRange,AllowDragging,HeadersVisibility,Row,Column,CellRangeEventArgs}from"@mescius/wijmo.grid";import{Stacking,FlexChart,FlexPie,Position,Axis,SeriesVisibility,Series,TickMark,ChartType}from"@mescius/wijmo.chart";import*as selfModule from"@mescius/wijmo.olap";var _TextBuilder=function(){function _TextBuilder(){this._text=""}Object.defineProperty(_TextBuilder.prototype,"length",{get:function(){return this._text.length},enumerable:!0,configurable:!0});_TextBuilder.prototype.toString=function(){return this._text};_TextBuilder.prototype.append=function(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];this._text=(e=this._text).concat.apply(e,t)};_TextBuilder.prototype.joinToList=function(e){for(var t,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var o=i.join();this.length>0&&o.length>0?this._text=(t=this._text).concat.apply(t,[e].concat(i)):o.length>0&&(this._text=o)};_TextBuilder.prototype.joinItemToList=function(e){this.joinToList(",",e)};_TextBuilder.prototype.wrap=function(e,t){this.length>0&&(this._text=e.concat(this._text,t))};_TextBuilder.wrap=function(e,t,i){return t.length>0?e.concat(t,i):""};return _TextBuilder}();export{_TextBuilder};export var DetailDialogClsNames={dialogBody:"wj-dialog-body",dialogFooter:"wj-dialog-footer",dialogHeader:"wj-dialog-header",hostElement:"wj-detaildialog",summary:"wj-summary"};export var PivotChartClsNames={hierarchicalAxesLine:"wj-hierarchicalaxes-line",hostElement:"wj-pivotchart"};export var PivotFieldEditorClsNames={hostElement:"wj-pivotfieldeditor"};export var PivotFilterEditorClsNames={hostElement:"wj-pivotfiltereditor"};export var PivotGridClsNames={colFieldHdr:"wj-col-field-hdr",hostElement:"wj-pivotgrid",pivotCollapse:"wj-pivot-collapse",rowFieldHdr:"wj-row-field-hdr"};export var PivotPanelClsNames={aggregate:"wj-aggregate",header:"wj-header",hostElement:"wj-pivotpanel"};export var SlicerClsNames={header:"wj-header",hostElement:"wj-slicer",noCheck:"wj-nocheck"};export var _GridContextMenuClsNames={hostElement:"wj-olap-context-menu"};var _Tally=function(){function _Tally(){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}_Tally.prototype.add=function(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++;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(isNumber(e)&&!isNaN(e)){isNumber(t)&&(e*=t);this._cntn++;this._sum+=e;this._sum2+=e*e}}}};_Tally.prototype.getAggregate=function(e){if(0==this._cnt)return null;var t=0==this._cntn?0:this._sum/this._cntn,i=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."};return _Tally}();export{_Tally};var _PivotKey=function(){function _PivotKey(e,t,i,n,o){this._fields=e;this._fieldCount=t;this._valueFields=i;this._valueFieldIndex=n;this._item=o}Object.defineProperty(_PivotKey.prototype,"fields",{get:function(){return this._fields},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"valueFields",{get:function(){return this._valueFields},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"valueField",{get:function(){return this._valueFields[this._valueFieldIndex]},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"values",{get:function(){if(null==this._vals){this._vals=new Array(this._fieldCount);for(var e=0;e<this._fieldCount;e++){var t=this._fields[e];this._vals[e]=t._getValue(this._item,!1)}}return this._vals},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"fieldNames",{get:function(){if(!this._names){this._names=[];for(var e=0;e<this.fields.length;e++){var t=this._fields[e];this._names.push(t._getName())}}return this._names},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"aggregate",{get:function(){var e=this._valueFields,t=this._valueFieldIndex;assert(e&&t>-1&&t<e.length,"aggregate not available for this key");return e[t].aggregate},enumerable:!0,configurable:!0});_PivotKey.prototype.getValue=function(e,t){if(0==this.values.length)return culture.olap.PivotEngine.grandTotal;if(e>this.values.length-1)return culture.olap.PivotEngine.subTotal;var i=this.values[e];if(t&&!isString(i)){var n=this.fields[e],o=n?n.format:"";i=Globalize.format(this.values[e],o)}return i};Object.defineProperty(_PivotKey.prototype,"level",{get:function(){return this._fieldCount==this._fields.length?-1:this._fieldCount},enumerable:!0,configurable:!0});_PivotKey.prototype.compareTo=function(e){var t=0;if(null!=e&&e._fields==this._fields){for(var i=this.values,n=e.values,o=Math.min(i.length,n.length),r=0;r<o;r++){var s=null!=i[r]?getType(i[r]):null,l=i[r],a=n[r],d=this._fields[r];if(d.sortComparer){t=d.sortComparer(l,a);if(isNumber(t)){if(0!=t)return d.descending?-t:t;continue}}if(s==DataType.Date){var u=d.format;if(u&&"d"!=u&&"D"!=u){var h=d._getValue(this._item,!0),c=d._getValue(e._item,!0),p=Globalize.parseDate(h,u),g=Globalize.parseDate(c,u);if(p&&g){l=p;a=g}else{l=h;a=c}}}if(!(l==a||DateTime.equals(l,a))){if(null==l)return 1;if(null==a)return-1;t=l<a?-1:1;return d.descending?-t:t}}if(i.length==n.length&&0!=(t=this._valueFieldIndex-e._valueFieldIndex))return t;if(0!=(t=n.length-i.length))return t*(this.fields.engine.totalsBeforeData?-1:1)}return 0};_PivotKey.prototype.matchesItem=function(e){for(var t=0;t<this._vals.length;t++){if(this.getValue(t,!0)!=this._fields[t]._getValue(e,!0))return!1}return!0};_PivotKey.prototype.toString=function(e){if(!this._key||e){for(var t="",i=0;i<this._fieldCount;i++){var n=this._fields[i];t+=n._getName()+":"+n._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";return _PivotKey}();export{_PivotKey};var _NOT_EDITABLE="This collection is not editable.",PivotCollectionView=function(e){__extends(PivotCollectionView,e);function PivotCollectionView(t){var i=e.call(this)||this;i.canAddNew=i.canRemove=!1;i._ng=asType(t,PivotEngine,!1);return i}Object.defineProperty(PivotCollectionView.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});PivotCollectionView.prototype.implementsInterface=function(t){return"IEditableCollectionView"!=t&&e.prototype.implementsInterface.call(this,t)};PivotCollectionView.prototype.editItem=function(e){assert(!1,_NOT_EDITABLE)};PivotCollectionView.prototype.addNew=function(){assert(!1,_NOT_EDITABLE)};PivotCollectionView.prototype._performSort=function(e){var t=this._ng;if(t.sortableGroups&&t._getShowRowTotals()==ShowTotals.Subtotals){var i=0,n=e.length-1;0==this._getItemLevel(e[i])&&i++;0==this._getItemLevel(e[n])&&n--;this._sortGroups(e,1,i,n)}else this._sortData(e)};PivotCollectionView.prototype._performFilter=function(e){return this._ng&&0==this._ng.valueFields.length&&0==this._ng.rowFields.length?[]:this.canFilter&&this._filter?e.filter(this._filter,this):e};PivotCollectionView.prototype._getGroupRange=function(e,t){var i=this._ng,n=e.indexOf(t),o=n,r=this._getItemLevel(e[n]);if(i.totalsBeforeData)for(o=n;o<e.length-1;o++){if((s=this._getItemLevel(e[o+1]))>-1&&s<=r)break}else for(n=o;n;n--){var s;if((s=this._getItemLevel(e[n-1]))>-1&&s<=r)break}return[n,o]};PivotCollectionView.prototype._sortGroups=function(t,i,n,o){for(var r=[],s=n;s<=o;s++)this._getItemLevel(t[s])==i&&r.push(t[s]);if(r.length){e.prototype._performSort.call(this,r);var l=[];for(s=0;s<r.length;s++){for(var a=this._getGroupRange(t,r[s]),d=l.length,u=a[0];u<=a[1];u++)l.push(t[u]);var h=l.length-1;if(i<this._ng.rowFields.length-1)this._sortGroups(l,i+1,n+d,h);else{var c=this._ng.totalsBeforeData?1:0;this._sortSegment(l,d+c,h+c)}}for(s=0;s<l.length;s++)t[n+s]=l[s]}else this._sortData(t)};PivotCollectionView.prototype._sortSegment=function(t,i,n){var o=t.slice(i,n);e.prototype._performSort.call(this,o);for(var r=0;r<o.length;r++)t[i+r]=o[r]};PivotCollectionView.prototype._sortData=function(t){for(var i=0;i<t.length;i++)if(!(this._getItemLevel(t[i])>-1)){for(var n=i;n<t.length-1&&!(this._getItemLevel(t[n+1])>-1);n++);if(n>i){var o=t.slice(i,n+1);e.prototype._performSort.call(this,o);for(var r=0;r<o.length;r++)t[i+r]=o[r]}i=n}};PivotCollectionView.prototype._getItemLevel=function(e){return e[_PivotKey._ROW_KEY_NAME].level};return PivotCollectionView}(CollectionView);export{PivotCollectionView};var PivotField=function(){function PivotField(e,t,i,n){this._isExplicitAggregate=!1;this.propertyChanged=new Event;this._ng=e;this._binding=new PivotFieldBinding(this,t);this._header=i||toHeaderCase(t);this._showAs=ShowAs.NoCalculation;this._isContentHtml=!1;this._visible=!0;this._format="";this._filter=new PivotFilter(this);copy(this,n);null==this._dataType&&this._updateDataTypeByBinding();this._isExplicitAggregate||this._updateAggregateByDataType()}Object.defineProperty(PivotField.prototype,"binding",{get:function(){return this._binding?this._binding.path:null},set:function(e){if(e!=this.binding){var t=this.binding,i=asString(e);this._binding=i?new PivotFieldBinding(this,i):null;if(null==this._dataType){this._updateDataTypeByBinding();this._isExplicitAggregate||this._updateAggregateByDataType()}var n=new PropertyChangedEventArgs("binding",t,e);this.onPropertyChanged(n)}},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"getValue",{get:function(){return this._getValueFn},set:function(e){this._getValueFn=asFunction(e,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"getAggregateValue",{get:function(){return this._getAggValueFn},set:function(e){this._getAggValueFn=asFunction(e,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"header",{get:function(){return this._header},set:function(e){e=asString(e,!1);var t=this._ng.fields.getField(e);!e||t&&t!=this?assert(!1,"field headers must be unique and non-empty."):this._setProp("_header",asString(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"aggregate",{get:function(){return this._aggregate},set:function(e){this._isExplicitAggregate=!0;this._setProp("_aggregate",asEnum(e,Aggregate))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"showAs",{get:function(){return this._showAs},set:function(e){this._setProp("_showAs",asEnum(e,ShowAs))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"weightField",{get:function(){return this._weightField},set:function(e){this._setProp("_weightField",asType(e,PivotField,!0))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"dataType",{get:function(){return this._dataType},set:function(e){this._setProp("_dataType",asEnum(e,DataType))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"isMeasure",{get:function(){return this._dataType==DataType.Number},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"subFields",{get:function(){return this._subFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"format",{get:function(){return this._format},set:function(e){this._setProp("_format",asString(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"align",{get:function(){return this._align},set:function(e){this._setProp("_align",asString(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"width",{get:function(){return this._width},set:function(e){this._setProp("_width",asNumber(e,!0,!0))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"wordWrap",{get:function(){return this._wordWrap},set:function(e){this._setProp("_wordWrap",asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"descending",{get:function(){return!!this._descending},set:function(e){this._setProp("_descending",asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"isContentHtml",{get:function(){return this._isContentHtml},set:function(e){this._setProp("_isContentHtml",asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"visible",{get:function(){return this._visible},set:function(e){this._setProp("_visible",asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"sortComparer",{get:function(){return this._srtCmp},set:function(e){e!=this.sortComparer&&(this._srtCmp=asFunction(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"collectionView",{get:function(){return this.engine?this.engine.collectionView:null},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"isActive",{get:function(){return this._getIsActive()},set:function(e){this._setIsActive(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"parentField",{get:function(){return this._parent},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"key",{get:function(){return this.header},enumerable:!0,configurable:!0});PivotField.prototype.onPropertyChanged=function(e){this.propertyChanged.raise(this,e);this._ng._fieldPropertyChanged(this,e)};PivotField.prototype._updateDataTypeByBinding=function(){if(this._ng&&this._binding)for(var e=this._ng.collectionView,t=e?e.items.length:0,i=0;i<t;i++){var n=e.items[i];if(null!=n){this._dataType=getType(this._binding.getValue(n));break}}};PivotField.prototype._updateAggregateByDataType=function(){this._aggregate=this.dataType==DataType.Number?Aggregate.Sum:Aggregate.Cnt};PivotField.prototype._copy=function(e,t){var i=this;if("subFields"==e){this._subFields?this._subFields.splice(0,this._subFields.length):this._subFields=[];t&&t.length&&t.forEach((function(e){var t=i.engine._createField(e,i._autoGenerated);i._subFields.push(t)}));return!0}if("filter"==e){this._setFilterProxy(t);return!0}return!1};PivotField.prototype._getFilterProxy=function(){var e=this.filter;if(e.conditionFilter.isActive){var 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){var n=e.valueFilter;return{filterText:n.filterText,showValues:n.showValues}}assert(!1,"inactive filters shouldn't be persisted.");return null};PivotField.prototype._setFilterProxy=function(e){var t=this.filter,i=t.conditionFilter,n=t.valueFilter;t.clear();e.conditionFilter?e=e.conditionFilter:e.valueFilter&&(e=e.valueFilter);if(e.condition1){var o=e.condition1,r=changeType(o.value,this.dataType);i.condition1.value=r||o.value;i.condition1.operator=o.operator;var s=e.condition2;if(s){var l=changeType(s.value,this.dataType);i.condition2.value=l||s.value;i.condition2.operator=s.operator}isBoolean(e.and)&&(i.and=e.and)}if(e.showValues){n.filterText=e.filterText;n.showValues=e.showValues}};PivotField.prototype._getIsActive=function(){if(this._ng&&!this._hasSubFields())for(var e=this._ng._viewLists,t=0;t<e.length;t++)if(e[t].indexOf(this)>-1)return!0;return!1};PivotField.prototype._setIsActive=function(e){if(this._ng&&!this._hasSubFields()){var t=this.isActive;if((e=asBoolean(e))!=t)if(e)this.isMeasure?this._ng.valueFields.push(this):this._ng.rowFields.push(this);else{for(var i=this._ng._viewLists,n=0;n<i.length;n++)for(var o=i[n],r=0;r<o.length;r++){if((l=o[r])==this||l.parentField==this){o.removeAt(r);r--}}var s=this._ng.fields;for(r=s.length-1;r>=0;r--){var l;if((l=s[r]).parentField==this){s.removeAt(r);r--}}}}};PivotField.prototype._hasSubFields=function(){return null!=this._subFields&&this._subFields.length>0};PivotField.prototype._clone=function(){var e=new PivotField(this._ng,this.binding);this._ng._copyProps(e,this,PivotField._props);e._autoGenerated=!0;e._parent=this;for(var t=this.header.replace(/\d+$/,""),i=2;;i++){var n=t+i.toString();if(null==this._ng.fields.getField(n)){e._header=n;break}}return e};PivotField.prototype._setProp=function(e,t,i){var n=this[e];if(t!=n){this[e]=t;var o=new PropertyChangedEventArgs(e.substr(1),n,t);this.onPropertyChanged(o)}};PivotField.prototype._getName=function(){return this.header||this.binding};PivotField.prototype._getValue=function(e,t){var i=this._binding,n=null;e&&(n=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 n?Globalize.format(n,this._format):n};PivotField.prototype._getWeight=function(e){var t=this._weightField?this._weightField._getValue(e,!1):null;return isNumber(t)?t:null};PivotField._props=["dataType","format","width","wordWrap","aggregate","showAs","descending","isContentHtml","visible"];return PivotField}();export{PivotField};var CubePivotField=function(e){__extends(CubePivotField,e);function CubePivotField(t,i,n,o){var r=e.call(this,t,i,n,o)||this;assert(null!=r.dimensionType,"CubePivotField objects must specify the field's dimensionType");return r}Object.defineProperty(CubePivotField.prototype,"header",{get:function(){return this._header},set:function(e){this._setProp("_header",asString(e))},enumerable:!0,configurable:!0});Object.defineProperty(CubePivotField.prototype,"dimensionType",{get:function(){return this._dimensionType},set:function(e){this._setProp("_dimensionType",asEnum(e,DimensionType,!1))},enumerable:!0,configurable:!0});Object.defineProperty(CubePivotField.prototype,"isMeasure",{get:function(){switch(this._dimensionType){case 1:case 2:case 8:return!0}return!1},enumerable:!0,configurable:!0});Object.defineProperty(CubePivotField.prototype,"key",{get:function(){return this.binding},enumerable:!0,configurable:!0});CubePivotField.prototype._clone=function(){throw"CubePivotField objects cannot be cloned"};return CubePivotField}(PivotField);export{CubePivotField};export var DimensionType;!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||(DimensionType={}));var Slicer=function(e){__extends(Slicer,e);function Slicer(t,i){var n=e.call(this,t,null,isIE()&&!isEdge())||this;n._hdr=null;n._mSel=!1;n._updatingFilter=!1;n._propChanged=!1;n._fldPropChangeBnd=n._fldPropChange.bind(n);var o=n.getTemplate();n.applyTemplate(SlicerClsNames.hostElement+" "+SlicerClsNames.noCheck+" "+ControlClsNames.hostElement+" "+ControlClsNames.content,o,{_root:"root",_divHdr:"div-hdr",_divHdrText:"div-hdr-text",_btnMSel:"btn-msel",_btnClear:"btn-clear"});var r=culture.olap.Slicer,s=new Tooltip;setAttribute(n._btnMSel,"aria-label",r.multiSelect);setAttribute(n._btnClear,"aria-label",r.clearFilter);s.setTooltip(n._btnMSel,r.multiSelect);s.setTooltip(n._btnClear,r.clearFilter);n.addEventListener(n._btnClear,"click",(function(e){n._clear()}));n.addEventListener(n._btnMSel,"click",(function(e){n.multiSelect=!n.multiSelect}));n.initialize(i);return n}Object.defineProperty(Slicer,"controlTemplate",{get:function(){Slicer._ctrlTemplate||(Slicer._ctrlTemplate='<div wj-part="root"><div wj-part="div-hdr" class="'+SlicerClsNames.header+'"><div wj-part="div-hdr-text"></div><button wj-part="btn-msel" class="'+InputFormElementsClsNames.btn+' btn-msel" tabindex="-1"><span class='+GlyphClsNames.glyph+'>≡</span></button><button wj-part="btn-clear" class="'+InputFormElementsClsNames.btn+' btn-clear" tabindex="-1"><span class='+GlyphClsNames.glyph+">×</span></button></div></div>");return Slicer._ctrlTemplate},set:function(e){Slicer._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"field",{get:function(){return this._fld},set:function(e){var t=this;if(e!=this._fld){if(this._divListBox){removeChild(this._divListBox);this._divListBox=null;this._lbx.dispose();this._lbx=null}if(this._edt){this._clear();this._edt.dispose()}var i=this._fld;if(i){i.filter.filterType=this._originalFilterType;i.filter.valueFilter.uniqueValues=this._uniqueValues;i.propertyChanged.removeHandler(this._fldPropChangeBnd)}if(i=this._fld=asType(e,PivotField,!0)){this._originalFilterType=i.filter.filterType;i.filter.filterType=FilterType.Value;var n=i.engine;this._uniqueValues=i.filter.valueFilter.uniqueValues;if(n.isServer&&!this._uniqueValues){var o=n._getUniqueValues(i);i.filter.valueFilter.uniqueValues=o}i.propertyChanged.addHandler(this._fldPropChangeBnd);i.isActive||i.engine.filterFields.push(i);var r=document.createElement("div");this._edt=new ValueFilterEditor(r,i.filter.valueFilter)}if(this._edt){this._divListBox=this._edt.hostElement.querySelector("."+ListBoxClsNames.hostElement);this._root.appendChild(this._divListBox);this._lbx=Control.getControl(this._divListBox);this._lbx.checkedItemsChanged.addHandler((function(e,n){if(!t._propChanged){var o=t._lbx.selectedItem;if(!t.multiSelect&&o){t._mSel=!0;t._lbx.checkedItems=[o];t._mSel=!1}}if(t._edt&&i){t._updateFilter();i.engine.invalidate()}}))}this._updateHeader();isIE()&&!isEdge()&&this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"header",{get:function(){return this._hdr},set:function(e){if(e!=this._hdr){this._hdr=asString(e);this._updateHeader()}},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"showHeader",{get:function(){return"none"!=this._divHdr.style.display},set:function(e){this._divHdr.style.display=asBoolean(e)?"":"none"},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"showCheckboxes",{get:function(){return!hasClass(this.hostElement,SlicerClsNames.noCheck)},set:function(e){toggleClass(this.hostElement,SlicerClsNames.noCheck,!asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"multiSelect",{get:function(){return this._mSel},set:function(e){this._mSel=asBoolean(e);toggleClass(this._btnMSel,ControlStateClsNames.active,this._mSel)},enumerable:!0,configurable:!0});Slicer.prototype.refresh=function(t){var i=this;void 0===t&&(t=!0);isIE()&&!isEdge()&&this.hostElement&&setTimeout((function(){setCss(i._lbx.hostElement,{height:i.hostElement.clientHeight-i._divHdr.offsetHeight})}));e.prototype.refresh.call(this,t)};Slicer.prototype._fldPropChange=function(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};Slicer.prototype._updateHeader=function(){var e=this._hdr;e||null==this._fld||(e=this._fld.header);this._divHdrText.textContent=e};Slicer.prototype._clear=function(){if(this._edt){this._edt.clearEditor(!1);this._updateFilter();this._fld.engine.invalidate()}};Slicer.prototype._updateFilter=function(){this._updatingFilter=!0;this._edt.updateFilter();this._updatingFilter=!1};Slicer._ctrlTemplate="";return Slicer}(Control);export{Slicer};var _GridContextMenu=function(e){__extends(_GridContextMenu,e);function _GridContextMenu(){var t=e.call(this,document.createElement("div"),{header:"PivotGrid Context Menu",displayMemberPath:"text",commandParameterPath:"parm",command:{executeCommand:function(e){t._execute(e)},canExecuteCommand:function(e){return t._canExecute(e)}}})||this;t.itemsSource=t._getMenuItems();addClass(t.dropDown,"context-menu "+_GridContextMenuClsNames.hostElement);return t}_GridContextMenu.prototype.refresh=function(t){void 0===t&&(t=!0);this.itemsSource=this._getMenuItems();e.prototype.refresh.call(this,t)};_GridContextMenu.prototype.attach=function(e){var t=this;assert(e instanceof PivotGrid,"Expecting a PivotGrid control...");var i=e.hostElement;i.addEventListener("contextmenu",(function(n){if(e.customContextMenu){n.preventDefault();t.owner=i;if(t._selectField(n)){var o=t.dropDown;t.selectedIndex=-1;if(t.onIsDroppedDownChanging(new CancelEventArgs)){showPopup(o,n);t.onIsDroppedDownChanged();o.focus()}}}}))};_GridContextMenu.prototype._selectField=function(e){this._targetField=null;this._htDown=null;var t=Control.getControl(this.owner),i=t.engine,n=i.valueFields,o=i.columnFields,r=t.hitTest(e),s=CellType;switch(r.cellType){case s.Cell:t.select(r.range);this._targetField=n[r.col%n.length];this._htDown=r;break;case s.ColumnHeader:this._targetField=r.row<o.length?o[r.row]:n[r.col%n.length];break;case s.RowHeader:this._targetField=t._colRowFields.get(r.getColumn());break;case s.TopLeft:r.row==r.panel.rows.length-1&&(this._targetField=t._colRowFields.get(r.getColumn()))}return null!=this._targetField};_GridContextMenu.prototype._getMenuItems=function(){for(var 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="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon">⌕</div>Show Detail...',parm:"detail"}],t=0;t<e.length;t++){var i=e[t];if(i.parm){var n=culture.olap._ListContextMenu[i.parm];assert(n,"missing localized text for item "+i.parm);i.text=i.text.replace(/([^>]+$)/,n)}}return e};_GridContextMenu.prototype._execute=function(e){var t=this._targetField,i=Control.getControl(this.owner),n=i?i.engine:null,o=this._htDown;switch(e){case"remove":n.removeField(t);break;case"edit":n.editField(t);break;case"detail":i.showDetail(o.row,o.col)}};_GridContextMenu.prototype._canExecute=function(e){var t=this._targetField,i=Control.getControl(this.owner),n=i?i.engine:null,o=this._htDown;if(null==t||null==n)return!1;switch(e){case"remove":return!0;case"edit":return n.allowFieldEditing;case"detail":return null!=o&&!(t instanceof CubePivotField)&&n.valueFields.length>0}return!0};return _GridContextMenu}(Menu);export{_GridContextMenu};var PivotFieldCollection=function(e){__extends(PivotFieldCollection,e);function PivotFieldCollection(t){var i=e.call(this)||this;i._ng=t;return i}Object.defineProperty(PivotFieldCollection.prototype,"maxItems",{get:function(){return this._maxItems},set:function(e){this._maxItems=asInt(e,!0,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotFieldCollection.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});PivotFieldCollection.prototype.getField=function(e){return this._getField(this,e)};PivotFieldCollection.prototype._getField=function(e,t){for(var i=0;i<e.length;i++){var n=e[i];if(n.key==t)return n;if(n._hasSubFields()&&(n=this._getField(n.subFields,t)))return n}return null};PivotFieldCollection.prototype.push=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];for(var n=this._ng,o=0;t&&o<t.length;o++){var r=t[o];isString(r)&&(r=this==n.fields?new PivotField(n,r):n.fields.getField(r));assert(r instanceof PivotField,"This collection must contain PivotField objects only.");if(r.key&&this.getField(r.key)){assert(!1,"PivotField keys must be unique.");return-1}if(null!=this._maxItems&&this.length>=this._maxItems)break;e.prototype.push.call(this,r)}return this.length};return PivotFieldCollection}(ObservableArray);export{PivotFieldCollection};var _PivotNode=function(){function _PivotNode(e,t,i,n,o,r){this._key=new _PivotKey(e,t,i,n,o);this._nodes={};this._parent=r}_PivotNode.prototype.getNode=function(e,t,i,n,o){for(var r=this,s=0;s<t;s++){var l=e[s]._getValue(o,!0);if(!(a=r._nodes[l])){a=new _PivotNode(e,s+1,i,n,o,r);r._nodes[l]=a}r=a}if(i&&n>-1){var a;l=i[n].header;if(!(a=r._nodes[l])){a=new _PivotNode(e,t,i,n,o,r);r._nodes[l]=a}r=a}return r};Object.defineProperty(_PivotNode.prototype,"key",{get:function(){return this._key},enumerable:!0,configurable:!0});Object.defineProperty(_PivotNode.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0});Object.defineProperty(_PivotNode.prototype,"tree",{get:function(){this._tree||(this._tree=new _PivotNode(null,0,null,-1,null));return this._tree},enumerable:!0,configurable:!0});return _PivotNode}();export{_PivotNode};var _ServerConnection=function(){function _ServerConnection(e,t){this._ng=asType(e,PivotEngine);assert(this._isValidUrl(t),"Invalid service Url: "+t+")")}_ServerConnection.prototype.getFields=function(){var e=this,t=null;httpRequest(this._getUrl("Fields"),{async:!1,success:function(e){t=JSON.parse(e.responseText);isArray(t)||console.error("Failed to get fields from server: "+e.responseText)},error:function(t){e._handleError("Getting Fields",t)}});return t};_ServerConnection.prototype.getUniqueValues=function(e){var t=this,i=null;httpRequest(this._getUrl("UniqueValues",null,e.header),{method:"POST",async:!1,data:{view:this._ng.viewDefinition},success:function(e){i=JSON.parse(e.responseText);isArray(i)||console.error("Failed to get unique field values from server: "+e.responseText)},error:function(e){t._handleError("Getting Unique Field Values",e)}});return i};_ServerConnection.prototype.getOutputView=function(e){var t=this;this.clearPendingRequests();this._sendHttpRequest("Analyses",{method:"POST",data:{view:this._ng.viewDefinition},success:function(i){var n=JSON.parse(i.responseText);t._token=n.token;t._start=Date.now();t._handleResult(n.status,e)},error:function(e){t._handleError("Analyses",e)}})};_ServerConnection.prototype.getDetail=function(e,t){for(var i,n=[],o=this._ng.rowFields.length,r=e?e.values.length:0,s=0;s<o;s++)s<r?n.push(_ServerConnection._getRequestedValue(e.values[s])):n.push(null);o=this._ng.columnFields.length;r=t?t.values.length:0;for(s=0;s<o;s++)s<r?n.push(_ServerConnection._getRequestedValue(t.values[s])):n.push(null);i=new ObservableArray;this._loadArray("Detail",i,{method:"POST",view:this._ng.viewDefinition,keys:n,max:this._ng.serverMaxDetail});return i};_ServerConnection.prototype.getSortedKeys=function(e,t){var i=this,n=Object.keys(e);if(this._ng.sortOnServer){if(n.length>1){var o={},r=[],s=[];n.forEach((function(e){i._insertKey(o,e,t)}));this._reorderKeys(o,null,null,r,t);if(!t&&this._ng.valueFields.length>1){for(var l=r.length/this._ng.valueFields.length,a=r.length/l,d=0;d<l;d++)for(var u=0;u<a;u++)s.push(r[d+u*l]);return s}return r}}else n.sort((function(e,t){return i._ng._keys[e].compareTo(i._ng._keys[t])}));return n};_ServerConnection._getRequestedValue=function(e){if(isDate(e)){var t=e;return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()))}return e};_ServerConnection.prototype.clearPendingRequests=function(){this._clearRequest();this._clearTimeout();this._clearToken()};_ServerConnection.prototype.updateTallies=function(e){var t=this,i=this._ng,n=i.rowFields.length,o=i.columnFields.length,r=i.valueFields.length,s=new _PivotNode(i.rowFields,0,null,-1,null);e.forEach((function(e,l,a){var d=t._getAggregatedFieldCount(e,i.rowFields),u=s.getNode(i.rowFields,n-d,null,-1,e),h=u.key,c=h.toString(null),p=i._tallies[c];if(!p){i._keys[c]=h;i._tallies[c]=p={}}d=t._getAggregatedFieldCount(e,i.columnFields);for(var g=0;g<r;g++){var _=u.tree.getNode(i.columnFields,o-d,i.valueFields,g,e).key,f=_.toString(),v=i.valueFields[g],m=p[f];if(!m){i._keys[f]=_;(m=p[f]=new _ServerTally).add(t._getFieldValue(v,e,!1))}}}))};_ServerConnection.prototype._getFieldValue=function(e,t,i){var n=t[e.key];return i&&"string"!=typeof n?Globalize.format(n,e.format):n};_ServerConnection.prototype._getKeyLength=function(e,t){return e.split(";").length-(t?1:2)};_ServerConnection.prototype._insertKey=function(e,t,i){var n=t.split(";");i||n.pop();if(1==n.length)e[n.pop()]={};else{var o=n.pop(),r=e[o];r||(e[o]=r={});for(;n.length>0;){var s=n.shift();r[s]||(r[s]={});r=r[s]}}};_ServerConnection.prototype._joinKeys=function(e,t,i){return t&&i?[t,e,i].join(";"):i?[e,i].join(";"):e};_ServerConnection.prototype._reorderKeys=function(e,t,i,n,o){var r=this;Object.keys(e).forEach((function(s){var l=r._joinKeys(s,t,i),a=o?r._ng.showRowTotals:r._ng.showColumnTotals,d=Object.keys(e[s]).length,u=!t&&!i&&a!==ShowTotals.None||!t&&!d||t||a===ShowTotals.Subtotals;o||(l+=";");r._ng.totalsBeforeData&&u&&n.push(l);i?t?r._reorderKeys(e[s],[t,s].join(";"),i,n,o):r._reorderKeys(e[s],s,i,n,o):r._reorderKeys(e[s],null,s,n,o);!r._ng.totalsBeforeData&&u&&n.push(l)}))};_ServerConnection.prototype._getParentKey=function(e,t){var i=e.split(";");t?i.splice(i.length-2,1):i.splice(0,i.length-2);return i.join(";")};_ServerConnection.prototype._getAggregatedFieldCount=function(e,t){for(var i=t.length,n=0,o=0;o<i;o++){var r=t[o];null==this._getFieldValue(r,e,!1)&&n++}return n};_ServerConnection.prototype._loadArray=function(e,t,i){var n=this;i||(i={});null==i.skip&&(i.skip=0);null==i.top&&(i.top=100);var o=isNumber(i.max)?i.max:1e6;this._request=httpRequest(this._getUrl(e),{data:i,method:i.method||"GET",success:function(r){var s=JSON.parse(r.responseText);t.deferUpdate((function(){s.value.forEach((function(e){t.push(e)}))}));if(s.value.length==i.top&&t.length<o){i.skip+=i.top;n._loadArray(e,t,i)}},error:function(t){n._handleError(e,t)}})};_ServerConnection.prototype._getUrl=function(e,t,i){void 0===t&&(t=this._token);var n=this._ng.itemsSource.toString(),o=n.lastIndexOf("/");n.substr(0,o);switch(e=e.toLowerCase()){case"rawdata":case"detail":return n;case"fields":case"analyses":return n+"/"+e;case"clear":return n+"/analyses/"+t+"/";case"result":case"status":return n+"/analyses/"+t+"/"+e;case"uniquevalues":return n+"/fields/"+i+"/"+e}assert(!1,"Unrecognized command")};_ServerConnection.prototype._isValidUrl=function(e){var t=document.createElement("a");t.href=asString(e);t.href=t.href;return t.protocol&&t.hostname&&t.pathname&&"/"!=e[e.length-1]};_ServerConnection.prototype._handleResult=function(e,t){var i=this;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((function(){i._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..."})}};_ServerConnection.prototype._waitUntilComplete=function(e){var t=this;this._sendHttpRequest("Status",{success:function(i){var n=JSON.parse(i.responseText);t._handleResult(n,e)},error:function(e){t._handleError("Status",e)}})};_ServerConnection.prototype._getResults=function(e){var t=this;this._sendHttpRequest("Result",{success:function(i){t._clearToken();var n=JSON.parse(i.responseText);assert(isArray(n),"Result array Expected.");var o=[];t._ng._viewLists.forEach((function(e){o=o.concat(e.filter((function(e){return e.dataType==DataType.Date})))}));o.length>0&&n.forEach((function(e){o.forEach((function(t){var i=t._binding,n=i.getValue(e);isString(n)&&i.setValue(e,new Date(n))}))}));asFunction(e)(n)},error:function(e){t._handleError("Result",e)}})};_ServerConnection.prototype._handleError=function(e,t){this.clearPendingRequests();e='** HttpRequest error on command "'+e+'"';this._ng.onError(new RequestErrorEventArgs(t,e))&&this._throwResponseError(e,t)};_ServerConnection.prototype._sendHttpRequest=function(e,t){var i=this._getUrl(e);this._request=httpRequest(i,t)};_ServerConnection.prototype._throwResponseError=function(e,t){e=e+"\r\n"+t.status+"\r\n";var i=t.responseText||"";if(500==t.status&&t.responseText){i=JSON.parse(t.responseText).ExceptionMessage}throw e+=i||t.statusText};_ServerConnection.prototype._clearToken=function(){if(this._token){this._clearRequest();this._clearTimeout();this._sendHttpRequest("Clear",{method:"DELETE"});this._token=null}};_ServerConnection.prototype._clearRequest=function(){if(this._request&&4!=this._request.readyState){this._request.abort();this._request=null}};_ServerConnection.prototype._clearTimeout=function(){if(this._toGetStatus){clearTimeout(this._toGetStatus);this._toGetStatus=null}};_ServerConnection._TIMEOUT=6e4;_ServerConnection._POLL_INTERVAL=500;_ServerConnection._MAXDETAIL=1e3;return _ServerConnection}();export{_ServerConnection};var _ServerTally=function(e){__extends(_ServerTally,e);function _ServerTally(){return null!==e&&e.apply(this,arguments)||this}_ServerTally.prototype.add=function(e,t){assert(0==this._cnt,"Server tallies have a single value.");this._aggregatedValue=e};_ServerTally.prototype.getAggregate=function(e){return this._aggregatedValue};return _ServerTally}(_Tally);_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"}});export var ShowTotals;!function(e){e[e.None=0]="None";e[e.GrandTotals=1]="GrandTotals";e[e.Subtotals=2]="Subtotals"}(ShowTotals||(ShowTotals={}));export var ShowAs;!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||(ShowAs={}));var PivotEngine=function(){function PivotEngine(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 Event;this.viewDefinitionChanged=new Event;this.updatingView=new Event;this.updatedView=new Event;this.error=new Event;this._isUpdatingChanged=new Event;this._hasDeferredUpdatesChanged=new 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];var t=this._fieldListChanged.bind(this);this._fields.collectionChanged.addHandler(t);this._viewLists.forEach((function(e){e.collectionChanged.addHandler(t)}));this._defaultFilterType=null;copy(this,e)}Object.defineProperty(PivotEngine.prototype,"itemsSource",{get:function(){return this._items},set:function(e){var t=this;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;isString(e)?this._server=new _ServerConnection(this,e):isObject(e)&&!tryCast(e,"ICollectionView")?this._server=new _SqlServerConnection(this,e):this._cv=asCollectionView(e);null!=this._cv&&this._cv.collectionChanged.addHandler(this._cvCollectionChanged,this);this.deferUpdate((function(){t.autoGenerateFields&&t._generateFields();t._updateFieldTypes()}));this.onItemsSourceChanged()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"isServer",{get:function(){return null!=this._server},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"collectionView",{get:function(){return this._cv},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"pivotView",{get:function(){return this._pivotView},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"showRowTotals",{get:function(){return this._showRowTotals},set:function(e){if((e=asEnum(e,ShowTotals))!=this.showRowTotals){this._showRowTotals=e;this.onViewDefinitionChanged();this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"showColumnTotals",{get:function(){return this._showColTotals},set:function(e){if((e=asEnum(e,ShowTotals))!=this.showColumnTotals){this._showColTotals=e;this.onViewDefinitionChanged();this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"totalsBeforeData",{get:function(){return this._totalsBefore},set:function(e){if(e!=this._totalsBefore){this._totalsBefore=asBoolean(e);this.onViewDefinitionChanged();this._updatePivotView()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"sortableGroups",{get:function(){return this._sortableGroups},set:function(e){if(e!=this._sortableGroups){this._sortableGroups=asBoolean(e);this.onViewDefinitionChanged()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"sortOnServer",{get:function(){return this._sortOnServer},set:function(e){this._sortOnServer=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"showZeros",{get:function(){return this._showZeros},set:function(e){if(e!=this._showZeros){this._showZeros=asBoolean(e);this.onViewDefinitionChanged();this._updatePivotView()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"defaultFilterType",{get:function(){return null!=this._defaultFilterType?this._defaultFilterType:this._server?FilterType.Condition:FilterType.Both},set:function(e){this._defaultFilterType=asEnum(e,FilterType,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"autoGenerateFields",{get:function(){return this._autoGenFields},set:function(e){this._autoGenFields=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"allowFieldEditing",{get:function(){return this._allowFieldEditing},set:function(e){this._allowFieldEditing=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"fields",{get:function(){return this._fields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"rowFields",{get:function(){return this._rowFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"columnFields",{get:function(){return this._columnFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"filterFields",{get:function(){return this._filterFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"valueFields",{get:function(){return this._valueFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"viewDefinition",{get:function(){var e=this,t={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((function(i){var n=e._getFieldDefinition(i);t.fields.push(n)}));return JSON.stringify(t)},set:function(e){var t=this,i=JSON.parse(e);i&&this.deferUpdate((function(){t._copyProps(t,i,PivotEngine._props);t.fields.clear();i.fields.forEach((function(e){var i=t._getFieldFromDefinition(e);t.fields.push(i)}));i.fields.forEach((function(e,i){isString(e.weightField)&&(t.fields[i].weightField=t.fields.getField(e.weightField))}));t._setFieldCollectionProxy(t.rowFields,i.rowFields);t._setFieldCollectionProxy(t.columnFields,i.columnFields);t._setFieldCollectionProxy(t.filterFields,i.filterFields);t._setFieldCollectionProxy(t.valueFields,i.valueFields)}))},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"isViewDefined",{get:function(){var 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},enumerable:!0,configurable:!0});PivotEngine.prototype.beginUpdate=function(){this.cancelPendingUpdates();this._updating++;1===this._updating&&this._onIsUpdatingChanged()};PivotEngine.prototype.endUpdate=function(){this._updating--;if(this._updating<=0){if(this._viewDefinitionChanged){this._viewDefinitionChanged=!1;this.onViewDefinitionChanged();this._setHasDeferredUpdates(!1)}this._onIsUpdatingChanged();this.refresh()}};Object.defineProperty(PivotEngine.prototype,"isUpdating",{get:function(){return this._updating>0},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"hasDeferredUpdates",{get:function(){return this._hasDeferredUpdates},enumerable:!0,configurable:!0});PivotEngine.prototype._setHasDeferredUpdates=function(e){if(this._hasDeferredUpdates!==e){this._hasDeferredUpdates=e;this._onHasDeferredUpdatesChanged()}};PivotEngine.prototype.deferUpdate=function(e){try{this.beginUpdate();e()}finally{this.endUpdate()}};PivotEngine.prototype.refresh=function(e){void 0===e&&(e=!1);this._updateView(e)};PivotEngine.prototype.invalidate=function(){var e=this;this._toInv&&(this._toInv=clearTimeout(this._toInv));this.isUpdating||(this._toInv=setTimeout((function(){e.refresh()}),Control._REFRESH_INTERVAL))};Object.defineProperty(PivotEngine.prototype,"async",{get:function(){return this._async},set:function(e){if(e!=this._async){this.cancelPendingUpdates();this._async=asBoolean(e)}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"serverTimeout",{get:function(){return this._serverParms.timeout},set:function(e){this._serverParms.timeout=asNumber(e,!1,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"serverPollInterval",{get:function(){return this._serverParms.pollInterval},set:function(e){this._serverParms.pollInterval=asNumber(e,!1,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"serverMaxDetail",{get:function(){return this._serverParms.maxDetail},set:function(e){this._serverParms.maxDetail=asNumber(e,!1,!0)},enumerable:!0,configurable:!0});PivotEngine.prototype.cancelPendingUpdates=function(){if(this._toUpdateTallies){clearTimeout(this._toUpdateTallies);this._toUpdateTallies=null}};PivotEngine.prototype.getDetail=function(e,t){var i=this,n=e?e[_PivotKey._ROW_KEY_NAME]:null,o=this._getKey(t);if(this._server)return this._server.getDetail(n,o);var r=this.collectionView.items,s=[];r.forEach((function(e){!i._applyFilter(e)||null!=n&&!n.matchesItem(e)||null!=o&&!o.matchesItem(e)||s.push(e)}));return s};PivotEngine.prototype.getDetailView=function(e,t){var i=this.getDetail(e,t);return new CollectionView(i)};PivotEngine.prototype.getKeys=function(e,t){var i=e?e[_PivotKey._ROW_KEY_NAME]:null,n=this._getKey(t);return{rowKey:{fields:i?i.fieldNames:[],values:i?i.values:[]},colKey:{fields:n?n.fieldNames:[],values:n?n.values:[]}}};PivotEngine.prototype.editField=function(e){if(this.allowFieldEditing){var t=new PivotFieldEditor(document.createElement("div"),{field:e});new Popup(document.createElement("div"),{content:t.hostElement}).show(!0)}};PivotEngine.prototype.removeField=function(e){for(var t=0;t<this._viewLists.length;t++){var i=this._viewLists[t],n=i.indexOf(e);if(n>-1){i.removeAt(n);return}}};PivotEngine.prototype.onItemsSourceChanged=function(e){this.itemsSourceChanged.raise(this,e)};PivotEngine.prototype.onViewDefinitionChanged=function(e){if(this._updating<=0){this.viewDefinitionChanged.raise(this,e);this._viewDefinitionChanged=!1;this._setHasDeferredUpdates(!1)}else{this._viewDefinitionChanged=!0;this._setHasDeferredUpdates(!0)}};PivotEngine.prototype.onUpdatingView=function(e){this.updatingView.raise(this,e)};PivotEngine.prototype.onUpdatedView=function(e){this.updatedView.raise(this,e)};PivotEngine.prototype.onError=function(e){this.error.raise(this,e);return!e.cancel};PivotEngine.prototype._onIsUpdatingChanged=function(e){this._isUpdatingChanged.raise(this,e)};PivotEngine.prototype._onHasDeferredUpdatesChanged=function(e){this._hasDeferredUpdatesChanged.raise(this,e)};PivotEngine.prototype._copy=function(e,t){var i=this;switch(e){case"fields":this.fields.clear();this._viewLists.forEach((function(e){e.clear()}));asArray(t).forEach((function(e){var t=i._createField(e,!1);i.fields.push(t)}));this._updateFieldTypes();return!0;case"rowFields":case"columnFields":case"valueFields":case"filterFields":this[e].clear();if(!isArray(t)){this[e].maxItems=t.maxItems;t=t.items}asArray(t).forEach((function(t){var n=i.fields.getField(t);i[e].push(n)}));return!0}return!1};PivotEngine.prototype._getKey=function(e){return this._keys[e]};PivotEngine.prototype._getRowKey=function(e){var t=e;if(isNumber(e)){var i=this._pivotView;t=(i.items.length?i.items:i.sourceCollection)[e]}return t?t[_PivotKey._ROW_KEY_NAME]:null};PivotEngine.prototype._getRowLevel=function(e){var t=this._getRowKey(e);return t?t.level:-1};PivotEngine.prototype._getColKey=function(e){isNumber(e)&&(e=this._colBindings[e]);if(isString(e))return this._getKey(e);assert(null==e||e instanceof _PivotKey,"invalid parameter in call to _getColLevel");return e};PivotEngine.prototype._getColLevel=function(e){return(e=this._getColKey(e))?e.level:-1};PivotEngine.prototype._getFieldByColKey=function(e){var t=this._getColKey(e);return t&&t.valueField};PivotEngine.prototype._applyFilter=function(e){for(var t=this._activeFilterFields,i=0;i<t.length;i++){if(!t[i].filter.apply(e))return!1}return!0};PivotEngine.prototype._updateView=function(e){var t=this;void 0===e&&(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((function(i){if(t.isViewDefined){t._server.updateTallies(i);t._updatePivotView(e)}}));return}this._viewLists.forEach((function(e){e.forEach((function(e){e.filter.isActive&&t._activeFilterFields.push(e)}))}));if(this.isViewDefined&&hasItems(this._cv)){this._batchStart=Date.now();this._updateTallies(this._cv.items,0,e)}else this._updatePivotView(e);this._setHasDeferredUpdates(!1)}};PivotEngine.prototype._updateTallies=function(e,t,i){var n=this;void 0===i&&(i=!1);var o=e.length,r=new _PivotNode(this._rowFields,0,null,-1,null),s=this.valueFields;0==s.length&&this.columnFields.length>0&&(s=new PivotFieldCollection(this)).push(new PivotField(this,"","",{aggregate:Aggregate.Sum}));for(var l=ShowTotals,a=this._rowFields.length,d=this._getShowRowTotals(),u=d==l.None?a:0,h=d==l.GrandTotals?Math.max(1,a):1,c=this._columnFields.length,p=this._getShowColTotals(),g=p==l.None?c:0,_=p==l.GrandTotals?Math.max(1,c):1,f=s.length,_loop_1=function(o){if(v._async&&o-t>=PivotEngine._BATCH_SIZE&&Date.now()-v._batchStart>PivotEngine._BATCH_DELAY){v._toUpdateTallies=setTimeout((function(){n.onUpdatingView(new ProgressEventArgs(Math.round(o/e.length*100)));n._batchStart=Date.now();n._updateTallies(e,o,i)}),PivotEngine._BATCH_TIMEOUT);return{value:void 0}}v._cntTotal++;var l=e[o];if(!v._activeFilterFields.length||v._applyFilter(l)){v._cntFiltered++;for(var d=u;d<=a;d+=h){var p=r.getNode(v._rowFields,d,null,-1,l),m=p.key,y=m.toString(),w=v._tallies[y];if(!w){v._keys[y]=m;v._tallies[y]=w={}}for(var b=g;b<=c;b+=_)for(var C=0;C<f;C++){var P=p.tree.getNode(v._columnFields,b,s,C,l).key,F=P.toString(),S=w[F];if(!S){v._keys[F]=P;S=w[F]=new _Tally}var E=s[C],T=E._getValue(l,!1),x=E.weightField?E._getWeight(l):null;S.add(T,x)}}}},v=this,m=t;m<o;m++){var y=_loop_1(m);if("object"==typeof y)return y.value}this._toUpdateTallies=null;this._updatePivotView(i)};PivotEngine.prototype._updatePivotView=function(e){var t=this;void 0===e&&(e=!1);if(!this.isUpdating||e){var i=this._pivotView;i.deferUpdate((function(){t.onUpdatingView(new ProgressEventArgs(100));i.cancelEdit();i.cancelNew();var e=i.sourceCollection;e.length=0;var n={};for(var o in t._tallies)n[o]=!0;var r={};for(var o in t._tallies){var s=t._tallies[o];for(var l in s)r[l]=!0}var a=[],d=[];if(t._server)a=t._server.getSortedKeys(n,!0),d=t._server.getSortedKeys(r,!1);else{a=t._getSortedKeys(n);d=t._getSortedKeys(r)}for(var u=0;u<a.length;u++){var h=a[u],c=(s=t._tallies[h],{});c[_PivotKey._ROW_KEY_NAME]=t._getKey(h);for(var p=0;p<d.length;p++){var g=d[p],_=s[g],f=t._getKey(g),v=_?_.getAggregate(f.aggregate):null;null==v&&t._showZeros&&(v=0);c[g]=v}e.push(c)}t._colBindings=d;t._updateFieldValues(e);i.sortDescriptions.clear();i.refresh()}));this.onUpdatedView()}};PivotEngine.prototype._getSortedKeys=function(e){var t=this,i=Object.keys(e);i.sort((function(e,i){return t._keys[e].compareTo(t._keys[i])}));return i};PivotEngine.prototype._updateFieldValues=function(e){for(var t=this.valueFields.length,i=0;i<t;i++){var n=this.valueFields[i];if(isFunction(n.getAggregateValue))for(var o=i;o<this._colBindings.length;o+=t)for(var r=0;r<e.length;r++){var s=e[r],l=this._colBindings[o],a=this._getAggregateObject(s,l);s[l]=n.getAggregateValue.call(this,a)}}var _loop_2=function(i){var n=d.valueFields[i];switch(n.showAs){case ShowAs.RunTot:case ShowAs.RunTotPct:for(var o=i;o<d._colBindings.length;o+=t){for(var r=0;r<e.length;r++){(u=e[r])[p=d._colBindings[o]]=d._getRunningTotal(e,r,o)}if(n.showAs==ShowAs.RunTotPct)for(r=0;r<e.length;r++){var s=(u=e[r])[p=d._colBindings[o]];if(isNumber(s)){var l=d._getLastValueInRowGroup(e,r,o);0!=l&&(u[p]=s/l)}}}break;case ShowAs.PctGrand:case ShowAs.PctCol:var a=0;if(n.showAs==ShowAs.PctGrand)for(o=i;o<d._colBindings.length;o+=t)-1==d._getColLevel(o)&&(a+=d._getColTotal(e,o));var _loop_3=function(t){n.showAs==ShowAs.PctCol&&(a=d._getColTotal(e,t));var i=d._colBindings[t];e.forEach((function(e){var t=e[i];isNumber(t)&&(e[i]=0!=a?t/a:null)}))};for(o=i;o<d._colBindings.length;o+=t)_loop_3(o);break;case ShowAs.PctRow:for(r=0;r<e.length;r++){var u=e[r],h=0;for(o=i;o<d._colBindings.length;o+=t)if(-1==d._getColLevel(o)){var c=u[p=d._colBindings[o]];isNumber(c)&&(h+=c)}for(o=i;o<d._colBindings.length;o+=t){c=u[p=d._colBindings[o]];isNumber(c)&&(u[p]=0!=h?c/h:null)}}break;case ShowAs.DiffRow:case ShowAs.DiffRowPct:case ShowAs.PctPrevRow:for(o=i;o<d._colBindings.length;o+=t)for(r=e.length-1;r>=0;r--){(u=e[r])[p=d._colBindings[o]]=d._getRowDifference(e,r,o,n.showAs)}break;case ShowAs.DiffCol:case ShowAs.DiffColPct:case ShowAs.PctPrevCol:for(r=0;r<e.length;r++)for(o=d._colBindings.length-t+i;o>=0;o-=t){var p;(u=e[r])[p=d._colBindings[o]]=d._getColDifference(e,r,o,n.showAs)}}},d=this;for(i=0;i<t;i++)_loop_2(i)};PivotEngine.prototype._getAggregateObject=function(e,t){var i={},n=/(.+:.+;)*((.+):.+;)/,o=t.match(n);for(var r in e){var s=r.match(n);s&&s[1]==o[1]&&(i[s[3]]=e[r])}return i};PivotEngine.prototype._getColTotal=function(e,t){var i=this,n=this._colBindings[t],o=0;e.forEach((function(e){if(-1==i._getRowLevel(e)){var t=e[n];isNumber(t)&&(o+=t)}}));return o};PivotEngine.prototype._getRunningTotal=function(e,t,i){var n=this._getRowLevel(e[t]);if(0==n)return null;for(var o=this._colBindings[i],r=e[t][o],s=this._getShowRowTotals(),l=this.rowFields.length-2,a=t-1;a>=0;a--){var d=this._getRowLevel(e[a]);if(d==n){if(l>-1&&n<0&&s!=ShowTotals.Subtotals){var u=e[t].$rowKey,h=e[a].$rowKey;if(u.values[l]!=h.values[l])return null}r+=e[a][o];break}if(d>n)break}return r};PivotEngine.prototype._getLastValueInRowGroup=function(e,t,i){for(var n=this._colBindings[i],o=e[t][n],r=this._getRowLevel(e[t]),s=this.rowFields.length-2,l=this._getShowRowTotals(),a=t+1;a<e.length;a++){var d=this._getRowLevel(e[a]);if(d==r){if(s>-1&&r<0&&l!=ShowTotals.Subtotals){var u=e[t].$rowKey,h=e[a].$rowKey;if(u.values[s]!=h.values[s])return o}o=e[a][n]}if(d>r)break}return o};PivotEngine.prototype._getRowDifference=function(e,t,i,n){var o=this._getRowLevel(e[t]);if(0==o)return null;for(var r=this._colBindings[i],s=e[t][r],l=this.rowFields.length-2,a=this._getShowRowTotals(),d=t-1;d>=0;d--){var u=this._getRowLevel(e[d]);if(u==o){if(l>-1&&o<0&&a!=ShowTotals.Subtotals){var h=e[t].$rowKey,c=e[d].$rowKey;if(h.values[l]!=c.values[l])return null}var p=e[d][r];switch(n){case ShowAs.DiffRow:s-=p;break;case ShowAs.DiffRowPct:s=(s-p)/p;break;case ShowAs.PctPrevRow:s/=p}return s}if(u>o)break}return n==ShowAs.PctPrevRow?1:null};PivotEngine.prototype._getColDifference=function(e,t,i,n){var o=this._getColLevel(i);if(0==o)return null;for(var r=e[t],s=r[this._colBindings[i]],l=this.valueFields.length,a=this.columnFields.length-2,d=this._getShowColTotals(),u=i-l;u>=0;u-=l){var h=this._getColLevel(u);if(h==o){if(a>-1&&o<0&&d!=ShowTotals.Subtotals){var c=this._getKey(this._colBindings[i]),p=this._getKey(this._colBindings[u]);if(c.values[a]!=p.values[a])return null}var g=r[this._colBindings[u]];switch(n){case ShowAs.DiffCol:s-=g;break;case ShowAs.DiffColPct:s=(s-g)/g;break;case ShowAs.PctPrevCol:s/=g}return s}if(h>o)break}return n==ShowAs.PctPrevCol?1:null};PivotEngine.prototype._getShowRowTotals=function(){return this._valueFields.length?this._showRowTotals:ShowTotals.None};PivotEngine.prototype._getShowColTotals=function(){return this._valueFields.length?this._showColTotals:ShowTotals.None};PivotEngine.prototype._getUniqueValues=function(e){return this._server?this._server.getUniqueValues(e):null};PivotEngine.prototype._generateFields=function(){var e=this;this._viewLists.forEach((function(e){e.clear()}));for(var t=0;t<this.fields.length;t++){if(this.fields[t]._autoGenerated){this.fields.removeAt(t);t--}}if(this._server){this._server.getFields().forEach((function(t){var i=e._createField(t,!0);e.fields.getField(i.header)||e.fields.push(i)}))}else{var i=this.collectionView,n=i?i.items:null;n&&n.length&&this.autoGenerateFields&&getTypes(n,0).forEach((function(t){var i=e._createField({binding:t.binding,header:toHeaderCase(t.binding),dataType:t.dataType},!0);e.fields.getField(i.header)||e.fields.push(i)}))}};PivotEngine.prototype._updateFieldTypes=function(){var e=this,t=this.collectionView,i=t?t.sourceCollection:null;i&&i.length&&this.fields.forEach((function(t){e._updateFieldType(t,i)}))};PivotEngine.prototype._updateFieldType=function(e,t){var i=this;if(e._hasSubFields())e.subFields.forEach((function(e){i._updateFieldType(e,t)}));else{if(null==e.dataType&&e.binding)for(var n=0;n<t.length;n++){var o=e._binding.getValue(t[n]);if(null!=o){e.dataType=isPrimitive(o)?getType(o):null;break}}if(null!=e.dataType){e.format||(e.format=e.dataType==DataType.Date?"d":"n0");e.aggregate==Aggregate.Sum&&e.dataType!=DataType.Number&&(e.aggregate=Aggregate.Cnt)}}};PivotEngine.prototype._createField=function(e,t){var i;if(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||isString(e)){i.format=i.dataType==DataType.Date?"d":"n0";i.aggregate=i.dataType==DataType.Number?Aggregate.Sum:Aggregate.Cnt}e&&!isString(e)&©(i,e);return i};PivotEngine.prototype._cvCollectionChanged=function(e,t){this.invalidate()};PivotEngine.prototype._fieldListChanged=function(e,t){if(t.action==NotifyCollectionChangedAction.Add){for(var i=e,n=0;n<i.length-1;n++)if(i[n].key)for(var o=n+1;o<i.length;o++)if(i[n].key==i[o].key){i.removeAt(o);o--}if(i!=this._fields)if(this._fields.getField(t.item.key)){for(n=0;n<this._viewLists.length;n++)if(this._viewLists[n]!=i){var r=this._viewLists[n];(s=r.indexOf(t.item))>-1&&r.removeAt(s)}}else i.removeAt(t.index);if(isNumber(i.maxItems)&&i.maxItems>-1)for(;i.length>i.maxItems;){var s;i[s=i.length-1]==t.item&&s>0&&s--;i.removeAt(s)}}this.onViewDefinitionChanged();this.invalidate()};PivotEngine.prototype._fieldPropertyChanged=function(e,t){this.onViewDefinitionChanged();if(e.isActive){var 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())}};PivotEngine.prototype._copyProps=function(e,t,i){for(var n=0;n<i.length;n++){var o=i[n];null!=t[o]&&(e[o]=t[o])}};PivotEngine.prototype._getFieldFromDefinition=function(e){var t=e.filter;e.filter&&delete e.filter;var i=this._createField(e,!0);if(t){i._setFilterProxy(t);e.filter=t}return i};PivotEngine.prototype._getFieldDefinition=function(e){var t=this,i={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&&(i.weightField=e.weightField._getName());e.key&&(i.key=e.key);e.filter.isActive&&(i.filter=e._getFilterProxy());if(e._hasSubFields()){i.subFields=[];e.subFields.forEach((function(e){i.subFields.push(t._getFieldDefinition(e))}))}e instanceof CubePivotField&&(i.dimensionType=e.dimensionType);return i};PivotEngine.prototype._getFieldCollectionProxy=function(e){var t={items:[]};isNumber(e.maxItems)&&e.maxItems>-1&&(t.maxItems=e.maxItems);for(var i=0;i<e.length;i++){var n=e[i];t.items.push(n.key)}return t};PivotEngine.prototype._setFieldCollectionProxy=function(e,t){e.clear();e.maxItems=isNumber(t.maxItems)?t.maxItems:null;for(var i=0;i<t.items.length;i++)e.push(t.items[i])};PivotEngine._BATCH_SIZE=1e4;PivotEngine._BATCH_TIMEOUT=0;PivotEngine._BATCH_DELAY=100;PivotEngine._props=["showZeros","showRowTotals","showColumnTotals","totalsBeforeData","sortableGroups","defaultFilterType"];return PivotEngine}();export{PivotEngine};var ProgressEventArgs=function(e){__extends(ProgressEventArgs,e);function ProgressEventArgs(t){var i=e.call(this)||this;i._progress=asNumber(t);return i}Object.defineProperty(ProgressEventArgs.prototype,"progress",{get:function(){return this._progress},enumerable:!0,configurable:!0});return ProgressEventArgs}(EventArgs);export{ProgressEventArgs};var _ListContextMenu=function(e){__extends(_ListContextMenu,e);function _ListContextMenu(t){var i=e.call(this,document.createElement("div"),{header:"Field Context Menu",displayMemberPath:"text",commandParameterPath:"parm",command:{executeCommand:function(e){i._execute(e)},canExecuteCommand:function(e){return i._canExecute(e)}}})||this;i._full=t;i.itemsSource=i._getMenuItems(t);addClass(i.dropDown,"context-menu "+_GridContextMenuClsNames.hostElement);return i}_ListContextMenu.prototype.refresh=function(t){void 0===t&&(t=!0);this.itemsSource=this._getMenuItems(this._full);e.prototype.refresh.call(this,t)};_ListContextMenu.prototype.attach=function(e){var t=this;assert(e instanceof FlexGrid,"Expecting a FlexGrid control...");var i=e.hostElement;i.addEventListener("contextmenu",(function(n){if(t._selectField(e,n)){n.preventDefault();t.owner=i;t.show(n)}}))};_ListContextMenu.prototype._selectField=function(e,t){var i=e.hitTest(t);if(i.panel!=e.cells||!i.range.isValid)return!1;var n=e.rows[i.row].dataItem;if(n instanceof CubePivotField&&n.subFields&&n.subFields.length)return!1;e.select(i.range,!0);return!0};_ListContextMenu.prototype._getMenuItems=function(e){var 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="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon"><span class='+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="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon menu-icon-remove">✖</div>*',parm:"remove"},{text:'<div class="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon">⛭</div>*',parm:"edit"}]:[{text:'<div class="menu-icon"><span class='+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="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon">⛭</div>*',parm:"edit"}];for(var i=0;i<t.length;i++){var n=t[i];if(n.parm){var o=culture.olap._ListContextMenu[n.parm];assert(o,"missing localized text for item "+n.parm);n.text=n.text.replace(/([^>]+$)/,o)}}return t};_ListContextMenu.prototype._execute=function(e){var t=Control.getControl(this.owner),i=t.itemsSource,n=t.selection.row,o=t.rows[n].dataItem,r=o?o.engine:null,s=this._getTargetList(r,e);switch(e){case"up":case"first":case"down":case"last":if(r){var l=i.indexOf(o),a="up"==e?l-1:"first"==e?0:"down"==e?l+1:"last"==e?i.length:-1;r.deferUpdate((function(){i.removeAt(l);i.insert(a,o)}))}break;case"filter":case"rows":case"cols":case"vals":s&&o&&s.push(o);break;case"remove":o&&r.removeField(o);break;case"edit":o&&r.editField(o)}};_ListContextMenu.prototype._canExecute=function(e){var t=Control.getControl(this.owner);if(!t)return!1;var i=t.selection.row,n=i>-1?t.rows[i].dataItem:null,o=n?n.engine:null,r=this._getTargetList(o,e),s=!!n&&n instanceof CubePivotField,l=!!n&&n.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!l&&r&&r.indexOf(n)<0;case"vals":return(!s||l)&&r&&r.indexOf(n)<0;case"edit":return o&&o.allowFieldEditing;case"detail":return n&&!s}return!0};_ListContextMenu.prototype._getTargetList=function(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};return _ListContextMenu}(Menu);export{_ListContextMenu};var PivotPanel=function(e){__extends(PivotPanel,e);function PivotPanel(t,i){var n=e.call(this,t,null,!0)||this;n._showIcons=!0;n._restrictDrag=null;n.deferredUpdateChanged=new Event;n.itemsSourceChanged=new Event;n.viewDefinitionChanged=new Event;n.updatingView=new Event;n.updatedView=new Event;n._isUpdatingChangedBnd=n._isUpdatingChanged.bind(n);var o=n.getTemplate();n.applyTemplate(ControlClsNames.hostElement+" "+ControlClsNames.content+" "+PivotPanelClsNames.hostElement,o,{_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"});n._globalize();var r=n.hostElement;n.addEventListener(r,"dragstart",n._dragstart.bind(n));n.addEventListener(r,"dragover",n._dragover.bind(n));n.addEventListener(r,"dragleave",n._dragover.bind(n));n.addEventListener(r,"drop",n._drop.bind(n));n.addEventListener(r,"dragend",n._dragend.bind(n));n._lbFields=n._createFieldGrid(n._dFields);n._lbFilters=n._createFieldGrid(n._dFilters);n._lbRows=n._createFieldGrid(n._dRows);n._lbCols=n._createFieldGrid(n._dCols);n._lbVals=n._createFieldGrid(n._dVals);var s=n._ctxMenuShort=new _ListContextMenu(!1);s.attach(n._lbFields);(s=n._ctxMenuFull=new _ListContextMenu(!0)).attach(n._lbFilters);s.attach(n._lbRows);s.attach(n._lbCols);s.attach(n._lbVals);n._dMarker=createElement('<div class="'+FlexGridClsNames.marker+'" style="display:none"> </div>');n.hostElement.appendChild(n._dMarker);n.addEventListener(n._btnUpdate,"click",(function(e){n._ng.refresh(!0);n.refresh();e.preventDefault()}));n.addEventListener(n._chkDefer,"click",(function(e){n.deferredUpdate=n._chkDefer.checked;n._updateDeferredUpdateElements()}));n.engine=new PivotEngine;n.initialize(i);return n}Object.defineProperty(PivotPanel,"controlTemplate",{get:function(){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="'+GlyphClsNames.glyph+" "+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='+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='+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='+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='+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="'+InputFormElementsClsNames.btn+" "+ControlStateClsNames.disabled+'" style="float:right;margin:6px" disabled></button></div></div>');return PivotPanel._ctrlTemplate},set:function(e){PivotPanel._ctrlTemplate=e},enumerable:!0,configurable:!0});PivotPanel.prototype._getProductInfo=function(){return"D6F4,PivotPanel"};Object.defineProperty(PivotPanel.prototype,"engine",{get:function(){return this._ng},set:function(e){var t,i=this,n=this._ng;if(n){n.itemsSourceChanged.removeHandler(this._itemsSourceChanged);n.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged);n.updatingView.removeHandler(this._updatingView);n.updatedView.removeHandler(this._updatedView);n.error.removeHandler(this._requestError);n._isUpdatingChanged.removeHandler(this._isUpdatingChangedBnd);t=this.deferredUpdate}e=asType(e,PivotEngine,!1);(n=this._ng=e).itemsSourceChanged.addHandler(this._itemsSourceChanged,this);n.viewDefinitionChanged.addHandler(this._viewDefinitionChanged,this);n.updatingView.addHandler(this._updatingView,this);n.updatedView.addHandler(this._updatedView,this);n.error.addHandler(this._requestError,this);n._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._lbFields.collectionView.filter=function(e){return e.visible&&null==e.parentField};"Filters,Rows,Cols,Vals".split(",").forEach((function(e){i["_lb"+e].collectionView.filter=function(e){return e.visible}}));this._updateDeferredUpdateElements()},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"itemsSource",{get:function(){return this._ng.itemsSource},set:function(e){e instanceof PivotEngine?this.engine=e:this._ng.itemsSource=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"collectionView",{get:function(){return this._ng.collectionView},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"pivotView",{get:function(){return this._ng.pivotView},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"autoGenerateFields",{get:function(){return this.engine.autoGenerateFields},set:function(e){this._ng.autoGenerateFields=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"fields",{get:function(){return this._ng.fields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"rowFields",{get:function(){return this._ng.rowFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"columnFields",{get:function(){return this._ng.columnFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"valueFields",{get:function(){return this._ng.valueFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"filterFields",{get:function(){return this._ng.filterFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"viewDefinition",{get:function(){return this._ng.viewDefinition},set:function(e){this._ng.viewDefinition=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"isViewDefined",{get:function(){return this._ng.isViewDefined},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"showFieldIcons",{get:function(){return this._showIcons},set:function(e){if(e!=this._showIcons){this._showIcons=asBoolean(e);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"restrictDragging",{get:function(){return this._restrictDrag},set:function(e){this._restrictDrag=asBoolean(e,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"deferredUpdate",{get:function(){return this.engine.isUpdating},set:function(e){this.deferredUpdate!=e&&(e?this._ng.beginUpdate():this._ng.endUpdate())},enumerable:!0,configurable:!0});PivotPanel.prototype.onDeferredUpdateChanged=function(e){this.deferredUpdateChanged.raise(this,e)};PivotPanel.prototype.onItemsSourceChanged=function(e){this.itemsSourceChanged.raise(this,e)};PivotPanel.prototype.onViewDefinitionChanged=function(e){this.viewDefinitionChanged.raise(this,e)};PivotPanel.prototype.onUpdatingView=function(e){this.updatingView.raise(this,e)};PivotPanel.prototype.onUpdatedView=function(e){this.updatedView.raise(this,e)};PivotPanel.prototype.refresh=function(t){var i=this;void 0===t&&(t=!0);if(this.hostElement){["Fields","Filters","Rows","Cols","Vals"].forEach((function(e){var t=i["_lb"+e],n=t?t.collectionView:null;if(t&&n){t.refresh();n.refresh()}}));if(t){this._globalize();this._ctxMenuShort.refresh();this._ctxMenuFull.refresh()}}e.prototype.refresh.call(this,t)};PivotPanel.prototype._copy=function(e,t){switch(e){case"engine":this.engine=t;return!0}return!1};PivotPanel.prototype._globalize=function(){var e=culture.olap.PivotPanel;setText(this._gFlds,e.fields);setText(this._gDrag,e.drag);setText(this._gFlt,e.filters);setText(this._gCols,e.cols);setText(this._gRows,e.rows);setText(this._gVals,e.vals);setText(this._gDefer,e.defer);setText(this._btnUpdate,e.update)};PivotPanel.prototype._itemsSourceChanged=function(e,t){this.onItemsSourceChanged(t)};PivotPanel.prototype._viewDefinitionChanged=function(e,t){this.invalidate();this.onViewDefinitionChanged(t)};PivotPanel.prototype._updatingView=function(e,t){var i=clamp(t.progress,5,100)%100;this._dProgress.style.width=i+"%";this.onUpdatingView(t)};PivotPanel.prototype._updatedView=function(e,t){this.onUpdatedView(t)};PivotPanel.prototype._requestError=function(e,t){this._dProgress.style.width="0"};PivotPanel.prototype._isUpdatingChanged=function(){this._updateDeferredUpdateElements();this.onDeferredUpdateChanged()};PivotPanel.prototype._updateDeferredUpdateElements=function(){var e=this.deferredUpdate;this._chkDefer.checked=e;enable(this._btnUpdate,e)};PivotPanel.prototype._createFieldGrid=function(e){var t=this,i=new FlexGrid(e,{autoGenerateColumns:!1,childItemsPath:"subFields",columns:[{binding:"header",width:"*"}],headersVisibility:"None",selectionMode:"Cell",alternatingRowStep:0});i.cells.hostElement.parentElement.style.overflowX="hidden";i.formatItem.addHandler((function(e,i){var n=e.rows[i.row].dataItem;assert(n instanceof PivotField,"PivotField expected...");var o=n._hasSubFields();toggleClass(i.cell,PivotPanelClsNames.header,o);i.cell.setAttribute("draggable",(!o).toString());var r=i.cell.innerHTML;n.filter.isActive&&(r+=" <span class="+GlyphClsNames.filter+"></span>");e!=t._lbVals||isFunction(n.getAggregateValue)||(r+=' <span class="'+PivotPanelClsNames.aggregate+'">('+Aggregate[n.aggregate]+")</span>");if(e==t._lbFields&&!o){if(t._showIcons){var s=n.isMeasure?"measure":"dimension";r='<span class="'+GlyphClsNames.glyph+"-"+s+'"></span> '+r}r='<label><input type="checkbox"'+(n.isActive?" checked":"")+"> "+r+"</label>"}i.cell.innerHTML=r}));i.addEventListener(e,"click",(function(e){var n=e.target;if(n instanceof HTMLInputElement&&"checkbox"==n.type){var o=t._hitTestField(i,e);o instanceof PivotField&&(o.isActive=n.checked)}}));return i};PivotPanel.prototype._dragstart=function(e){var 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){_startDrag(e.dataTransfer,"copyMove");e.stopPropagation()}}};PivotPanel.prototype._dragover=function(e){var t=!1,i=this._getFlexGridTarget(e);if(i&&this._dragField){if(this._dragSource==this._dFields&&i!=this._lbFields){var n=i.itemsSource;if(null==n.maxItems||n.length<n.maxItems){var o=this._dragField;i.itemsSource.indexOf(o)<0?t=!0:i==this._lbVals&&(t=!(o instanceof CubePivotField))}}this._dragSource&&this._dragSource!=this._dFields&&(t=!0)}if(t&&this._getRestrictDrag()&&this._dragSource!=i.hostElement){var r=this._dragField.isMeasure;i==this._lbVals?t=r:i!=this._lbRows&&i!=this._lbCols||(t=!r)}if(t){this._updateDropMarker(i,e);e.dataTransfer.dropEffect=this._dragSource==this._dFields?"copy":"move";e.preventDefault();e.stopPropagation()}else this._updateDropMarker()};PivotPanel.prototype._drop=function(e){var t=this,i=this._getFlexGridTarget(e);if(i&&this._dragField){var n=Control.getControl(this._dragSource),o=this._dragField;if(n==this._lbFields&&i==this._lbVals&&i.itemsSource.indexOf(o)>-1){o=o._clone();this.engine.fields.push(o)}i==this._lbFields?o.isActive=!1:this._ng.deferUpdate((function(){var e=i.itemsSource,n=e.indexOf(o);if(n!=t._dropIndex){if(n>-1){e.removeAt(n);n<t._dropIndex&&t._dropIndex--}e.insert(t._dropIndex,o)}}))}this._resetMouseState()};PivotPanel.prototype._dragend=function(e){this._resetMouseState()};PivotPanel.prototype._hitTestField=function(e,t){var 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};PivotPanel.prototype._getRestrictDrag=function(){var e=this._restrictDrag;null==e&&this.fields.length&&(e=this.fields[0]instanceof CubePivotField);return e};PivotPanel.prototype._resetMouseState=function(){this._dragSource=null;this._updateDropMarker()};PivotPanel.prototype._getFlexGridTarget=function(e){var t=Control.getControl(closest(e.target,"."+FlexGridClsNames.hostElement));return t instanceof FlexGrid?t:null};PivotPanel.prototype._updateDropMarker=function(e,t){if(t){var i,n=this.hostElement,o=n.getBoundingClientRect();if(e.rows.length){var r=e.hitTest(t).row;if(r>-1){i=e.getCellBoundingRect(r,0);if(t.clientY>n.scrollTop+i.top+i.height/2&&r<e.rows.length){i.top+=i.height;r++}this._dropIndex=r}else{r=e.viewRange.bottomRow;(i=e.getCellBoundingRect(r,0)).top+=i.height;this._dropIndex=r+1}}else{(i=Rect.fromBoundingRect(e.hostElement.getBoundingClientRect())).top+=4;this._dropIndex=0}setCss(this._dMarker,{left:Math.round(i.left-o.left)+n.scrollLeft,top:Math.round(i.top-o.top-2)+n.scrollTop,width:Math.round(i.width),height:4,display:""})}else this._dMarker.style.display="none"};PivotPanel._ctrlTemplate="";return PivotPanel}(Control);export{PivotPanel};var PivotGrid=function(e){__extends(PivotGrid,e);function PivotGrid(t,i){var n=e.call(this,t)||this;n._showDetailOnDoubleClick=!0;n._collapsibleSubtotals=!0;n._customCtxMenu=!0;n._ctxMenu=new _GridContextMenu;n._showRowFldSort=!1;n._showRowFldHdrs=!0;n._showColFldHdrs=!0;n._showValFldHdrs=!1;n._centerVert=!0;n._collapsedKeys={};n._resizingColumn=!1;n._outlineMode=!1;n._ignoreClick=!1;n._colRowFields=new Map;n._prevCulture=culture.Globalize.name;n._hdrCols._setDefaultSize(n._cols.defaultSize);addClass(n.hostElement,PivotGridClsNames.hostElement);n.isReadOnly=!0;n.copyHeaders=HeadersVisibility.All;n.deferResizing=!0;n.alternatingRowStep=0;n.autoGenerateColumns=!1;n.allowDragging=AllowDragging.None;n.allowMerging=AllowMerging.All;n.mergeManager=new _PivotMergeManager;n.customContextMenu=!0;n.treeIndent=32;n.initialize(i);n.formatItem.addHandler(n._formatItem,n);var o=n.hostElement;n.addEventListener(o,"mousedown",n._mousedown.bind(n),!0);n.addEventListener(o,"mouseup",n._mouseup.bind(n),!0);n.addEventListener(o,"dblclick",n._dblclick.bind(n),!0);n.addEventListener(o,"click",n._click.bind(n),!0);n.addEventListener(o,"keydown",n._keydown.bind(n),!0);n._ctxMenu.attach(n);return n}PivotGrid.prototype._getProductInfo=function(){return"D6F4,PivotGrid"};Object.defineProperty(PivotGrid.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showDetailOnDoubleClick",{get:function(){return this._showDetailOnDoubleClick},set:function(e){this._showDetailOnDoubleClick=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"detailDialog",{get:function(){this._dlgDetail||(this._dlgDetail=new DetailDialog(document.createElement("div")));return this._dlgDetail},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showRowFieldHeaders",{get:function(){return this._showRowFldHdrs},set:function(e){if(e!=this._showRowFldHdrs){this._showRowFldHdrs=asBoolean(e);this._updateFixedContent()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showColumnFieldHeaders",{get:function(){return this._showColFldHdrs},set:function(e){if(e!=this._showColFldHdrs){this._showColFldHdrs=asBoolean(e);this._updateFixedContent()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showValueFieldHeaders",{get:function(){return this._showValFldHdrs},set:function(e){if(e!=this._showValFldHdrs){this._showValFldHdrs=asBoolean(e);this._updateFixedCounts();this._updateFixedContent()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showRowFieldSort",{get:function(){return this._showRowFldSort},set:function(e){if(e!=this._showRowFldSort){this._showRowFldSort=asBoolean(e);this._updateFixedContent()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"customContextMenu",{get:function(){return this._customCtxMenu},set:function(e){this._customCtxMenu=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"collapsibleSubtotals",{get:function(){return this._collapsibleSubtotals},set:function(e){if(e!=this._collapsibleSubtotals){this._collapsibleSubtotals=asBoolean(e);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"centerHeadersVertically",{get:function(){return this._centerVert},set:function(e){if(e!=this._centerVert){this._centerVert=asBoolean(e);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"outlineMode",{get:function(){return this._outlineMode},set:function(e){if(e!=this._outlineMode){this._outlineMode=asBoolean(e);this._bindGrid(!0)}},enumerable:!0,configurable:!0});PivotGrid.prototype.getKeys=function(e,t){var i=this.rows[asInt(e)],n=this.columns[asInt(t)],o=i?i.dataItem:null,r=n?n.binding:null;return this._ng.getKeys(o,r)};PivotGrid.prototype.getDetail=function(e,t){var i=this.rows[asInt(e)].dataItem,n=this.columns[asInt(t)].binding;return this._ng.getDetail(i,n)};PivotGrid.prototype.getDetailView=function(e,t){var i=this.rows[asInt(e)].dataItem,n=this.columns[asInt(t)].binding;return this._ng.getDetailView(i,n)};PivotGrid.prototype.showDetail=function(e,t){if(this._ng.valueFields.length){var i=this.detailDialog;i.showDetail(this,new CellRange(e,t));i.show(!0)}};PivotGrid.prototype.collapseRowsToLevel=function(e){this._collapseRowsToLevel(e)};PivotGrid.prototype.collapseColumnsToLevel=function(e){this._collapseColsToLevel(e)};PivotGrid.prototype._getQuickAutoSize=function(){return isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter};PivotGrid.prototype._bindGrid=function(t){var i=this;this.deferUpdate((function(){var n=i.preserveOutlineState||i._resizingColumn,o=i._collapsedKeys,r=i.rows,s=i.columns;n||(o=i._collapsedKeys={});e.prototype._bindGrid.call(i,t);if(i._ng&&n&&!isEmpty(o)){for(var l=i._ng.totalsBeforeData,a=l?r.length-1:0,d=l?-1:r.length,u=l?-1:1,h=a;h!=d;h+=u){var c=r[h].dataItem;(p=c?c[_PivotKey._ROW_KEY_NAME]:null)&&p.level>=0&&o[p.toString()]&&i._setRowCollapsed(new CellRange(h,p.level-1),!0)}a=l?s.length-1:0;d=l?-1:s.length;u=l?-1:1;for(h=a;h!=d;h+=u){var p,g=s[h].binding;(p=i._ng._getKey(g))&&p.level>0&&o[p.toString()]&&i._setColCollapsed(new CellRange(p.level-1,h),!0)}}}))};PivotGrid.prototype._getCollectionView=function(e){e instanceof PivotPanel?e=e.engine.pivotView:e instanceof PivotEngine&&(e=e.pivotView);return asCollectionView(e)};PivotGrid.prototype.refresh=function(t){void 0===t&&(t=!0);this._ctxMenu.refresh();var i=culture.Globalize.name;if(this._prevCulture!==i){this._prevCulture=i;this._updateFixedContent()}e.prototype.refresh.call(this,t)};PivotGrid.prototype.onItemsSourceChanged=function(t){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={};var i=this.collectionView;this._ng=i instanceof PivotCollectionView?i.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);e.prototype.onItemsSourceChanged.call(this,t)};PivotGrid.prototype.onResizedColumn=function(t){var i=this._ng;if(i){this._resizingColumn=!0;if(t.panel.columns==this.rowHeaders.columns){(o=this._colRowFields.get(t.getColumn()))instanceof PivotField&&(o.width=t.panel.columns[t.col].renderWidth)}if(t.panel.columns==this.columnHeaders.columns){var n=i.valueFields;if(n.length>0){var o;(o=n[t.col%n.length]).width=t.panel.columns[t.col].renderWidth}}this._resizingColumn=!1}e.prototype.onResizedColumn.call(this,t)};PivotGrid.prototype.onSortingColumn=function(t){var i=this._ng;return(!i||!i.isUpdating)&&e.prototype.onSortingColumn.call(this,t)};PivotGrid.prototype.onDraggingColumn=function(t){var i=this._ng;return(!i||!i.isUpdating)&&e.prototype.onDraggingColumn.call(this,t)};PivotGrid.prototype.onDraggedColumn=function(t){var i=this._ng;if(i&&t.panel.columns==this.topLeftCells.columns){var n=i.rowFields,o=n[t.data.col];i.deferUpdate((function(){n.removeAt(t.data.col);n.insert(t.col,o)}))}e.prototype.onDraggedColumn.call(this,t)};PivotGrid.prototype._updatingView=function(){this._updateFixedCounts();this.columns.clear();this.rows.clear()};PivotGrid.prototype._viewDefinitionChanged=function(){this._resizingColumn||(this._collapsedKeys={})};PivotGrid.prototype._hasDeferredUpdatesChanged=function(){for(var e,t=this.engine,i=t&&t.hasDeferredUpdates,n=this.hostElement.querySelectorAll("."+PivotGrid._WJC_COLLAPSE),o=0;o<n.length;o++)e=n[o],toggleClass(e,PivotGrid._WJC_DISABLED,i)};PivotGrid.prototype.onLoadedRows=function(t){0==this.columns.length&&this._generateColumns();this._updateFixedCounts();this._updateFixedContent();e.prototype.onLoadedRows.call(this,t)};PivotGrid.prototype._generateColumns=function(){var e=this.collectionView,t=e?e.sourceCollection:null,i=t&&t.length,n=this.engine;if(n&&i)for(var o=Object.keys(t[0]).filter((function(e){return e!=_PivotKey._ROW_KEY_NAME})),r=[Aggregate.Cnt,Aggregate.CntAll],s=0;s<o.length;s++){var l=n._getFieldByColKey(o[s]);this.columns.push(new Column({binding:o[s],dataType:l&&-1===r.indexOf(l.aggregate)?l.dataType:DataType.Number,allowMerging:!0}))}};PivotGrid.prototype._updateFixedCounts=function(){var e,t=this._ng,i=t&&t.isViewDefined;e=Math.max(1,i?t.rowFields.length:1);var n=this.topLeftCells.columns;n.clear();this._colRowFields.clear();for(var o=0;o<e;o++){var r=new Column({allowMerging:!0});n.push(r);i&&this._colRowFields.set(r,t.rowFields[o])}e=Math.max(1,i?t.columnFields.length:1);t&&t.columnFields.length&&(t.valueFields.length>1||this.showValueFieldHeaders)&&e++;var s=this.topLeftCells.rows;s.clear();for(o=0;o<e;o++)s.push(new Row)};PivotGrid.prototype._updateFixedContent=function(){var e=this._ng;if(e&&e.isViewDefined){for(var t=e.rowFields,i=e.columnFields,n=e.valueFields,o=this.outlineMode?t.map((function(e){return e.header})).join(" / "):"",r=this.topLeftCells,s=0;s<r.rows.length;s++)for(var l=0;l<r.columns.length;l++){var a="";this.showRowFieldHeaders&&l<t.length&&s==r.rows.length-1&&(a=this.outlineMode?o:t[l].header);this.showColumnFieldHeaders&&!a&&s<i.length&&0==l&&(a=i[s].header+":");r.setCellData(s,l,a,!1,!1)}r=this.rowHeaders;for(s=0;s<r.rows.length;s++){var d=r.rows[s].dataItem[_PivotKey._ROW_KEY_NAME];assert(d instanceof _PivotKey,"missing PivotKey for row...");for(l=0;l<r.columns.length;l++){a=d.getValue(l,!0);r.setCellData(s,l,a,!1,!1)}}r=this.columnHeaders;for(l=0;l<r.columns.length;l++){d=e._getKey(r.columns[l].binding);assert(d instanceof _PivotKey,"missing PivotKey for column...");for(s=0;s<r.rows.length;s++){a=d.getValue(s,!0);s==r.rows.length-1&&n.length&&(n.length>1||0==i.length||d.level>-1||this.showValueFieldHeaders)&&(a=n[l%n.length].header);r.setCellData(s,l,a,!1,!1)}}r=this.topLeftCells;for(l=0;l<r.columns.length;l++){var u=r.columns[l],h=l<t.length?t[l]:null;u.wordWrap=h?h.wordWrap:null;u.align=h?h.align:null;if(this.outlineMode&&l<r.columns.length-1){u.width=this.treeIndent;u.allowResizing=!1}else{u.allowResizing=!0;u.width=h&&isNumber(h.width)?h.width:null}}r=this.cells;for(l=0;l<r.columns.length;l++){u=r.columns[l],h=n.length?n[l%n.length]:null;u.width=h&&isNumber(h.width)?h.width:null;u.wordWrap=h?h.wordWrap:null;u.format=h?h.format:null;u.align=h?h.align:null}this.invalidate()}else this.topLeftCells.setCellData(0,0,null)};PivotGrid.prototype._updateDefaultSizes=function(){var t=e.prototype._updateDefaultSizes.call(this);this._hdrCols._setDefaultSize(4*t);return t};PivotGrid.prototype._formatItem=function(e,t){var i=this._ng,n=t.panel,o=t.cell;if(i){if(n==this.topLeftCells){var r=0==i.rowFields.length||t.row<n.rows.length-1||t.row==n.rows.length-1&&!this.showRowFieldHeaders;toggleClass(o,PivotGridClsNames.colFieldHdr,r);toggleClass(o,PivotGridClsNames.rowFieldHdr,!r)}var s,l=null;n==this.topLeftCells&&t.row==n.rows.length-1&&this.allowDragging&AllowDragging.Columns&&(l=!0);setAttribute(o,"draggable",l);switch(n){case this.rowHeaders:s=i.rowFields[t.col%i.rowFields.length];break;case this.columnHeaders:s=i.columnFields[t.row];break;case this.cells:s=i.valueFields[t.col]}s&&s.isContentHtml&&(o.innerHTML=o.textContent);var a=n.columns[t.col].binding,d=n.rows==this.rows?i._getRowLevel(t.row):-1,u=n.columns==this.columns?i._getColLevel(a):-1;toggleClass(o,PivotPanelClsNames.aggregate,d>-1||u>-1);if(this._collapsibleSubtotals){if(n==this.rowHeaders&&i._getShowRowTotals()==ShowTotals.Subtotals)if(this.outlineMode){var h=this._getGroupedRows(t.range);if(t.col<i.rowFields.length-1){if(!h.containsRow(t.row)){var c=this._getRowCollapsed(t.range);o.innerHTML=this._getCollapsedGlyph(c)+o.innerHTML}}}else{h=this.getMergedRange(n,t.row,t.col,!1)||t.range;if(t.col<i.rowFields.length-1&&h.rowSpan>1){c=this._getRowCollapsed(h);o.innerHTML=this._getCollapsedGlyph(c)+o.innerHTML}}this.outlineMode&&n==this.rowHeaders&&t.range.rightCol<n.columns.length-1&&(o.innerHTML="");if(n==this.columnHeaders&&i._getShowColTotals()==ShowTotals.Subtotals){h=this.getMergedRange(n,t.row,t.col,!1)||t.range;if(t.row<i.columnFields.length-1&&h.columnSpan>1){var p=this._getColCollapsed(h);o.innerHTML=this._getCollapsedGlyph(p)+o.innerHTML}}}if(n==this.topLeftCells&&this.showRowFieldSort&&t.col<i.rowFields.length&&t.row==this._getSortRowIndex()){s=i.rowFields[t.col];toggleClass(o,FlexGridClsNames.sortAsc,!s.descending);toggleClass(o,FlexGridClsNames.sortDesc,s.descending);o.innerHTML+=' <span class="'+GlyphClsNames.glyph+"-"+(s.descending?"down":"up")+'"></span>'}n!=this.cells&&toggleClass(o,UtilitesClsNames.alignVCenter,this._centerVert)}};PivotGrid.prototype._getCollapsedGlyph=function(e){var t=this.engine,i=t&&t.hasDeferredUpdates;return'<div class="'+(PivotGrid._WJC_COLLAPSE+(i?" "+PivotGrid._WJC_DISABLED:""))+'"><span class="'+GlyphClsNames.glyph+"-"+(e?"plus":"minus")+'"></span></div>'};PivotGrid.prototype._mousedown=function(e){if(e.defaultPrevented||0!=e.button)this._htDown=null;else{var t=this._htDown=this.hitTest(e),i=t.panel;this._ignoreClick=!1;var n=this.engine,o=n&&n.hasDeferredUpdates,r=closestClass(e.target,PivotGrid._WJC_COLLAPSE);if(!o&&null!=r&&null!=i){var s=t.range,l=void 0;switch(i.cellType){case CellType.RowHeader:var a=this.getMergedRange(i,s.row,s.col);a&&s.copy(a);l=this._getRowCollapsed(s);e.shiftKey||e.ctrlKey?this._collapseRowsToLevel(s.col+(l?2:1)):this._setRowCollapsed(s,!l);break;case CellType.ColumnHeader:l=this._getColCollapsed(s);e.shiftKey||e.ctrlKey?this._collapseColsToLevel(s.row+(l?2:1)):this._setColCollapsed(s,!l)}e.preventDefault();this._ignoreClick=!0;this._htDown=null;this.focus()}}};PivotGrid.prototype._mouseup=function(e){if(this._htDown&&!e.defaultPrevented&&!this._mouseHdl._szRowCol){var t=this.hitTest(e);if(this._htDown.panel==t.panel&&t.range.equals(this._htDown.range)){var i=this._ng,n=this.topLeftCells;if(t.panel==n&&t.row==n.rows.length-1&&t.col>-1){var o=t.getColumn();if(this.allowSorting&&o.allowSorting&&!t.edgeRight){var r=this._colRowFields.get(o);if(r&&!i.isUpdating){var s=new CellRangeEventArgs(t.panel,t.range);if(this.onSortingColumn(s)){i.pivotView.sortDescriptions.clear();r.descending=!r.descending;this.onSortedColumn(s)}}}e.preventDefault();this._ignoreClick=!0}}}};PivotGrid.prototype._click=function(e){this._ignoreClick&&e.preventDefault()};PivotGrid.prototype._dblclick=function(e){if(!e.defaultPrevented&&this._showDetailOnDoubleClick){var t=this._htDown;if(t&&t.panel==this.cells){var i=this._ng;i&&i.fields.length>0&&(i.fields[0]instanceof CubePivotField||this.showDetail(t.row,t.col))}}};PivotGrid.prototype._keydown=function(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&this.collapsibleSubtotals){var t=this.selection;if(t.isValid){var i=this._getRowLevel(t.topRow);i<0&&(i=this.rowHeaders.columns.length-1);var n=this._getKeyCode(e);switch(n){case Key.Left:case Key.Right:var o=new CellRange(t.row,i-1);this._setRowCollapsed(o,n==Key.Left);e.preventDefault()}}}};PivotGrid.prototype._getRowLevel=function(e){return this._ng._getRowLevel(e)};PivotGrid.prototype._getGroupedRows=function(e){var t,i=this._getRowLevel.bind(this),n=e.col+1,o=this.rows.length,r=this._ng.totalsBeforeData,s=e.row;if(0==i(s)){s=r?1:0;t=r?o-1:o-2}else{if(r)for(;s<o&&!(i(s)<0);s++);else for(;s>=0&&!(i(s)<0);s--);for(;s>0;s--){if((l=i(s-1))>=0&&l<=n)break}for(t=s;t<o-1;t++){var l;if((l=i(t+1))>=0&&l<=n)break}}assert(t>=s,"group end < start?");return t>=s?new CellRange(s,e.col,t,e.col2):e};PivotGrid.prototype._toggleRowCollapsed=function(e){this._setRowCollapsed(e,!this._getRowCollapsed(e))};PivotGrid.prototype._getRowCollapsed=function(e){e=this._getGroupedRows(e);var t=this._ng.totalsBeforeData?e.row-1:e.row2+1,i=this.rows[t]||this.rows[e.row],n=i?i.dataItem[_PivotKey._ROW_KEY_NAME]:null;return!!n&&this._collapsedKeys[n.toString()]};PivotGrid.prototype._setRowCollapsed=function(e,t){var i=this;e=this._getGroupedRows(e);var n=this._ng.totalsBeforeData?e.row-1:e.row2+1,o=this.rows[n]||this.rows[e.row],r=o?o.dataItem[_PivotKey._ROW_KEY_NAME]:null;r&&(this._collapsedKeys[r.toString()]=t);this.deferUpdate((function(){for(var r=e.row;r<=e.row2;r++)i.rows[r].visible=!t;o&&(o.visible=!0);if(!t){var s=i._getRowLevel(n),l=[];for(r=e.row;r<=e.row2;r++)if(i._getRowLevel(r)>-1){var a=i._getGroupedRows(new CellRange(r,s));assert(a.row>=e.row&&a.row2<=e.row2,"child range overflow");l.push(a);r++}l.forEach((function(e){var t=i._getRowCollapsed(e);i._setRowCollapsed(e,t)}))}}))};PivotGrid.prototype._collapseRowsToLevel=function(e){var t=this;e>=this._ng.rowFields.length&&(e=-1);this.deferUpdate((function(){for(var i=0;i<t.rows.length;i++){var n=t._getRowLevel(i);if(n>0){var o=t.rows[i].dataItem[_PivotKey._ROW_KEY_NAME];t._collapsedKeys[o.toString()]=e>0&&n>=e}if(e<0)t.rows[i].visible=!0;else{var r=n>-1&&n<=e;r||(t._ng.totalsBeforeData?0==i&&(r=!0):i==t.rows.length-1&&(r=!0));t.rows[i].visible=r}}}))};PivotGrid.prototype._getColLevel=function(e){return this._ng._getColLevel(this.columns[e].binding)};PivotGrid.prototype._getGroupedCols=function(e){var t,i=this._getColLevel.bind(this),n=e.row+1,o=this.columns.length,r=this._ng.totalsBeforeData,s=e.col;if(0==i(s)){s=r?1:0;t=r?o-1:o-2}else{if(this._ng.totalsBeforeData)for(s=e.col;s<o&&!(i(s)<0);s++);else for(s=e.col;s>=0&&!(i(s)<0);s--);for(;s>0;s--){if((l=i(s-1))>=0&&l<=n)break}for(t=s;t<o-1;t++){var l;if((l=i(t+1))>=0&&l<=n)break}}assert(t>=s,"group end < start?");return t>=s?new CellRange(e.row,s,e.row2,t):e};PivotGrid.prototype._toggleColCollapsed=function(e){this._setColCollapsed(e,!this._getColCollapsed(e))};PivotGrid.prototype._getColCollapsed=function(e){e=this._getGroupedCols(e);var t=this._ng,i=t.totalsBeforeData?e.col-t.valueFields.length:e.col2+1,n=this.columns[i],o=n?n.binding:null;return!!o&&this._collapsedKeys[o.toString()]};PivotGrid.prototype._setColCollapsed=function(e,t){var i=this;e=this._getGroupedCols(e);var n=this._ng,o=n.totalsBeforeData?e.col-n.valueFields.length:e.col2+1,r=this.columns[o],s=r?r.binding:null;s&&(this._collapsedKeys[s.toString()]=t);this.deferUpdate((function(){for(var r=1;r<=n.valueFields.length;r++)i.columns[n.totalsBeforeData?e.col-r:e.col2+r].visible=!0;for(var s=e.col;s<=e.col2;s++)i.columns[s].visible=!t;if(!t){var l=i._getColLevel(o),a=[];for(s=e.col;s<=e.col2;s++)if(i._getColLevel(s)>-1){var d=i._getGroupedCols(new CellRange(l,s));assert(d.col>=e.col&&d.col2<=e.col2,"child range overflow");a.push(d);s+=n.valueFields.length-1}a.forEach((function(e){var t=i._getColCollapsed(e);i._setColCollapsed(e,t)}))}}))};PivotGrid.prototype._collapseColsToLevel=function(e){var t=this;e>=this._ng.columnFields.length&&(e=-1);this.deferUpdate((function(){for(var i=0;i<t.columns.length;i++){var n=t._getColLevel(i);if(n>0){var o=t._ng._getKey(t.columns[i].binding);t._collapsedKeys[o.toString()]=e>0&&n>=e}if(e<0)t.columns[i].visible=!0;else{var r=n>-1&&n<=e;t.columns[i].visible=r}}}))};PivotGrid._WJC_COLLAPSE=PivotGridClsNames.pivotCollapse;PivotGrid._WJC_DISABLED=ControlStateClsNames.disabled;return PivotGrid}(FlexGrid);export{PivotGrid};var DetailDialog=function(e){__extends(DetailDialog,e);function DetailDialog(t,i){var n=e.call(this,t,null)||this,o=n.getTemplate();n.applyTemplate(ControlClsNames.hostElement+" "+DetailDialogClsNames.hostElement,o,{_sCnt:"sp-cnt",_dSummary:"div-summary",_dGrid:"div-grid",_btnOK:"btn-ok",_gHdr:"g-hdr"});n._g=new FlexGrid(n._dGrid,{isReadOnly:!0});n.initialize(i);return n}Object.defineProperty(DetailDialog,"controlTemplate",{get:function(){DetailDialog._ctrlTemplate||(DetailDialog._ctrlTemplate='<div><div class="'+DetailDialogClsNames.dialogHeader+'"><span wj-part="g-hdr">Detail View:</span> <span wj-part="sp-cnt"></span></div><div class="'+DetailDialogClsNames.dialogBody+'"><div wj-part="div-summary" class="'+DetailDialogClsNames.summary+'"></div><div wj-part="div-grid"></div></div><div class="'+DetailDialogClsNames.dialogFooter+'"><button wj-part="btn-ok"class="'+UtilitesClsNames.hide+" "+InputFormElementsClsNames.btn+'">OK</button> </div></div>');return DetailDialog._ctrlTemplate},set:function(e){DetailDialog._ctrlTemplate=e},enumerable:!0,configurable:!0});DetailDialog.prototype.showDetail=function(e,t){var i=this,n=e.getDetailView(t.row,t.col);this._g.itemsSource=n;var o=tryCast(n,"IPagedCollectionView");this._updateDetailCount(o?o.totalItemCount:n.items.length);n.collectionChanged.addHandler((function(){i._updateDetailCount(n.items.length)}));var r=e.engine,s=culture.olap.DetailDialog,l="";this._gHdr.textContent=s.header;this._btnOK.textContent=s.ok;var a=e.rows[t.row].dataItem[_PivotKey._ROW_KEY_NAME];this._rowHdr=escapeHtml(this._getHeader(a));this._rowHdr&&(l+=s.row+": <b>"+this._rowHdr+"</b><br>");var d=r._getKey(e.columns[t.col].binding);this._colHdr=escapeHtml(this._getHeader(d));this._colHdr&&(l+=s.col+": <b>"+this._colHdr+"</b><br>");var u=r.valueFields,h=u[t.col%u.length],c=e.getCellData(t.row,t.col,!0);this._cellHdr=escapeHtml(h.header);this._cellValue=escapeHtml(c);l+=this._cellHdr+": <b>"+this._cellValue+"</b>";this._dSummary.innerHTML=l};Object.defineProperty(DetailDialog.prototype,"rowHeader",{get:function(){return this._rowHdr},enumerable:!0,configurable:!0});Object.defineProperty(DetailDialog.prototype,"columnHeader",{get:function(){return this._colHdr},enumerable:!0,configurable:!0});Object.defineProperty(DetailDialog.prototype,"cellHeader",{get:function(){return this._cellHdr},enumerable:!0,configurable:!0});Object.defineProperty(DetailDialog.prototype,"cellValue",{get:function(){return this._cellValue},enumerable:!0,configurable:!0});Object.defineProperty(DetailDialog.prototype,"detailCount",{get:function(){return this._detailCount},enumerable:!0,configurable:!0});DetailDialog.prototype._updateDetailCount=function(e){var t=culture.olap.DetailDialog;this._sCnt.textContent=format(1==e?t.item:t.items,{cnt:e});this._detailCount=e};DetailDialog.prototype._getHeader=function(e){if(e&&e.values&&e.values.length){for(var t=[],i=0;i<e.values.length;i++)t.push(e.getValue(i,!0));return t.join(" - ")}return null};DetailDialog._ctrlTemplate="";return DetailDialog}(Popup);export{DetailDialog};var _PivotMergeManager=function(e){__extends(_PivotMergeManager,e);function _PivotMergeManager(){return null!==e&&e.apply(this,arguments)||this}_PivotMergeManager.prototype.getMergedRange=function(t,i,n,o){void 0===o&&(o=!0);var r=t.grid.collectionView;this._ng=r instanceof PivotCollectionView?r.engine:null;if(!this._ng)return e.prototype.getMergedRange.call(this,t,i,n,o);if(i<0||i>=t.rows.length||n<0||n>=t.columns.length)return null;var s=t.grid.allowMerging,l=AllowMerging;switch(t.cellType){case CellType.TopLeft:return 0!=(s&l.AllHeaders)?this._getMergedTopLeftRange(t,i,n):null;case CellType.RowHeader:return 0!=(s&l.RowHeaders)?this._getMergedRowHeaderRange(t,i,n,o?t.viewRange:null):null;case CellType.ColumnHeader:return 0!=(s&l.ColumnHeaders)?this._getMergedColumnHeaderRange(t,i,n,o?t.viewRange:null):null}return null};_PivotMergeManager.prototype._getMergedTopLeftRange=function(e,t,i){var n=new CellRange(t,i),o=e.grid;if(o.outlineMode&&o.showRowFieldHeaders&&n.row==e.rows.length-1){n.col=0;n.col2=e.columns.length-1;return n}for(;n.col>0&&!e.getCellData(t,n.col,!0);)n.col--;for(;n.col2<e.columns.length-1&&!e.getCellData(t,n.col2+1,!0);)n.col2++;return n.isSingleCell?null:n};_PivotMergeManager.prototype._getMergedRowHeaderRange=function(e,t,i,n){var o=e.grid;if(!e.columns[i].allowMerging)return null;if(o.outlineMode){if(this._isSubtotal(e,t,i)||this._isSubtotal(e,t,i+1)){var r=this._getOutlineRange(e,t,i);return r.isSingleCell?null:r}if(i<e.columns.length-1){var s=o._getGroupedRows(new CellRange(t,i));return s.isSingleCell?null:s}return null}var l=this._ng._getRowLevel(t);if(l>-1&&i>=l){var a=e.getCellData(t,i,!1),d=void 0,u=void 0,h=n?n.col:0,c=n?n.col2:e.columns.length-1;for(d=i;d>h&&e.getCellData(t,d-1,!1)==a;d--);for(u=i;u<c&&e.getCellData(t,u+1,!1)==a;u++);return d!=u?new CellRange(t,d,t,u):null}var p,g,_=n?n.row:0,f=n?n.row2:e.rows.length-1;for(p=t;p>_&&this._sameColumnValues(e,t,p-1,i);p--);for(g=t;g<f&&this._sameColumnValues(e,t,g+1,i);g++);return p!=g?new CellRange(p,i,g,i):null};_PivotMergeManager.prototype._sameColumnValues=function(e,t,i,n){for(;n>=0;n--){if(e.getCellData(t,n,!1)!=e.getCellData(i,n,!1))return!1}return!0};_PivotMergeManager.prototype._isSubtotal=function(e,t,i){var n=e.rows[t].dataItem,o=n?n[_PivotKey._ROW_KEY_NAME]:null;return n&&i>o.values.length-1&&i<e.columns.length};_PivotMergeManager.prototype._getOutlineRange=function(e,t,i){var n=new CellRange(t,i);n.col2=e.columns.length-1;for(;n.col&&this._isSubtotal(e,t,n.col);)n.col--;return n};_PivotMergeManager.prototype._getMergedColumnHeaderRange=function(e,t,i,n){var o=e.columns[i],r=this._ng._getKey(o.binding),s=e.getCellData(t,i,!1),l=this._ng._getColLevel(r);if(l>-1&&t>=l){var a=void 0,d=void 0,u=n?n.row:0,h=n?n.row2:e.rows.length-1;for(a=t;a>u&&e.getCellData(a-1,i,!1)==s;a--);for(d=t;d<h&&e.getCellData(d+1,i,!1)==s;d++);if(a!=d)return new CellRange(a,i,d,i)}if(n){i<e.columns._frozenInternal&&(n.col=n.col2=0);t<e.rows._frozenInternal&&(n.row=n.row2=0)}var c,p,g=n?n.col:0,_=n?n.col2:e.columns.length-1;for(c=i;c>g&&this._sameRowValues(e,t,i,c-1);c--);for(p=i;p<_&&this._sameRowValues(e,t,i,p+1);p++);return c!=p?new CellRange(t,c,t,p):null};_PivotMergeManager.prototype._sameRowValues=function(e,t,i,n){for(;t>=0;t--){if(e.getCellData(t,i,!1)!=e.getCellData(t,n,!1))return!1}return!0};return _PivotMergeManager}(MergeManager);export{_PivotMergeManager};export var PivotChartType;!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||(PivotChartType={}));export var LegendVisibility;!function(e){e[e.Always=0]="Always";e[e.Never=1]="Never";e[e.Auto=2]="Auto"}(LegendVisibility||(LegendVisibility={}));var PivotChart=function(e){__extends(PivotChart,e);function PivotChart(t,i){var n=e.call(this,t)||this;n._chartType=PivotChartType.Column;n._showHierarchicalAxes=!0;n._showTotals=!1;n._showTitle=!0;n._showLegend=LegendVisibility.Always;n._legendPosition=Position.Right;n._maxSeries=PivotChart.MAX_SERIES;n._maxPoints=PivotChart.MAX_POINTS;n._stacking=Stacking.None;n._colItms=[];n._dataItms=[];n._lblsSrc=[];n._grpLblsSrc=[];addClass(n.hostElement,PivotChartClsNames.hostElement);n._isPieChart()?n._createFlexPie():n._createFlexChart();e.prototype.initialize.call(n,i);return n}PivotChart.prototype._getProductInfo=function(){return"D6F4,PivotChart"};Object.defineProperty(PivotChart.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"itemsSource",{get:function(){return this._itemsSource},set:function(e){if(e&&this._itemsSource!==e){var t=this._itemsSource;e instanceof PivotPanel?e=e.engine.pivotView:e instanceof PivotEngine&&(e=e.pivotView);this._itemsSource=asCollectionView(e);this._onItemsSourceChanged(t)}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"chartType",{get:function(){return this._chartType},set:function(e){if((e=asEnum(e,PivotChartType))!=this._chartType){var t=this._chartType;this._chartType=e;this._changeChartType();e!==PivotChartType.Bar&&t!==PivotChartType.Bar||this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"showHierarchicalAxes",{get:function(){return this._showHierarchicalAxes},set:function(e){if(e!=this._showHierarchicalAxes){this._showHierarchicalAxes=asBoolean(e,!0);!this._isPieChart()&&this._flexChart&&this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc)}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"showTotals",{get:function(){return this._showTotals},set:function(e){if(e!=this._showTotals){this._showTotals=asBoolean(e,!0);this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"showTitle",{get:function(){return this._showTitle},set:function(e){if(e!=this._showTitle){this._showTitle=asBoolean(e,!0);this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"showLegend",{get:function(){return this._showLegend},set:function(e){if((e=asEnum(e,LegendVisibility))!=this.showLegend){this._showLegend=e;this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"legendPosition",{get:function(){return this._legendPosition},set:function(e){if((e=asEnum(e,Position))!=this.legendPosition){this._legendPosition=e;this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"stacking",{get:function(){return this._stacking},set:function(e){if((e=asEnum(e,Stacking))!=this._stacking){this._stacking=e;if(this._flexChart){this._flexChart.stacking=this._stacking;this._updatePivotChart()}}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"maxSeries",{get:function(){return this._maxSeries},set:function(e){if(e!=this._maxSeries){this._maxSeries=asNumber(e);this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"maxPoints",{get:function(){return this._maxPoints},set:function(e){if(e!=this._maxPoints){this._maxPoints=asNumber(e);this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"flexChart",{get:function(){return this._flexChart},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"flexPie",{get:function(){return this._flexPie},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"header",{get:function(){return this._header},set:function(e){if(e!=this._header){this._header=asString(e,!0);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"footer",{get:function(){return this._footer},set:function(e){if(e!=this._footer){this._footer=asString(e,!0);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"headerStyle",{get:function(){return this._headerStyle},set:function(e){if(e!=this._headerStyle){this._headerStyle=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"footerStyle",{get:function(){return this._footerStyle},set:function(e){if(e!=this._footerStyle){this._footerStyle=e;this.invalidate()}},enumerable:!0,configurable:!0});PivotChart.prototype.refresh=function(t){void 0===t&&(t=!0);e.prototype.refresh.call(this,t);this._isPieChart()?this._flexPie&&this._flexPie.refresh(t):this._flexChart&&this._flexChart.refresh(t);this._updatePivotChart()};PivotChart.prototype.saveImageToDataUrl=function(e,t){this._isPieChart()?this._flexPie&&this._flexPie.saveImageToDataUrl(e,t):this._flexChart&&this._flexChart.saveImageToDataUrl(e,t)};PivotChart.prototype.saveImageToFile=function(e){this._isPieChart()?this._flexPie&&this._flexPie.saveImageToFile(e):this._flexChart&&this._flexChart.saveImageToFile(e)};PivotChart.prototype._onItemsSourceChanged=function(e){this._ng&&this._ng.updatedView.removeHandler(this._updatePivotChart,this);e&&e.collectionChanged.removeHandler(this._updatePivotChart,this);var 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()};PivotChart.prototype._createFlexChart=function(){var e=this,t=document.createElement("div");this.hostElement.appendChild(t);this._flexChart=new FlexChart(t);this._flexChart._bindingSeparator=null;this._flexChart.legend.position=Position.Right;this._flexChart.bindingX=_PivotKey._ROW_KEY_NAME;this._flexChart.stacking=this._stacking;this._flexChart.tooltip.content=function(t){var i=t.name?"<b>"+t.name+"</b> <br/>":"";return i+=e._getLabel(t.x)+" "+e._getValue(t)};this._flexChart.hostElement.style.visibility="hidden"};PivotChart.prototype._createFlexPie=function(){var e=this,t=document.createElement("div");this.hostElement.appendChild(t);this._colMenu=new MultiSelect(t,{displayMemberPath:"text",placeholder:culture.olap.PivotPanel.cols,selectedValuePath:"prop",showSelectAllCheckbox:!0});this._colMenu.hostElement.style.visibility="hidden";this._colMenu.checkedItemsChanged.addHandler((function(t,i){return e._updateFlexPieBinding()}));var i=document.createElement("div");this.hostElement.appendChild(i);this._flexPie=new FlexPie(i);this._flexPie.bindingName=_PivotKey._ROW_KEY_NAME;this._flexPie.tooltip.content=function(t){return"<b>"+e._getLabel(e._dataItms[t.pointIndex][_PivotKey._ROW_KEY_NAME])+"</b> <br/>"+e._getValue(t)};this._flexPie.rendering.addHandler(this._updatePieInfo,this)};PivotChart.prototype._updatePivotChart=function(){if(this._ng&&this._ng.pivotView){for(var e,t=[],i=[],n=[],o=0,r=this._ng.pivotView,s=this._ng.rowFields,l=0;l<r.items.length;l++){var a=r.items[l],d=a.$rowKey;0==l&&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(var u=0;u<s.length;u++){n.length<=u&&n.push([]);if(this._getMergeIndex(d,e)<u){o=n[u].length-1;var h=n[u][o];0===o&&u<s.length-1&&(h.value=(h.width-1)/2);if(o>0&&u<s.length-1){var c=this._getOffsetWidth(n[u]);h.value=c+(h.width-1)/2}n[u].push({value:t.length-1,text:d.getValue(u,!0),width:1})}else{o=n[u].length-1;n[u][o].width++}}e=d}}for(u=0;u<s.length;u++)if(u<n.length){o=n[u].length-1;n[u][o].value=this._getOffsetWidth(n[u])+(n[u][o].width-1)/2}this._dataItms=t;this._lblsSrc=i;this._grpLblsSrc=n;this._updateFlexChartOrPie()}};PivotChart.prototype._updateFlexChartOrPie=function(){var e=this._isPieChart();!e&&this._flexChart?this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc):e&&this._flexPie&&this._updateFlexPie(this._dataItms,this._lblsSrc)};PivotChart.prototype._updateFlexChart=function(e,t,i){var n,o=this._flexChart,r=o?o.hostElement:null;if(this._ng&&o&&r){o.beginUpdate();o.itemsSource=e;this._createSeries();o.series&&o.series.length>0&&e.length>0?r.style.visibility="visible":r.style.visibility="hidden";o.header=this.header||this._getChartTitle();this.headerStyle&&(o.headerStyle=this.headerStyle);this.footer&&(o.footer=this.footer);this.footerStyle&&(o.footerStyle=this.footerStyle);if(this._isRotatedChart()){if(this._showHierarchicalAxes&&i.length>0){o.axisY.itemsSource=i[i.length-1];o.axisX.labelAngle=void 0;if(i.length>=2)for(var s=i.length-2;s>=0;s--)this._createGroupAxes(i[s])}else{o.axisY.labelAngle=void 0;o.axisY.itemsSource=t}o.axisX.itemsSource=void 0}else{if(this._showHierarchicalAxes&&i.length>0){o.axisX.itemsSource=i[i.length-1];if(i.length>=2)for(s=i.length-2;s>=0;s--)this._createGroupAxes(i[s])}else{o.axisX.labelAngle=void 0;o.axisX.itemsSource=t}o.axisY.itemsSource=void 0}o.axisX.labelPadding=6;o.axisY.labelPadding=6;if(this._isRotatedChart()){n=o.axisX;o.axisY.reversed=!0}else{n=o.axisY;o.axisY.reversed=!1}o.stacking!==Stacking.Stacked100pc&&this._ng.valueFields.length>0&&this._ng.valueFields[0].format?n.format=this._ng.valueFields[0].format:n.format="";o.legend.position=this._getLegendPosition();o.endUpdate()}};PivotChart.prototype._updateFlexPie=function(e,t){var i=this._flexPie,n=i?i.hostElement:null,o=this._colMenu;if(this._ng&&i&&n){this._colItms.length>0&&e.length>0?n.style.visibility="visible":n.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();var r=this._getTitle(this._ng.columnFields);""!==r&&(r="<b>"+r+": </b>");if(this._colItms&&this._colItms.length>1&&e.length>0){o.hostElement.style.visibility="visible";o.itemsSource=this._colItms;o.checkedItems=[this._colItms[0]];o.invalidate()}else o.hostElement.style.visibility="hidden"}};PivotChart.prototype._getLegendPosition=function(){var e=this.legendPosition;if(this.showLegend==LegendVisibility.Never)e=Position.None;else if(this.showLegend==LegendVisibility.Auto&&this.flexChart&&this.flexChart.series){var t=0;this.flexChart.series.forEach((function(e){var i=e.visibility;e.name&&i!=SeriesVisibility.Hidden&&i!=SeriesVisibility.Plot&&t++}));t<2&&(e=Position.None)}return e};PivotChart.prototype._createSeries=function(){this._flexChart&&(this._flexChart.series.length=0);for(var e=1==this._ng.valueFields.length,t=0;t<this._colItms.length;t++){var i=new Series,n=this._colItms[t].prop,o=this._colItms[t].text;if(e){var r=o.lastIndexOf(";");r>-1&&(o=o.substr(0,r))}i.binding=n;i.name=o;this._flexChart.series.push(i)}};PivotChart.prototype._getColumns=function(e){var t,i=0;if(e){this._colItms=[];for(var n in e)if(e.hasOwnProperty(n)&&n!==_PivotKey._ROW_KEY_NAME&&i<this._maxSeries&&this._isValidColumn(n)){t=this._ng._getKey(n);this._getLabel(t);this._colItms.push({prop:n,text:this._getLabel(t)});i++}}};PivotChart.prototype._createGroupAxes=function(e){var t,i=this,n=this._flexChart,o=this._isRotatedChart()?n.axisY:n.axisX;if(e){(t=new Axis).labelAngle=0;t.labelPadding=6;t.position=this._isRotatedChart()?Position.Left:Position.Bottom;t.majorTickMarks=TickMark.None;t.itemsSource=e;t.reversed=o.reversed;t.axisLine=!1;t.itemFormatter=function(n,o){if(t._axrect){var r=.5*e.filter((function(e){return e.value==o.val}))[0].width;if(i._isRotatedChart()){var s=t.reversed?-1:1,l=t.convert(o.val+r)+5*s,a=t.convert(o.val-r)-5*s,d=t._axrect.left+t._axrect.width-5;n.drawLine(d,l,d,a,PivotChart.HRHAXISCSS);n.drawLine(d,l,d+5,l,PivotChart.HRHAXISCSS);n.drawLine(d,a,d+5,a,PivotChart.HRHAXISCSS);n.drawLine(d,o.pos.y,d-5,o.pos.y,PivotChart.HRHAXISCSS)}else{var u=t.convert(o.val-r)+5,h=t.convert(o.val+r)-5,c=t._axrect.top;n.drawLine(u,c,h,c,PivotChart.HRHAXISCSS);n.drawLine(u,c,u,c-5,PivotChart.HRHAXISCSS);n.drawLine(h,c,h,c-5,PivotChart.HRHAXISCSS);n.drawLine(o.pos.x,c,o.pos.x,c+5,PivotChart.HRHAXISCSS)}}return o};t.min=o.actualMin;t.max=o.actualMax;o.rangeChanged.addHandler((function(){isNaN(t.min)&&isNaN(o.actualMin)||t.min==o.actualMin||(t.min=o.actualMin);isNaN(t.max)&&isNaN(o.actualMax)||t.max==o.actualMax||(t.max=o.actualMax)}));var r=new Series;r.visibility=SeriesVisibility.Hidden;this._isRotatedChart()?r.axisY=t:r.axisX=t;n.series.push(r)}};PivotChart.prototype._updateFlexPieBinding=function(){var e="",t=[];this._colMenu.checkedItems.forEach((function(i){e.length>0&&(e+=",");e+=i.prop;t.push(i.text)}));this._flexPie.binding=e;this._flexPie.titles=t.length>1?t:null};PivotChart.prototype._updatePieInfo=function(){var e=this;this._flexPie&&(this._flexPie._labels=this._flexPie._labels.map((function(t,i){return e._lblsSrc[i].text})))};PivotChart.prototype._changeChartType=function(){var 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=ChartType.Column;break;case PivotChartType.Bar:e=ChartType.Bar;break;case PivotChartType.Scatter:e=ChartType.Scatter;break;case PivotChartType.Line:e=ChartType.Line;break;case PivotChartType.Area:e=ChartType.Area}if(this._flexChart)"none"!==this._flexChart.hostElement.style.display&&e!==PivotChartType.Bar&&this._flexChart.chartType!==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)}};PivotChart.prototype._swapChartAndPie=function(e){var t=this;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";setTimeout((function(){t._colMenu.hostElement.style.top=""}),0)}};PivotChart.prototype._getLabel=function(e){var t="";if(!e||!e.values)return t;var 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(var n=0;n<e.values.length;n++){n>0&&(t+="; ");t+=e.getValue(n,!0)}i&&(t+="; "+i.header)}return t};PivotChart.prototype._getValue=function(e){var t=this._ng.valueFields,i=e.series?e.series.chart.series.indexOf(e.series):0,n=i<t.length?t[i].format:t.length?t[0].format:"";return n?Globalize.format(e.y,n):e._yfmt};PivotChart.prototype._getChartTitle=function(){if(!this.showTitle||!this._ng.valueFields.length)return null;var e=this._ng,t=this._getTitle(e.valueFields),i=this._getTitle(e.rowFields),n=this._getTitle(e.columnFields),o=t,r=culture.olap.PivotChart;if(t&&this._dataItms.length>0){i&&(o+=format(" {by} {rows}",{by:r.by,rows:i}));n&&(o+=format(" {and} {cols}",{and:i?r.and:r.by,cols:n}))}return o};PivotChart.prototype._getTitle=function(e){for(var t="",i=0;i<e.length;i++){t.length>0&&(t+="; ");t+=e[i].header}return t};PivotChart.prototype._isValidColumn=function(e){var 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)};PivotChart.prototype._isTotalRow=function(e){return e.values.length<this._ng.rowFields.length};PivotChart.prototype._isPieChart=function(){return this._chartType==PivotChartType.Pie};PivotChart.prototype._isRotatedChart=function(){return!this._isPieChart()&&this._chartType==PivotChartType.Bar!==this._flexChart.rotated};PivotChart.prototype._getMergeIndex=function(e,t){var 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(var n=0;n<e.values.length;n++){if(e.getValue(n,!0)!=t.getValue(n,!0))return i;i=n}return i};PivotChart.prototype._getOffsetWidth=function(e){var t=0;if(e.length<=1)return t;for(var i=0;i<e.length-1;i++)t+=e[i].width;return t};PivotChart.MAX_SERIES=100;PivotChart.MAX_POINTS=100;PivotChart.HRHAXISCSS=PivotChartClsNames.hierarchicalAxesLine;return PivotChart}(Control);export{PivotChart};var _MdxQueryBuilder=function(){function _MdxQueryBuilder(e,t){this._ng=null;this._cubeName=null;this._ng=e;this._cubeName=t}_MdxQueryBuilder.prototype.buildQuery=function(){var 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()};_MdxQueryBuilder.prototype.buildWhereSection=function(e){var t=new _TextBuilder;if(1==e.length){t.append(this.buildSetForMeasuresShelf(e));t.wrap(" WHERE ","")}return t.toString()};_MdxQueryBuilder.prototype.buildCubeName=function(){var e=new _TextBuilder;e.append(this.buildSubcubeExpression());var t=e.length>0;t&&e.wrap("SELECT "," FROM ");e.append("[",this._cubeName,"]");t&&e.wrap("(",")");return e.toString()};_MdxQueryBuilder.prototype.buildSubcubeExpression=function(){var e=new _TextBuilder,t=this.getMeasureFilterExpressions(this._ng.valueFields),i=this.buildFilterAttributeSet(this._ng.filterFields),n=this.buildFilterAttributeSet(this._ng.rowFields,t),o=this.buildFilterAttributeSet(this._ng.columnFields,0==n.length?t:null);e.joinItemToList(i);e.joinItemToList(n);e.joinItemToList(o);if(e.length>0){e.wrap("(",")");e.append(" ON COLUMNS")}return e.toString()};_MdxQueryBuilder.prototype.buildFilterAttributeSet=function(e,t){for(var i=new _TextBuilder,n=0;n<e.length;n++){var o=e[n],r=this.buildFilterString(o,0==n?t:null);i.joinItemToList(r)}return i.toString()};_MdxQueryBuilder.prototype.buildFilterString=function(e,t){var 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()};_MdxQueryBuilder.prototype.getValueFilterString=function(e){var t=new _TextBuilder,i=e.filter.valueFilter,n=Object.keys(i.showValues).map((function(t){return e.key+".["+t+"]"}));t.append(n.join(","));t.length>0&&t.wrap("{","}");return t.toString()};_MdxQueryBuilder.prototype.getConditionFilterString=function(e,t){var i=new _TextBuilder,n=e.key+".LEVELS(1).ALLMEMBERS",o=e.filter.conditionFilter.condition1,r=e.filter.conditionFilter.condition2;if(o.isActive){i.append(this.getConditionFilterExpression(e,o));r.isActive&&i.append(e.filter.conditionFilter.and?" AND ":" OR ")}r.isActive&&i.append(this.getConditionFilterExpression(e,r));if(t&&t.length>0){i.length>0&&i.append(" AND ");i.append(t.join(" AND "))}i.length>0&&i.wrap("Filter("+n+",(","))");return i.toString()};_MdxQueryBuilder.prototype.getMeasureFilterExpressions=function(e){for(var t=[],i=0;i<e.length;i++){var n=new _TextBuilder,o=e[i],r=(o.dimensionType,DimensionType.Measure,o.filter.conditionFilter.condition1),s=o.filter.conditionFilter.condition2;if(r.isActive){n.append(this.getConditionFilterExpression(o,r));s.isActive&&n.append(o.filter.conditionFilter.and?" AND ":" OR ")}s.isActive&&n.append(this.getConditionFilterExpression(o,s));if(n.length>0){n.wrap("(",")");t.push(n.toString())}}return t};_MdxQueryBuilder.prototype.getConditionFilterExpression=function(e,t){if(!t.isActive)return"";var i=e.dimensionType==DimensionType.Measure,n=e.dataType==DataType.Number,o=e.dataType==DataType.Date,r=n||o?"member_value":"member_caption",s=i?e.key:e.key+".CurrentMember."+r,l=o?"CDate('"+Globalize.formatDate(t.value,"d")+"')":t.value.toString(),a=new _TextBuilder;switch(t.operator){case Operator.BW:a.append("(Left(",s,",",l.length.toString(),')="',l,'")');break;case Operator.NBW:a.append("(Left(",s,",",l.length.toString(),')<>"',l,'")');break;case Operator.EW:a.append("(Right(",s,",",l.length.toString(),')="',l,'")');break;case Operator.NEW:a.append("(Right(",s,",",l.length.toString(),')<>"',l,'")');break;case Operator.EQ:i||n||o?a.append("(",s,")=",l):a.append("(",s,')="',l,'"');break;case Operator.NE:i||n||o?a.append("(",s,")<>",l):a.append("(",s,')<>"',l,'"');break;case Operator.CT:a.append("(InStr(1,",s,',"',l,'")>0)');break;case Operator.NC:a.append("(InStr(1,",s,',"',l,'")=0))');break;case Operator.GT:a.append("(",s,")>",l);break;case Operator.LT:a.append("(",s,")<",l);break;case Operator.GE:a.append("(",s,")>=",l);break;case Operator.LE:a.append("(",s,")<=",l)}return a.toString()};_MdxQueryBuilder.prototype.buildAxes=function(){var 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()};_MdxQueryBuilder.prototype.buildSetForAttributesShelf=function(e){for(var t=new _TextBuilder,i=0;i<e.length;i++){var n=e[i];n.dimensionType!=DimensionType.Attribute&&n.dimensionType!=DimensionType.Hierarchy||t.joinItemToList(this.buildAttributeSetForAxis(n));i>0&&t.wrap("CrossJoin(",")")}t.wrap("NON EMPTY ","");return t.toString()};_MdxQueryBuilder.prototype.buildSetForAttributesColumnShelf=function(e){for(var t=new _TextBuilder,i=0;i<e.length;i++){var n=e[i];n.dimensionType!=DimensionType.Attribute&&n.dimensionType!=DimensionType.Hierarchy||t.joinItemToList(this.buildAttributeSetForAxis(n))}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()};_MdxQueryBuilder.prototype.buildSetForMeasuresShelf=function(e){for(var t=new _TextBuilder,i=0;i<e.length;i++){var n=e[i];n.dimensionType!=DimensionType.Measure&&n.dimensionType!=DimensionType.Kpi||t.joinItemToList(this.buildMeasureSetForAxis(n))}t.wrap("{","}");return t.toString()};_MdxQueryBuilder.prototype.buildAttributeSetForAxis=function(e){var t=new _TextBuilder;if(e.dimensionType==DimensionType.Hierarchy){t.append(e.key);t.append(".ALLMEMBERS");t.wrap("{","}");t.wrap("HIERARCHIZE(",")")}return t.toString()};_MdxQueryBuilder.prototype.buildMeasureSetForAxis=function(e){var t=new _TextBuilder;e.dimensionType!=DimensionType.Measure&&e.dimensionType!=DimensionType.Kpi||t.append(e.key);return t.toString()};return _MdxQueryBuilder}();export{_MdxQueryBuilder};var _SqlServerConnection=function(e){__extends(_SqlServerConnection,e);function _SqlServerConnection(t,i){var n=e.call(this,t,i.url)||this;n._jsonResult=null;n._dataTypes=null;n._debug=!1;t.sortOnServer=!0;assert(isString(i.cube)&&!isNullOrWhiteSpace(i.cube),"Cube name required.");n._cubeName=i.cube;n._catalogName=isString(i.catalog)&&!isNullOrWhiteSpace(i.catalog)?i.catalog:"";n._url=i.url;n._user=i.user;n._password=i.password;return n}_SqlServerConnection.prototype.getFields=function(){this._getSession();this._jsonResult=null;this._dataTypes=null;this._getProperties(this._token);this._getDimensions(this._token);this._endSession();return this._jsonResult};_SqlServerConnection.prototype.getOutputView=function(e){var t=this;this._ng.onUpdatingView(new ProgressEventArgs(0));var i=new _MdxQueryBuilder(this._ng,this._cubeName).buildQuery();this._jsonResult=[];this._getSession();this._execQuery(this._token,i,(function(i){asFunction(e)(t._jsonResult);t._ng.onUpdatedView(new ProgressEventArgs(100))}))};_SqlServerConnection.prototype.getDetail=function(e,t){throw"getDetail method not supported"};_SqlServerConnection.prototype.getSortedKeys=function(e,t){var i=this,n=Object.keys(e);if(this._ng.sortOnServer){if(n.length>1){var o=t?this._ng.showRowTotals:this._ng.showColumnTotals,r=t?this._ng.rowFields.length:this._ng.columnFields.length,s=this._ng.valueFields.length;if(!this._ng.totalsBeforeData&&o!==ShowTotals.None){var l=-1,a=[],d=[];n.forEach((function(e){var n=i._getKeyLength(e,t);if(n===r)d.push(e);else if(n>=l)a.push(e);else{if(a.length>=s)for(var o=0;o<s;o++)d.push(a.pop());a.push(e)}l=n}));if(a.length>0){a.reverse();d=d.concat(a)}return d}}}else n.sort((function(e,t){return i._ng._keys[e].compareTo(i._ng._keys[t])}));return n};_SqlServerConnection.prototype._getSession=function(){var e=this,t=this._url;return httpRequest(t,{async:!1,data:_ENV_SESSION,method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(t){var i=t.responseXML.getElementsByTagName("Session");e._token=i[0].getAttribute("SessionId")},error:function(t){e._handleError("Begin Session",t)}})};_SqlServerConnection.prototype._endSession=function(){var e=this,t=this._url;return httpRequest(t,{async:!1,data:_ENV_ENDSESSION(this._token),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},error:function(t){e._handleError("End Session",t)},complete:function(t){e._token=void 0}})};_SqlServerConnection.prototype._getProperties=function(e){var t=this,i=this._url;return httpRequest(i,{async:!1,data:_ENV_PROPERTIES(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(e){for(var i={},n=e.responseXML.getElementsByTagName("row"),o=0;o<n.length;o++){var r=_getTagValue(n[o],"HIERARCHY_UNIQUE_NAME");switch(Number(_getTagValue(n[o],"DATA_TYPE"))){case 2:case 3:case 4:case 5:case 6:i[r]=DataType.Number;break;case 7:i[r]=DataType.Date}}t._dataTypes=i},error:function(e){t._handleError("Get Properties",e)}})};_SqlServerConnection.prototype._getDimensions=function(e){var t=this,i=this._url;return httpRequest(i,{async:!1,data:_ENV_DIMENSIONS(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(i){for(var n=[],o=i.responseXML.getElementsByTagName("row"),r=0;r<o.length;r++){if("2"!==_getTagValue(o[r],"DIMENSION_TYPE")){var s=_getTagValue(o[r],"DIMENSION_UNIQUE_NAME"),l={header:_getTagValue(o[r],"DIMENSION_CAPTION"),dataType:DataType.Object,dimensionType:DimensionType.Dimension,subFields:[]};t._getSubFolders(e,s,l);n.push(l)}else t._getMeasures(e,n)}var a={header:"KPIs",dataType:DataType.Object,dimensionType:DimensionType.Kpi,subFields:[]};t._getKPIs(e,a);n.push(a);t._jsonResult=n},error:function(e){t._handleError("Get Dimensions",e)}})};_SqlServerConnection.prototype._getSubFolders=function(e,t,i){var n=this,o=this._url;httpRequest(o,{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:function(e){for(var t=e.responseXML.getElementsByTagName("row"),o=0;o<t.length;o++){var r={header:_getTagValue(t[o],"HIERARCHY_NAME"),binding:_getTagValue(t[o],"HIERARCHY_UNIQUE_NAME"),dataType:DataType.String,dimensionType:DimensionType.Hierarchy};n._dataTypes[r.binding]&&(r.dataType=n._dataTypes[r.binding]);for(var s=_getTagValue(t[o],"HIERARCHY_DISPLAY_FOLDER").split("\\"),l=i,a=0;a<s.length;a++)if(""!=s[a]){var d={header:s[a],dataType:DataType.Object,dimensionType:DimensionType.Folder,subFields:[]};if(_containsFolder(l,s[a]))l=_findSubFieldByName(l,s[a]);else{l.subFields.push(d);l=d}}l.subFields.push(r)}},error:function(e){n._handleError("Get Hierarchies",e)}})};_SqlServerConnection.prototype._getMeasures=function(e,t){var i=this,n=this._url;return httpRequest(n,{async:!1,data:_ENV_MEASURES(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(e){for(var i=e.responseXML.getElementsByTagName("row"),n={},o=0;o<i.length;o++){var r=_getTagValue(i[o],"MEASUREGROUP_NAME"),s={header:_getTagValue(i[o],"MEASURE_CAPTION"),binding:_getTagValue(i[o],"MEASURE_UNIQUE_NAME"),dataType:DataType.Number,dimensionType:DimensionType.Measure};if(Object.keys(n).indexOf(r)<0){var l={header:r,dataType:DataType.Number,dimensionType:DimensionType.Measure,subFields:[]};l.subFields.push(s);t.push(l);n[r]=l}else n[r].subFields.push(s)}},error:function(e){i._handleError("Get Measures",e)}})};_SqlServerConnection.prototype._getKPIs=function(e,t){var i=this,n=this._url;return httpRequest(n,{async:!1,data:_ENV_KPIS(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(e){for(var i=e.responseXML.getElementsByTagName("row"),n=0;n<i.length;n++){for(var o=_getTagValue(i[n],"KPI_DISPLAY_FOLDER").split("\\"),r=t,s=0;s<o.length;s++){var l={header:o[s],dataType:DataType.Object,dimensionType:DimensionType.Folder,subFields:[]};if(_containsFolder(r,o[s]))r=_findSubFieldByName(r,o[s]);else{r.subFields.push(l);r=l}}var a={header:_getTagValue(i[n],"KPI_CAPTION"),binding:_getTagValue(i[n],"KPI_VALUE"),dataType:DataType.Number,dimensionType:DimensionType.Kpi};r.subFields.push(a)}},error:function(e){i._handleError("Get KPIs",e)}})};_SqlServerConnection.prototype._execQuery=function(e,t,i){var n=this,o=this._url;return httpRequest(o,{async:!0,data:_ENV_QUERY(e,this._catalogName,t),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(e){var o=e.responseXML,r=o.querySelector("Error");if(r){throw"SSAS Error\r\n"+r.getAttribute("Description")+"\r\n"+t}n._createPivotKeys(o);asFunction(i)(e)},error:function(e){n._handleError("Execute Query",e)},complete:function(){n._endSession()}})};_SqlServerConnection.prototype._createPivotKeys=function(e){var t=null,i=null,n=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']"));var o=t&&this._ng.rowFields.length>0,r=i&&this._ng.columnFields.length>0;o&&r?this._createRowKeys(n,t,i):o?this._createRowOnlyKeys(n,t):r&&this._createColumnOnlyKeys(n,i)};_SqlServerConnection.prototype._createRowKeys=function(e,t,i){for(var n=t.getElementsByTagName("Tuple"),o=i.getElementsByTagName("Tuple"),r=this._ng.showRowTotals!==ShowTotals.None?0:1,s=this._ng.showColumnTotals!==ShowTotals.None?0:this._ng.valueFields.length,l=r;l<n.length;l++){var a=l*o.length,d=n[l],u=this._validateTuple(d,this._ng.showRowTotals);if(u)for(var h=s;h<o.length;h++){var c=o[h],p=this._validateTuple(c,this._ng.showColumnTotals);if(p){for(var g in u)p[g]=u[g];for(var _=0;_<this._ng.valueFields.length;_++){p[this._ng.valueFields[_].key]=_getCellValue(e,a+h+_)}this._jsonResult.push(p)}}}};_SqlServerConnection.prototype._createRowOnlyKeys=function(e,t){for(var i=t.getElementsByTagName("Tuple"),n=this._ng.valueFields.length,o=this._ng.showRowTotals!==ShowTotals.None?0:1,r=o*n,s=o;s<i.length;s++){var l=i[s],a=this._validateTuple(l,this._ng.showRowTotals);if(a){for(var d=0;d<this._ng.valueFields.length;d++){a[this._ng.valueFields[d].key]=_getCellValue(e,r++)}this._jsonResult.push(a)}else r++}};_SqlServerConnection.prototype._createColumnOnlyKeys=function(e,t){for(var i=t.getElementsByTagName("Tuple"),n=this._ng.valueFields.length,o=this._ng.showColumnTotals!==ShowTotals.None?0:1,r=o;r<i.length;r+=n){var s=i[r],l=this._validateTuple(s,this._ng.showColumnTotals);if(l){for(var a=0;a<this._ng.valueFields.length;a++){l[this._ng.valueFields[a].key]=_getCellValue(e,r-o+a)}this._jsonResult.push(l)}}};_SqlServerConnection.prototype._validateTuple=function(e,t){for(var i=e.getElementsByTagName("Member"),n=void 0,o={},r=0;r<i.length;r++){var s=i[r],l=_getLevelNumber(s),a=s.getAttribute("Hierarchy"),d=_getCaptionValue(s);if(0==r)n=l;else{if(l>n)return null;if(t!==ShowTotals.Subtotals&&l!==n&&"[Measures]"!==a)return null;n=l}a.indexOf(".")>=0?o[a]=d:null!==d&&(o[d]=null)}return o};return _SqlServerConnection}(_ServerConnection);export{_SqlServerConnection};function _getTagValue(e,t){var 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){var i="Cell[CellOrdinal='"+t.toString()+"']",n=e.querySelector(i);if(n){var o=_getTagValue(n,"Value");if(o)return Number(o)}return null}function _findSubFieldByName(e,t){if(e.subFields)for(var i=0;i<e.subFields.length;i++){var n=e.subFields[i];if(n.header==t)return n}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}var _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=function(e){return'\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=function(e,t,i){return'\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=function(e,t,i,n){return'\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>"+n+"</DIMENSION_UNIQUE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>"},_ENV_MEASURES=function(e,t,i){return'\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=function(e,t,i){return'\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=function(e,t,i){return'\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=function(e,t,i){return'\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=function(e,t,i){return'\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>"},PivotFilter=function(){function PivotFilter(e){this._fld=e;var t=e;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=this._fld.engine.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t)}Object.defineProperty(PivotFilter.prototype,"filterType",{get:function(){return null!=this._filterType?this._filterType:this._fld.engine.defaultFilterType},set:function(e){if((e=asEnum(e,FilterType,!0))!=this._filterType){this._filterType=e;this.clear()}},enumerable:!0,configurable:!0});PivotFilter.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)};Object.defineProperty(PivotFilter.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0});PivotFilter.prototype.clear=function(){var 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 PropertyChangedEventArgs("filter",null,null))};Object.defineProperty(PivotFilter.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0});Object.defineProperty(PivotFilter.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0});return PivotFilter}();export{PivotFilter};var PivotFilterEditor=function(e){__extends(PivotFilterEditor,e);function PivotFilterEditor(t,i,n){var o=e.call(this,t)||this;o.finishEditing=new Event;o.hostElement.tabIndex=-1;var r=o.getTemplate();o.applyTemplate(ControlClsNames.hostElement+" "+ControlClsNames.content+" "+PivotFilterEditorClsNames.hostElement,r,{_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnOk:"btn-ok"});setText(o._aVal,culture.FlexGridFilter.values);setText(o._aCnd,culture.FlexGridFilter.conditions);setText(o._btnOk,culture.olap.PivotFieldEditor.ok);var s=o._btnClicked.bind(o);o.addEventListener(o._btnOk,"click",s);o.addEventListener(o._aVal,"click",s);o.addEventListener(o._aCnd,"click",s);o.addEventListener(o.hostElement,"keydown",(function(e){switch(e.keyCode){case Key.Enter:switch(e.target.tagName){case"A":case"BUTTON":o._btnClicked(e);break;default:o.onFinishEditing(new CancelEventArgs)}e.preventDefault();break;case Key.Escape:o.onFinishEditing(new CancelEventArgs);e.preventDefault();break;case Key.Tab:moveFocus(o.hostElement,e.shiftKey?-1:1);e.preventDefault()}}));o._fld=i;o._uniqueValues=i.filter.valueFilter.uniqueValues;o.initialize(n);o.updateEditor();return o}Object.defineProperty(PivotFilterEditor,"controlTemplate",{get:function(){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="'+InputFormElementsClsNames.btn+'"></button></div></div>');return PivotFilterEditor._ctrlTemplate},set:function(e){PivotFilterEditor._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotFilterEditor.prototype,"field",{get:function(){return this._fld},enumerable:!0,configurable:!0});Object.defineProperty(PivotFilterEditor.prototype,"filter",{get:function(){return this._fld?this._fld.filter:null},enumerable:!0,configurable:!0});Object.defineProperty(PivotFilterEditor.prototype,"isEditorClear",{get:function(){switch(this._getFilterType()){case FilterType.Value:return!this._edtVal||this._edtVal.isEditorClear;case FilterType.Condition:return!this._edtCnd||this._edtCnd.isEditorClear}assert(!1,"unknown filter type?");return!1},enumerable:!0,configurable:!0});PivotFilterEditor.prototype.updateEditor=function(){var e=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){var i=this._fld,n=i.engine;if(n.isServer&&!this._uniqueValues){var o=n._getUniqueValues(i);i.filter.valueFilter.uniqueValues=o}this._edtVal.updateEditor()}this._edtCnd&&this._edtCnd.updateEditor()};PivotFilterEditor.prototype.updateFilter=function(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}this.field.onPropertyChanged(new PropertyChangedEventArgs("filter",null,null))};PivotFilterEditor.prototype.clearEditor=function(){this._edtVal&&this._edtVal.clearEditor();this._edtCnd&&this._edtCnd.clearEditor()};PivotFilterEditor.prototype.onFinishEditing=function(e){this.finishEditing.raise(this,e);return!e.cancel};PivotFilterEditor.prototype._showFilter=function(e){e==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter));e==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter));if(0!=(e&this.filter.filterType))if(e==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 FilterType.None:case FilterType.Condition:case FilterType.Value:this._divType.style.display="none";break;default:this._divType.style.display=""}};PivotFilterEditor.prototype._enableLink=function(e,t){e.style.textDecoration=t?"":"none";e.style.fontWeight=t?"":"bold";setAttribute(e,"href",t?"":null)};PivotFilterEditor.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition};PivotFilterEditor.prototype._btnClicked=function(e){e.preventDefault();e.stopPropagation();if(!hasClass(e.target,ControlStateClsNames.disabled))if(e.target!=this._aVal)if(e.target!=this._aCnd)this.onFinishEditing(new CancelEventArgs);else{this._showFilter(FilterType.Condition);moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);moveFocus(this._edtVal.hostElement,0)}};PivotFilterEditor._ctrlTemplate="";return PivotFilterEditor}(Control);export{PivotFilterEditor};var PivotFieldEditor=function(e){__extends(PivotFieldEditor,e);function PivotFieldEditor(t,i){var n=e.call(this,t,null,!0)||this;n.hostElement.tabIndex=-1;var o=n.getTemplate();n.applyTemplate(ControlClsNames.hostElement+" "+PivotFieldEditorClsNames.hostElement,o,{_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"});n._pvDate=new Date;var r=culture.olap.PivotFieldEditor;setText(n._gDlg,r.dialogHeader);setText(n._gHdr,r.header);setText(n._gAgg,r.summary);setText(n._gShw,r.showAs);setText(n._gWfl,r.weighBy);setText(n._gSrt,r.sort);setText(n._gFlt,r.filter);setText(n._gFmt,r.format);setText(n._gSmp,r.sample);setText(n._btnFltEdt,r.edit);setText(n._btnFltClr,r.clear);setText(n._btnApply,r.ok);setText(n._btnCancel,r.cancel);n._cmbHdr=new ComboBox(n._dHdr);n._cmbAgg=new ComboBox(n._dAgg);n._cmbShw=new ComboBox(n._dShw);n._cmbWFl=new ComboBox(n._dWFl);n._cmbSrt=new ComboBox(n._dSrt);n._cmbFmt=new ComboBox(n._dFmt);n._cmbSmp=new ComboBox(n._dSmp);n._initAggregateOptions();n._initShowAsOptions();n._initFormatOptions();n._initSortOptions();n._updatePreview();n._cmbShw.textChanged.addHandler(n._updateFormat,n);n._cmbFmt.textChanged.addHandler(n._updatePreview,n);n.addEventListener(n._btnFltEdt,"click",(function(e){n._editFilter();e.preventDefault()}));n.addEventListener(n._btnFltClr,"click",(function(e){n._createFilterEditor();setTimeout((function(){n._eFlt.clearEditor();n._btnFltEdt.focus();enable(n._btnFltClr,!1)}));e.preventDefault()}));n.addEventListener(n._btnApply,"click",(function(e){n.updateField()}));n.initialize(i);return n}Object.defineProperty(PivotFieldEditor,"controlTemplate",{get:function(){PivotFieldEditor._ctrlTemplate||(PivotFieldEditor._ctrlTemplate='<div><div class="'+DetailDialogClsNames.dialogHeader+'" tabindex="-1"><span wj-part="g-dlg"></span> <span wj-part="sp-bnd"></span></div><div class="'+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="'+UtilitesClsNames.separator+'"><td wj-part="g-agg"></td><td><div wj-part="div-agg"></div></td></tr><tr class="'+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="'+UtilitesClsNames.separator+'"><td wj-part="g-flt"></td><td><div><button wj-part="btn-flt-edt" class="'+InputFormElementsClsNames.btn+'"></button> <button wj-part="btn-flt-clr" class="'+InputFormElementsClsNames.btn+'"></button></div></td></tr><tr class="'+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="'+DetailDialogClsNames.dialogFooter+'"><button wj-part="btn-apply" class="'+InputFormElementsClsNames.btn+" "+UtilitesClsNames.hide+'"></button> <button wj-part="btn-cancel" class="'+InputFormElementsClsNames.btn+" "+UtilitesClsNames.hide+'"></button></div></div>');return PivotFieldEditor._ctrlTemplate},set:function(e){PivotFieldEditor._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotFieldEditor.prototype,"field",{get:function(){return this._fld},set:function(e){if(e!=this._fld){this._fld=asType(e,PivotField);this.updateEditor()}},enumerable:!0,configurable:!0});PivotFieldEditor.prototype.updateEditor=function(){var 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();var t=e.engine.defaultFilterType!=FilterType.None&&(null!=e.binding||isFunction(e.getValue));enable(this._btnFltEdt,t);enable(this._btnFltClr,t&&e.filter.isActive);this._cmbFmt.collectionView.refresh();this._cmbFmt.selectedValue=e.format;this._cmbFmt.selectedValue||(this._cmbFmt.text=e.format);var i=e instanceof CubePivotField;this._cmbAgg.isDisabled=i||!!e.getAggregateValue;this._cmbWFl.isDisabled=i}};PivotFieldEditor.prototype.updateField=function(){var e=this._fld;if(e){var t=this._cmbHdr.text.trim();e.header=t||toHeaderCase(e.binding);e.aggregate=this._cmbAgg.selectedValue;e.showAs=this._cmbShw.selectedValue;e.weightField=this._cmbWFl.selectedValue;e.descending=this._cmbSrt.selectedValue;var i=e.format;e.format=this._cmbFmt.selectedValue||this._cmbFmt.text;var n=this._eFlt;if(n){n.updateFilter();var o=e.dataType==DataType.Number,r=e.dataType==DataType.Date;if(i!=e.format&&(o||r)){var s=e.filter.valueFilter;if(s&&s.isActive&&!s.dataMap){var l={};if(o)for(var a in s.showValues){var d=Globalize.parseFloat(a);l[Globalize.format(d,e.format)]=!0}else if(r)for(var a in s.showValues){d=Globalize.parseDate(a,i);l[Globalize.format(d,e.format)]=!0}s.showValues=l}}}}};PivotFieldEditor.prototype._initAggregateOptions=function(){var e=this,t=culture.olap.PivotFieldEditor.aggs,i=Aggregate,n=[{key:t.sum,val:i.Sum,all:!1},{key:t.cnt,val:i.Cnt,all:!0},{key:t.avg,val:i.Avg,all:!1},{key:t.max,val:i.Max,all:!0},{key:t.min,val:i.Min,all:!0},{key:t.rng,val:i.Rng,all:!1},{key:t.std,val:i.Std,all:!1},{key:t.var,val:i.Var,all:!1},{key:t.stdp,val:i.StdPop,all:!1},{key:t.varp,val:i.VarPop,all:!1},{key:t.first,val:i.First,all:!0},{key:t.last,val:i.Last,all:!0}];this._cmbAgg.itemsSource=n;this._cmbAgg.collectionView.filter=function(t){if(t&&t.all)return!0;if(e._fld){var i=e._fld.dataType;return i==DataType.Number||i==DataType.Boolean}return!1};this._cmbAgg.initialize({displayMemberPath:"key",selectedValuePath:"val"})};PivotFieldEditor.prototype._initShowAsOptions=function(){var e=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"})};PivotFieldEditor.prototype._initFormatOptions=function(){var e=this,t=culture.olap.PivotFieldEditor.formats,i=[{key:t.n0,val:"n0",all:!0},{key:t.n2,val:"n2",all:!0},{key:t.c,val:"c",all:!0},{key:t.p0,val:"p0",all:!0},{key:t.p2,val:"p2",all:!0},{key:t.n2c,val:"n2,",all:!0},{key:t.n2cc,val:"n2,,",all:!0},{key:t.n2ccc,val:"n2,,,",all:!0},{key:t.d,val:"d",all:!1},{key:t.MMMMddyyyy,val:"MMMM dd, yyyy",all:!1},{key:t.dMyy,val:"d/M/yy",all:!1},{key:t.ddMyy,val:"dd/M/yy",all:!1},{key:t.dMyyyy,val:"dd/M/yyyy",all:!1},{key:t.MMMyyyy,val:"MMM yyyy",all:!1},{key:t.MMMMyyyy,val:"MMMM yyyy",all:!1},{key:t.yyyy,val:"yyyy",all:!1},{key:t.yyyyQq,val:'yyyy "Q"q',all:!1},{key:t.FYEEEEQU,val:'"FY"EEEE "Q"U',all:!1}];this._cmbFmt.itemsSource=i;this._cmbFmt.isEditable=!0;this._cmbFmt.isRequired=!1;this._cmbFmt.collectionView.filter=function(t){return!(!t||!t.all)||!!e._fld&&e._fld.dataType==DataType.Date};this._cmbFmt.initialize({displayMemberPath:"key",selectedValuePath:"val"})};PivotFieldEditor.prototype._initWeighByOptions=function(){var e=this._fld;if(e){var t=[{key:culture.olap.PivotFieldEditor.none,val:null}];e.engine.fields.forEach((function(i){i!=e&&i.dataType==DataType.Number&&t.push({key:i.header,val:i})}));this._cmbWFl.initialize({displayMemberPath:"key",selectedValuePath:"val",itemsSource:t,selectedValue:e.weightField})}};PivotFieldEditor.prototype._initSortOptions=function(){var e=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"})};PivotFieldEditor.prototype._updateFormat=function(){var e=ShowAs[this._cmbShw.selectedValue];this._cmbFmt.selectedValue=e.indexOf("Pct")>-1?"p0":"n0"};PivotFieldEditor.prototype._updatePreview=function(){var e=this._cmbFmt.selectedValue||this._cmbFmt.text,t=Globalize.format,i="";if(e){var n=e[0].toLowerCase();i="nfgxc".indexOf(n)>-1?t(1234.5678,e):t("p"==n?.12345678:this._pvDate,e)}this._cmbSmp.text=i};PivotFieldEditor.prototype._editFilter=function(){this._createFilterEditor();showPopup(this._dFlt,this._btnFltEdt,!1,!1,!1);moveFocus(this._dFlt,0)};PivotFieldEditor.prototype._createFilterEditor=function(){var e=this;if(!this._dFlt){this._dFlt=document.createElement("div");this._eFlt=new PivotFilterEditor(this._dFlt,this._fld);addClass(this._dFlt,DropDownClsNames.dropDownPanel);this._eFlt.lostFocus.addHandler((function(){setTimeout((function(){var t=Control.getControl(e._dFlt);t&&!t.containsFocus()&&e._closeFilter()}),10)}));this._eFlt.finishEditing.addHandler((function(){e._closeFilter();enable(e._btnFltClr,!e._eFlt.isEditorClear)}))}};PivotFieldEditor.prototype._closeFilter=function(){if(this._dFlt){hidePopup(this._dFlt,!0);this.focus()}};PivotFieldEditor._ctrlTemplate="";return PivotFieldEditor}(Control);export{PivotFieldEditor};_registerModule("wijmo.olap",selfModule);var PivotFieldBinding=function(e){__extends(PivotFieldBinding,e);function PivotFieldBinding(t,i){var n=e.call(this,i)||this;n._fld=t;return n}PivotFieldBinding.prototype.getValue=function(t){var i=this._fld;return isFunction(i.getValue)?i._getValue(t,!1):e.prototype.getValue.call(this,t)};return PivotFieldBinding}(Binding);export{PivotFieldBinding};
|
|
14
|
+
var __extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}();import{CollectionView,asType,assert,ObservableArray,asInt,isString,isBoolean,isNumber,Aggregate,httpRequest,isArray,isDate,Globalize,asString,DataType,asFunction,RequestErrorEventArgs,isNullOrWhiteSpace,PropertyChangedEventArgs,asEnum,Control,setText,culture,Key,CancelEventArgs,moveFocus,setAttribute,hasClass,Event,ControlStateClsNames,ControlClsNames,InputFormElementsClsNames,addClass,enable,showPopup,toHeaderCase,hidePopup,isFunction,UtilitesClsNames,EventArgs,NotifyCollectionChangedAction,_addCultureInfo,copy,tryCast,getType,getTypes,isObject,isPrimitive,asCollectionView,asBoolean,asNumber,asArray,hasItems,Binding,changeType,DateTime,GlyphClsNames,createElement,clamp,toggleClass,_startDrag,closest,Rect,setCss,format,isEmpty,closestClass,escapeHtml,isIE,isEdge,Tooltip,removeChild,_registerModule}from"@mescius/wijmo";import{FilterType,Operator,ValueFilter,ConditionFilter,ValueFilterEditor,ConditionFilterEditor}from"@mescius/wijmo.grid.filter";import{ComboBox,DropDownClsNames,Popup,Menu,MultiSelect,ListBoxClsNames}from"@mescius/wijmo.input";import{FlexGrid,FlexGridClsNames,CellType,AllowMerging,MergeManager,CellRange,AllowDragging,HeadersVisibility,Row,Column,CellRangeEventArgs}from"@mescius/wijmo.grid";import{Stacking,FlexChart,FlexPie,Position,Axis,SeriesVisibility,Series,TickMark,ChartType}from"@mescius/wijmo.chart";import*as selfModule from"@mescius/wijmo.olap";var _TextBuilder=function(){function _TextBuilder(){this._text=""}Object.defineProperty(_TextBuilder.prototype,"length",{get:function(){return this._text.length},enumerable:!0,configurable:!0});_TextBuilder.prototype.toString=function(){return this._text};_TextBuilder.prototype.append=function(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];this._text=(e=this._text).concat.apply(e,t)};_TextBuilder.prototype.joinToList=function(e){for(var t,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var o=i.join();this.length>0&&o.length>0?this._text=(t=this._text).concat.apply(t,[e].concat(i)):o.length>0&&(this._text=o)};_TextBuilder.prototype.joinItemToList=function(e){this.joinToList(",",e)};_TextBuilder.prototype.wrap=function(e,t){this.length>0&&(this._text=e.concat(this._text,t))};_TextBuilder.wrap=function(e,t,i){return t.length>0?e.concat(t,i):""};return _TextBuilder}();export{_TextBuilder};export var DetailDialogClsNames={dialogBody:"wj-dialog-body",dialogFooter:"wj-dialog-footer",dialogHeader:"wj-dialog-header",hostElement:"wj-detaildialog",summary:"wj-summary"};export var PivotChartClsNames={hierarchicalAxesLine:"wj-hierarchicalaxes-line",hostElement:"wj-pivotchart"};export var PivotFieldEditorClsNames={hostElement:"wj-pivotfieldeditor"};export var PivotFilterEditorClsNames={hostElement:"wj-pivotfiltereditor"};export var PivotGridClsNames={colFieldHdr:"wj-col-field-hdr",hostElement:"wj-pivotgrid",pivotCollapse:"wj-pivot-collapse",rowFieldHdr:"wj-row-field-hdr"};export var PivotPanelClsNames={aggregate:"wj-aggregate",header:"wj-header",hostElement:"wj-pivotpanel"};export var SlicerClsNames={header:"wj-header",hostElement:"wj-slicer",noCheck:"wj-nocheck"};export var _GridContextMenuClsNames={hostElement:"wj-olap-context-menu"};var _Tally=function(){function _Tally(){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}_Tally.prototype.add=function(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++;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(isNumber(e)&&!isNaN(e)){isNumber(t)&&(e*=t);this._cntn++;this._sum+=e;this._sum2+=e*e}}}};_Tally.prototype.getAggregate=function(e){if(0==this._cnt)return null;var t=0==this._cntn?0:this._sum/this._cntn,i=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."};return _Tally}();export{_Tally};var _PivotKey=function(){function _PivotKey(e,t,i,n,o){this._fields=e;this._fieldCount=t;this._valueFields=i;this._valueFieldIndex=n;this._item=o}Object.defineProperty(_PivotKey.prototype,"fields",{get:function(){return this._fields},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"valueFields",{get:function(){return this._valueFields},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"valueField",{get:function(){return this._valueFields[this._valueFieldIndex]},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"values",{get:function(){if(null==this._vals){this._vals=new Array(this._fieldCount);for(var e=0;e<this._fieldCount;e++){var t=this._fields[e];this._vals[e]=t._getValue(this._item,!1)}}return this._vals},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"fieldNames",{get:function(){if(!this._names){this._names=[];for(var e=0;e<this.fields.length;e++){var t=this._fields[e];this._names.push(t._getName())}}return this._names},enumerable:!0,configurable:!0});Object.defineProperty(_PivotKey.prototype,"aggregate",{get:function(){var e=this._valueFields,t=this._valueFieldIndex;assert(e&&t>-1&&t<e.length,"aggregate not available for this key");return e[t].aggregate},enumerable:!0,configurable:!0});_PivotKey.prototype.getValue=function(e,t){if(0==this.values.length)return culture.olap.PivotEngine.grandTotal;if(e>this.values.length-1)return culture.olap.PivotEngine.subTotal;var i=this.values[e];if(t&&!isString(i)){var n=this.fields[e],o=n?n.format:"";i=Globalize.format(this.values[e],o)}return i};Object.defineProperty(_PivotKey.prototype,"level",{get:function(){return this._fieldCount==this._fields.length?-1:this._fieldCount},enumerable:!0,configurable:!0});_PivotKey.prototype.compareTo=function(e){var t=0;if(null!=e&&e._fields==this._fields){for(var i=this.values,n=e.values,o=Math.min(i.length,n.length),r=0;r<o;r++){var s=null!=i[r]?getType(i[r]):null,l=i[r],a=n[r],d=this._fields[r];if(d.sortComparer){t=d.sortComparer(l,a);if(isNumber(t)){if(0!=t)return d.descending?-t:t;continue}}if(s==DataType.Date){var u=d.format;if(u&&"d"!=u&&"D"!=u){var h=d._getValue(this._item,!0),c=d._getValue(e._item,!0),p=Globalize.parseDate(h,u),g=Globalize.parseDate(c,u);if(p&&g){l=p;a=g}else{l=h;a=c}}}if(!(l==a||DateTime.equals(l,a))){if(null==l)return 1;if(null==a)return-1;t=l<a?-1:1;return d.descending?-t:t}}if(i.length==n.length&&0!=(t=this._valueFieldIndex-e._valueFieldIndex))return t;if(0!=(t=n.length-i.length))return t*(this.fields.engine.totalsBeforeData?-1:1)}return 0};_PivotKey.prototype.matchesItem=function(e){for(var t=0;t<this._vals.length;t++){if(this.getValue(t,!0)!=this._fields[t]._getValue(e,!0))return!1}return!0};_PivotKey.prototype.toString=function(e){if(!this._key||e){for(var t="",i=0;i<this._fieldCount;i++){var n=this._fields[i];t+=n._getName()+":"+n._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";return _PivotKey}();export{_PivotKey};var _NOT_EDITABLE="This collection is not editable.",PivotCollectionView=function(e){__extends(PivotCollectionView,e);function PivotCollectionView(t){var i=e.call(this)||this;i.canAddNew=i.canRemove=!1;i._ng=asType(t,PivotEngine,!1);return i}Object.defineProperty(PivotCollectionView.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});PivotCollectionView.prototype.implementsInterface=function(t){return"IEditableCollectionView"!=t&&e.prototype.implementsInterface.call(this,t)};PivotCollectionView.prototype.editItem=function(e){assert(!1,_NOT_EDITABLE)};PivotCollectionView.prototype.addNew=function(){assert(!1,_NOT_EDITABLE)};PivotCollectionView.prototype._performSort=function(e){var t=this._ng;if(t.sortableGroups&&t._getShowRowTotals()==ShowTotals.Subtotals){var i=0,n=e.length-1;0==this._getItemLevel(e[i])&&i++;0==this._getItemLevel(e[n])&&n--;this._sortGroups(e,1,i,n)}else this._sortData(e)};PivotCollectionView.prototype._performFilter=function(e){return this._ng&&0==this._ng.valueFields.length&&0==this._ng.rowFields.length?[]:this.canFilter&&this._filter?e.filter(this._filter,this):e};PivotCollectionView.prototype._getGroupRange=function(e,t){var i=this._ng,n=e.indexOf(t),o=n,r=this._getItemLevel(e[n]);if(i.totalsBeforeData)for(o=n;o<e.length-1;o++){if((s=this._getItemLevel(e[o+1]))>-1&&s<=r)break}else for(n=o;n;n--){var s;if((s=this._getItemLevel(e[n-1]))>-1&&s<=r)break}return[n,o]};PivotCollectionView.prototype._sortGroups=function(t,i,n,o){for(var r=[],s=n;s<=o;s++)this._getItemLevel(t[s])==i&&r.push(t[s]);if(r.length){e.prototype._performSort.call(this,r);var l=[];for(s=0;s<r.length;s++){for(var a=this._getGroupRange(t,r[s]),d=l.length,u=a[0];u<=a[1];u++)l.push(t[u]);var h=l.length-1;if(i<this._ng.rowFields.length-1)this._sortGroups(l,i+1,n+d,h);else{var c=this._ng.totalsBeforeData?1:0;this._sortSegment(l,d+c,h+c)}}for(s=0;s<l.length;s++)t[n+s]=l[s]}else this._sortData(t)};PivotCollectionView.prototype._sortSegment=function(t,i,n){var o=t.slice(i,n);e.prototype._performSort.call(this,o);for(var r=0;r<o.length;r++)t[i+r]=o[r]};PivotCollectionView.prototype._sortData=function(t){for(var i=0;i<t.length;i++)if(!(this._getItemLevel(t[i])>-1)){for(var n=i;n<t.length-1&&!(this._getItemLevel(t[n+1])>-1);n++);if(n>i){var o=t.slice(i,n+1);e.prototype._performSort.call(this,o);for(var r=0;r<o.length;r++)t[i+r]=o[r]}i=n}};PivotCollectionView.prototype._getItemLevel=function(e){return e[_PivotKey._ROW_KEY_NAME].level};return PivotCollectionView}(CollectionView);export{PivotCollectionView};var PivotField=function(){function PivotField(e,t,i,n){this._isExplicitAggregate=!1;this.propertyChanged=new Event;this._ng=e;this._binding=new PivotFieldBinding(this,t);this._header=i||toHeaderCase(t);this._showAs=ShowAs.NoCalculation;this._isContentHtml=!1;this._visible=!0;this._format="";this._filter=new PivotFilter(this);copy(this,n);null==this._dataType&&this._updateDataTypeByBinding();this._isExplicitAggregate||this._updateAggregateByDataType()}Object.defineProperty(PivotField.prototype,"binding",{get:function(){return this._binding?this._binding.path:null},set:function(e){if(e!=this.binding){var t=this.binding,i=asString(e);this._binding=i?new PivotFieldBinding(this,i):null;if(null==this._dataType){this._updateDataTypeByBinding();this._isExplicitAggregate||this._updateAggregateByDataType()}var n=new PropertyChangedEventArgs("binding",t,e);this.onPropertyChanged(n)}},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"getValue",{get:function(){return this._getValueFn},set:function(e){this._getValueFn=asFunction(e,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"getAggregateValue",{get:function(){return this._getAggValueFn},set:function(e){this._getAggValueFn=asFunction(e,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"header",{get:function(){return this._header},set:function(e){e=asString(e,!1);var t=this._ng.fields.getField(e);!e||t&&t!=this?assert(!1,"field headers must be unique and non-empty."):this._setProp("_header",asString(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"aggregate",{get:function(){return this._aggregate},set:function(e){this._isExplicitAggregate=!0;this._setProp("_aggregate",asEnum(e,Aggregate))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"showAs",{get:function(){return this._showAs},set:function(e){this._setProp("_showAs",asEnum(e,ShowAs))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"weightField",{get:function(){return this._weightField},set:function(e){this._setProp("_weightField",asType(e,PivotField,!0))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"dataType",{get:function(){return this._dataType},set:function(e){this._setProp("_dataType",asEnum(e,DataType))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"isMeasure",{get:function(){return this._dataType==DataType.Number},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"subFields",{get:function(){return this._subFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"format",{get:function(){return this._format},set:function(e){this._setProp("_format",asString(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"align",{get:function(){return this._align},set:function(e){this._setProp("_align",asString(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"width",{get:function(){return this._width},set:function(e){this._setProp("_width",asNumber(e,!0,!0))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"wordWrap",{get:function(){return this._wordWrap},set:function(e){this._setProp("_wordWrap",asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"descending",{get:function(){return!!this._descending},set:function(e){this._setProp("_descending",asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"isContentHtml",{get:function(){return this._isContentHtml},set:function(e){this._setProp("_isContentHtml",asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"visible",{get:function(){return this._visible},set:function(e){this._setProp("_visible",asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"sortComparer",{get:function(){return this._srtCmp},set:function(e){e!=this.sortComparer&&(this._srtCmp=asFunction(e))},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"collectionView",{get:function(){return this.engine?this.engine.collectionView:null},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"isActive",{get:function(){return this._getIsActive()},set:function(e){this._setIsActive(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"parentField",{get:function(){return this._parent},enumerable:!0,configurable:!0});Object.defineProperty(PivotField.prototype,"key",{get:function(){return this.header},enumerable:!0,configurable:!0});PivotField.prototype.onPropertyChanged=function(e){this.propertyChanged.raise(this,e);this._ng._fieldPropertyChanged(this,e)};PivotField.prototype._updateDataTypeByBinding=function(){if(this._ng&&this._binding)for(var e=this._ng.collectionView,t=e?e.items.length:0,i=0;i<t;i++){var n=e.items[i];if(null!=n){this._dataType=getType(this._binding.getValue(n));break}}};PivotField.prototype._updateAggregateByDataType=function(){this._aggregate=this.dataType==DataType.Number?Aggregate.Sum:Aggregate.Cnt};PivotField.prototype._copy=function(e,t){var i=this;if("subFields"==e){this._subFields?this._subFields.splice(0,this._subFields.length):this._subFields=[];t&&t.length&&t.forEach((function(e){var t=i.engine._createField(e,i._autoGenerated);i._subFields.push(t)}));return!0}if("filter"==e){this._setFilterProxy(t);return!0}return!1};PivotField.prototype._getFilterProxy=function(){var e=this.filter;if(e.conditionFilter.isActive){var 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){var n=e.valueFilter;return{filterText:n.filterText,showValues:n.showValues}}assert(!1,"inactive filters shouldn't be persisted.");return null};PivotField.prototype._setFilterProxy=function(e){var t=this.filter,i=t.conditionFilter,n=t.valueFilter;t.clear();e.conditionFilter?e=e.conditionFilter:e.valueFilter&&(e=e.valueFilter);if(e.condition1){var o=e.condition1,r=changeType(o.value,this.dataType);i.condition1.value=r||o.value;i.condition1.operator=o.operator;var s=e.condition2;if(s){var l=changeType(s.value,this.dataType);i.condition2.value=l||s.value;i.condition2.operator=s.operator}isBoolean(e.and)&&(i.and=e.and)}if(e.showValues){n.filterText=e.filterText;n.showValues=e.showValues}};PivotField.prototype._getIsActive=function(){if(this._ng&&!this._hasSubFields())for(var e=this._ng._viewLists,t=0;t<e.length;t++)if(e[t].indexOf(this)>-1)return!0;return!1};PivotField.prototype._setIsActive=function(e){if(this._ng&&!this._hasSubFields()){var t=this.isActive;if((e=asBoolean(e))!=t)if(e)this.isMeasure?this._ng.valueFields.push(this):this._ng.rowFields.push(this);else{for(var i=this._ng._viewLists,n=0;n<i.length;n++)for(var o=i[n],r=0;r<o.length;r++){if((l=o[r])==this||l.parentField==this){o.removeAt(r);r--}}var s=this._ng.fields;for(r=s.length-1;r>=0;r--){var l;if((l=s[r]).parentField==this){s.removeAt(r);r--}}}}};PivotField.prototype._hasSubFields=function(){return null!=this._subFields&&this._subFields.length>0};PivotField.prototype._clone=function(){var e=new PivotField(this._ng,this.binding);this._ng._copyProps(e,this,PivotField._props);e._autoGenerated=!0;e._parent=this;for(var t=this.header.replace(/\d+$/,""),i=2;;i++){var n=t+i.toString();if(null==this._ng.fields.getField(n)){e._header=n;break}}return e};PivotField.prototype._setProp=function(e,t,i){var n=this[e];if(t!=n){this[e]=t;var o=new PropertyChangedEventArgs(e.substr(1),n,t);this.onPropertyChanged(o)}};PivotField.prototype._getName=function(){return this.header||this.binding};PivotField.prototype._getValue=function(e,t){var i=this._binding,n=null;e&&(n=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 n?Globalize.format(n,this._format):n};PivotField.prototype._getWeight=function(e){var t=this._weightField?this._weightField._getValue(e,!1):null;return isNumber(t)?t:null};PivotField._props=["dataType","format","width","wordWrap","aggregate","showAs","descending","isContentHtml","visible"];return PivotField}();export{PivotField};var CubePivotField=function(e){__extends(CubePivotField,e);function CubePivotField(t,i,n,o){var r=e.call(this,t,i,n,o)||this;assert(null!=r.dimensionType,"CubePivotField objects must specify the field's dimensionType");return r}Object.defineProperty(CubePivotField.prototype,"header",{get:function(){return this._header},set:function(e){this._setProp("_header",asString(e))},enumerable:!0,configurable:!0});Object.defineProperty(CubePivotField.prototype,"dimensionType",{get:function(){return this._dimensionType},set:function(e){this._setProp("_dimensionType",asEnum(e,DimensionType,!1))},enumerable:!0,configurable:!0});Object.defineProperty(CubePivotField.prototype,"isMeasure",{get:function(){switch(this._dimensionType){case 1:case 2:case 8:return!0}return!1},enumerable:!0,configurable:!0});Object.defineProperty(CubePivotField.prototype,"key",{get:function(){return this.binding},enumerable:!0,configurable:!0});CubePivotField.prototype._clone=function(){throw"CubePivotField objects cannot be cloned"};return CubePivotField}(PivotField);export{CubePivotField};export var DimensionType;!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||(DimensionType={}));var Slicer=function(e){__extends(Slicer,e);function Slicer(t,i){var n=e.call(this,t,null,isIE()&&!isEdge())||this;n._hdr=null;n._mSel=!1;n._updatingFilter=!1;n._propChanged=!1;n._fldPropChangeBnd=n._fldPropChange.bind(n);var o=n.getTemplate();n.applyTemplate(SlicerClsNames.hostElement+" "+SlicerClsNames.noCheck+" "+ControlClsNames.hostElement+" "+ControlClsNames.content,o,{_root:"root",_divHdr:"div-hdr",_divHdrText:"div-hdr-text",_btnMSel:"btn-msel",_btnClear:"btn-clear"});var r=culture.olap.Slicer,s=new Tooltip;setAttribute(n._btnMSel,"aria-label",r.multiSelect);setAttribute(n._btnClear,"aria-label",r.clearFilter);s.setTooltip(n._btnMSel,r.multiSelect);s.setTooltip(n._btnClear,r.clearFilter);n.addEventListener(n._btnClear,"click",(function(e){n._clear()}));n.addEventListener(n._btnMSel,"click",(function(e){n.multiSelect=!n.multiSelect}));n.initialize(i);return n}Object.defineProperty(Slicer,"controlTemplate",{get:function(){Slicer._ctrlTemplate||(Slicer._ctrlTemplate='<div wj-part="root"><div wj-part="div-hdr" class="'+SlicerClsNames.header+'"><div wj-part="div-hdr-text"></div><button wj-part="btn-msel" class="'+InputFormElementsClsNames.btn+' btn-msel" tabindex="-1"><span class='+GlyphClsNames.glyph+'>≡</span></button><button wj-part="btn-clear" class="'+InputFormElementsClsNames.btn+' btn-clear" tabindex="-1"><span class='+GlyphClsNames.glyph+">×</span></button></div></div>");return Slicer._ctrlTemplate},set:function(e){Slicer._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"field",{get:function(){return this._fld},set:function(e){var t=this;if(e!=this._fld){if(this._divListBox){removeChild(this._divListBox);this._divListBox=null;this._lbx.dispose();this._lbx=null}if(this._edt){this._clear();this._edt.dispose()}var i=this._fld;if(i){i.filter.filterType=this._originalFilterType;i.filter.valueFilter.uniqueValues=this._uniqueValues;i.propertyChanged.removeHandler(this._fldPropChangeBnd)}if(i=this._fld=asType(e,PivotField,!0)){this._originalFilterType=i.filter.filterType;i.filter.filterType=FilterType.Value;var n=i.engine;this._uniqueValues=i.filter.valueFilter.uniqueValues;if(n.isServer&&!this._uniqueValues){var o=n._getUniqueValues(i);i.filter.valueFilter.uniqueValues=o}i.propertyChanged.addHandler(this._fldPropChangeBnd);i.isActive||i.engine.filterFields.push(i);var r=document.createElement("div");this._edt=new ValueFilterEditor(r,i.filter.valueFilter)}if(this._edt){this._divListBox=this._edt.hostElement.querySelector("."+ListBoxClsNames.hostElement);this._root.appendChild(this._divListBox);this._lbx=Control.getControl(this._divListBox);this._lbx.checkedItemsChanged.addHandler((function(e,n){if(!t._propChanged){var o=t._lbx.selectedItem;if(!t.multiSelect&&o){t._mSel=!0;t._lbx.checkedItems=[o];t._mSel=!1}}if(t._edt&&i){t._updateFilter();i.engine.invalidate()}}))}this._updateHeader();isIE()&&!isEdge()&&this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"header",{get:function(){return this._hdr},set:function(e){if(e!=this._hdr){this._hdr=asString(e);this._updateHeader()}},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"showHeader",{get:function(){return"none"!=this._divHdr.style.display},set:function(e){this._divHdr.style.display=asBoolean(e)?"":"none"},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"showCheckboxes",{get:function(){return!hasClass(this.hostElement,SlicerClsNames.noCheck)},set:function(e){toggleClass(this.hostElement,SlicerClsNames.noCheck,!asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(Slicer.prototype,"multiSelect",{get:function(){return this._mSel},set:function(e){this._mSel=asBoolean(e);toggleClass(this._btnMSel,ControlStateClsNames.active,this._mSel)},enumerable:!0,configurable:!0});Slicer.prototype.refresh=function(t){var i=this;void 0===t&&(t=!0);isIE()&&!isEdge()&&this.hostElement&&setTimeout((function(){setCss(i._lbx.hostElement,{height:i.hostElement.clientHeight-i._divHdr.offsetHeight})}));e.prototype.refresh.call(this,t)};Slicer.prototype._fldPropChange=function(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};Slicer.prototype._updateHeader=function(){var e=this._hdr;e||null==this._fld||(e=this._fld.header);this._divHdrText.textContent=e};Slicer.prototype._clear=function(){if(this._edt){this._edt.clearEditor(!1);this._updateFilter();this._fld.engine.invalidate()}};Slicer.prototype._updateFilter=function(){this._updatingFilter=!0;this._edt.updateFilter();this._updatingFilter=!1};Slicer._ctrlTemplate="";return Slicer}(Control);export{Slicer};var _GridContextMenu=function(e){__extends(_GridContextMenu,e);function _GridContextMenu(){var t=e.call(this,document.createElement("div"),{header:"PivotGrid Context Menu",displayMemberPath:"text",commandParameterPath:"parm",command:{executeCommand:function(e){t._execute(e)},canExecuteCommand:function(e){return t._canExecute(e)}}})||this;t.itemsSource=t._getMenuItems();addClass(t.dropDown,"context-menu "+_GridContextMenuClsNames.hostElement);return t}Object.defineProperty(_GridContextMenu,"controlTemplate",{get:function(){_GridContextMenu._ctrlTemplate||(_GridContextMenu._ctrlTemplate=Menu.controlTemplate);return _GridContextMenu._ctrlTemplate},set:function(e){_GridContextMenu._ctrlTemplate=e},enumerable:!0,configurable:!0});_GridContextMenu.prototype.refresh=function(t){void 0===t&&(t=!0);this.itemsSource=this._getMenuItems();e.prototype.refresh.call(this,t)};_GridContextMenu.prototype.attach=function(e){var t=this;assert(e instanceof PivotGrid,"Expecting a PivotGrid control...");var i=e.hostElement;i.addEventListener("contextmenu",(function(n){if(e.customContextMenu){n.preventDefault();t.owner=i;if(t._selectField(n)){var o=t.dropDown;t.selectedIndex=-1;if(t.onIsDroppedDownChanging(new CancelEventArgs)){showPopup(o,n);t.onIsDroppedDownChanged();o.focus()}}}}))};_GridContextMenu.prototype._selectField=function(e){this._targetField=null;this._htDown=null;var t=Control.getControl(this.owner),i=t.engine,n=i.valueFields,o=i.columnFields,r=t.hitTest(e),s=CellType;switch(r.cellType){case s.Cell:t.select(r.range);this._targetField=n[r.col%n.length];this._htDown=r;break;case s.ColumnHeader:this._targetField=r.row<o.length?o[r.row]:n[r.col%n.length];break;case s.RowHeader:this._targetField=t._colRowFields.get(r.getColumn());break;case s.TopLeft:r.row==r.panel.rows.length-1&&(this._targetField=t._colRowFields.get(r.getColumn()))}return null!=this._targetField};_GridContextMenu.prototype._getMenuItems=function(){for(var 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="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon">⌕</div>Show Detail...',parm:"detail"}],t=0;t<e.length;t++){var i=e[t];if(i.parm){var n=culture.olap._ListContextMenu[i.parm];assert(n,"missing localized text for item "+i.parm);i.text=i.text.replace(/([^>]+$)/,n)}}return e};_GridContextMenu.prototype._execute=function(e){var t=this._targetField,i=Control.getControl(this.owner),n=i?i.engine:null,o=this._htDown;switch(e){case"remove":n.removeField(t);break;case"edit":n.editField(t);break;case"detail":i.showDetail(o.row,o.col)}};_GridContextMenu.prototype._canExecute=function(e){var t=this._targetField,i=Control.getControl(this.owner),n=i?i.engine:null,o=this._htDown;if(null==t||null==n)return!1;switch(e){case"remove":return!0;case"edit":return n.allowFieldEditing;case"detail":return null!=o&&!(t instanceof CubePivotField)&&n.valueFields.length>0}return!0};_GridContextMenu._ctrlTemplate="";return _GridContextMenu}(Menu);export{_GridContextMenu};var PivotFieldCollection=function(e){__extends(PivotFieldCollection,e);function PivotFieldCollection(t){var i=e.call(this)||this;i._ng=t;return i}Object.defineProperty(PivotFieldCollection.prototype,"maxItems",{get:function(){return this._maxItems},set:function(e){this._maxItems=asInt(e,!0,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotFieldCollection.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});PivotFieldCollection.prototype.getField=function(e){return this._getField(this,e)};PivotFieldCollection.prototype._getField=function(e,t){for(var i=0;i<e.length;i++){var n=e[i];if(n.key==t)return n;if(n._hasSubFields()&&(n=this._getField(n.subFields,t)))return n}return null};PivotFieldCollection.prototype.push=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];for(var n=this._ng,o=0;t&&o<t.length;o++){var r=t[o];isString(r)&&(r=this==n.fields?new PivotField(n,r):n.fields.getField(r));assert(r instanceof PivotField,"This collection must contain PivotField objects only.");if(r.key&&this.getField(r.key)){assert(!1,"PivotField keys must be unique.");return-1}if(null!=this._maxItems&&this.length>=this._maxItems)break;e.prototype.push.call(this,r)}return this.length};return PivotFieldCollection}(ObservableArray);export{PivotFieldCollection};var _PivotNode=function(){function _PivotNode(e,t,i,n,o,r){this._key=new _PivotKey(e,t,i,n,o);this._nodes={};this._parent=r}_PivotNode.prototype.getNode=function(e,t,i,n,o){for(var r=this,s=0;s<t;s++){var l=e[s]._getValue(o,!0);if(!(a=r._nodes[l])){a=new _PivotNode(e,s+1,i,n,o,r);r._nodes[l]=a}r=a}if(i&&n>-1){var a;l=i[n].header;if(!(a=r._nodes[l])){a=new _PivotNode(e,t,i,n,o,r);r._nodes[l]=a}r=a}return r};Object.defineProperty(_PivotNode.prototype,"key",{get:function(){return this._key},enumerable:!0,configurable:!0});Object.defineProperty(_PivotNode.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0});Object.defineProperty(_PivotNode.prototype,"tree",{get:function(){this._tree||(this._tree=new _PivotNode(null,0,null,-1,null));return this._tree},enumerable:!0,configurable:!0});return _PivotNode}();export{_PivotNode};var _ServerConnection=function(){function _ServerConnection(e,t){this._ng=asType(e,PivotEngine);assert(this._isValidUrl(t),"Invalid service Url: "+t+")")}_ServerConnection.prototype.getFields=function(){var e=this,t=null;httpRequest(this._getUrl("Fields"),{async:!1,success:function(e){t=JSON.parse(e.responseText);isArray(t)||console.error("Failed to get fields from server: "+e.responseText)},error:function(t){e._handleError("Getting Fields",t)}});return t};_ServerConnection.prototype.getUniqueValues=function(e){var t=this,i=null;httpRequest(this._getUrl("UniqueValues",null,e.header),{method:"POST",async:!1,data:{view:this._ng.viewDefinition},success:function(e){i=JSON.parse(e.responseText);isArray(i)||console.error("Failed to get unique field values from server: "+e.responseText)},error:function(e){t._handleError("Getting Unique Field Values",e)}});return i};_ServerConnection.prototype.getOutputView=function(e){var t=this;this.clearPendingRequests();this._sendHttpRequest("Analyses",{method:"POST",data:{view:this._ng.viewDefinition},success:function(i){var n=JSON.parse(i.responseText);t._token=n.token;t._start=Date.now();t._handleResult(n.status,e)},error:function(e){t._handleError("Analyses",e)}})};_ServerConnection.prototype.getDetail=function(e,t){for(var i,n=[],o=this._ng.rowFields.length,r=e?e.values.length:0,s=0;s<o;s++)s<r?n.push(_ServerConnection._getRequestedValue(e.values[s])):n.push(null);o=this._ng.columnFields.length;r=t?t.values.length:0;for(s=0;s<o;s++)s<r?n.push(_ServerConnection._getRequestedValue(t.values[s])):n.push(null);i=new ObservableArray;this._loadArray("Detail",i,{method:"POST",view:this._ng.viewDefinition,keys:n,max:this._ng.serverMaxDetail});return i};_ServerConnection.prototype.getSortedKeys=function(e,t){var i=this,n=Object.keys(e);if(this._ng.sortOnServer){if(n.length>1){var o={},r=[],s=[];n.forEach((function(e){i._insertKey(o,e,t)}));this._reorderKeys(o,null,null,r,t);if(!t&&this._ng.valueFields.length>1){for(var l=r.length/this._ng.valueFields.length,a=r.length/l,d=0;d<l;d++)for(var u=0;u<a;u++)s.push(r[d+u*l]);return s}return r}}else n.sort((function(e,t){return i._ng._keys[e].compareTo(i._ng._keys[t])}));return n};_ServerConnection._getRequestedValue=function(e){if(isDate(e)){var t=e;return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()))}return e};_ServerConnection.prototype.clearPendingRequests=function(){this._clearRequest();this._clearTimeout();this._clearToken()};_ServerConnection.prototype.updateTallies=function(e){var t=this,i=this._ng,n=i.rowFields.length,o=i.columnFields.length,r=i.valueFields.length,s=new _PivotNode(i.rowFields,0,null,-1,null);e.forEach((function(e,l,a){var d=t._getAggregatedFieldCount(e,i.rowFields),u=s.getNode(i.rowFields,n-d,null,-1,e),h=u.key,c=h.toString(null),p=i._tallies[c];if(!p){i._keys[c]=h;i._tallies[c]=p={}}d=t._getAggregatedFieldCount(e,i.columnFields);for(var g=0;g<r;g++){var _=u.tree.getNode(i.columnFields,o-d,i.valueFields,g,e).key,f=_.toString(),v=i.valueFields[g],m=p[f];if(!m){i._keys[f]=_;(m=p[f]=new _ServerTally).add(t._getFieldValue(v,e,!1))}}}))};_ServerConnection.prototype._getFieldValue=function(e,t,i){var n=t[e.key];return i&&"string"!=typeof n?Globalize.format(n,e.format):n};_ServerConnection.prototype._getKeyLength=function(e,t){return e.split(";").length-(t?1:2)};_ServerConnection.prototype._insertKey=function(e,t,i){var n=t.split(";");i||n.pop();if(1==n.length)e[n.pop()]={};else{var o=n.pop(),r=e[o];r||(e[o]=r={});for(;n.length>0;){var s=n.shift();r[s]||(r[s]={});r=r[s]}}};_ServerConnection.prototype._joinKeys=function(e,t,i){return t&&i?[t,e,i].join(";"):i?[e,i].join(";"):e};_ServerConnection.prototype._reorderKeys=function(e,t,i,n,o){var r=this;Object.keys(e).forEach((function(s){var l=r._joinKeys(s,t,i),a=o?r._ng.showRowTotals:r._ng.showColumnTotals,d=Object.keys(e[s]).length,u=!t&&!i&&a!==ShowTotals.None||!t&&!d||t||a===ShowTotals.Subtotals;o||(l+=";");r._ng.totalsBeforeData&&u&&n.push(l);i?t?r._reorderKeys(e[s],[t,s].join(";"),i,n,o):r._reorderKeys(e[s],s,i,n,o):r._reorderKeys(e[s],null,s,n,o);!r._ng.totalsBeforeData&&u&&n.push(l)}))};_ServerConnection.prototype._getParentKey=function(e,t){var i=e.split(";");t?i.splice(i.length-2,1):i.splice(0,i.length-2);return i.join(";")};_ServerConnection.prototype._getAggregatedFieldCount=function(e,t){for(var i=t.length,n=0,o=0;o<i;o++){var r=t[o];null==this._getFieldValue(r,e,!1)&&n++}return n};_ServerConnection.prototype._loadArray=function(e,t,i){var n=this;i||(i={});null==i.skip&&(i.skip=0);null==i.top&&(i.top=100);var o=isNumber(i.max)?i.max:1e6;this._request=httpRequest(this._getUrl(e),{data:i,method:i.method||"GET",success:function(r){var s=JSON.parse(r.responseText);t.deferUpdate((function(){s.value.forEach((function(e){t.push(e)}))}));if(s.value.length==i.top&&t.length<o){i.skip+=i.top;n._loadArray(e,t,i)}},error:function(t){n._handleError(e,t)}})};_ServerConnection.prototype._getUrl=function(e,t,i){void 0===t&&(t=this._token);var n=this._ng.itemsSource.toString(),o=n.lastIndexOf("/");n.substr(0,o);switch(e=e.toLowerCase()){case"rawdata":case"detail":return n;case"fields":case"analyses":return n+"/"+e;case"clear":return n+"/analyses/"+t+"/";case"result":case"status":return n+"/analyses/"+t+"/"+e;case"uniquevalues":return n+"/fields/"+i+"/"+e}assert(!1,"Unrecognized command")};_ServerConnection.prototype._isValidUrl=function(e){var t=document.createElement("a");t.href=asString(e);t.href=t.href;return t.protocol&&t.hostname&&t.pathname&&"/"!=e[e.length-1]};_ServerConnection.prototype._handleResult=function(e,t){var i=this;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((function(){i._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..."})}};_ServerConnection.prototype._waitUntilComplete=function(e){var t=this;this._sendHttpRequest("Status",{success:function(i){var n=JSON.parse(i.responseText);t._handleResult(n,e)},error:function(e){t._handleError("Status",e)}})};_ServerConnection.prototype._getResults=function(e){var t=this;this._sendHttpRequest("Result",{success:function(i){t._clearToken();var n=JSON.parse(i.responseText);assert(isArray(n),"Result array Expected.");var o=[];t._ng._viewLists.forEach((function(e){o=o.concat(e.filter((function(e){return e.dataType==DataType.Date})))}));o.length>0&&n.forEach((function(e){o.forEach((function(t){var i=t._binding,n=i.getValue(e);isString(n)&&i.setValue(e,new Date(n))}))}));asFunction(e)(n)},error:function(e){t._handleError("Result",e)}})};_ServerConnection.prototype._handleError=function(e,t){this.clearPendingRequests();e='** HttpRequest error on command "'+e+'"';this._ng.onError(new RequestErrorEventArgs(t,e))&&this._throwResponseError(e,t)};_ServerConnection.prototype._sendHttpRequest=function(e,t){var i=this._getUrl(e);this._request=httpRequest(i,t)};_ServerConnection.prototype._throwResponseError=function(e,t){e=e+"\r\n"+t.status+"\r\n";var i=t.responseText||"";if(500==t.status&&t.responseText){i=JSON.parse(t.responseText).ExceptionMessage}throw e+=i||t.statusText};_ServerConnection.prototype._clearToken=function(){if(this._token){this._clearRequest();this._clearTimeout();this._sendHttpRequest("Clear",{method:"DELETE"});this._token=null}};_ServerConnection.prototype._clearRequest=function(){if(this._request&&4!=this._request.readyState){this._request.abort();this._request=null}};_ServerConnection.prototype._clearTimeout=function(){if(this._toGetStatus){clearTimeout(this._toGetStatus);this._toGetStatus=null}};_ServerConnection._TIMEOUT=6e4;_ServerConnection._POLL_INTERVAL=500;_ServerConnection._MAXDETAIL=1e3;return _ServerConnection}();export{_ServerConnection};var _ServerTally=function(e){__extends(_ServerTally,e);function _ServerTally(){return null!==e&&e.apply(this,arguments)||this}_ServerTally.prototype.add=function(e,t){assert(0==this._cnt,"Server tallies have a single value.");this._aggregatedValue=e};_ServerTally.prototype.getAggregate=function(e){return this._aggregatedValue};return _ServerTally}(_Tally);_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"}});export var ShowTotals;!function(e){e[e.None=0]="None";e[e.GrandTotals=1]="GrandTotals";e[e.Subtotals=2]="Subtotals"}(ShowTotals||(ShowTotals={}));export var ShowAs;!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||(ShowAs={}));var PivotEngine=function(){function PivotEngine(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 Event;this.viewDefinitionChanged=new Event;this.updatingView=new Event;this.updatedView=new Event;this.error=new Event;this._isUpdatingChanged=new Event;this._hasDeferredUpdatesChanged=new 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];var t=this._fieldListChanged.bind(this);this._fields.collectionChanged.addHandler(t);this._viewLists.forEach((function(e){e.collectionChanged.addHandler(t)}));this._defaultFilterType=null;copy(this,e)}Object.defineProperty(PivotEngine.prototype,"itemsSource",{get:function(){return this._items},set:function(e){var t=this;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;isString(e)?this._server=new _ServerConnection(this,e):isObject(e)&&!tryCast(e,"ICollectionView")?this._server=new _SqlServerConnection(this,e):this._cv=asCollectionView(e);null!=this._cv&&this._cv.collectionChanged.addHandler(this._cvCollectionChanged,this);this.deferUpdate((function(){t.autoGenerateFields&&t._generateFields();t._updateFieldTypes()}));this.onItemsSourceChanged()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"isServer",{get:function(){return null!=this._server},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"collectionView",{get:function(){return this._cv},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"pivotView",{get:function(){return this._pivotView},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"showRowTotals",{get:function(){return this._showRowTotals},set:function(e){if((e=asEnum(e,ShowTotals))!=this.showRowTotals){this._showRowTotals=e;this.onViewDefinitionChanged();this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"showColumnTotals",{get:function(){return this._showColTotals},set:function(e){if((e=asEnum(e,ShowTotals))!=this.showColumnTotals){this._showColTotals=e;this.onViewDefinitionChanged();this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"totalsBeforeData",{get:function(){return this._totalsBefore},set:function(e){if(e!=this._totalsBefore){this._totalsBefore=asBoolean(e);this.onViewDefinitionChanged();this._updatePivotView()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"sortableGroups",{get:function(){return this._sortableGroups},set:function(e){if(e!=this._sortableGroups){this._sortableGroups=asBoolean(e);this.onViewDefinitionChanged()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"sortOnServer",{get:function(){return this._sortOnServer},set:function(e){this._sortOnServer=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"showZeros",{get:function(){return this._showZeros},set:function(e){if(e!=this._showZeros){this._showZeros=asBoolean(e);this.onViewDefinitionChanged();this._updatePivotView()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"defaultFilterType",{get:function(){return null!=this._defaultFilterType?this._defaultFilterType:this._server?FilterType.Condition:FilterType.Both},set:function(e){this._defaultFilterType=asEnum(e,FilterType,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"exclusiveValueSearch",{get:function(){return this._xValueSearch},set:function(e){this._xValueSearch=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"autoGenerateFields",{get:function(){return this._autoGenFields},set:function(e){this._autoGenFields=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"allowFieldEditing",{get:function(){return this._allowFieldEditing},set:function(e){this._allowFieldEditing=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"fields",{get:function(){return this._fields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"rowFields",{get:function(){return this._rowFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"columnFields",{get:function(){return this._columnFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"filterFields",{get:function(){return this._filterFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"valueFields",{get:function(){return this._valueFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"viewDefinition",{get:function(){var e=this,t={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((function(i){var n=e._getFieldDefinition(i);t.fields.push(n)}));return JSON.stringify(t)},set:function(e){var t=this,i=JSON.parse(e);i&&this.deferUpdate((function(){t._copyProps(t,i,PivotEngine._props);t.fields.clear();i.fields.forEach((function(e){var i=t._getFieldFromDefinition(e);t.fields.push(i)}));i.fields.forEach((function(e,i){isString(e.weightField)&&(t.fields[i].weightField=t.fields.getField(e.weightField))}));t._setFieldCollectionProxy(t.rowFields,i.rowFields);t._setFieldCollectionProxy(t.columnFields,i.columnFields);t._setFieldCollectionProxy(t.filterFields,i.filterFields);t._setFieldCollectionProxy(t.valueFields,i.valueFields)}))},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"isViewDefined",{get:function(){var 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},enumerable:!0,configurable:!0});PivotEngine.prototype.beginUpdate=function(){this.cancelPendingUpdates();this._updating++;1===this._updating&&this._onIsUpdatingChanged()};PivotEngine.prototype.endUpdate=function(){this._updating--;if(this._updating<=0){if(this._viewDefinitionChanged){this._viewDefinitionChanged=!1;this.onViewDefinitionChanged();this._setHasDeferredUpdates(!1)}this._onIsUpdatingChanged();this.refresh()}};Object.defineProperty(PivotEngine.prototype,"isUpdating",{get:function(){return this._updating>0},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"hasDeferredUpdates",{get:function(){return this._hasDeferredUpdates},enumerable:!0,configurable:!0});PivotEngine.prototype._setHasDeferredUpdates=function(e){if(this._hasDeferredUpdates!==e){this._hasDeferredUpdates=e;this._onHasDeferredUpdatesChanged()}};PivotEngine.prototype.deferUpdate=function(e){try{this.beginUpdate();e()}finally{this.endUpdate()}};PivotEngine.prototype.refresh=function(e){void 0===e&&(e=!1);this._updateView(e)};PivotEngine.prototype.invalidate=function(){var e=this;this._toInv&&(this._toInv=clearTimeout(this._toInv));this.isUpdating||(this._toInv=setTimeout((function(){e.refresh()}),Control._REFRESH_INTERVAL))};Object.defineProperty(PivotEngine.prototype,"async",{get:function(){return this._async},set:function(e){if(e!=this._async){this.cancelPendingUpdates();this._async=asBoolean(e)}},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"serverTimeout",{get:function(){return this._serverParms.timeout},set:function(e){this._serverParms.timeout=asNumber(e,!1,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"serverPollInterval",{get:function(){return this._serverParms.pollInterval},set:function(e){this._serverParms.pollInterval=asNumber(e,!1,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotEngine.prototype,"serverMaxDetail",{get:function(){return this._serverParms.maxDetail},set:function(e){this._serverParms.maxDetail=asNumber(e,!1,!0)},enumerable:!0,configurable:!0});PivotEngine.prototype.cancelPendingUpdates=function(){if(this._toUpdateTallies){clearTimeout(this._toUpdateTallies);this._toUpdateTallies=null}};PivotEngine.prototype.getDetail=function(e,t){var i=this,n=e?e[_PivotKey._ROW_KEY_NAME]:null,o=this._getKey(t);if(this._server)return this._server.getDetail(n,o);var r=this.collectionView.items,s=[];r.forEach((function(e){!i._applyFilter(e)||null!=n&&!n.matchesItem(e)||null!=o&&!o.matchesItem(e)||s.push(e)}));return s};PivotEngine.prototype.getDetailView=function(e,t){var i=this.getDetail(e,t);return new CollectionView(i)};PivotEngine.prototype.getKeys=function(e,t){var i=e?e[_PivotKey._ROW_KEY_NAME]:null,n=this._getKey(t);return{rowKey:{fields:i?i.fieldNames:[],values:i?i.values:[]},colKey:{fields:n?n.fieldNames:[],values:n?n.values:[]}}};PivotEngine.prototype.editField=function(e){if(this.allowFieldEditing){var t=new PivotFieldEditor(document.createElement("div"),{field:e});new Popup(document.createElement("div"),{content:t.hostElement}).show(!0)}};PivotEngine.prototype.removeField=function(e){for(var t=0;t<this._viewLists.length;t++){var i=this._viewLists[t],n=i.indexOf(e);if(n>-1){i.removeAt(n);return}}};PivotEngine.prototype.onItemsSourceChanged=function(e){this.itemsSourceChanged.raise(this,e)};PivotEngine.prototype.onViewDefinitionChanged=function(e){if(this._updating<=0){this.viewDefinitionChanged.raise(this,e);this._viewDefinitionChanged=!1;this._setHasDeferredUpdates(!1)}else{this._viewDefinitionChanged=!0;this._setHasDeferredUpdates(!0)}};PivotEngine.prototype.onUpdatingView=function(e){this.updatingView.raise(this,e)};PivotEngine.prototype.onUpdatedView=function(e){this.updatedView.raise(this,e)};PivotEngine.prototype.onError=function(e){this.error.raise(this,e);return!e.cancel};PivotEngine.prototype._onIsUpdatingChanged=function(e){this._isUpdatingChanged.raise(this,e)};PivotEngine.prototype._onHasDeferredUpdatesChanged=function(e){this._hasDeferredUpdatesChanged.raise(this,e)};PivotEngine.prototype._copy=function(e,t){var i=this;switch(e){case"fields":this.fields.clear();this._viewLists.forEach((function(e){e.clear()}));asArray(t).forEach((function(e){var t=i._createField(e,!1);i.fields.push(t)}));this._updateFieldTypes();return!0;case"rowFields":case"columnFields":case"valueFields":case"filterFields":this[e].clear();if(!isArray(t)){this[e].maxItems=t.maxItems;t=t.items}asArray(t).forEach((function(t){var n=i.fields.getField(t);i[e].push(n)}));return!0}return!1};PivotEngine.prototype._getKey=function(e){return this._keys[e]};PivotEngine.prototype._getRowKey=function(e){var t=e;if(isNumber(e)){var i=this._pivotView;t=(i.items.length?i.items:i.sourceCollection)[e]}return t?t[_PivotKey._ROW_KEY_NAME]:null};PivotEngine.prototype._getRowLevel=function(e){var t=this._getRowKey(e);return t?t.level:-1};PivotEngine.prototype._getColKey=function(e){isNumber(e)&&(e=this._colBindings[e]);if(isString(e))return this._getKey(e);assert(null==e||e instanceof _PivotKey,"invalid parameter in call to _getColLevel");return e};PivotEngine.prototype._getColLevel=function(e){return(e=this._getColKey(e))?e.level:-1};PivotEngine.prototype._getFieldByColKey=function(e){var t=this._getColKey(e);return t&&t.valueField};PivotEngine.prototype._applyFilter=function(e){for(var t=this._activeFilterFields,i=0;i<t.length;i++){if(!t[i].filter.apply(e))return!1}return!0};PivotEngine.prototype._updateView=function(e){var t=this;void 0===e&&(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((function(i){if(t.isViewDefined){t._server.updateTallies(i);t._updatePivotView(e)}}));return}this._viewLists.forEach((function(e){e.forEach((function(e){e.filter.isActive&&t._activeFilterFields.push(e)}))}));if(this.isViewDefined&&hasItems(this._cv)){this._batchStart=Date.now();this._updateTallies(this._cv.items,0,e)}else this._updatePivotView(e);this._setHasDeferredUpdates(!1)}};PivotEngine.prototype._updateTallies=function(e,t,i){var n=this;void 0===i&&(i=!1);var o=e.length,r=new _PivotNode(this._rowFields,0,null,-1,null),s=this.valueFields;0==s.length&&this.columnFields.length>0&&(s=new PivotFieldCollection(this)).push(new PivotField(this,"","",{aggregate:Aggregate.Sum}));for(var l=ShowTotals,a=this._rowFields.length,d=this._getShowRowTotals(),u=d==l.None?a:0,h=d==l.GrandTotals?Math.max(1,a):1,c=this._columnFields.length,p=this._getShowColTotals(),g=p==l.None?c:0,_=p==l.GrandTotals?Math.max(1,c):1,f=s.length,_loop_1=function(o){if(v._async&&o-t>=PivotEngine._BATCH_SIZE&&Date.now()-v._batchStart>PivotEngine._BATCH_DELAY){v._toUpdateTallies=setTimeout((function(){n.onUpdatingView(new ProgressEventArgs(Math.round(o/e.length*100)));n._batchStart=Date.now();n._updateTallies(e,o,i)}),PivotEngine._BATCH_TIMEOUT);return{value:void 0}}v._cntTotal++;var l=e[o];if(!v._activeFilterFields.length||v._applyFilter(l)){v._cntFiltered++;for(var d=u;d<=a;d+=h){var p=r.getNode(v._rowFields,d,null,-1,l),m=p.key,y=m.toString(),w=v._tallies[y];if(!w){v._keys[y]=m;v._tallies[y]=w={}}for(var b=g;b<=c;b+=_)for(var C=0;C<f;C++){var P=p.tree.getNode(v._columnFields,b,s,C,l).key,F=P.toString(),S=w[F];if(!S){v._keys[F]=P;S=w[F]=new _Tally}var E=s[C],T=E._getValue(l,!1),x=E.weightField?E._getWeight(l):null;S.add(T,x)}}}},v=this,m=t;m<o;m++){var y=_loop_1(m);if("object"==typeof y)return y.value}this._toUpdateTallies=null;this._updatePivotView(i)};PivotEngine.prototype._updatePivotView=function(e){var t=this;void 0===e&&(e=!1);if(!this.isUpdating||e){var i=this._pivotView;i.deferUpdate((function(){t.onUpdatingView(new ProgressEventArgs(100));i.cancelEdit();i.cancelNew();var e=i.sourceCollection;e.length=0;var n={};for(var o in t._tallies)n[o]=!0;var r={};for(var o in t._tallies){var s=t._tallies[o];for(var l in s)r[l]=!0}var a=[],d=[];if(t._server)a=t._server.getSortedKeys(n,!0),d=t._server.getSortedKeys(r,!1);else{a=t._getSortedKeys(n);d=t._getSortedKeys(r)}for(var u=0;u<a.length;u++){var h=a[u],c=(s=t._tallies[h],{});c[_PivotKey._ROW_KEY_NAME]=t._getKey(h);for(var p=0;p<d.length;p++){var g=d[p],_=s[g],f=t._getKey(g),v=_?_.getAggregate(f.aggregate):null;null==v&&t._showZeros&&(v=0);c[g]=v}e.push(c)}t._colBindings=d;t._updateFieldValues(e);i.sortDescriptions.clear();i.refresh()}));this.onUpdatedView()}};PivotEngine.prototype._getSortedKeys=function(e){var t=this,i=Object.keys(e);i.sort((function(e,i){return t._keys[e].compareTo(t._keys[i])}));return i};PivotEngine.prototype._updateFieldValues=function(e){for(var t=this.valueFields.length,i=0;i<t;i++){var n=this.valueFields[i];if(isFunction(n.getAggregateValue))for(var o=i;o<this._colBindings.length;o+=t)for(var r=0;r<e.length;r++){var s=e[r],l=this._colBindings[o],a=this._getAggregateObject(s,l);s[l]=n.getAggregateValue.call(this,a)}}var _loop_2=function(i){var n=d.valueFields[i];switch(n.showAs){case ShowAs.RunTot:case ShowAs.RunTotPct:for(var o=i;o<d._colBindings.length;o+=t){for(var r=0;r<e.length;r++){(u=e[r])[p=d._colBindings[o]]=d._getRunningTotal(e,r,o)}if(n.showAs==ShowAs.RunTotPct)for(r=0;r<e.length;r++){var s=(u=e[r])[p=d._colBindings[o]];if(isNumber(s)){var l=d._getLastValueInRowGroup(e,r,o);0!=l&&(u[p]=s/l)}}}break;case ShowAs.PctGrand:case ShowAs.PctCol:var a=0;if(n.showAs==ShowAs.PctGrand)for(o=i;o<d._colBindings.length;o+=t)-1==d._getColLevel(o)&&(a+=d._getColTotal(e,o));var _loop_3=function(t){n.showAs==ShowAs.PctCol&&(a=d._getColTotal(e,t));var i=d._colBindings[t];e.forEach((function(e){var t=e[i];isNumber(t)&&(e[i]=0!=a?t/a:null)}))};for(o=i;o<d._colBindings.length;o+=t)_loop_3(o);break;case ShowAs.PctRow:for(r=0;r<e.length;r++){var u=e[r],h=0;for(o=i;o<d._colBindings.length;o+=t)if(-1==d._getColLevel(o)){var c=u[p=d._colBindings[o]];isNumber(c)&&(h+=c)}for(o=i;o<d._colBindings.length;o+=t){c=u[p=d._colBindings[o]];isNumber(c)&&(u[p]=0!=h?c/h:null)}}break;case ShowAs.DiffRow:case ShowAs.DiffRowPct:case ShowAs.PctPrevRow:for(o=i;o<d._colBindings.length;o+=t)for(r=e.length-1;r>=0;r--){(u=e[r])[p=d._colBindings[o]]=d._getRowDifference(e,r,o,n.showAs)}break;case ShowAs.DiffCol:case ShowAs.DiffColPct:case ShowAs.PctPrevCol:for(r=0;r<e.length;r++)for(o=d._colBindings.length-t+i;o>=0;o-=t){var p;(u=e[r])[p=d._colBindings[o]]=d._getColDifference(e,r,o,n.showAs)}}},d=this;for(i=0;i<t;i++)_loop_2(i)};PivotEngine.prototype._getAggregateObject=function(e,t){var i={},n=/(.+:.+;)*((.+):.+;)/,o=t.match(n);for(var r in e){var s=r.match(n);s&&s[1]==o[1]&&(i[s[3]]=e[r])}return i};PivotEngine.prototype._getColTotal=function(e,t){var i=this,n=this._colBindings[t],o=0;e.forEach((function(e){if(-1==i._getRowLevel(e)){var t=e[n];isNumber(t)&&(o+=t)}}));return o};PivotEngine.prototype._getRunningTotal=function(e,t,i){var n=this._getRowLevel(e[t]);if(0==n)return null;for(var o=this._colBindings[i],r=e[t][o],s=this._getShowRowTotals(),l=this.rowFields.length-2,a=t-1;a>=0;a--){var d=this._getRowLevel(e[a]);if(d==n){if(l>-1&&n<0&&s!=ShowTotals.Subtotals){var u=e[t].$rowKey,h=e[a].$rowKey;if(u.values[l]!=h.values[l])return null}r+=e[a][o];break}if(d>n)break}return r};PivotEngine.prototype._getLastValueInRowGroup=function(e,t,i){for(var n=this._colBindings[i],o=e[t][n],r=this._getRowLevel(e[t]),s=this.rowFields.length-2,l=this._getShowRowTotals(),a=t+1;a<e.length;a++){var d=this._getRowLevel(e[a]);if(d==r){if(s>-1&&r<0&&l!=ShowTotals.Subtotals){var u=e[t].$rowKey,h=e[a].$rowKey;if(u.values[s]!=h.values[s])return o}o=e[a][n]}if(d>r)break}return o};PivotEngine.prototype._getRowDifference=function(e,t,i,n){var o=this._getRowLevel(e[t]);if(0==o)return null;for(var r=this._colBindings[i],s=e[t][r],l=this.rowFields.length-2,a=this._getShowRowTotals(),d=t-1;d>=0;d--){var u=this._getRowLevel(e[d]);if(u==o){if(l>-1&&o<0&&a!=ShowTotals.Subtotals){var h=e[t].$rowKey,c=e[d].$rowKey;if(h.values[l]!=c.values[l])return null}var p=e[d][r];switch(n){case ShowAs.DiffRow:s-=p;break;case ShowAs.DiffRowPct:s=(s-p)/p;break;case ShowAs.PctPrevRow:s/=p}return s}if(u>o)break}return n==ShowAs.PctPrevRow?1:null};PivotEngine.prototype._getColDifference=function(e,t,i,n){var o=this._getColLevel(i);if(0==o)return null;for(var r=e[t],s=r[this._colBindings[i]],l=this.valueFields.length,a=this.columnFields.length-2,d=this._getShowColTotals(),u=i-l;u>=0;u-=l){var h=this._getColLevel(u);if(h==o){if(a>-1&&o<0&&d!=ShowTotals.Subtotals){var c=this._getKey(this._colBindings[i]),p=this._getKey(this._colBindings[u]);if(c.values[a]!=p.values[a])return null}var g=r[this._colBindings[u]];switch(n){case ShowAs.DiffCol:s-=g;break;case ShowAs.DiffColPct:s=(s-g)/g;break;case ShowAs.PctPrevCol:s/=g}return s}if(h>o)break}return n==ShowAs.PctPrevCol?1:null};PivotEngine.prototype._getShowRowTotals=function(){return this._valueFields.length?this._showRowTotals:ShowTotals.None};PivotEngine.prototype._getShowColTotals=function(){return this._valueFields.length?this._showColTotals:ShowTotals.None};PivotEngine.prototype._getUniqueValues=function(e){return this._server?this._server.getUniqueValues(e):null};PivotEngine.prototype._generateFields=function(){var e=this;this._viewLists.forEach((function(e){e.clear()}));for(var t=0;t<this.fields.length;t++){if(this.fields[t]._autoGenerated){this.fields.removeAt(t);t--}}if(this._server){this._server.getFields().forEach((function(t){var i=e._createField(t,!0);e.fields.getField(i.header)||e.fields.push(i)}))}else{var i=this.collectionView,n=i?i.items:null;n&&n.length&&this.autoGenerateFields&&getTypes(n,0).forEach((function(t){var i=e._createField({binding:t.binding,header:toHeaderCase(t.binding),dataType:t.dataType},!0);e.fields.getField(i.header)||e.fields.push(i)}))}};PivotEngine.prototype._updateFieldTypes=function(){var e=this,t=this.collectionView,i=t?t.sourceCollection:null;i&&i.length&&this.fields.forEach((function(t){e._updateFieldType(t,i)}))};PivotEngine.prototype._updateFieldType=function(e,t){var i=this;if(e._hasSubFields())e.subFields.forEach((function(e){i._updateFieldType(e,t)}));else{if(null==e.dataType&&e.binding)for(var n=0;n<t.length;n++){var o=e._binding.getValue(t[n]);if(null!=o){e.dataType=isPrimitive(o)?getType(o):null;break}}if(null!=e.dataType){e.format||(e.format=e.dataType==DataType.Date?"d":"n0");e.aggregate==Aggregate.Sum&&e.dataType!=DataType.Number&&(e.aggregate=Aggregate.Cnt)}}};PivotEngine.prototype._createField=function(e,t){var i;if(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||isString(e)){i.format=i.dataType==DataType.Date?"d":"n0";i.aggregate=i.dataType==DataType.Number?Aggregate.Sum:Aggregate.Cnt}e&&!isString(e)&©(i,e);return i};PivotEngine.prototype._cvCollectionChanged=function(e,t){this.invalidate()};PivotEngine.prototype._fieldListChanged=function(e,t){if(t.action==NotifyCollectionChangedAction.Add){for(var i=e,n=0;n<i.length-1;n++)if(i[n].key)for(var o=n+1;o<i.length;o++)if(i[n].key==i[o].key){i.removeAt(o);o--}if(i!=this._fields)if(this._fields.getField(t.item.key)){for(n=0;n<this._viewLists.length;n++)if(this._viewLists[n]!=i){var r=this._viewLists[n];(s=r.indexOf(t.item))>-1&&r.removeAt(s)}}else i.removeAt(t.index);if(isNumber(i.maxItems)&&i.maxItems>-1)for(;i.length>i.maxItems;){var s;i[s=i.length-1]==t.item&&s>0&&s--;i.removeAt(s)}}this.onViewDefinitionChanged();this.invalidate()};PivotEngine.prototype._fieldPropertyChanged=function(e,t){this.onViewDefinitionChanged();if(e.isActive){var 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())}};PivotEngine.prototype._copyProps=function(e,t,i){for(var n=0;n<i.length;n++){var o=i[n];null!=t[o]&&(e[o]=t[o])}};PivotEngine.prototype._getFieldFromDefinition=function(e){var t=e.filter;e.filter&&delete e.filter;var i=this._createField(e,!0);if(t){i._setFilterProxy(t);e.filter=t}return i};PivotEngine.prototype._getFieldDefinition=function(e){var t=this,i={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&&(i.weightField=e.weightField._getName());e.key&&(i.key=e.key);e.filter.isActive&&(i.filter=e._getFilterProxy());if(e._hasSubFields()){i.subFields=[];e.subFields.forEach((function(e){i.subFields.push(t._getFieldDefinition(e))}))}e instanceof CubePivotField&&(i.dimensionType=e.dimensionType);return i};PivotEngine.prototype._getFieldCollectionProxy=function(e){var t={items:[]};isNumber(e.maxItems)&&e.maxItems>-1&&(t.maxItems=e.maxItems);for(var i=0;i<e.length;i++){var n=e[i];t.items.push(n.key)}return t};PivotEngine.prototype._setFieldCollectionProxy=function(e,t){e.clear();e.maxItems=isNumber(t.maxItems)?t.maxItems:null;for(var i=0;i<t.items.length;i++)e.push(t.items[i])};PivotEngine._BATCH_SIZE=1e4;PivotEngine._BATCH_TIMEOUT=0;PivotEngine._BATCH_DELAY=100;PivotEngine._props=["showZeros","showRowTotals","showColumnTotals","totalsBeforeData","sortableGroups","defaultFilterType"];return PivotEngine}();export{PivotEngine};var ProgressEventArgs=function(e){__extends(ProgressEventArgs,e);function ProgressEventArgs(t){var i=e.call(this)||this;i._progress=asNumber(t);return i}Object.defineProperty(ProgressEventArgs.prototype,"progress",{get:function(){return this._progress},enumerable:!0,configurable:!0});return ProgressEventArgs}(EventArgs);export{ProgressEventArgs};var _ListContextMenu=function(e){__extends(_ListContextMenu,e);function _ListContextMenu(t){var i=e.call(this,document.createElement("div"),{header:"Field Context Menu",displayMemberPath:"text",commandParameterPath:"parm",command:{executeCommand:function(e){i._execute(e)},canExecuteCommand:function(e){return i._canExecute(e)}}})||this;i._full=t;i.itemsSource=i._getMenuItems(t);addClass(i.dropDown,"context-menu "+_GridContextMenuClsNames.hostElement);return i}Object.defineProperty(_ListContextMenu,"controlTemplate",{get:function(){_ListContextMenu._ctrlTemplate||(_ListContextMenu._ctrlTemplate=Menu.controlTemplate);return _ListContextMenu._ctrlTemplate},set:function(e){_ListContextMenu._ctrlTemplate=e},enumerable:!0,configurable:!0});_ListContextMenu.prototype.refresh=function(t){void 0===t&&(t=!0);this.itemsSource=this._getMenuItems(this._full);e.prototype.refresh.call(this,t)};_ListContextMenu.prototype.attach=function(e){var t=this;assert(e instanceof FlexGrid,"Expecting a FlexGrid control...");var i=e.hostElement;i.addEventListener("contextmenu",(function(n){if(t._selectField(e,n)){n.preventDefault();t.owner=i;t.show(n)}}))};_ListContextMenu.prototype._selectField=function(e,t){var i=e.hitTest(t);if(i.panel!=e.cells||!i.range.isValid)return!1;var n=e.rows[i.row].dataItem;if(n instanceof CubePivotField&&n.subFields&&n.subFields.length)return!1;e.select(i.range,!0);return!0};_ListContextMenu.prototype._getMenuItems=function(e){var 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="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon"><span class='+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="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon menu-icon-remove">✖</div>*',parm:"remove"},{text:'<div class="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon">⛭</div>*',parm:"edit"}]:[{text:'<div class="menu-icon"><span class='+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="'+UtilitesClsNames.separator+'"></div>'},{text:'<div class="menu-icon">⛭</div>*',parm:"edit"}];for(var i=0;i<t.length;i++){var n=t[i];if(n.parm){var o=culture.olap._ListContextMenu[n.parm];assert(o,"missing localized text for item "+n.parm);n.text=n.text.replace(/([^>]+$)/,o)}}return t};_ListContextMenu.prototype._execute=function(e){var t=Control.getControl(this.owner),i=t.itemsSource,n=t.selection.row,o=t.rows[n].dataItem,r=o?o.engine:null,s=this._getTargetList(r,e);switch(e){case"up":case"first":case"down":case"last":if(r){var l=i.indexOf(o),a="up"==e?l-1:"first"==e?0:"down"==e?l+1:"last"==e?i.length:-1;r.deferUpdate((function(){i.removeAt(l);i.insert(a,o)}))}break;case"filter":case"rows":case"cols":case"vals":s&&o&&s.push(o);break;case"remove":o&&r.removeField(o);break;case"edit":o&&r.editField(o)}};_ListContextMenu.prototype._canExecute=function(e){var t=Control.getControl(this.owner);if(!t)return!1;var i=t.selection.row,n=i>-1?t.rows[i].dataItem:null,o=n?n.engine:null,r=this._getTargetList(o,e),s=!!n&&n instanceof CubePivotField,l=!!n&&n.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!l&&r&&r.indexOf(n)<0;case"vals":return(!s||l)&&r&&r.indexOf(n)<0;case"edit":return o&&o.allowFieldEditing;case"detail":return n&&!s}return!0};_ListContextMenu.prototype._getTargetList=function(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};_ListContextMenu._ctrlTemplate="";return _ListContextMenu}(Menu);export{_ListContextMenu};var PivotPanel=function(e){__extends(PivotPanel,e);function PivotPanel(t,i){var n=e.call(this,t,null,!0)||this;n._showIcons=!0;n._restrictDrag=null;n.deferredUpdateChanged=new Event;n.itemsSourceChanged=new Event;n.viewDefinitionChanged=new Event;n.updatingView=new Event;n.updatedView=new Event;n._isUpdatingChangedBnd=n._isUpdatingChanged.bind(n);var o=n.getTemplate();n.applyTemplate(ControlClsNames.hostElement+" "+ControlClsNames.content+" "+PivotPanelClsNames.hostElement,o,{_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"});n._globalize();var r=n.hostElement;n.addEventListener(r,"dragstart",n._dragstart.bind(n));n.addEventListener(r,"dragover",n._dragover.bind(n));n.addEventListener(r,"dragleave",n._dragover.bind(n));n.addEventListener(r,"drop",n._drop.bind(n));n.addEventListener(r,"dragend",n._dragend.bind(n));n._lbFields=n._createFieldGrid(n._dFields);n._lbFilters=n._createFieldGrid(n._dFilters);n._lbRows=n._createFieldGrid(n._dRows);n._lbCols=n._createFieldGrid(n._dCols);n._lbVals=n._createFieldGrid(n._dVals);var s=n._ctxMenuShort=new _ListContextMenu(!1);s.attach(n._lbFields);(s=n._ctxMenuFull=new _ListContextMenu(!0)).attach(n._lbFilters);s.attach(n._lbRows);s.attach(n._lbCols);s.attach(n._lbVals);n._dMarker=createElement('<div class="'+FlexGridClsNames.marker+'" style="display:none"> </div>');n.hostElement.appendChild(n._dMarker);n.addEventListener(n._btnUpdate,"click",(function(e){n._ng.refresh(!0);n.refresh();e.preventDefault()}));n.addEventListener(n._chkDefer,"click",(function(e){n.deferredUpdate=n._chkDefer.checked;n._updateDeferredUpdateElements()}));n.engine=new PivotEngine;n.initialize(i);return n}Object.defineProperty(PivotPanel,"controlTemplate",{get:function(){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="'+GlyphClsNames.glyph+" "+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='+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='+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='+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='+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="'+InputFormElementsClsNames.btn+" "+ControlStateClsNames.disabled+'" style="float:right;margin:6px" disabled></button></div></div>');return PivotPanel._ctrlTemplate},set:function(e){PivotPanel._ctrlTemplate=e},enumerable:!0,configurable:!0});PivotPanel.prototype._getProductInfo=function(){return"D6F4,PivotPanel"};Object.defineProperty(PivotPanel.prototype,"engine",{get:function(){return this._ng},set:function(e){var t,i=this,n=this._ng;if(n){n.itemsSourceChanged.removeHandler(this._itemsSourceChanged);n.viewDefinitionChanged.removeHandler(this._viewDefinitionChanged);n.updatingView.removeHandler(this._updatingView);n.updatedView.removeHandler(this._updatedView);n.error.removeHandler(this._requestError);n._isUpdatingChanged.removeHandler(this._isUpdatingChangedBnd);t=this.deferredUpdate}e=asType(e,PivotEngine,!1);(n=this._ng=e).itemsSourceChanged.addHandler(this._itemsSourceChanged,this);n.viewDefinitionChanged.addHandler(this._viewDefinitionChanged,this);n.updatingView.addHandler(this._updatingView,this);n.updatedView.addHandler(this._updatedView,this);n.error.addHandler(this._requestError,this);n._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._lbFields.collectionView.filter=function(e){return e.visible&&null==e.parentField};"Filters,Rows,Cols,Vals".split(",").forEach((function(e){i["_lb"+e].collectionView.filter=function(e){return e.visible}}));this._updateDeferredUpdateElements()},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"itemsSource",{get:function(){return this._ng.itemsSource},set:function(e){e instanceof PivotEngine?this.engine=e:this._ng.itemsSource=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"collectionView",{get:function(){return this._ng.collectionView},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"pivotView",{get:function(){return this._ng.pivotView},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"autoGenerateFields",{get:function(){return this.engine.autoGenerateFields},set:function(e){this._ng.autoGenerateFields=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"fields",{get:function(){return this._ng.fields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"rowFields",{get:function(){return this._ng.rowFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"columnFields",{get:function(){return this._ng.columnFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"valueFields",{get:function(){return this._ng.valueFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"filterFields",{get:function(){return this._ng.filterFields},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"viewDefinition",{get:function(){return this._ng.viewDefinition},set:function(e){this._ng.viewDefinition=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"isViewDefined",{get:function(){return this._ng.isViewDefined},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"showFieldIcons",{get:function(){return this._showIcons},set:function(e){if(e!=this._showIcons){this._showIcons=asBoolean(e);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"restrictDragging",{get:function(){return this._restrictDrag},set:function(e){this._restrictDrag=asBoolean(e,!0)},enumerable:!0,configurable:!0});Object.defineProperty(PivotPanel.prototype,"deferredUpdate",{get:function(){return this.engine.isUpdating},set:function(e){this.deferredUpdate!=e&&(e?this._ng.beginUpdate():this._ng.endUpdate())},enumerable:!0,configurable:!0});PivotPanel.prototype.onDeferredUpdateChanged=function(e){this.deferredUpdateChanged.raise(this,e)};PivotPanel.prototype.onItemsSourceChanged=function(e){this.itemsSourceChanged.raise(this,e)};PivotPanel.prototype.onViewDefinitionChanged=function(e){this.viewDefinitionChanged.raise(this,e)};PivotPanel.prototype.onUpdatingView=function(e){this.updatingView.raise(this,e)};PivotPanel.prototype.onUpdatedView=function(e){this.updatedView.raise(this,e)};PivotPanel.prototype.refresh=function(t){var i=this;void 0===t&&(t=!0);if(this.hostElement){["Fields","Filters","Rows","Cols","Vals"].forEach((function(e){var t=i["_lb"+e],n=t?t.collectionView:null;if(t&&n){t.refresh();n.refresh()}}));if(t){this._globalize();this._ctxMenuShort.refresh();this._ctxMenuFull.refresh()}}e.prototype.refresh.call(this,t)};PivotPanel.prototype._copy=function(e,t){switch(e){case"engine":this.engine=t;return!0}return!1};PivotPanel.prototype._globalize=function(){var e=culture.olap.PivotPanel;setText(this._gFlds,e.fields);setText(this._gDrag,e.drag);setText(this._gFlt,e.filters);setText(this._gCols,e.cols);setText(this._gRows,e.rows);setText(this._gVals,e.vals);setText(this._gDefer,e.defer);setText(this._btnUpdate,e.update)};PivotPanel.prototype._itemsSourceChanged=function(e,t){this.onItemsSourceChanged(t)};PivotPanel.prototype._viewDefinitionChanged=function(e,t){this.invalidate();this.onViewDefinitionChanged(t)};PivotPanel.prototype._updatingView=function(e,t){var i=clamp(t.progress,5,100)%100;this._dProgress.style.width=i+"%";this.onUpdatingView(t)};PivotPanel.prototype._updatedView=function(e,t){this.onUpdatedView(t)};PivotPanel.prototype._requestError=function(e,t){this._dProgress.style.width="0"};PivotPanel.prototype._isUpdatingChanged=function(){this._updateDeferredUpdateElements();this.onDeferredUpdateChanged()};PivotPanel.prototype._updateDeferredUpdateElements=function(){var e=this.deferredUpdate;this._chkDefer.checked=e;enable(this._btnUpdate,e)};PivotPanel.prototype._createFieldGrid=function(e){var t=this,i=new FlexGrid(e,{autoGenerateColumns:!1,childItemsPath:"subFields",columns:[{binding:"header",width:"*"}],headersVisibility:"None",selectionMode:"Cell",alternatingRowStep:0});i.cells.hostElement.parentElement.style.overflowX="hidden";i.formatItem.addHandler((function(e,i){var n=e.rows[i.row].dataItem;assert(n instanceof PivotField,"PivotField expected...");var o=n._hasSubFields();toggleClass(i.cell,PivotPanelClsNames.header,o);i.cell.setAttribute("draggable",(!o).toString());var r=i.cell.innerHTML;n.filter.isActive&&(r+=" <span class="+GlyphClsNames.filter+"></span>");e!=t._lbVals||isFunction(n.getAggregateValue)||(r+=' <span class="'+PivotPanelClsNames.aggregate+'">('+Aggregate[n.aggregate]+")</span>");if(e==t._lbFields&&!o){if(t._showIcons){var s=n.isMeasure?"measure":"dimension";r='<span class="'+GlyphClsNames.glyph+"-"+s+'"></span> '+r}r='<label><input type="checkbox"'+(n.isActive?" checked":"")+"> "+r+"</label>"}i.cell.innerHTML=r}));i.addEventListener(e,"click",(function(e){var n=e.target;if(n instanceof HTMLInputElement&&"checkbox"==n.type){var o=t._hitTestField(i,e);o instanceof PivotField&&(o.isActive=n.checked)}}));return i};PivotPanel.prototype._dragstart=function(e){var 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){_startDrag(e.dataTransfer,"copyMove");e.stopPropagation()}}};PivotPanel.prototype._dragover=function(e){var t=!1,i=this._getFlexGridTarget(e);if(i&&this._dragField){if(this._dragSource==this._dFields&&i!=this._lbFields){var n=i.itemsSource;if(null==n.maxItems||n.length<n.maxItems){var o=this._dragField;i.itemsSource.indexOf(o)<0?t=!0:i==this._lbVals&&(t=!(o instanceof CubePivotField))}}this._dragSource&&this._dragSource!=this._dFields&&(t=!0)}if(t&&this._getRestrictDrag()&&this._dragSource!=i.hostElement){var r=this._dragField.isMeasure;i==this._lbVals?t=r:i!=this._lbRows&&i!=this._lbCols||(t=!r)}if(t){this._updateDropMarker(i,e);e.dataTransfer.dropEffect=this._dragSource==this._dFields?"copy":"move";e.preventDefault();e.stopPropagation()}else this._updateDropMarker()};PivotPanel.prototype._drop=function(e){var t=this,i=this._getFlexGridTarget(e);if(i&&this._dragField){var n=Control.getControl(this._dragSource),o=this._dragField;if(n==this._lbFields&&i==this._lbVals&&i.itemsSource.indexOf(o)>-1){o=o._clone();this.engine.fields.push(o)}i==this._lbFields?o.isActive=!1:this._ng.deferUpdate((function(){var e=i.itemsSource,n=e.indexOf(o);if(n!=t._dropIndex){if(n>-1){e.removeAt(n);n<t._dropIndex&&t._dropIndex--}e.insert(t._dropIndex,o)}}))}this._resetMouseState()};PivotPanel.prototype._dragend=function(e){this._resetMouseState()};PivotPanel.prototype._hitTestField=function(e,t){var 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};PivotPanel.prototype._getRestrictDrag=function(){var e=this._restrictDrag;null==e&&this.fields.length&&(e=this.fields[0]instanceof CubePivotField);return e};PivotPanel.prototype._resetMouseState=function(){this._dragSource=null;this._updateDropMarker()};PivotPanel.prototype._getFlexGridTarget=function(e){var t=Control.getControl(closest(e.target,"."+FlexGridClsNames.hostElement));return t instanceof FlexGrid?t:null};PivotPanel.prototype._updateDropMarker=function(e,t){if(t){var i,n=this.hostElement,o=n.getBoundingClientRect();if(e.rows.length){var r=e.hitTest(t).row;if(r>-1){i=e.getCellBoundingRect(r,0);if(t.clientY>n.scrollTop+i.top+i.height/2&&r<e.rows.length){i.top+=i.height;r++}this._dropIndex=r}else{r=e.viewRange.bottomRow;(i=e.getCellBoundingRect(r,0)).top+=i.height;this._dropIndex=r+1}}else{(i=Rect.fromBoundingRect(e.hostElement.getBoundingClientRect())).top+=4;this._dropIndex=0}setCss(this._dMarker,{left:Math.round(i.left-o.left)+n.scrollLeft,top:Math.round(i.top-o.top-2)+n.scrollTop,width:Math.round(i.width),height:4,display:""})}else this._dMarker.style.display="none"};PivotPanel._ctrlTemplate="";return PivotPanel}(Control);export{PivotPanel};var PivotGrid=function(e){__extends(PivotGrid,e);function PivotGrid(t,i){var n=e.call(this,t)||this;n._showDetailOnDoubleClick=!0;n._collapsibleSubtotals=!0;n._customCtxMenu=!0;n._ctxMenu=new _GridContextMenu;n._showRowFldSort=!1;n._showRowFldHdrs=!0;n._showColFldHdrs=!0;n._showValFldHdrs=!1;n._centerVert=!0;n._collapsedKeys={};n._resizingColumn=!1;n._outlineMode=!1;n._ignoreClick=!1;n._colRowFields=new Map;n._prevCulture=culture.Globalize.name;n._hdrCols._setDefaultSize(n._cols.defaultSize);addClass(n.hostElement,PivotGridClsNames.hostElement);n.isReadOnly=!0;n.copyHeaders=HeadersVisibility.All;n.deferResizing=!0;n.alternatingRowStep=0;n.autoGenerateColumns=!1;n.allowDragging=AllowDragging.None;n.allowMerging=AllowMerging.All;n.mergeManager=new _PivotMergeManager;n.customContextMenu=!0;n.treeIndent=32;n.initialize(i);n.formatItem.addHandler(n._formatItem,n);var o=n.hostElement;n.addEventListener(o,"mousedown",n._mousedown.bind(n),!0);n.addEventListener(o,"mouseup",n._mouseup.bind(n),!0);n.addEventListener(o,"dblclick",n._dblclick.bind(n),!0);n.addEventListener(o,"click",n._click.bind(n),!0);n.addEventListener(o,"keydown",n._keydown.bind(n),!0);n._ctxMenu.attach(n);return n}Object.defineProperty(PivotGrid,"controlTemplate",{get:function(){PivotGrid._ctrlTemplate||(PivotGrid._ctrlTemplate=FlexGrid.controlTemplate);return PivotGrid._ctrlTemplate},set:function(e){PivotGrid._ctrlTemplate=e},enumerable:!0,configurable:!0});PivotGrid.prototype._getProductInfo=function(){return"D6F4,PivotGrid"};Object.defineProperty(PivotGrid.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showDetailOnDoubleClick",{get:function(){return this._showDetailOnDoubleClick},set:function(e){this._showDetailOnDoubleClick=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"detailDialog",{get:function(){this._dlgDetail||(this._dlgDetail=new DetailDialog(document.createElement("div")));return this._dlgDetail},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showRowFieldHeaders",{get:function(){return this._showRowFldHdrs},set:function(e){if(e!=this._showRowFldHdrs){this._showRowFldHdrs=asBoolean(e);this._updateFixedContent()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showColumnFieldHeaders",{get:function(){return this._showColFldHdrs},set:function(e){if(e!=this._showColFldHdrs){this._showColFldHdrs=asBoolean(e);this._updateFixedContent()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showValueFieldHeaders",{get:function(){return this._showValFldHdrs},set:function(e){if(e!=this._showValFldHdrs){this._showValFldHdrs=asBoolean(e);this._updateFixedCounts();this._updateFixedContent()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"showRowFieldSort",{get:function(){return this._showRowFldSort},set:function(e){if(e!=this._showRowFldSort){this._showRowFldSort=asBoolean(e);this._updateFixedContent()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"customContextMenu",{get:function(){return this._customCtxMenu},set:function(e){this._customCtxMenu=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"collapsibleSubtotals",{get:function(){return this._collapsibleSubtotals},set:function(e){if(e!=this._collapsibleSubtotals){this._collapsibleSubtotals=asBoolean(e);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"centerHeadersVertically",{get:function(){return this._centerVert},set:function(e){if(e!=this._centerVert){this._centerVert=asBoolean(e);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotGrid.prototype,"outlineMode",{get:function(){return this._outlineMode},set:function(e){if(e!=this._outlineMode){this._outlineMode=asBoolean(e);this._bindGrid(!0)}},enumerable:!0,configurable:!0});PivotGrid.prototype.getKeys=function(e,t){var i=this.rows[asInt(e)],n=this.columns[asInt(t)],o=i?i.dataItem:null,r=n?n.binding:null;return this._ng.getKeys(o,r)};PivotGrid.prototype.getDetail=function(e,t){var i=this.rows[asInt(e)].dataItem,n=this.columns[asInt(t)].binding;return this._ng.getDetail(i,n)};PivotGrid.prototype.getDetailView=function(e,t){var i=this.rows[asInt(e)].dataItem,n=this.columns[asInt(t)].binding;return this._ng.getDetailView(i,n)};PivotGrid.prototype.showDetail=function(e,t){if(this._ng.valueFields.length){var i=this.detailDialog;i.showDetail(this,new CellRange(e,t));i.show(!0)}};PivotGrid.prototype.collapseRowsToLevel=function(e){this._collapseRowsToLevel(e)};PivotGrid.prototype.collapseColumnsToLevel=function(e){this._collapseColsToLevel(e)};PivotGrid.prototype._getQuickAutoSize=function(){return isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter};PivotGrid.prototype._bindGrid=function(t){var i=this;this.deferUpdate((function(){var n=i.preserveOutlineState||i._resizingColumn,o=i._collapsedKeys,r=i.rows,s=i.columns;n||(o=i._collapsedKeys={});e.prototype._bindGrid.call(i,t);if(i._ng&&n&&!isEmpty(o)){for(var l=i._ng.totalsBeforeData,a=l?r.length-1:0,d=l?-1:r.length,u=l?-1:1,h=a;h!=d;h+=u){var c=r[h].dataItem;(p=c?c[_PivotKey._ROW_KEY_NAME]:null)&&p.level>=0&&o[p.toString()]&&i._setRowCollapsed(new CellRange(h,p.level-1),!0)}a=l?s.length-1:0;d=l?-1:s.length;u=l?-1:1;for(h=a;h!=d;h+=u){var p,g=s[h].binding;(p=i._ng._getKey(g))&&p.level>0&&o[p.toString()]&&i._setColCollapsed(new CellRange(p.level-1,h),!0)}}}))};PivotGrid.prototype._getCollectionView=function(e){e instanceof PivotPanel?e=e.engine.pivotView:e instanceof PivotEngine&&(e=e.pivotView);return asCollectionView(e)};PivotGrid.prototype.refresh=function(t){void 0===t&&(t=!0);this._ctxMenu.refresh();var i=culture.Globalize.name;if(this._prevCulture!==i){this._prevCulture=i;this._updateFixedContent()}e.prototype.refresh.call(this,t)};PivotGrid.prototype.onItemsSourceChanged=function(t){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={};var i=this.collectionView;this._ng=i instanceof PivotCollectionView?i.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);e.prototype.onItemsSourceChanged.call(this,t)};PivotGrid.prototype.onResizedColumn=function(t){var i=this._ng;if(i){this._resizingColumn=!0;if(t.panel.columns==this.rowHeaders.columns){(o=this._colRowFields.get(t.getColumn()))instanceof PivotField&&(o.width=t.panel.columns[t.col].renderWidth)}if(t.panel.columns==this.columnHeaders.columns){var n=i.valueFields;if(n.length>0){var o;(o=n[t.col%n.length]).width=t.panel.columns[t.col].renderWidth}}this._resizingColumn=!1}e.prototype.onResizedColumn.call(this,t)};PivotGrid.prototype.onSortingColumn=function(t){var i=this._ng;return(!i||!i.isUpdating)&&e.prototype.onSortingColumn.call(this,t)};PivotGrid.prototype.onDraggingColumn=function(t){var i=this._ng;return(!i||!i.isUpdating)&&e.prototype.onDraggingColumn.call(this,t)};PivotGrid.prototype.onDraggedColumn=function(t){var i=this._ng;if(i&&t.panel.columns==this.topLeftCells.columns){var n=i.rowFields,o=n[t.data.col];i.deferUpdate((function(){n.removeAt(t.data.col);n.insert(t.col,o)}))}e.prototype.onDraggedColumn.call(this,t)};PivotGrid.prototype._updatingView=function(){this._updateFixedCounts();this.columns.clear();this.rows.clear()};PivotGrid.prototype._viewDefinitionChanged=function(){this._resizingColumn||(this._collapsedKeys={})};PivotGrid.prototype._hasDeferredUpdatesChanged=function(){for(var e,t=this.engine,i=t&&t.hasDeferredUpdates,n=this.hostElement.querySelectorAll("."+PivotGrid._WJC_COLLAPSE),o=0;o<n.length;o++)e=n[o],toggleClass(e,PivotGrid._WJC_DISABLED,i)};PivotGrid.prototype.onLoadedRows=function(t){0==this.columns.length&&this._generateColumns();this._updateFixedCounts();this._updateFixedContent();e.prototype.onLoadedRows.call(this,t)};PivotGrid.prototype._generateColumns=function(){var e=this.collectionView,t=e?e.sourceCollection:null,i=t&&t.length,n=this.engine;if(n&&i)for(var o=Object.keys(t[0]).filter((function(e){return e!=_PivotKey._ROW_KEY_NAME})),r=[Aggregate.Cnt,Aggregate.CntAll],s=0;s<o.length;s++){var l=n._getFieldByColKey(o[s]);this.columns.push(new Column({binding:o[s],dataType:l&&-1===r.indexOf(l.aggregate)?l.dataType:DataType.Number,allowMerging:!0}))}};PivotGrid.prototype._updateFixedCounts=function(){var e,t=this._ng,i=t&&t.isViewDefined;e=Math.max(1,i?t.rowFields.length:1);var n=this.topLeftCells.columns;n.clear();this._colRowFields.clear();for(var o=0;o<e;o++){var r=new Column({allowMerging:!0});n.push(r);i&&this._colRowFields.set(r,t.rowFields[o])}e=Math.max(1,i?t.columnFields.length:1);t&&t.columnFields.length&&(t.valueFields.length>1||this.showValueFieldHeaders)&&e++;var s=this.topLeftCells.rows;s.clear();for(o=0;o<e;o++)s.push(new Row)};PivotGrid.prototype._updateFixedContent=function(){var e=this._ng;if(e&&e.isViewDefined){for(var t=e.rowFields,i=e.columnFields,n=e.valueFields,o=this.outlineMode?t.map((function(e){return e.header})).join(" / "):"",r=this.topLeftCells,s=0;s<r.rows.length;s++)for(var l=0;l<r.columns.length;l++){var a="";this.showRowFieldHeaders&&l<t.length&&s==r.rows.length-1&&(a=this.outlineMode?o:t[l].header);this.showColumnFieldHeaders&&!a&&s<i.length&&0==l&&(a=i[s].header+":");r.setCellData(s,l,a,!1,!1)}r=this.rowHeaders;for(s=0;s<r.rows.length;s++){var d=r.rows[s].dataItem[_PivotKey._ROW_KEY_NAME];assert(d instanceof _PivotKey,"missing PivotKey for row...");for(l=0;l<r.columns.length;l++){a=d.getValue(l,!0);r.setCellData(s,l,a,!1,!1)}}r=this.columnHeaders;for(l=0;l<r.columns.length;l++){d=e._getKey(r.columns[l].binding);assert(d instanceof _PivotKey,"missing PivotKey for column...");for(s=0;s<r.rows.length;s++){a=d.getValue(s,!0);s==r.rows.length-1&&n.length&&(n.length>1||0==i.length||d.level>-1||this.showValueFieldHeaders)&&(a=n[l%n.length].header);r.setCellData(s,l,a,!1,!1)}}r=this.topLeftCells;for(l=0;l<r.columns.length;l++){var u=r.columns[l],h=l<t.length?t[l]:null;u.wordWrap=h?h.wordWrap:null;u.align=h?h.align:null;if(this.outlineMode&&l<r.columns.length-1){u.width=this.treeIndent;u.allowResizing=!1}else{u.allowResizing=!0;u.width=h&&isNumber(h.width)?h.width:null}}r=this.cells;for(l=0;l<r.columns.length;l++){u=r.columns[l],h=n.length?n[l%n.length]:null;u.width=h&&isNumber(h.width)?h.width:null;u.wordWrap=h?h.wordWrap:null;u.format=h?h.format:null;u.align=h?h.align:null}this.invalidate()}else this.topLeftCells.setCellData(0,0,null)};PivotGrid.prototype._updateDefaultSizes=function(){var t=e.prototype._updateDefaultSizes.call(this);this._hdrCols._setDefaultSize(4*t);return t};PivotGrid.prototype._formatItem=function(e,t){var i=this._ng,n=t.panel,o=t.cell;if(i){if(n==this.topLeftCells){var r=0==i.rowFields.length||t.row<n.rows.length-1||t.row==n.rows.length-1&&!this.showRowFieldHeaders;toggleClass(o,PivotGridClsNames.colFieldHdr,r);toggleClass(o,PivotGridClsNames.rowFieldHdr,!r)}var s,l=null;n==this.topLeftCells&&t.row==n.rows.length-1&&this.allowDragging&AllowDragging.Columns&&(l=!0);setAttribute(o,"draggable",l);switch(n){case this.rowHeaders:s=i.rowFields[t.col%i.rowFields.length];break;case this.columnHeaders:s=i.columnFields[t.row];break;case this.cells:s=i.valueFields[t.col]}s&&s.isContentHtml&&(o.innerHTML=o.textContent);var a=n.columns[t.col].binding,d=n.rows==this.rows?i._getRowLevel(t.row):-1,u=n.columns==this.columns?i._getColLevel(a):-1;toggleClass(o,PivotPanelClsNames.aggregate,d>-1||u>-1);if(this._collapsibleSubtotals){if(n==this.rowHeaders&&i._getShowRowTotals()==ShowTotals.Subtotals)if(this.outlineMode){var h=this._getGroupedRows(t.range);if(t.col<i.rowFields.length-1){if(!h.containsRow(t.row)){var c=this._getRowCollapsed(t.range);o.innerHTML=this._getCollapsedGlyph(c)+o.innerHTML}}}else{h=this.getMergedRange(n,t.row,t.col,!1)||t.range;if(t.col<i.rowFields.length-1&&h.rowSpan>1){c=this._getRowCollapsed(h);o.innerHTML=this._getCollapsedGlyph(c)+o.innerHTML}}this.outlineMode&&n==this.rowHeaders&&t.range.rightCol<n.columns.length-1&&(o.innerHTML="");if(n==this.columnHeaders&&i._getShowColTotals()==ShowTotals.Subtotals){h=this.getMergedRange(n,t.row,t.col,!1)||t.range;if(t.row<i.columnFields.length-1&&h.columnSpan>1){var p=this._getColCollapsed(h);o.innerHTML=this._getCollapsedGlyph(p)+o.innerHTML}}}if(n==this.topLeftCells&&this.showRowFieldSort&&t.col<i.rowFields.length&&t.row==this._getSortRowIndex()){s=i.rowFields[t.col];toggleClass(o,FlexGridClsNames.sortAsc,!s.descending);toggleClass(o,FlexGridClsNames.sortDesc,s.descending);o.innerHTML+=' <span class="'+GlyphClsNames.glyph+"-"+(s.descending?"down":"up")+'"></span>'}n!=this.cells&&toggleClass(o,UtilitesClsNames.alignVCenter,this._centerVert)}};PivotGrid.prototype._getCollapsedGlyph=function(e){var t=this.engine,i=t&&t.hasDeferredUpdates;return'<div class="'+(PivotGrid._WJC_COLLAPSE+(i?" "+PivotGrid._WJC_DISABLED:""))+'"><span class="'+GlyphClsNames.glyph+"-"+(e?"plus":"minus")+'"></span></div>'};PivotGrid.prototype._mousedown=function(e){if(e.defaultPrevented||0!=e.button)this._htDown=null;else{var t=this._htDown=this.hitTest(e),i=t.panel;this._ignoreClick=!1;var n=this.engine,o=n&&n.hasDeferredUpdates,r=closestClass(e.target,PivotGrid._WJC_COLLAPSE);if(!o&&null!=r&&null!=i){var s=t.range,l=void 0;switch(i.cellType){case CellType.RowHeader:var a=this.getMergedRange(i,s.row,s.col);a&&s.copy(a);l=this._getRowCollapsed(s);e.shiftKey||e.ctrlKey?this._collapseRowsToLevel(s.col+(l?2:1)):this._setRowCollapsed(s,!l);break;case CellType.ColumnHeader:l=this._getColCollapsed(s);e.shiftKey||e.ctrlKey?this._collapseColsToLevel(s.row+(l?2:1)):this._setColCollapsed(s,!l)}e.preventDefault();this._ignoreClick=!0;this._htDown=null;this.focus()}}};PivotGrid.prototype._mouseup=function(e){if(this._htDown&&!e.defaultPrevented&&!this._mouseHdl._szRowCol){var t=this.hitTest(e);if(this._htDown.panel==t.panel&&t.range.equals(this._htDown.range)){var i=this._ng,n=this.topLeftCells;if(t.panel==n&&t.row==n.rows.length-1&&t.col>-1){var o=t.getColumn();if(this.allowSorting&&o.allowSorting&&!t.edgeRight){var r=this._colRowFields.get(o);if(r&&!i.isUpdating){var s=new CellRangeEventArgs(t.panel,t.range);if(this.onSortingColumn(s)){i.pivotView.sortDescriptions.clear();r.descending=!r.descending;this.onSortedColumn(s)}}}e.preventDefault();this._ignoreClick=!0}}}};PivotGrid.prototype._click=function(e){this._ignoreClick&&e.preventDefault()};PivotGrid.prototype._dblclick=function(e){if(!e.defaultPrevented&&this._showDetailOnDoubleClick){var t=this._htDown;if(t&&t.panel==this.cells){var i=this._ng;i&&i.fields.length>0&&(i.fields[0]instanceof CubePivotField||this.showDetail(t.row,t.col))}}};PivotGrid.prototype._keydown=function(e){if(!e.defaultPrevented&&!e.ctrlKey&&e.altKey&&this.collapsibleSubtotals){var t=this.selection;if(t.isValid){var i=this._getRowLevel(t.topRow);i<0&&(i=this.rowHeaders.columns.length-1);var n=this._getKeyCode(e);switch(n){case Key.Left:case Key.Right:var o=new CellRange(t.row,i-1);this._setRowCollapsed(o,n==Key.Left);e.preventDefault()}}}};PivotGrid.prototype._getRowLevel=function(e){return this._ng._getRowLevel(e)};PivotGrid.prototype._getGroupedRows=function(e){var t,i=this._getRowLevel.bind(this),n=e.col+1,o=this.rows.length,r=this._ng.totalsBeforeData,s=e.row;if(0==i(s)){s=r?1:0;t=r?o-1:o-2}else{if(r)for(;s<o&&!(i(s)<0);s++);else for(;s>=0&&!(i(s)<0);s--);for(;s>0;s--){if((l=i(s-1))>=0&&l<=n)break}for(t=s;t<o-1;t++){var l;if((l=i(t+1))>=0&&l<=n)break}}assert(t>=s,"group end < start?");return t>=s?new CellRange(s,e.col,t,e.col2):e};PivotGrid.prototype._toggleRowCollapsed=function(e){this._setRowCollapsed(e,!this._getRowCollapsed(e))};PivotGrid.prototype._getRowCollapsed=function(e){e=this._getGroupedRows(e);var t=this._ng.totalsBeforeData?e.row-1:e.row2+1,i=this.rows[t]||this.rows[e.row],n=i?i.dataItem[_PivotKey._ROW_KEY_NAME]:null;return!!n&&this._collapsedKeys[n.toString()]};PivotGrid.prototype._setRowCollapsed=function(e,t){var i=this;e=this._getGroupedRows(e);var n=this._ng.totalsBeforeData?e.row-1:e.row2+1,o=this.rows[n]||this.rows[e.row],r=o?o.dataItem[_PivotKey._ROW_KEY_NAME]:null;r&&(this._collapsedKeys[r.toString()]=t);this.deferUpdate((function(){for(var r=e.row;r<=e.row2;r++)i.rows[r].visible=!t;o&&(o.visible=!0);if(!t){var s=i._getRowLevel(n),l=[];for(r=e.row;r<=e.row2;r++)if(i._getRowLevel(r)>-1){var a=i._getGroupedRows(new CellRange(r,s));assert(a.row>=e.row&&a.row2<=e.row2,"child range overflow");l.push(a);r++}l.forEach((function(e){var t=i._getRowCollapsed(e);i._setRowCollapsed(e,t)}))}}))};PivotGrid.prototype._collapseRowsToLevel=function(e){var t=this;e>=this._ng.rowFields.length&&(e=-1);this.deferUpdate((function(){for(var i=0;i<t.rows.length;i++){var n=t._getRowLevel(i);if(n>0){var o=t.rows[i].dataItem[_PivotKey._ROW_KEY_NAME];t._collapsedKeys[o.toString()]=e>0&&n>=e}if(e<0)t.rows[i].visible=!0;else{var r=n>-1&&n<=e;r||(t._ng.totalsBeforeData?0==i&&(r=!0):i==t.rows.length-1&&(r=!0));t.rows[i].visible=r}}}))};PivotGrid.prototype._getColLevel=function(e){return this._ng._getColLevel(this.columns[e].binding)};PivotGrid.prototype._getGroupedCols=function(e){var t,i=this._getColLevel.bind(this),n=e.row+1,o=this.columns.length,r=this._ng.totalsBeforeData,s=e.col;if(0==i(s)){s=r?1:0;t=r?o-1:o-2}else{if(this._ng.totalsBeforeData)for(s=e.col;s<o&&!(i(s)<0);s++);else for(s=e.col;s>=0&&!(i(s)<0);s--);for(;s>0;s--){if((l=i(s-1))>=0&&l<=n)break}for(t=s;t<o-1;t++){var l;if((l=i(t+1))>=0&&l<=n)break}}assert(t>=s,"group end < start?");return t>=s?new CellRange(e.row,s,e.row2,t):e};PivotGrid.prototype._toggleColCollapsed=function(e){this._setColCollapsed(e,!this._getColCollapsed(e))};PivotGrid.prototype._getColCollapsed=function(e){e=this._getGroupedCols(e);var t=this._ng,i=t.totalsBeforeData?e.col-t.valueFields.length:e.col2+1,n=this.columns[i],o=n?n.binding:null;return!!o&&this._collapsedKeys[o.toString()]};PivotGrid.prototype._setColCollapsed=function(e,t){var i=this;e=this._getGroupedCols(e);var n=this._ng,o=n.totalsBeforeData?e.col-n.valueFields.length:e.col2+1,r=this.columns[o],s=r?r.binding:null;s&&(this._collapsedKeys[s.toString()]=t);this.deferUpdate((function(){for(var r=1;r<=n.valueFields.length;r++)i.columns[n.totalsBeforeData?e.col-r:e.col2+r].visible=!0;for(var s=e.col;s<=e.col2;s++)i.columns[s].visible=!t;if(!t){var l=i._getColLevel(o),a=[];for(s=e.col;s<=e.col2;s++)if(i._getColLevel(s)>-1){var d=i._getGroupedCols(new CellRange(l,s));assert(d.col>=e.col&&d.col2<=e.col2,"child range overflow");a.push(d);s+=n.valueFields.length-1}a.forEach((function(e){var t=i._getColCollapsed(e);i._setColCollapsed(e,t)}))}}))};PivotGrid.prototype._collapseColsToLevel=function(e){var t=this;e>=this._ng.columnFields.length&&(e=-1);this.deferUpdate((function(){for(var i=0;i<t.columns.length;i++){var n=t._getColLevel(i);if(n>0){var o=t._ng._getKey(t.columns[i].binding);t._collapsedKeys[o.toString()]=e>0&&n>=e}if(e<0)t.columns[i].visible=!0;else{var r=n>-1&&n<=e;t.columns[i].visible=r}}}))};PivotGrid._WJC_COLLAPSE=PivotGridClsNames.pivotCollapse;PivotGrid._WJC_DISABLED=ControlStateClsNames.disabled;PivotGrid._ctrlTemplate="";return PivotGrid}(FlexGrid);export{PivotGrid};var DetailDialog=function(e){__extends(DetailDialog,e);function DetailDialog(t,i){var n=e.call(this,t,null)||this,o=n.getTemplate();n.applyTemplate(ControlClsNames.hostElement+" "+DetailDialogClsNames.hostElement,o,{_sCnt:"sp-cnt",_dSummary:"div-summary",_dGrid:"div-grid",_btnOK:"btn-ok",_gHdr:"g-hdr"});n._g=new FlexGrid(n._dGrid,{isReadOnly:!0});n.initialize(i);return n}Object.defineProperty(DetailDialog,"controlTemplate",{get:function(){DetailDialog._ctrlTemplate||(DetailDialog._ctrlTemplate='<div><div class="'+DetailDialogClsNames.dialogHeader+'"><span wj-part="g-hdr">Detail View:</span> <span wj-part="sp-cnt"></span></div><div class="'+DetailDialogClsNames.dialogBody+'"><div wj-part="div-summary" class="'+DetailDialogClsNames.summary+'"></div><div wj-part="div-grid"></div></div><div class="'+DetailDialogClsNames.dialogFooter+'"><button wj-part="btn-ok"class="'+UtilitesClsNames.hide+" "+InputFormElementsClsNames.btn+'">OK</button> </div></div>');return DetailDialog._ctrlTemplate},set:function(e){DetailDialog._ctrlTemplate=e},enumerable:!0,configurable:!0});DetailDialog.prototype.showDetail=function(e,t){var i=this,n=e.getDetailView(t.row,t.col);this._g.itemsSource=n;var o=tryCast(n,"IPagedCollectionView");this._updateDetailCount(o?o.totalItemCount:n.items.length);n.collectionChanged.addHandler((function(){i._updateDetailCount(n.items.length)}));var r=e.engine,s=culture.olap.DetailDialog,l="";this._gHdr.textContent=s.header;this._btnOK.textContent=s.ok;var a=e.rows[t.row].dataItem[_PivotKey._ROW_KEY_NAME];this._rowHdr=escapeHtml(this._getHeader(a));this._rowHdr&&(l+=s.row+": <b>"+this._rowHdr+"</b><br>");var d=r._getKey(e.columns[t.col].binding);this._colHdr=escapeHtml(this._getHeader(d));this._colHdr&&(l+=s.col+": <b>"+this._colHdr+"</b><br>");var u=r.valueFields,h=u[t.col%u.length],c=e.getCellData(t.row,t.col,!0);this._cellHdr=escapeHtml(h.header);this._cellValue=escapeHtml(c);l+=this._cellHdr+": <b>"+this._cellValue+"</b>";this._dSummary.innerHTML=l};Object.defineProperty(DetailDialog.prototype,"rowHeader",{get:function(){return this._rowHdr},enumerable:!0,configurable:!0});Object.defineProperty(DetailDialog.prototype,"columnHeader",{get:function(){return this._colHdr},enumerable:!0,configurable:!0});Object.defineProperty(DetailDialog.prototype,"cellHeader",{get:function(){return this._cellHdr},enumerable:!0,configurable:!0});Object.defineProperty(DetailDialog.prototype,"cellValue",{get:function(){return this._cellValue},enumerable:!0,configurable:!0});Object.defineProperty(DetailDialog.prototype,"detailCount",{get:function(){return this._detailCount},enumerable:!0,configurable:!0});DetailDialog.prototype._updateDetailCount=function(e){var t=culture.olap.DetailDialog;this._sCnt.textContent=format(1==e?t.item:t.items,{cnt:e});this._detailCount=e};DetailDialog.prototype._getHeader=function(e){if(e&&e.values&&e.values.length){for(var t=[],i=0;i<e.values.length;i++)t.push(e.getValue(i,!0));return t.join(" - ")}return null};DetailDialog._ctrlTemplate="";return DetailDialog}(Popup);export{DetailDialog};var _PivotMergeManager=function(e){__extends(_PivotMergeManager,e);function _PivotMergeManager(){return null!==e&&e.apply(this,arguments)||this}_PivotMergeManager.prototype.getMergedRange=function(t,i,n,o){void 0===o&&(o=!0);var r=t.grid.collectionView;this._ng=r instanceof PivotCollectionView?r.engine:null;if(!this._ng)return e.prototype.getMergedRange.call(this,t,i,n,o);if(i<0||i>=t.rows.length||n<0||n>=t.columns.length)return null;var s=t.grid.allowMerging,l=AllowMerging;switch(t.cellType){case CellType.TopLeft:return 0!=(s&l.AllHeaders)?this._getMergedTopLeftRange(t,i,n):null;case CellType.RowHeader:return 0!=(s&l.RowHeaders)?this._getMergedRowHeaderRange(t,i,n,o?t.viewRange:null):null;case CellType.ColumnHeader:return 0!=(s&l.ColumnHeaders)?this._getMergedColumnHeaderRange(t,i,n,o?t.viewRange:null):null}return null};_PivotMergeManager.prototype._getMergedTopLeftRange=function(e,t,i){var n=new CellRange(t,i),o=e.grid;if(o.outlineMode&&o.showRowFieldHeaders&&n.row==e.rows.length-1){n.col=0;n.col2=e.columns.length-1;return n}for(;n.col>0&&!e.getCellData(t,n.col,!0);)n.col--;for(;n.col2<e.columns.length-1&&!e.getCellData(t,n.col2+1,!0);)n.col2++;return n.isSingleCell?null:n};_PivotMergeManager.prototype._getMergedRowHeaderRange=function(e,t,i,n){var o=e.grid;if(!e.columns[i].allowMerging)return null;if(o.outlineMode){if(this._isSubtotal(e,t,i)||this._isSubtotal(e,t,i+1)){var r=this._getOutlineRange(e,t,i);return r.isSingleCell?null:r}if(i<e.columns.length-1){var s=o._getGroupedRows(new CellRange(t,i));return s.isSingleCell?null:s}return null}var l=this._ng._getRowLevel(t);if(l>-1&&i>=l){var a=e.getCellData(t,i,!1),d=void 0,u=void 0,h=n?n.col:0,c=n?n.col2:e.columns.length-1;for(d=i;d>h&&e.getCellData(t,d-1,!1)==a;d--);for(u=i;u<c&&e.getCellData(t,u+1,!1)==a;u++);return d!=u?new CellRange(t,d,t,u):null}var p,g,_=n?n.row:0,f=n?n.row2:e.rows.length-1;for(p=t;p>_&&this._sameColumnValues(e,t,p-1,i);p--);for(g=t;g<f&&this._sameColumnValues(e,t,g+1,i);g++);return p!=g?new CellRange(p,i,g,i):null};_PivotMergeManager.prototype._sameColumnValues=function(e,t,i,n){for(;n>=0;n--){if(e.getCellData(t,n,!1)!=e.getCellData(i,n,!1))return!1}return!0};_PivotMergeManager.prototype._isSubtotal=function(e,t,i){var n=e.rows[t].dataItem,o=n?n[_PivotKey._ROW_KEY_NAME]:null;return n&&i>o.values.length-1&&i<e.columns.length};_PivotMergeManager.prototype._getOutlineRange=function(e,t,i){var n=new CellRange(t,i);n.col2=e.columns.length-1;for(;n.col&&this._isSubtotal(e,t,n.col);)n.col--;return n};_PivotMergeManager.prototype._getMergedColumnHeaderRange=function(e,t,i,n){var o=e.columns[i],r=this._ng._getKey(o.binding),s=e.getCellData(t,i,!1),l=this._ng._getColLevel(r);if(l>-1&&t>=l){var a=void 0,d=void 0,u=n?n.row:0,h=n?n.row2:e.rows.length-1;for(a=t;a>u&&e.getCellData(a-1,i,!1)==s;a--);for(d=t;d<h&&e.getCellData(d+1,i,!1)==s;d++);if(a!=d)return new CellRange(a,i,d,i)}if(n){i<e.columns._frozenInternal&&(n.col=n.col2=0);t<e.rows._frozenInternal&&(n.row=n.row2=0)}var c,p,g=n?n.col:0,_=n?n.col2:e.columns.length-1;for(c=i;c>g&&this._sameRowValues(e,t,i,c-1);c--);for(p=i;p<_&&this._sameRowValues(e,t,i,p+1);p++);return c!=p?new CellRange(t,c,t,p):null};_PivotMergeManager.prototype._sameRowValues=function(e,t,i,n){for(;t>=0;t--){if(e.getCellData(t,i,!1)!=e.getCellData(t,n,!1))return!1}return!0};return _PivotMergeManager}(MergeManager);export{_PivotMergeManager};export var PivotChartType;!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||(PivotChartType={}));export var LegendVisibility;!function(e){e[e.Always=0]="Always";e[e.Never=1]="Never";e[e.Auto=2]="Auto"}(LegendVisibility||(LegendVisibility={}));var PivotChart=function(e){__extends(PivotChart,e);function PivotChart(t,i){var n=e.call(this,t)||this;n._chartType=PivotChartType.Column;n._showHierarchicalAxes=!0;n._showTotals=!1;n._showTitle=!0;n._showLegend=LegendVisibility.Always;n._legendPosition=Position.Right;n._maxSeries=PivotChart.MAX_SERIES;n._maxPoints=PivotChart.MAX_POINTS;n._stacking=Stacking.None;n._colItms=[];n._dataItms=[];n._lblsSrc=[];n._grpLblsSrc=[];addClass(n.hostElement,PivotChartClsNames.hostElement);n._isPieChart()?n._createFlexPie():n._createFlexChart();e.prototype.initialize.call(n,i);return n}PivotChart.prototype._getProductInfo=function(){return"D6F4,PivotChart"};Object.defineProperty(PivotChart.prototype,"engine",{get:function(){return this._ng},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"itemsSource",{get:function(){return this._itemsSource},set:function(e){if(e&&this._itemsSource!==e){var t=this._itemsSource;e instanceof PivotPanel?e=e.engine.pivotView:e instanceof PivotEngine&&(e=e.pivotView);this._itemsSource=asCollectionView(e);this._onItemsSourceChanged(t)}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"chartType",{get:function(){return this._chartType},set:function(e){if((e=asEnum(e,PivotChartType))!=this._chartType){var t=this._chartType;this._chartType=e;this._changeChartType();e!==PivotChartType.Bar&&t!==PivotChartType.Bar||this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"showHierarchicalAxes",{get:function(){return this._showHierarchicalAxes},set:function(e){if(e!=this._showHierarchicalAxes){this._showHierarchicalAxes=asBoolean(e,!0);!this._isPieChart()&&this._flexChart&&this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc)}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"showTotals",{get:function(){return this._showTotals},set:function(e){if(e!=this._showTotals){this._showTotals=asBoolean(e,!0);this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"showTitle",{get:function(){return this._showTitle},set:function(e){if(e!=this._showTitle){this._showTitle=asBoolean(e,!0);this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"showLegend",{get:function(){return this._showLegend},set:function(e){if((e=asEnum(e,LegendVisibility))!=this.showLegend){this._showLegend=e;this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"legendPosition",{get:function(){return this._legendPosition},set:function(e){if((e=asEnum(e,Position))!=this.legendPosition){this._legendPosition=e;this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"stacking",{get:function(){return this._stacking},set:function(e){if((e=asEnum(e,Stacking))!=this._stacking){this._stacking=e;if(this._flexChart){this._flexChart.stacking=this._stacking;this._updatePivotChart()}}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"maxSeries",{get:function(){return this._maxSeries},set:function(e){if(e!=this._maxSeries){this._maxSeries=asNumber(e);this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"maxPoints",{get:function(){return this._maxPoints},set:function(e){if(e!=this._maxPoints){this._maxPoints=asNumber(e);this._updatePivotChart()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"flexChart",{get:function(){return this._flexChart},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"flexPie",{get:function(){return this._flexPie},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"header",{get:function(){return this._header},set:function(e){if(e!=this._header){this._header=asString(e,!0);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"footer",{get:function(){return this._footer},set:function(e){if(e!=this._footer){this._footer=asString(e,!0);this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"headerStyle",{get:function(){return this._headerStyle},set:function(e){if(e!=this._headerStyle){this._headerStyle=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(PivotChart.prototype,"footerStyle",{get:function(){return this._footerStyle},set:function(e){if(e!=this._footerStyle){this._footerStyle=e;this.invalidate()}},enumerable:!0,configurable:!0});PivotChart.prototype.refresh=function(t){void 0===t&&(t=!0);e.prototype.refresh.call(this,t);this._isPieChart()?this._flexPie&&this._flexPie.refresh(t):this._flexChart&&this._flexChart.refresh(t);this._updatePivotChart()};PivotChart.prototype.saveImageToDataUrl=function(e,t){this._isPieChart()?this._flexPie&&this._flexPie.saveImageToDataUrl(e,t):this._flexChart&&this._flexChart.saveImageToDataUrl(e,t)};PivotChart.prototype.saveImageToFile=function(e){this._isPieChart()?this._flexPie&&this._flexPie.saveImageToFile(e):this._flexChart&&this._flexChart.saveImageToFile(e)};PivotChart.prototype._onItemsSourceChanged=function(e){this._ng&&this._ng.updatedView.removeHandler(this._updatePivotChart,this);e&&e.collectionChanged.removeHandler(this._updatePivotChart,this);var 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()};PivotChart.prototype._createFlexChart=function(){var e=this,t=document.createElement("div");this.hostElement.appendChild(t);this._flexChart=new FlexChart(t);this._flexChart._bindingSeparator=null;this._flexChart.legend.position=Position.Right;this._flexChart.bindingX=_PivotKey._ROW_KEY_NAME;this._flexChart.stacking=this._stacking;this._flexChart.tooltip.content=function(t){var i=t.name?"<b>"+t.name+"</b> <br/>":"";return i+=e._getLabel(t.x)+" "+e._getValue(t)};this._flexChart.hostElement.style.visibility="hidden"};PivotChart.prototype._createFlexPie=function(){var e=this,t=document.createElement("div");this.hostElement.appendChild(t);this._colMenu=new MultiSelect(t,{displayMemberPath:"text",placeholder:culture.olap.PivotPanel.cols,selectedValuePath:"prop",showSelectAllCheckbox:!0});this._colMenu.hostElement.style.visibility="hidden";this._colMenu.checkedItemsChanged.addHandler((function(t,i){return e._updateFlexPieBinding()}));var i=document.createElement("div");this.hostElement.appendChild(i);this._flexPie=new FlexPie(i);this._flexPie.bindingName=_PivotKey._ROW_KEY_NAME;this._flexPie.tooltip.content=function(t){return"<b>"+e._getLabel(e._dataItms[t.pointIndex][_PivotKey._ROW_KEY_NAME])+"</b> <br/>"+e._getValue(t)};this._flexPie.rendering.addHandler(this._updatePieInfo,this)};PivotChart.prototype._updatePivotChart=function(){if(this._ng&&this._ng.pivotView){for(var e,t=[],i=[],n=[],o=0,r=this._ng.pivotView,s=this._ng.rowFields,l=0;l<r.items.length;l++){var a=r.items[l],d=a.$rowKey;0==l&&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(var u=0;u<s.length;u++){n.length<=u&&n.push([]);if(this._getMergeIndex(d,e)<u){o=n[u].length-1;var h=n[u][o];0===o&&u<s.length-1&&(h.value=(h.width-1)/2);if(o>0&&u<s.length-1){var c=this._getOffsetWidth(n[u]);h.value=c+(h.width-1)/2}n[u].push({value:t.length-1,text:d.getValue(u,!0),width:1})}else{o=n[u].length-1;n[u][o].width++}}e=d}}for(u=0;u<s.length;u++)if(u<n.length){o=n[u].length-1;n[u][o].value=this._getOffsetWidth(n[u])+(n[u][o].width-1)/2}this._dataItms=t;this._lblsSrc=i;this._grpLblsSrc=n;this._updateFlexChartOrPie()}};PivotChart.prototype._updateFlexChartOrPie=function(){var e=this._isPieChart();!e&&this._flexChart?this._updateFlexChart(this._dataItms,this._lblsSrc,this._grpLblsSrc):e&&this._flexPie&&this._updateFlexPie(this._dataItms,this._lblsSrc)};PivotChart.prototype._updateFlexChart=function(e,t,i){var n,o=this._flexChart,r=o?o.hostElement:null;if(this._ng&&o&&r){o.beginUpdate();o.itemsSource=e;this._createSeries();o.series&&o.series.length>0&&e.length>0?r.style.visibility="visible":r.style.visibility="hidden";o.header=this.header||this._getChartTitle();this.headerStyle&&(o.headerStyle=this.headerStyle);this.footer&&(o.footer=this.footer);this.footerStyle&&(o.footerStyle=this.footerStyle);if(this._isRotatedChart()){if(this._showHierarchicalAxes&&i.length>0){o.axisY.itemsSource=i[i.length-1];o.axisX.labelAngle=void 0;if(i.length>=2)for(var s=i.length-2;s>=0;s--)this._createGroupAxes(i[s])}else{o.axisY.labelAngle=void 0;o.axisY.itemsSource=t}o.axisX.itemsSource=void 0}else{if(this._showHierarchicalAxes&&i.length>0){o.axisX.itemsSource=i[i.length-1];if(i.length>=2)for(s=i.length-2;s>=0;s--)this._createGroupAxes(i[s])}else{o.axisX.labelAngle=void 0;o.axisX.itemsSource=t}o.axisY.itemsSource=void 0}o.axisX.labelPadding=6;o.axisY.labelPadding=6;if(this._isRotatedChart()){n=o.axisX;o.axisY.reversed=!0}else{n=o.axisY;o.axisY.reversed=!1}o.stacking!==Stacking.Stacked100pc&&this._ng.valueFields.length>0&&this._ng.valueFields[0].format?n.format=this._ng.valueFields[0].format:n.format="";o.legend.position=this._getLegendPosition();o.endUpdate()}};PivotChart.prototype._updateFlexPie=function(e,t){var i=this._flexPie,n=i?i.hostElement:null,o=this._colMenu;if(this._ng&&i&&n){this._colItms.length>0&&e.length>0?n.style.visibility="visible":n.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();var r=this._getTitle(this._ng.columnFields);""!==r&&(r="<b>"+r+": </b>");if(this._colItms&&this._colItms.length>1&&e.length>0){o.hostElement.style.visibility="visible";o.itemsSource=this._colItms;o.checkedItems=[this._colItms[0]];o.invalidate()}else o.hostElement.style.visibility="hidden"}};PivotChart.prototype._getLegendPosition=function(){var e=this.legendPosition;if(this.showLegend==LegendVisibility.Never)e=Position.None;else if(this.showLegend==LegendVisibility.Auto&&this.flexChart&&this.flexChart.series){var t=0;this.flexChart.series.forEach((function(e){var i=e.visibility;e.name&&i!=SeriesVisibility.Hidden&&i!=SeriesVisibility.Plot&&t++}));t<2&&(e=Position.None)}return e};PivotChart.prototype._createSeries=function(){this._flexChart&&(this._flexChart.series.length=0);for(var e=1==this._ng.valueFields.length,t=0;t<this._colItms.length;t++){var i=new Series,n=this._colItms[t].prop,o=this._colItms[t].text;if(e){var r=o.lastIndexOf(";");r>-1&&(o=o.substr(0,r))}i.binding=n;i.name=o;this._flexChart.series.push(i)}};PivotChart.prototype._getColumns=function(e){var t,i=0;if(e){this._colItms=[];for(var n in e)if(e.hasOwnProperty(n)&&n!==_PivotKey._ROW_KEY_NAME&&i<this._maxSeries&&this._isValidColumn(n)){t=this._ng._getKey(n);this._getLabel(t);this._colItms.push({prop:n,text:this._getLabel(t)});i++}}};PivotChart.prototype._createGroupAxes=function(e){var t,i=this,n=this._flexChart,o=this._isRotatedChart()?n.axisY:n.axisX;if(e){(t=new Axis).labelAngle=0;t.labelPadding=6;t.position=this._isRotatedChart()?Position.Left:Position.Bottom;t.majorTickMarks=TickMark.None;t.itemsSource=e;t.reversed=o.reversed;t.axisLine=!1;t.itemFormatter=function(n,o){if(t._axrect){var r=.5*e.filter((function(e){return e.value==o.val}))[0].width;if(i._isRotatedChart()){var s=t.reversed?-1:1,l=t.convert(o.val+r)+5*s,a=t.convert(o.val-r)-5*s,d=t._axrect.left+t._axrect.width-5;n.drawLine(d,l,d,a,PivotChart.HRHAXISCSS);n.drawLine(d,l,d+5,l,PivotChart.HRHAXISCSS);n.drawLine(d,a,d+5,a,PivotChart.HRHAXISCSS);n.drawLine(d,o.pos.y,d-5,o.pos.y,PivotChart.HRHAXISCSS)}else{var u=t.convert(o.val-r)+5,h=t.convert(o.val+r)-5,c=t._axrect.top;n.drawLine(u,c,h,c,PivotChart.HRHAXISCSS);n.drawLine(u,c,u,c-5,PivotChart.HRHAXISCSS);n.drawLine(h,c,h,c-5,PivotChart.HRHAXISCSS);n.drawLine(o.pos.x,c,o.pos.x,c+5,PivotChart.HRHAXISCSS)}}return o};t.min=o.actualMin;t.max=o.actualMax;o.rangeChanged.addHandler((function(){isNaN(t.min)&&isNaN(o.actualMin)||t.min==o.actualMin||(t.min=o.actualMin);isNaN(t.max)&&isNaN(o.actualMax)||t.max==o.actualMax||(t.max=o.actualMax)}));var r=new Series;r.visibility=SeriesVisibility.Hidden;this._isRotatedChart()?r.axisY=t:r.axisX=t;n.series.push(r)}};PivotChart.prototype._updateFlexPieBinding=function(){var e="",t=[];this._colMenu.checkedItems.forEach((function(i){e.length>0&&(e+=",");e+=i.prop;t.push(i.text)}));this._flexPie.binding=e;this._flexPie.titles=t.length>1?t:null};PivotChart.prototype._updatePieInfo=function(){var e=this;this._flexPie&&(this._flexPie._labels=this._flexPie._labels.map((function(t,i){return e._lblsSrc[i].text})))};PivotChart.prototype._changeChartType=function(){var 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=ChartType.Column;break;case PivotChartType.Bar:e=ChartType.Bar;break;case PivotChartType.Scatter:e=ChartType.Scatter;break;case PivotChartType.Line:e=ChartType.Line;break;case PivotChartType.Area:e=ChartType.Area}if(this._flexChart)"none"!==this._flexChart.hostElement.style.display&&e!==PivotChartType.Bar&&this._flexChart.chartType!==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)}};PivotChart.prototype._swapChartAndPie=function(e){var t=this;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";setTimeout((function(){t._colMenu.hostElement.style.top=""}),0)}};PivotChart.prototype._getLabel=function(e){var t="";if(!e||!e.values)return t;var 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(var n=0;n<e.values.length;n++){n>0&&(t+="; ");t+=e.getValue(n,!0)}i&&(t+="; "+i.header)}return t};PivotChart.prototype._getValue=function(e){var t=this._ng.valueFields,i=e.series?e.series.chart.series.indexOf(e.series):0,n=i<t.length?t[i].format:t.length?t[0].format:"";return n?Globalize.format(e.y,n):e._yfmt};PivotChart.prototype._getChartTitle=function(){if(!this.showTitle||!this._ng.valueFields.length)return null;var e=this._ng,t=this._getTitle(e.valueFields),i=this._getTitle(e.rowFields),n=this._getTitle(e.columnFields),o=t,r=culture.olap.PivotChart;if(t&&this._dataItms.length>0){i&&(o+=format(" {by} {rows}",{by:r.by,rows:i}));n&&(o+=format(" {and} {cols}",{and:i?r.and:r.by,cols:n}))}return o};PivotChart.prototype._getTitle=function(e){for(var t="",i=0;i<e.length;i++){t.length>0&&(t+="; ");t+=e[i].header}return t};PivotChart.prototype._isValidColumn=function(e){var 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)};PivotChart.prototype._isTotalRow=function(e){return e.values.length<this._ng.rowFields.length};PivotChart.prototype._isPieChart=function(){return this._chartType==PivotChartType.Pie};PivotChart.prototype._isRotatedChart=function(){return!this._isPieChart()&&this._chartType==PivotChartType.Bar!==this._flexChart.rotated};PivotChart.prototype._getMergeIndex=function(e,t){var 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(var n=0;n<e.values.length;n++){if(e.getValue(n,!0)!=t.getValue(n,!0))return i;i=n}return i};PivotChart.prototype._getOffsetWidth=function(e){var t=0;if(e.length<=1)return t;for(var i=0;i<e.length-1;i++)t+=e[i].width;return t};PivotChart.MAX_SERIES=100;PivotChart.MAX_POINTS=100;PivotChart.HRHAXISCSS=PivotChartClsNames.hierarchicalAxesLine;return PivotChart}(Control);export{PivotChart};var _MdxQueryBuilder=function(){function _MdxQueryBuilder(e,t){this._ng=null;this._cubeName=null;this._ng=e;this._cubeName=t}_MdxQueryBuilder.prototype.buildQuery=function(){var 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()};_MdxQueryBuilder.prototype.buildWhereSection=function(e){var t=new _TextBuilder;if(1==e.length){t.append(this.buildSetForMeasuresShelf(e));t.wrap(" WHERE ","")}return t.toString()};_MdxQueryBuilder.prototype.buildCubeName=function(){var e=new _TextBuilder;e.append(this.buildSubcubeExpression());var t=e.length>0;t&&e.wrap("SELECT "," FROM ");e.append("[",this._cubeName,"]");t&&e.wrap("(",")");return e.toString()};_MdxQueryBuilder.prototype.buildSubcubeExpression=function(){var e=new _TextBuilder,t=this.getMeasureFilterExpressions(this._ng.valueFields),i=this.buildFilterAttributeSet(this._ng.filterFields),n=this.buildFilterAttributeSet(this._ng.rowFields,t),o=this.buildFilterAttributeSet(this._ng.columnFields,0==n.length?t:null);e.joinItemToList(i);e.joinItemToList(n);e.joinItemToList(o);if(e.length>0){e.wrap("(",")");e.append(" ON COLUMNS")}return e.toString()};_MdxQueryBuilder.prototype.buildFilterAttributeSet=function(e,t){for(var i=new _TextBuilder,n=0;n<e.length;n++){var o=e[n],r=this.buildFilterString(o,0==n?t:null);i.joinItemToList(r)}return i.toString()};_MdxQueryBuilder.prototype.buildFilterString=function(e,t){var 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()};_MdxQueryBuilder.prototype.getValueFilterString=function(e){var t=new _TextBuilder,i=e.filter.valueFilter,n=Object.keys(i.showValues).map((function(t){return e.key+".["+t+"]"}));t.append(n.join(","));t.length>0&&t.wrap("{","}");return t.toString()};_MdxQueryBuilder.prototype.getConditionFilterString=function(e,t){var i=new _TextBuilder,n=e.key+".LEVELS(1).ALLMEMBERS",o=e.filter.conditionFilter.condition1,r=e.filter.conditionFilter.condition2;if(o.isActive){i.append(this.getConditionFilterExpression(e,o));r.isActive&&i.append(e.filter.conditionFilter.and?" AND ":" OR ")}r.isActive&&i.append(this.getConditionFilterExpression(e,r));if(t&&t.length>0){i.length>0&&i.append(" AND ");i.append(t.join(" AND "))}i.length>0&&i.wrap("Filter("+n+",(","))");return i.toString()};_MdxQueryBuilder.prototype.getMeasureFilterExpressions=function(e){for(var t=[],i=0;i<e.length;i++){var n=new _TextBuilder,o=e[i],r=(o.dimensionType,DimensionType.Measure,o.filter.conditionFilter.condition1),s=o.filter.conditionFilter.condition2;if(r.isActive){n.append(this.getConditionFilterExpression(o,r));s.isActive&&n.append(o.filter.conditionFilter.and?" AND ":" OR ")}s.isActive&&n.append(this.getConditionFilterExpression(o,s));if(n.length>0){n.wrap("(",")");t.push(n.toString())}}return t};_MdxQueryBuilder.prototype.getConditionFilterExpression=function(e,t){if(!t.isActive)return"";var i=e.dimensionType==DimensionType.Measure,n=e.dataType==DataType.Number,o=e.dataType==DataType.Date,r=n||o?"member_value":"member_caption",s=i?e.key:e.key+".CurrentMember."+r,l=o?"CDate('"+Globalize.formatDate(t.value,"d")+"')":t.value.toString(),a=new _TextBuilder;switch(t.operator){case Operator.BW:a.append("(Left(",s,",",l.length.toString(),')="',l,'")');break;case Operator.NBW:a.append("(Left(",s,",",l.length.toString(),')<>"',l,'")');break;case Operator.EW:a.append("(Right(",s,",",l.length.toString(),')="',l,'")');break;case Operator.NEW:a.append("(Right(",s,",",l.length.toString(),')<>"',l,'")');break;case Operator.EQ:i||n||o?a.append("(",s,")=",l):a.append("(",s,')="',l,'"');break;case Operator.NE:i||n||o?a.append("(",s,")<>",l):a.append("(",s,')<>"',l,'"');break;case Operator.CT:a.append("(InStr(1,",s,',"',l,'")>0)');break;case Operator.NC:a.append("(InStr(1,",s,',"',l,'")=0))');break;case Operator.GT:a.append("(",s,")>",l);break;case Operator.LT:a.append("(",s,")<",l);break;case Operator.GE:a.append("(",s,")>=",l);break;case Operator.LE:a.append("(",s,")<=",l)}return a.toString()};_MdxQueryBuilder.prototype.buildAxes=function(){var 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()};_MdxQueryBuilder.prototype.buildSetForAttributesShelf=function(e){for(var t=new _TextBuilder,i=0;i<e.length;i++){var n=e[i];n.dimensionType!=DimensionType.Attribute&&n.dimensionType!=DimensionType.Hierarchy||t.joinItemToList(this.buildAttributeSetForAxis(n));i>0&&t.wrap("CrossJoin(",")")}t.wrap("NON EMPTY ","");return t.toString()};_MdxQueryBuilder.prototype.buildSetForAttributesColumnShelf=function(e){for(var t=new _TextBuilder,i=0;i<e.length;i++){var n=e[i];n.dimensionType!=DimensionType.Attribute&&n.dimensionType!=DimensionType.Hierarchy||t.joinItemToList(this.buildAttributeSetForAxis(n))}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()};_MdxQueryBuilder.prototype.buildSetForMeasuresShelf=function(e){for(var t=new _TextBuilder,i=0;i<e.length;i++){var n=e[i];n.dimensionType!=DimensionType.Measure&&n.dimensionType!=DimensionType.Kpi||t.joinItemToList(this.buildMeasureSetForAxis(n))}t.wrap("{","}");return t.toString()};_MdxQueryBuilder.prototype.buildAttributeSetForAxis=function(e){var t=new _TextBuilder;if(e.dimensionType==DimensionType.Hierarchy){t.append(e.key);t.append(".ALLMEMBERS");t.wrap("{","}");t.wrap("HIERARCHIZE(",")")}return t.toString()};_MdxQueryBuilder.prototype.buildMeasureSetForAxis=function(e){var t=new _TextBuilder;e.dimensionType!=DimensionType.Measure&&e.dimensionType!=DimensionType.Kpi||t.append(e.key);return t.toString()};return _MdxQueryBuilder}();export{_MdxQueryBuilder};var _SqlServerConnection=function(e){__extends(_SqlServerConnection,e);function _SqlServerConnection(t,i){var n=e.call(this,t,i.url)||this;n._jsonResult=null;n._dataTypes=null;n._debug=!1;t.sortOnServer=!0;assert(isString(i.cube)&&!isNullOrWhiteSpace(i.cube),"Cube name required.");n._cubeName=i.cube;n._catalogName=isString(i.catalog)&&!isNullOrWhiteSpace(i.catalog)?i.catalog:"";n._url=i.url;n._user=i.user;n._password=i.password;return n}_SqlServerConnection.prototype.getFields=function(){this._getSession();this._jsonResult=null;this._dataTypes=null;this._getProperties(this._token);this._getDimensions(this._token);this._endSession();return this._jsonResult};_SqlServerConnection.prototype.getOutputView=function(e){var t=this;this._ng.onUpdatingView(new ProgressEventArgs(0));var i=new _MdxQueryBuilder(this._ng,this._cubeName).buildQuery();this._jsonResult=[];this._getSession();this._execQuery(this._token,i,(function(i){asFunction(e)(t._jsonResult);t._ng.onUpdatedView(new ProgressEventArgs(100))}))};_SqlServerConnection.prototype.getDetail=function(e,t){throw"getDetail method not supported"};_SqlServerConnection.prototype.getSortedKeys=function(e,t){var i=this,n=Object.keys(e);if(this._ng.sortOnServer){if(n.length>1){var o=t?this._ng.showRowTotals:this._ng.showColumnTotals,r=t?this._ng.rowFields.length:this._ng.columnFields.length,s=this._ng.valueFields.length;if(!this._ng.totalsBeforeData&&o!==ShowTotals.None){var l=-1,a=[],d=[];n.forEach((function(e){var n=i._getKeyLength(e,t);if(n===r)d.push(e);else if(n>=l)a.push(e);else{if(a.length>=s)for(var o=0;o<s;o++)d.push(a.pop());a.push(e)}l=n}));if(a.length>0){a.reverse();d=d.concat(a)}return d}}}else n.sort((function(e,t){return i._ng._keys[e].compareTo(i._ng._keys[t])}));return n};_SqlServerConnection.prototype._getSession=function(){var e=this,t=this._url;return httpRequest(t,{async:!1,data:_ENV_SESSION,method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(t){var i=t.responseXML.getElementsByTagName("Session");e._token=i[0].getAttribute("SessionId")},error:function(t){e._handleError("Begin Session",t)}})};_SqlServerConnection.prototype._endSession=function(){var e=this,t=this._url;return httpRequest(t,{async:!1,data:_ENV_ENDSESSION(this._token),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},error:function(t){e._handleError("End Session",t)},complete:function(t){e._token=void 0}})};_SqlServerConnection.prototype._getProperties=function(e){var t=this,i=this._url;return httpRequest(i,{async:!1,data:_ENV_PROPERTIES(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(e){for(var i={},n=e.responseXML.getElementsByTagName("row"),o=0;o<n.length;o++){var r=_getTagValue(n[o],"HIERARCHY_UNIQUE_NAME");switch(Number(_getTagValue(n[o],"DATA_TYPE"))){case 2:case 3:case 4:case 5:case 6:i[r]=DataType.Number;break;case 7:i[r]=DataType.Date}}t._dataTypes=i},error:function(e){t._handleError("Get Properties",e)}})};_SqlServerConnection.prototype._getDimensions=function(e){var t=this,i=this._url;return httpRequest(i,{async:!1,data:_ENV_DIMENSIONS(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(i){for(var n=[],o=i.responseXML.getElementsByTagName("row"),r=0;r<o.length;r++){if("2"!==_getTagValue(o[r],"DIMENSION_TYPE")){var s=_getTagValue(o[r],"DIMENSION_UNIQUE_NAME"),l={header:_getTagValue(o[r],"DIMENSION_CAPTION"),dataType:DataType.Object,dimensionType:DimensionType.Dimension,subFields:[]};t._getSubFolders(e,s,l);n.push(l)}else t._getMeasures(e,n)}var a={header:"KPIs",dataType:DataType.Object,dimensionType:DimensionType.Kpi,subFields:[]};t._getKPIs(e,a);n.push(a);t._jsonResult=n},error:function(e){t._handleError("Get Dimensions",e)}})};_SqlServerConnection.prototype._getSubFolders=function(e,t,i){var n=this,o=this._url;httpRequest(o,{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:function(e){for(var t=e.responseXML.getElementsByTagName("row"),o=0;o<t.length;o++){var r={header:_getTagValue(t[o],"HIERARCHY_NAME"),binding:_getTagValue(t[o],"HIERARCHY_UNIQUE_NAME"),dataType:DataType.String,dimensionType:DimensionType.Hierarchy};n._dataTypes[r.binding]&&(r.dataType=n._dataTypes[r.binding]);for(var s=_getTagValue(t[o],"HIERARCHY_DISPLAY_FOLDER").split("\\"),l=i,a=0;a<s.length;a++)if(""!=s[a]){var d={header:s[a],dataType:DataType.Object,dimensionType:DimensionType.Folder,subFields:[]};if(_containsFolder(l,s[a]))l=_findSubFieldByName(l,s[a]);else{l.subFields.push(d);l=d}}l.subFields.push(r)}},error:function(e){n._handleError("Get Hierarchies",e)}})};_SqlServerConnection.prototype._getMeasures=function(e,t){var i=this,n=this._url;return httpRequest(n,{async:!1,data:_ENV_MEASURES(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(e){for(var i=e.responseXML.getElementsByTagName("row"),n={},o=0;o<i.length;o++){var r=_getTagValue(i[o],"MEASUREGROUP_NAME"),s={header:_getTagValue(i[o],"MEASURE_CAPTION"),binding:_getTagValue(i[o],"MEASURE_UNIQUE_NAME"),dataType:DataType.Number,dimensionType:DimensionType.Measure};if(Object.keys(n).indexOf(r)<0){var l={header:r,dataType:DataType.Number,dimensionType:DimensionType.Measure,subFields:[]};l.subFields.push(s);t.push(l);n[r]=l}else n[r].subFields.push(s)}},error:function(e){i._handleError("Get Measures",e)}})};_SqlServerConnection.prototype._getKPIs=function(e,t){var i=this,n=this._url;return httpRequest(n,{async:!1,data:_ENV_KPIS(e,this._catalogName,this._cubeName),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(e){for(var i=e.responseXML.getElementsByTagName("row"),n=0;n<i.length;n++){for(var o=_getTagValue(i[n],"KPI_DISPLAY_FOLDER").split("\\"),r=t,s=0;s<o.length;s++){var l={header:o[s],dataType:DataType.Object,dimensionType:DimensionType.Folder,subFields:[]};if(_containsFolder(r,o[s]))r=_findSubFieldByName(r,o[s]);else{r.subFields.push(l);r=l}}var a={header:_getTagValue(i[n],"KPI_CAPTION"),binding:_getTagValue(i[n],"KPI_VALUE"),dataType:DataType.Number,dimensionType:DimensionType.Kpi};r.subFields.push(a)}},error:function(e){i._handleError("Get KPIs",e)}})};_SqlServerConnection.prototype._execQuery=function(e,t,i){var n=this,o=this._url;return httpRequest(o,{async:!0,data:_ENV_QUERY(e,this._catalogName,t),method:"POST",user:this._user,password:this._password,requestHeaders:{"Content-Type":"text/xml"},success:function(e){var o=e.responseXML,r=o.querySelector("Error");if(r){throw"SSAS Error\r\n"+r.getAttribute("Description")+"\r\n"+t}n._createPivotKeys(o);asFunction(i)(e)},error:function(e){n._handleError("Execute Query",e)},complete:function(){n._endSession()}})};_SqlServerConnection.prototype._createPivotKeys=function(e){var t=null,i=null,n=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']"));var o=t&&this._ng.rowFields.length>0,r=i&&this._ng.columnFields.length>0;o&&r?this._createRowKeys(n,t,i):o?this._createRowOnlyKeys(n,t):r&&this._createColumnOnlyKeys(n,i)};_SqlServerConnection.prototype._createRowKeys=function(e,t,i){for(var n=t.getElementsByTagName("Tuple"),o=i.getElementsByTagName("Tuple"),r=this._ng.showRowTotals!==ShowTotals.None?0:1,s=this._ng.showColumnTotals!==ShowTotals.None?0:this._ng.valueFields.length,l=r;l<n.length;l++){var a=l*o.length,d=n[l],u=this._validateTuple(d,this._ng.showRowTotals);if(u)for(var h=s;h<o.length;h++){var c=o[h],p=this._validateTuple(c,this._ng.showColumnTotals);if(p){for(var g in u)p[g]=u[g];for(var _=0;_<this._ng.valueFields.length;_++){p[this._ng.valueFields[_].key]=_getCellValue(e,a+h+_)}this._jsonResult.push(p)}}}};_SqlServerConnection.prototype._createRowOnlyKeys=function(e,t){for(var i=t.getElementsByTagName("Tuple"),n=this._ng.valueFields.length,o=this._ng.showRowTotals!==ShowTotals.None?0:1,r=o*n,s=o;s<i.length;s++){var l=i[s],a=this._validateTuple(l,this._ng.showRowTotals);if(a){for(var d=0;d<this._ng.valueFields.length;d++){a[this._ng.valueFields[d].key]=_getCellValue(e,r++)}this._jsonResult.push(a)}else r++}};_SqlServerConnection.prototype._createColumnOnlyKeys=function(e,t){for(var i=t.getElementsByTagName("Tuple"),n=this._ng.valueFields.length,o=this._ng.showColumnTotals!==ShowTotals.None?0:1,r=o;r<i.length;r+=n){var s=i[r],l=this._validateTuple(s,this._ng.showColumnTotals);if(l){for(var a=0;a<this._ng.valueFields.length;a++){l[this._ng.valueFields[a].key]=_getCellValue(e,r-o+a)}this._jsonResult.push(l)}}};_SqlServerConnection.prototype._validateTuple=function(e,t){for(var i=e.getElementsByTagName("Member"),n=void 0,o={},r=0;r<i.length;r++){var s=i[r],l=_getLevelNumber(s),a=s.getAttribute("Hierarchy"),d=_getCaptionValue(s);if(0==r)n=l;else{if(l>n)return null;if(t!==ShowTotals.Subtotals&&l!==n&&"[Measures]"!==a)return null;n=l}a.indexOf(".")>=0?o[a]=d:null!==d&&(o[d]=null)}return o};return _SqlServerConnection}(_ServerConnection);export{_SqlServerConnection};function _getTagValue(e,t){var 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){var i="Cell[CellOrdinal='"+t.toString()+"']",n=e.querySelector(i);if(n){var o=_getTagValue(n,"Value");if(o)return Number(o)}return null}function _findSubFieldByName(e,t){if(e.subFields)for(var i=0;i<e.subFields.length;i++){var n=e.subFields[i];if(n.header==t)return n}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}var _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=function(e){return'\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=function(e,t,i){return'\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=function(e,t,i,n){return'\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>"+n+"</DIMENSION_UNIQUE_NAME>\n </RestrictionList>\n </Restrictions>\n <Properties>\n </Properties>\n </Discover>\n </Body>\n </Envelope>"},_ENV_MEASURES=function(e,t,i){return'\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=function(e,t,i){return'\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=function(e,t,i){return'\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=function(e,t,i){return'\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=function(e,t,i){return'\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>"},PivotFilter=function(){function PivotFilter(e){this._fld=e;var t=e;this._valueFilter=new ValueFilter(t);this._valueFilter.exclusiveValueSearch=this._fld.engine.exclusiveValueSearch;this._conditionFilter=new ConditionFilter(t)}Object.defineProperty(PivotFilter.prototype,"filterType",{get:function(){return null!=this._filterType?this._filterType:this._fld.engine.defaultFilterType},set:function(e){if((e=asEnum(e,FilterType,!0))!=this._filterType){this._filterType=e;this.clear()}},enumerable:!0,configurable:!0});PivotFilter.prototype.apply=function(e){return this._conditionFilter.apply(e)&&this._valueFilter.apply(e)};Object.defineProperty(PivotFilter.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0});PivotFilter.prototype.clear=function(){var 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 PropertyChangedEventArgs("filter",null,null))};Object.defineProperty(PivotFilter.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0});Object.defineProperty(PivotFilter.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0});return PivotFilter}();export{PivotFilter};var PivotFilterEditor=function(e){__extends(PivotFilterEditor,e);function PivotFilterEditor(t,i,n){var o=e.call(this,t)||this;o.finishEditing=new Event;o.hostElement.tabIndex=-1;var r=o.getTemplate();o.applyTemplate(ControlClsNames.hostElement+" "+ControlClsNames.content+" "+PivotFilterEditorClsNames.hostElement,r,{_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnOk:"btn-ok"});setText(o._aVal,culture.FlexGridFilter.values);setText(o._aCnd,culture.FlexGridFilter.conditions);setText(o._btnOk,culture.olap.PivotFieldEditor.ok);var s=o._btnClicked.bind(o);o.addEventListener(o._btnOk,"click",s);o.addEventListener(o._aVal,"click",s);o.addEventListener(o._aCnd,"click",s);o.addEventListener(o.hostElement,"keydown",(function(e){switch(e.keyCode){case Key.Enter:switch(e.target.tagName){case"A":case"BUTTON":o._btnClicked(e);break;default:o.onFinishEditing(new CancelEventArgs)}e.preventDefault();break;case Key.Escape:o.onFinishEditing(new CancelEventArgs);e.preventDefault();break;case Key.Tab:moveFocus(o.hostElement,e.shiftKey?-1:1);e.preventDefault()}}));o._fld=i;o._uniqueValues=i.filter.valueFilter.uniqueValues;o.initialize(n);o.updateEditor();return o}Object.defineProperty(PivotFilterEditor,"controlTemplate",{get:function(){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="'+InputFormElementsClsNames.btn+'"></button></div></div>');return PivotFilterEditor._ctrlTemplate},set:function(e){PivotFilterEditor._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotFilterEditor.prototype,"field",{get:function(){return this._fld},enumerable:!0,configurable:!0});Object.defineProperty(PivotFilterEditor.prototype,"filter",{get:function(){return this._fld?this._fld.filter:null},enumerable:!0,configurable:!0});Object.defineProperty(PivotFilterEditor.prototype,"isEditorClear",{get:function(){switch(this._getFilterType()){case FilterType.Value:return!this._edtVal||this._edtVal.isEditorClear;case FilterType.Condition:return!this._edtCnd||this._edtCnd.isEditorClear}assert(!1,"unknown filter type?");return!1},enumerable:!0,configurable:!0});PivotFilterEditor.prototype.updateEditor=function(){var e=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){var i=this._fld,n=i.engine;if(n.isServer&&!this._uniqueValues){var o=n._getUniqueValues(i);i.filter.valueFilter.uniqueValues=o}this._edtVal.updateEditor()}this._edtCnd&&this._edtCnd.updateEditor()};PivotFilterEditor.prototype.updateFilter=function(){switch(this._getFilterType()){case FilterType.Value:this._edtVal.updateFilter();this.filter.conditionFilter.clear();break;case FilterType.Condition:this._edtCnd.updateFilter();this.filter.valueFilter.clear()}this.field.onPropertyChanged(new PropertyChangedEventArgs("filter",null,null))};PivotFilterEditor.prototype.clearEditor=function(){this._edtVal&&this._edtVal.clearEditor();this._edtCnd&&this._edtCnd.clearEditor()};PivotFilterEditor.prototype.onFinishEditing=function(e){this.finishEditing.raise(this,e);return!e.cancel};PivotFilterEditor.prototype._showFilter=function(e){e==FilterType.Value&&null==this._edtVal&&(this._edtVal=new ValueFilterEditor(this._divEdtVal,this.filter.valueFilter));e==FilterType.Condition&&null==this._edtCnd&&(this._edtCnd=new ConditionFilterEditor(this._divEdtCnd,this.filter.conditionFilter));if(0!=(e&this.filter.filterType))if(e==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 FilterType.None:case FilterType.Condition:case FilterType.Value:this._divType.style.display="none";break;default:this._divType.style.display=""}};PivotFilterEditor.prototype._enableLink=function(e,t){e.style.textDecoration=t?"":"none";e.style.fontWeight=t?"":"bold";setAttribute(e,"href",t?"":null)};PivotFilterEditor.prototype._getFilterType=function(){var e=FilterType;return"none"!=this._divEdtVal.style.display?e.Value:e.Condition};PivotFilterEditor.prototype._btnClicked=function(e){e.preventDefault();e.stopPropagation();if(!hasClass(e.target,ControlStateClsNames.disabled))if(e.target!=this._aVal)if(e.target!=this._aCnd)this.onFinishEditing(new CancelEventArgs);else{this._showFilter(FilterType.Condition);moveFocus(this._edtCnd.hostElement,0)}else{this._showFilter(FilterType.Value);moveFocus(this._edtVal.hostElement,0)}};PivotFilterEditor._ctrlTemplate="";return PivotFilterEditor}(Control);export{PivotFilterEditor};var PivotFieldEditor=function(e){__extends(PivotFieldEditor,e);function PivotFieldEditor(t,i){var n=e.call(this,t,null,!0)||this;n.hostElement.tabIndex=-1;var o=n.getTemplate();n.applyTemplate(ControlClsNames.hostElement+" "+PivotFieldEditorClsNames.hostElement,o,{_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"});n._pvDate=new Date;var r=culture.olap.PivotFieldEditor;setText(n._gDlg,r.dialogHeader);setText(n._gHdr,r.header);setText(n._gAgg,r.summary);setText(n._gShw,r.showAs);setText(n._gWfl,r.weighBy);setText(n._gSrt,r.sort);setText(n._gFlt,r.filter);setText(n._gFmt,r.format);setText(n._gSmp,r.sample);setText(n._btnFltEdt,r.edit);setText(n._btnFltClr,r.clear);setText(n._btnApply,r.ok);setText(n._btnCancel,r.cancel);n._cmbHdr=new ComboBox(n._dHdr);n._cmbAgg=new ComboBox(n._dAgg);n._cmbShw=new ComboBox(n._dShw);n._cmbWFl=new ComboBox(n._dWFl);n._cmbSrt=new ComboBox(n._dSrt);n._cmbFmt=new ComboBox(n._dFmt);n._cmbSmp=new ComboBox(n._dSmp);n._initAggregateOptions();n._initShowAsOptions();n._initFormatOptions();n._initSortOptions();n._updatePreview();n._cmbShw.textChanged.addHandler(n._updateFormat,n);n._cmbFmt.textChanged.addHandler(n._updatePreview,n);n.addEventListener(n._btnFltEdt,"click",(function(e){n._editFilter();e.preventDefault()}));n.addEventListener(n._btnFltClr,"click",(function(e){n._createFilterEditor();setTimeout((function(){n._eFlt.clearEditor();n._btnFltEdt.focus();enable(n._btnFltClr,!1)}));e.preventDefault()}));n.addEventListener(n._btnApply,"click",(function(e){n.updateField()}));n.initialize(i);return n}Object.defineProperty(PivotFieldEditor,"controlTemplate",{get:function(){PivotFieldEditor._ctrlTemplate||(PivotFieldEditor._ctrlTemplate='<div><div class="'+DetailDialogClsNames.dialogHeader+'" tabindex="-1"><span wj-part="g-dlg"></span> <span wj-part="sp-bnd"></span></div><div class="'+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="'+UtilitesClsNames.separator+'"><td wj-part="g-agg"></td><td><div wj-part="div-agg"></div></td></tr><tr class="'+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="'+UtilitesClsNames.separator+'"><td wj-part="g-flt"></td><td><div><button wj-part="btn-flt-edt" class="'+InputFormElementsClsNames.btn+'"></button> <button wj-part="btn-flt-clr" class="'+InputFormElementsClsNames.btn+'"></button></div></td></tr><tr class="'+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="'+DetailDialogClsNames.dialogFooter+'"><button wj-part="btn-apply" class="'+InputFormElementsClsNames.btn+" "+UtilitesClsNames.hide+'"></button> <button wj-part="btn-cancel" class="'+InputFormElementsClsNames.btn+" "+UtilitesClsNames.hide+'"></button></div></div>');return PivotFieldEditor._ctrlTemplate},set:function(e){PivotFieldEditor._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(PivotFieldEditor.prototype,"field",{get:function(){return this._fld},set:function(e){if(e!=this._fld){this._fld=asType(e,PivotField);this.updateEditor()}},enumerable:!0,configurable:!0});PivotFieldEditor.prototype.updateEditor=function(){var 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();var t=e.engine.defaultFilterType!=FilterType.None&&(null!=e.binding||isFunction(e.getValue));enable(this._btnFltEdt,t);enable(this._btnFltClr,t&&e.filter.isActive);this._cmbFmt.collectionView.refresh();this._cmbFmt.selectedValue=e.format;this._cmbFmt.selectedValue||(this._cmbFmt.text=e.format);var i=e instanceof CubePivotField;this._cmbAgg.isDisabled=i||!!e.getAggregateValue;this._cmbWFl.isDisabled=i}};PivotFieldEditor.prototype.updateField=function(){var e=this._fld;if(e){var t=this._cmbHdr.text.trim();e.header=t||toHeaderCase(e.binding);e.aggregate=this._cmbAgg.selectedValue;e.showAs=this._cmbShw.selectedValue;e.weightField=this._cmbWFl.selectedValue;e.descending=this._cmbSrt.selectedValue;var i=e.format;e.format=this._cmbFmt.selectedValue||this._cmbFmt.text;var n=this._eFlt;if(n){n.updateFilter();var o=e.dataType==DataType.Number,r=e.dataType==DataType.Date;if(i!=e.format&&(o||r)){var s=e.filter.valueFilter;if(s&&s.isActive&&!s.dataMap){var l={};if(o)for(var a in s.showValues){var d=Globalize.parseFloat(a);l[Globalize.format(d,e.format)]=!0}else if(r)for(var a in s.showValues){d=Globalize.parseDate(a,i);l[Globalize.format(d,e.format)]=!0}s.showValues=l}}}}};PivotFieldEditor.prototype._initAggregateOptions=function(){var e=this,t=culture.olap.PivotFieldEditor.aggs,i=Aggregate,n=[{key:t.sum,val:i.Sum,all:!1},{key:t.cnt,val:i.Cnt,all:!0},{key:t.avg,val:i.Avg,all:!1},{key:t.max,val:i.Max,all:!0},{key:t.min,val:i.Min,all:!0},{key:t.rng,val:i.Rng,all:!1},{key:t.std,val:i.Std,all:!1},{key:t.var,val:i.Var,all:!1},{key:t.stdp,val:i.StdPop,all:!1},{key:t.varp,val:i.VarPop,all:!1},{key:t.first,val:i.First,all:!0},{key:t.last,val:i.Last,all:!0}];this._cmbAgg.itemsSource=n;this._cmbAgg.collectionView.filter=function(t){if(t&&t.all)return!0;if(e._fld){var i=e._fld.dataType;return i==DataType.Number||i==DataType.Boolean}return!1};this._cmbAgg.initialize({displayMemberPath:"key",selectedValuePath:"val"})};PivotFieldEditor.prototype._initShowAsOptions=function(){var e=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"})};PivotFieldEditor.prototype._initFormatOptions=function(){var e=this,t=culture.olap.PivotFieldEditor.formats,i=[{key:t.n0,val:"n0",all:!0},{key:t.n2,val:"n2",all:!0},{key:t.c,val:"c",all:!0},{key:t.p0,val:"p0",all:!0},{key:t.p2,val:"p2",all:!0},{key:t.n2c,val:"n2,",all:!0},{key:t.n2cc,val:"n2,,",all:!0},{key:t.n2ccc,val:"n2,,,",all:!0},{key:t.d,val:"d",all:!1},{key:t.MMMMddyyyy,val:"MMMM dd, yyyy",all:!1},{key:t.dMyy,val:"d/M/yy",all:!1},{key:t.ddMyy,val:"dd/M/yy",all:!1},{key:t.dMyyyy,val:"dd/M/yyyy",all:!1},{key:t.MMMyyyy,val:"MMM yyyy",all:!1},{key:t.MMMMyyyy,val:"MMMM yyyy",all:!1},{key:t.yyyy,val:"yyyy",all:!1},{key:t.yyyyQq,val:'yyyy "Q"q',all:!1},{key:t.FYEEEEQU,val:'"FY"EEEE "Q"U',all:!1}];this._cmbFmt.itemsSource=i;this._cmbFmt.isEditable=!0;this._cmbFmt.isRequired=!1;this._cmbFmt.collectionView.filter=function(t){return!(!t||!t.all)||!!e._fld&&e._fld.dataType==DataType.Date};this._cmbFmt.initialize({displayMemberPath:"key",selectedValuePath:"val"})};PivotFieldEditor.prototype._initWeighByOptions=function(){var e=this._fld;if(e){var t=[{key:culture.olap.PivotFieldEditor.none,val:null}];e.engine.fields.forEach((function(i){i!=e&&i.dataType==DataType.Number&&t.push({key:i.header,val:i})}));this._cmbWFl.initialize({displayMemberPath:"key",selectedValuePath:"val",itemsSource:t,selectedValue:e.weightField})}};PivotFieldEditor.prototype._initSortOptions=function(){var e=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"})};PivotFieldEditor.prototype._updateFormat=function(){var e=ShowAs[this._cmbShw.selectedValue];this._cmbFmt.selectedValue=e.indexOf("Pct")>-1?"p0":"n0"};PivotFieldEditor.prototype._updatePreview=function(){var e=this._cmbFmt.selectedValue||this._cmbFmt.text,t=Globalize.format,i="";if(e){var n=e[0].toLowerCase();i="nfgxc".indexOf(n)>-1?t(1234.5678,e):t("p"==n?.12345678:this._pvDate,e)}this._cmbSmp.text=i};PivotFieldEditor.prototype._editFilter=function(){this._createFilterEditor();showPopup(this._dFlt,this._btnFltEdt,!1,!1,!1);moveFocus(this._dFlt,0)};PivotFieldEditor.prototype._createFilterEditor=function(){var e=this;if(!this._dFlt){this._dFlt=document.createElement("div");this._eFlt=new PivotFilterEditor(this._dFlt,this._fld);addClass(this._dFlt,DropDownClsNames.dropDownPanel);this._eFlt.lostFocus.addHandler((function(){setTimeout((function(){var t=Control.getControl(e._dFlt);t&&!t.containsFocus()&&e._closeFilter()}),10)}));this._eFlt.finishEditing.addHandler((function(){e._closeFilter();enable(e._btnFltClr,!e._eFlt.isEditorClear)}))}};PivotFieldEditor.prototype._closeFilter=function(){if(this._dFlt){hidePopup(this._dFlt,!0);this.focus()}};PivotFieldEditor._ctrlTemplate="";return PivotFieldEditor}(Control);export{PivotFieldEditor};_registerModule("wijmo.olap",selfModule);var PivotFieldBinding=function(e){__extends(PivotFieldBinding,e);function PivotFieldBinding(t,i){var n=e.call(this,i)||this;n._fld=t;return n}PivotFieldBinding.prototype.getValue=function(t){var i=this._fld;return isFunction(i.getValue)?i._getValue(t,!1):e.prototype.getValue.call(this,t)};return PivotFieldBinding}(Binding);export{PivotFieldBinding};
|