var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.checkStringArgs=function(a,b,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in c||(c[e]={});c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};
$jscomp.polyfill("String.prototype.startsWith",function(a){return a?a:function(a,c){var b=$jscomp.checkStringArgs(this,a,"startsWith");a+="";var e=b.length,h=a.length;c=Math.max(0,Math.min(c|0,b.length));for(var f=0;f<h&&c<e;)if(b[c++]!=a[f++])return!1;return f>=h}},"es6","es3");
zul.mesh.SortWidget=zk.$extends(zul.mesh.HeaderWidget,{_sortDirection:"natural",_sortAscending:"none",_sortDescending:"none",$define:{sortDirection:function(a){if(this.desktop){var b=jq(this.$n("sort-icon"));b.removeClass();switch(a){case "ascending":b.addClass("z-icon-caret-up");break;case "descending":b.addClass("z-icon-caret-down")}}},sortAscending:function(a){a||(this._sortAscending=a="none");if(this.desktop){var b=jq(this.$n("sort-icon"));"none"==a?b.removeClass():b.addClass("z-icon-caret-up")}},
sortDescending:function(a){a||(this._sortDescending=a="none");if(this.desktop){var b=jq(this.$n("sort-icon"));"none"==a?b.removeClass():b.addClass("z-icon-caret-down")}}},$init:function(){this.$supers("$init",arguments);this.listen({onSort:this},-1E3)},setSort:function(a){a&&a.startsWith("client")?(this.setSortAscending(a),this.setSortDescending(a)):(this.setSortAscending("none"),this.setSortDescending("none"))},isSortable_:function(){return"none"!=this._sortAscending||"none"!=this._sortDescending},
sort:function(a,b){if(!this.checkClientSort_(a))return!1;b.stop();this.replaceCavedChildrenInOrder_(a);return!0},checkClientSort_:function(a){var b=this.getSortDirection();if(a){if("ascending"==b)return!1}else if("descending"==b)return!1;a=a?this._sortAscending:this._sortDescending;if("fromServer"==a)return!1;if("none"==a)return evt.stop(),!1;a=this.getMeshWidget();return!a||a.isModel()?!1:!0},replaceCavedChildrenInOrder_:function(a){var b=this.getMeshWidget(),c=this.getMeshBody(),d=this.getSortDirection(),
e=a?this._sortAscending:this._sortDescending,h=c.desktop,f=c.$n();try{c.unbind();for(var g=[],q=this.getChildIndex(),k=0,n=0,r=b.getBodyWidgetIterator(),p;p=r.next();n++)for(var l=0,m=p.firstChild;m;m=m.nextSibling,l++)l==q&&(g[k++]={wgt:m,index:n});var t="ascending"==d?-1:1,u=this.sorting,v="client(number)"==e;g.sort(function(a,b){var c=u(a.wgt,b.wgt,v)*t;0==c&&(c=a.index<b.index?-1:1);return c});k=0;for(l=g.length;k<l;k++)c.appendChild(g[k].wgt.parent);this._fixDirection(a)}finally{c.replaceHTML(f,
h)}},sorting:function(a,b,c){a="function"==typeof a.getLabel?a.getLabel():"function"==typeof a.getValue?a.getValue():a;b="function"==typeof b.getLabel?b.getLabel():"function"==typeof b.getValue?b.getValue():b;return c?a-b:a>b?1:a<b?-1:0},_fixDirection:function(a){a=a?"ascending":"descending";for(var b=this.parent.firstChild;b;b=b.nextSibling)b.setSortDirection(b==this?a:"natural")},onSort:function(a){var b=this.getSortDirection();"ascending"==b?this.sort(!1,a):"descending"==b?this.sort(!0,a):this.sort(!0,
a)||this.sort(!1,a)},bind_:function(){this.$supers(zul.mesh.SortWidget,"bind_",arguments);if("none"!=this._sortAscending||"none"!=this._sortDescending){var a=jq(this.$n()),b=jq(this.$n("sort-icon"));a.addClass(this.$s("sort"));switch(this._sortDirection){case "ascending":b.addClass("z-icon-caret-up");break;case "descending":b.addClass("z-icon-caret-down")}}},unbind_:function(){this.$supers(zul.mesh.SortWidget,"unbind_",arguments)},getColumnMenuPopup_:zk.$void,_doMenuClick:function(a){if(this.parent._menupopup&&
"none"!=this.parent._menupopup){var b=this.parent._menupopup,c=this.$n("btn");jq(this.$n()).addClass(this.$s("visited"));b="auto"==b&&this.parent._mpop?this.parent._mpop:this.$f(this.parent._menupopup);if(zul.menu.Menupopup.isInstance(b)){var d=zk(c).revisedOffset(),e="none"!=this.getSortAscending(),h="none"!=this.getSortDescending(),f=this.getMeshWidget();if(b.$instanceof(zul.mesh.ColumnMenupopup)){b.getAscitem().setVisible(e);b.getDescitem().setVisible(h);var g=f.getModel();zk.feature.pe&&b.getGroupitem()&&
("group"==g||!g||this.isListen("onGroup",{asapOnly:1})?b.getGroupitem().setVisible(e||h):b.getGroupitem().setVisible(!1));zk.feature.ee&&b.getUngroupitem()&&(g=!g||this.isListen("onUngroup",{asapOnly:1}),b.getUngroupitem().setVisible(g&&f.hasGroup()));(f=b.getDescitem().nextSibling)&&f.setVisible(e||h)}else b.listen({onOpen:[this.parent,this.parent._onMenuPopup]});b.open(c,[d[0],d[1]+c.offsetHeight-4],null,{sendOnOpen:!0})}a.stop()}}});
