(function(){function k(a){return zk.isLoaded("zkex.sel")&&a.$instanceof(zkex.sel.Listgroup)}function h(a){a._nativebar&&(a=a.frozen)&&a._syncFrozen()}function l(a){if(a.desktop){var b=a.$n("empty"),c=0;if(a._nrows)b.style.display="none";else{if(a.listhead)for(var d=a.listhead.firstChild;d;d=d.nextSibling)c++;b.colSpan=c||1;b.style.display="table-cell"}}a._shallFixEmpty=!1}var f=zul.sel.Listbox=zk.$extends(zul.sel.SelectWidget,{_nrows:0,groupSelect:!1,_scrollbar:null,$define:{emptyMessage:function(a){if(this.desktop){var b=
jq(this.$n("empty-content")),c=this.$s("emptybody-content");a&&0!=a.trim().length?b.addClass(c):b.removeClass(c);b.html(a)}}},$init:function(){this.$supers(f,"$init",arguments);this._groupsInfo=[]},getGroupCount:function(){return this._groupsInfo.length},getGroups:function(){return this._groupsInfo.$clone()},hasGroup:function(){return this._groupsInfo.length},nextItem:function(a){if(a)for(;(a=a.nextSibling)&&!a.$instanceof(zul.sel.Listitem););return a},previousItem:function(a){if(a)for(;(a=a.previousSibling)&&
!a.$instanceof(zul.sel.Listitem););return a},getOddRowSclass:function(){return null==this._scOddRow?this.$s("odd"):this._scOddRow},setOddRowSclass:function(a){a||(a=null);this._scOddRow!=a&&(this._scOddRow=a,this.$n()&&this.rows&&this.stripe());return this},inSelectMold:function(){return"select"==this.getMold()},onSize:function(){this.$supers(f,"onSize",arguments);var a=this,b=this.desktop&&!this.inSelectMold()&&!this._nativebar;!this._scrollbar&&b&&(!zk.mobile||zk.mobile&&(this.getHeight()||this.getVflex()))&&
(this._scrollbar=zul.mesh.Scrollbar.init(this));setTimeout(function(){a.desktop&&(b&&a.refreshBar_(),a._syncSelInView())},300)},destroyBar_:function(){var a=this._scrollbar;a&&(a.destroy(),this._scrollbar=null)},bind_:function(a,b,c){this.$supers(f,"bind_",arguments);this._shallStripe=!0;var d=this;c.push(function(){d.stripe();h(d);l(d)});this._shallScrollIntoView=!0;this._listbox$shallUpdateScrollPos&&this._fireOnScrollPos();zWatch.listen({onCommandReady:this})},unbind_:function(){zWatch.unlisten({onCommandReady:this});
this.destroyBar_();this.$supers(f,"unbind_",arguments)},_syncSelInView:function(){if(this._shallScrollIntoView){if(!this.paging||this.$class.shallSyncSelInView&&this.$class.shallSyncSelInView[this.uuid]||this._listbox$shallSyncSelInView){for(var a=this._selItems,b=-1,c=0;c<a.length;c++)if(a[c]._index<b||0>b)b=c;a=a[b];b=this._listbox$shallSyncSelInView;if(a){c=this._scrollbar;var d=a.$n().offsetTop;c?b?c.scrollToElement(a.$n()):c.scrollTo(zul.mesh.Scrollbar.getScrollPosH(this),d):(b?zk(a).scrollIntoView(this.ebody):
this.ebody.scrollTop=d,this._tmpScrollTop=this.ebody.scrollTop)}this.$class.shallSyncSelInView&&(this.$class.shallSyncSelInView[this.uuid]=!1);b&&(this._listbox$shallSyncSelInView=!1)}this._shallScrollIntoView=!1}},_doScroll:function(){this._tmpScrollTop&&(this.ebody.scrollTop=this._tmpScrollTop,this._tmpScrollTop=null);this.$super(zul.sel.Listbox,"_doScroll")},onCommandReady:function(){this._shallStripe&&this.stripe()},onResponse:function(a,b){this.desktop&&this._shallFixEmpty&&l(this);this.$supers(f,
"onResponse",arguments)},_syncStripe:function(){this._shallStripe=!0},stripe:function(){var a=this.getOddRowSclass();if(a){for(var b=!(this._offset&1),c=this.getBodyWidgetIterator(),d=0,e;e=c.next();d++)e.isVisible()&&e.isStripeable_()&&(jq(e)[b?"removeClass":"addClass"](a),b=!b);this._shallStripe=!1;return this}},rerender:function(){this.$supers(f,"rerender",arguments);this._syncStripe();return this},getCaveNode:function(){return this.$n("rows")||this.$n("cave")},insertChildHTML_:function(a,b,c){(b=
!b||a.$instanceof(zul.sel.Listitem)&&!b.$instanceof(zul.sel.Listitem)?null:b.getFirstNode_())?jq(b).before(a.redrawHTML_()):jq(this.getCaveNode()).append(a.redrawHTML_());a.bind(c)},insertBefore:function(a,b,c){if(this.$super("insertBefore",a,b,c||!this.z_rod&&!a.$instanceof(zul.sel.Listitem)))return this._fixOnAdd(a,c),!0},appendChild:function(a,b){if(this.$super("appendChild",a,b||!this.z_rod&&!a.$instanceof(zul.sel.Listitem)))return this.insertingBefore_||this._fixOnAdd(a,b),!0},_fixOnAdd:function(a,
b,c,d){if(a.$instanceof(zul.sel.Listitem)){k(a)&&this._groupsInfo.push(a);this.firstItem&&this.previousItem(a)||(this.firstItem=a);this.lastItem&&this.nextItem(a)||(this.lastItem=a);++this._nrows;a.isSelected()&&!this._selItems.$contains(a)&&this._selItems.push(a);var e=c=!0}else a.$instanceof(zul.sel.Listhead)?this.listhead=a:a.$instanceof(zul.mesh.Paging)?this.paging=a:a.$instanceof(zul.sel.Listfoot)?this.listfoot=a:a.$instanceof(zul.mesh.Frozen)&&(this.frozen=a);this._syncEmpty();if(!d){if(!b&&
!e)return this.rerender();c&&this._syncStripe();b||this._syncSize();this.desktop&&h(this)}},removeChild:function(a,b){if(this.$super("removeChild",a,b))return this._fixOnRemove(a,b),!0},_fixOnRemove:function(a,b){if(a==this.listhead)this.listhead=null;else if(a==this.paging)this.paging=null;else if(a==this.frozen)this.frozen=null,this.destroyBar_();else if(a==this.listfoot)this.listfoot=null;else if(!a.$instanceof(zul.mesh.Auxhead)){if(a==this.firstItem){var c=this.firstChild;for(var d=zul.sel.Listitem;c&&
!c.$instanceof(d);c=c.nextSibling);this.firstItem=c}if(a==this.lastItem){c=this.lastChild;for(d=zul.sel.Listitem;c&&!c.$instanceof(d);c=c.previousSibling);this.lastItem=c}k(a)&&this._groupsInfo.$remove(a);--this._nrows;a.isSelected()&&this._selItems.$remove(a);c=!0}this._syncEmpty();b||(c&&this._syncStripe(),this._syncSize())},redrawEmpty_:function(a){a.push('<tbody class="',this.$s("emptybody"),'"><tr><td id="',this.uuid,'-empty" style="display:none">','<div id="',this.uuid,'-empty-content"');this._emptyMessage&&
0!=this._emptyMessage.trim().length&&a.push('class="',this.$s("emptybody-content"),'"');a.push(">",this._emptyMessage,"</div></td></tr></tbody>")},replaceChildHTML_:function(a,b,c,d,e){if(a._renderdefer){var g=this.getOddRowSclass(),m=jq(b).hasClass(g);this.$supers("replaceChildHTML_",arguments);m&&jq(a).addClass(g)}else this.$supers("replaceChildHTML_",arguments)},_syncEmpty:function(){this._shallFixEmpty=!0},onChildReplaced_:function(a,b){this.$supers(f,"onChildReplaced_",arguments);a&&this._fixOnRemove(a,
!0);b&&this._fixOnAdd(b,!0,!1,!0);(a&&a.$instanceof(zul.sel.Listitem)||b&&b.$instanceof(zul.sel.Listitem))&&this._syncStripe();this._syncSize();this.desktop&&h(this)},getHeadWidgetClass:function(){return zul.sel.Listhead},itemIterator:_zkf=function(a){return new zul.sel.ItemIter(this,a)},getBodyWidgetIterator:_zkf,_updHeaderCM:function(){var a;this._headercm&&this._multiple&&(a=this.listhead)&&(a=a.firstChild)&&(a._checked=this._isAllSelected());this.$supers(f,"_updHeaderCM",arguments)},checkOnHighlightDisabled_:function(){if(this._selectOnHighlightDisabled){var a=
window.getSelection||document.selection;if(a)return 0<a().toString().length}},scrollToIndex:function(a,b){var c=this;this.waitForRendered_().then(function(){c._scrollToIndex(a,b)})},_getFirstItemIndex:function(){return this.firstItem._index},_getLastItemIndex:function(){return this.lastItem._index},setItemsInvalid_:function(a){var b=this;zAu.createWidgets(a,function(c){if(b.$n("rows"))b.replaceCavedChildren_("rows",c);else{for(var d,e=b.firstItem;e;){var g=b.nextItem(e);g||(d=e.nextSibling);b.removeChild(e,
!0);e=g}e=0;for(g=c.length;e<g;++e)b.insertBefore(c[e],d,!0)}},function(c){for(var d=c,e=c;d;e=d,d=d.parent)if(d==b&&e.$instanceof(zul.sel.Listitem))return null;return c})}});zul.sel.ItemIter=zk.$extends(zk.Object,{$init:function(a,b){this.box=a;this.opts=b},_init:function(){if(!this._isInit){this._isInit=!0;var a=this.box.firstItem;if(this.opts&&this.opts.skipHidden)for(;a&&!a.isVisible();a=this.box.nextItem(a));this.p=a}},hasNext:function(){this._init();return this.p},next:function(){this._init();
var a=this.p,b=a?a.parent.nextItem(a):null;if(this.opts&&this.opts.skipHidden)for(;b&&!b.isVisible();b=b.parent.nextItem(b));a&&(this.p=b);return a}})})();
