define(["Ti/_/declare","Ti/_/UI/FontWidget","Ti/_/dom","Ti/UI","Ti/_/has","Ti/_/style","Ti/_/lang"],function(t,e,i,o,n,r,s){var h=r.set,a=15,d=require.on;return t("Ti.UI.PickerColumn",e,{constructor:function(){var t=this,e=n("touch")?"touchend":"click",r=t.domNode,s=t.__values__.constants.rows=[],h=t._upArrow=i.create("div",{className:"TiUIElementGradient",style:{textAlign:"center",position:"absolute",top:0,height:"40px",left:0,right:0,borderBottom:"1px solid #666",fontSize:"28px",cursor:"pointer"},innerHTML:"∧"},r),a=t._titleContainer=i.create("div",{style:{position:"absolute",top:"50%",height:"1em",width:"100%",marginTop:"-0.5em",textAlign:"center"}},r),l=i.create("div",{style:{position:"absolute",top:"40px",bottom:"40px",width:"100%"}},r),c=t._downArrow=i.create("div",{className:"TiUIElementGradient",innerHTML:"∨",style:{textAlign:"center",position:"absolute",bottom:"0px",height:"40px",width:"100%",borderTop:"1px solid #666",fontSize:"28px",cursor:"pointer"}},r);t._addStyleableDomNode(a),this._handles=[d(h,e,function(){var e=s.indexOf(t.selectedRow);t.selectedRow=e>0?s[e-1]:s[s.length-1]}),d(l,e,function(){var e=o.createWindow(),i=o.createView({backgroundColor:"#000",opacity:0,left:0,top:0,right:0,bottom:0}),n=o.createView({width:"75%",height:o.SIZE,backgroundColor:"#fff",layout:o._LAYOUT_CONSTRAINING_VERTICAL,borderRadius:3,opacity:0}),r=0,h=0,a=s.map(function(e){var i=e===t.selectedRow;return i&&(r=parseInt(h++)),{title:e.title,hasCheck:i}}),d=o.createTableView({left:5,right:5,top:5,height:a.length<10?o.SIZE:"70%",data:a}),l=o.createButton({left:5,top:5,right:5,title:"Cancel"});d.addEventListener("singletap",function(i){i.index in s&&(t.selectedRow=s[i.index]),e.close()}),l.addEventListener("singletap",function(){e.close()}),e._add(i),e._add(n),n._add(d),n._add(l),n._add(o.createView({height:"5px"})),e.open(),setTimeout(function(){i.animate({opacity:.5,duration:200},function(){n.animate({opacity:1,duration:200},function(){d.scrollToIndex(r)})})},30)}),d(c,e,function(){var e=s.indexOf(t.selectedRow);t.selectedRow=e<s.length-1?s[e+1]:s[0]})]},destroy:function(){event.off(this._handles),e.prototype.destroy.apply(this,arguments)},_setCorners:function(t,e,i){h(this._upArrow,{borderTopLeftRadius:t?i:"0px",borderTopRightRadius:e?i:"0px"}),h(this._downArrow,{borderBottomLeftRadius:t?i:"0px",borderBottomRightRadius:e?i:"0px"}),this.borderWidth=[0,e?0:1,0,0],this.borderColor="#666"},_defaultWidth:o.SIZE,_defaultHeight:o.SIZE,_preLayout:function(){return this._updateContentWidth(),this._parentPicker&&this._parentPicker._updateColumnHeights(),!0},_getContentSize:function(){var t=this._titleContainer;return text=t.innerHTML,{width:Math.max(this._widestRowWidth+a,100),height:this._tallestRowHeight+a+this._upArrow.clientHeight+this._downArrow.clientHeight}},_widestRowWidth:0,_tallestRowHeight:0,_updateContentWidth:function(){for(var t,e=0,i=0,o=this.rows.length;o>i;)t=this.rows[i++],e=Math.max(e,t._measureText(t.title,t.domNode).width);this._widestRowWidth!==e&&(this._widestRowWidth=e)},_getTallestRowHeight:function(){for(var t=0,e=0,i=this.rows.length;i>e;e++){var o=this.rows[e];t=Math.max(t,o._measureText(o.title,o.domNode).height)}return t},_setTallestRowHeight:function(t){this._tallestRowHeight!==t&&(this._tallestRowHeight=t,this._triggerLayout())},addRow:function(t){this.rows.push(t),t._parentColumn=this,this._updateContentWidth(),this._parentPicker&&this._parentPicker._updateColumnHeights(),this.selectedRow||(this.selectedRow=t),this._publish(t)},removeRow:function(t){var e=this.rows.indexOf(t);-1!==e&&(this.rows.splice(e,1),t._parentColumn=void 0,this._updateContentWidth(),this._parentPicker&&this._parentPicker._updateColumnHeights(),this.selectedRow===t&&(this.selectedRow=this.rows[0])),this._unpublish(t)},constants:{rowCount:{get:function(){return this.rows.length}},rows:void 0},properties:{selectedRow:{set:function(t){if(t){var e=this.rows.indexOf(t);if(-1===e)return;this.font=t.font,this.color=s.val(t.color,""),this._titleContainer.innerHTML=t.title,this._hasSizeDimensions()&&this._triggerLayout()}else this.font=void 0,this.color=void 0,this._titleContainer.innerHTML="",this._hasSizeDimensions()&&this._triggerLayout();return t},post:function(t){this.fireEvent("change",{column:this,rowIndex:this.rows.indexOf(t),row:t,value:t&&t.title})}}}})});