// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
require({cache:{"url:widgets/NetworkTrace/setting/summarySettingSelector.html":'\x3cdiv class\x3d"summarySelector"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"showSummarySettingsButton" class\x3d"jimu-icon jimu-icon-add esriCTHover"\r\n        title\x3d"${nls.summaryTab.addSummaryItemsTitle}"\x3e\r\n    \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dijit/_WidgetsInTemplateMixin dijit/_WidgetBase dijit/_TemplatedMixin dojo/text!./summarySettingSelector.html dijit/TooltipDialog dijit/popup dojo/_base/lang dojo/_base/html dojo/on dojo/dom-construct dijit/form/Select".split(" "),function(q,r,t,u,v,w,n,k,x,l,e,p){return q([t,u,r],{baseClass:"jimu-widget-NetworkTrace-setting",templateString:v,_isTooltipDialogOpened:!1,startup:function(){this.inherited(arguments)},postCreate:function(){this._createTooltipDialog(this.domNode);
this._hideTooltipDialog()},destroy:function(){this.tooltipDialog&&(n.close(this.tooltipDialog),this.tooltipDialog.destroy());this.inherited(arguments)},_showTooltipDialog:function(){n.open({parent:this.getParent(),popup:this.tooltipDialog,around:this.domNode});this._isTooltipDialogOpened=!0},_hideTooltipDialog:function(){n.close(this.tooltipDialog);this._isTooltipDialogOpened=!1},_createTooltipDialog:function(){var b=this._createSummarySettingOptions();this.tooltipDialog=new w({content:b,baseClass:"jimu-widget-NetworkTrace-setting"});
this.own(l(this.domNode,"click",k.hitch(this,function(a){a.stopPropagation();a.preventDefault();this._isTooltipDialogOpened?this._hideTooltipDialog():this._showTooltipDialog()})))},_createSummarySettingOptions:function(){var b=e.create("div",{"class":"esriCTSummarySettingSelector"});e.create("div",{innerHTML:this.nls.summaryTab.addSummaryItemsTitle,"class":"esriCTOutputHeaderLabel"},b);for(var a=[],d=0;d<this.inputOutputParamArray.length;d++)a.push({label:this.inputOutputParamArray[d].name,value:this.inputOutputParamArray[d].name,
defaultValue:this.inputOutputParamArray[d].defaultValue,selected:0===d?!0:!1});d=e.create("table",{"class":"esriCTPopupTable"},b);var f=e.create("tr",{},d);e.create("td",{innerHTML:this.nls.summaryTab.inputOutput},f);f=e.create("td",{},f);f=e.create("div",{"class":"esriCTDropDownContainer"},f);this.outputSelect=new p({options:a,"class":"esriCTSummaryExpressionSelect"});this.outputSelect.placeAt(f);a=e.create("tr",{},d);e.create("td",{innerHTML:this.nls.summaryTab.operator},a);a=e.create("td",{},a);
a=e.create("div",{"class":"esriCTDropDownContainer"},a);this.operatorSelect=new p({options:[],"class":"esriCTSummaryExpressionSelect"});this.operatorSelect.placeAt(a);this.own(l(this.operatorSelect,"change",k.hitch(this,function(){this.operatorSelect.get("value")===this.nls.summaryTab.outputOperatorCountOption?this.fieldSelect.set("disabled",!0):this.fieldSelect.set("disabled",!1)})));a=e.create("tr",{},d);e.create("td",{innerHTML:this.nls.summaryTab.field},a);a=e.create("td",{},a);a=e.create("div",
{"class":"esriCTDropDownContainer"},a);this.fieldSelect=new p({options:[],"class":"esriCTSummaryExpressionSelect"});this.fieldSelect.placeAt(a);d=e.create("tr",{},d);d=e.create("td",{colspan:"2"},d);a=e.create("div",{"class":"esriCTButtonContainer"},d);d=e.create("div",{"class":"jimu-btn jimu-float-leading esriCTAddButtonMargin",innerHTML:this.nls.summaryTab.expressionAddButtonText},a);a=e.create("div",{"class":"jimu-btn jimu-float-trailing",innerHTML:this.nls.common.cancel},a);this.own(l(a,"click",
k.hitch(this,this._hideTooltipDialog)));this.own(l(document.body,"click",k.hitch(this,function(c){this.isPartOfPopup(c.target||c.srcElement,b)||this._hideTooltipDialog()})));this.own(l(d,"click",k.hitch(this,this._addExpression)));this.outputSelect.startup();this.own(this.outputSelect.on("change",k.hitch(this,this._onOutputDropDownChange)));this._onOutputDropDownChange(this.outputSelect.getValue());return b},_onOutputDropDownChange:function(b){var a=this.fieldSelect,d=this.operatorSelect,f=this.inputOutputParamArray,
c=[];for(c=0;c<f.length;c++)if(f[c].name===b){b=[];if(f[c].defaultValue&&f[c].defaultValue.fields)var g=f[c].defaultValue.fields;if(g&&0<g.length)for(var h=0;h<g.length;h++)if("esriFieldTypeDouble"===g[h].type||"esriFieldTypeSmallInteger"===g[h].type||"esriFieldTypeInteger"===g[h].type){var m=e.create("option",{});m.innerHTML=g[h].name;m.value=g[h].name;m.title=g[h].name;b.push(m)}0<b.length?c="Input"===f[c].type?this._getOperatorOptions(!0,!1,!1,!1):this._getOperatorOptions(!1,!1,!0,!1):(b=[{label:"",
value:"",selected:!0}],c=this._getOperatorOptions(!0,!1,!1,!1));a.set("options",b);a.set("disabled",!0);d.set("options",c);a.startup();d.startup();break}},_addExpression:function(){this._editorObj.focus();var b="";""!==this.outputSelect.get("value")&&(b=""!==b?b+":"+this.outputSelect.get("value"):this.outputSelect.get("value"));""===this.fieldSelect.get("value")||this.fieldSelect.get("disabled")||(b=""!==b?b+":"+this.fieldSelect.get("value"):this.fieldSelect.get("value"));""!==this.operatorSelect.get("value")&&
(b=""!==b?b+":"+this.operatorSelect.get("value"):this.operatorSelect.get("value"));this._editorObj.execCommand("inserthtml","{"+b+"}")},_getOperatorOptions:function(b,a,d,f){var c=[];b?c.push({label:this.nls.summaryTab.inputOperatorCountOption,value:this.nls.summaryTab.inputOperatorCountOption,selected:!0}):a?(c.push({label:this.nls.summaryTab.outputOperatorCountOption,value:this.nls.summaryTab.outputOperatorCountOption,selected:!0}),f&&c.push({label:this.nls.summaryTab.outputOperatorSkipCountOption,
value:this.nls.summaryTab.outputOperatorSkipCountOption,selected:!1})):d&&(c.push({label:this.nls.summaryTab.outputOperatorCountOption,value:this.nls.summaryTab.outputOperatorCountOption,selected:!0}),c.push({label:this.nls.summaryTab.fieldOperatorSumOption,value:this.nls.summaryTab.fieldOperatorSumOption,selected:!0}),c.push({label:this.nls.summaryTab.fieldOperatorMinOption,value:this.nls.summaryTab.fieldOperatorMinOption,selected:!1}),c.push({label:this.nls.summaryTab.fieldOperatorMaxOption,value:this.nls.summaryTab.fieldOperatorMaxOption,
selected:!1}),c.push({label:this.nls.summaryTab.fieldOperatorMeanOption,value:this.nls.summaryTab.fieldOperatorMeanOption,selected:!1}));return c},isPartOfPopup:function(b,a){return b===a||x.isDescendant(b,a)}})});