// 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/Query/setting/PopupConfig.html":'\x3cdiv\x3e\r\n\t\x3cdiv style\x3d"margin-top:15px;margin-bottom:10px;"\x3e\r\n\t\t\x3cfieldset id\x3d"popupcontent"\x3e\r\n\t\t\t\x3cdiv class\x3d"radio-label-container radio-div portal-radio-div"\x3e\r\n\t\t\t\t\x3cinput name\x3d"popupcontent" data-dojo-type\x3d"dijit/form/RadioButton" data-dojo-attach-point\x3d"portalRadio" class\x3d"jimu-radio-btn"/\x3e\r\n\t\t\t\t\x3clabel data-dojo-attach-point\x3d"portalLabel"\x3e${nls.webMapPopupTip}\x3c/label\x3e\r\n\t\t\t\x3c/div\x3e\r\n\t\t\t\x3cdiv class\x3d"radio-label-container radio-div custom-radio-div" style\x3d"margin-top:10px;"\x3e\r\n\t\t\t\t\x3cinput name\x3d"popupcontent" data-dojo-type\x3d"dijit/form/RadioButton" data-dojo-attach-point\x3d"customRadio" class\x3d"jimu-radio-btn"/\x3e\r\n\t\t\t\t\x3clabel data-dojo-attach-point\x3d"customLabel"\x3e${nls.customPopupTip}\x3c/label\x3e\r\n\t\t\t\x3c/div\x3e\r\n\t\t\x3c/fieldset\x3e\r\n\t\x3c/div\x3e\r\n\t\x3ctable class\x3d"title-sorting-table"\x3e\r\n\t\t\x3ccolgroup\x3e\r\n\t\t\t\x3ccol width\x3d"auto"\x3e\x3c/col\x3e\r\n\t\t\t\x3ccol width\x3d"38px"\x3e\x3c/col\x3e\r\n\t\t\x3c/colgroup\x3e\r\n\t\t\x3ctbody\x3e\r\n\t\t\t\x3ctr class\x3d"indent-tr"\x3e\r\n\t\t\t\t\x3ctd colspan\x3d"2" class\x3d"indent-td" style\x3d"padding-bottom:4px;"\x3e\r\n\t\t\t\t\t\x3cspan class\x3d"light-stress"\x3e${nls.resultItemTitle}:\x3c/span\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\x3c/tr\x3e\r\n\t\t\t\x3ctr class\x3d"indent-tr"\x3e\r\n\t\t\t\t\x3ctd class\x3d"indent-td"\x3e\r\n\t\t\t\t\t\x3cdiv data-dojo-attach-point\x3d"titleTextBox" data-dojo-type\x3d"dijit/form/ValidationTextBox"\r\n\t\t\t\t\tdata-dojo-props\x3d\'required:true,trim:true\' style\x3d"width:100%;" /\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\t\x3ctd\x3e\r\n\t\t\t\t\t\x3cdiv data-dojo-attach-point\x3d"btnAddFields" data-dojo-attach-event\x3d"onclick:_onAddClicked" class\x3d"setting-btn btn-add-fields jimu-float-trailing"\x3e\r\n\t\t\t\t\t\t\x3cdiv class\x3d"jimu-icon jimu-icon-add"\x3e\x3c/div\x3e\r\n\t\t\t\t\t\x3c/div\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\x3c/tr\x3e\r\n\t\t\t\x3ctr class\x3d"indent-tr"\x3e\r\n\t\t\t\t\x3ctd colspan\x3d"2" class\x3d"indent-td" style\x3d"padding-top:10px;padding-bottom:4px;"\x3e\r\n\t\t\t\t\t\x3cspan class\x3d"light-stress"\x3e${nls.resultItemContent}:\x3c/span\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\x3c/tr\x3e\r\n\t\t\t\x3ctr class\x3d"indent-tr"\x3e\r\n\t\t\t\t\x3ctd class\x3d"indent-td"\x3e\r\n\t\t\t\t\t\x3cdiv data-dojo-attach-point\x3d"displayFieldsTextBox" class\x3d"display-fields-textbox" data-dojo-type\x3d"dijit/form/ValidationTextBox"\r\n\t\t\t\t\tdata-dojo-props\x3d\'required:true,trim:true,disabled:true\' style\x3d"width:100%;" /\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\t\x3ctd\x3e\r\n\t\t\t\t\t\x3cdiv data-dojo-attach-point\x3d"btnSetDisplayFields" class\x3d"setting-btn btn-display-fields jimu-float-trailing" data-dojo-attach-event\x3d"onclick:_onBtnSetDisplayFieldsClicked"\x3e\r\n\t\t\t\t\t\t\x3cdiv class\x3d"jimu-icon jimu-icon-edit"\x3e\x3c/div\x3e\r\n\t\t\t\t\t\x3c/div\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\x3c/tr\x3e\r\n\t\t\t\x3ctr\x3e\r\n\t\t\t\t\x3ctd colspan\x3d"2" style\x3d"padding-top:15px;padding-bottom:7px;"\x3e\r\n\t\t\t\t\t\x3cspan class\x3d"light-stress"\x3e${nls.sortingFields}:\x3c/span\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\x3c/tr\x3e\r\n\t\t\t\x3ctr\x3e\r\n\t\t\t\t\x3ctd data-dojo-attach-point\x3d"tdSortFields"\x3e\r\n\t\t\t\t\t\x3cdiv data-dojo-attach-point\x3d"sortFieldsDiv" class\x3d"sort-fields-div jimu-ellipsis"\x3e\x3c/div\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\t\x3ctd\x3e\r\n\t\t\t\t\t\x3cdiv data-dojo-attach-point\x3d"btnSortFields" class\x3d"setting-btn btn-sort-fields jimu-float-trailing" data-dojo-attach-event\x3d"onclick:_onBtnSortFieldsClicked"\x3e\r\n\t\t\t\t\t\t\x3cdiv class\x3d"jimu-icon jimu-icon-edit" data-dojo-attach-point\x3d"sortFieldsIcon"\x3e\x3c/div\x3e\r\n\t\t\t\t\t\x3c/div\x3e\r\n\t\t\t\t\x3c/td\x3e\r\n\t\t\t\x3c/tr\x3e\r\n\t\t\x3c/tbody\x3e\r\n\t\x3c/table\x3e\r\n\t\x3cdiv data-dojo-attach-point\x3d"displayFieldsSection" style\x3d"display:none;"\x3e\r\n\t\t\x3cdiv data-dojo-attach-point\x3d"displayFieldsDiv"\x3e\r\n\t\t\t\x3cdiv style\x3d"margin-top:7px;margin-bottom:8px;font-size:12px;"\x3e${nls.fieldsSetTip}\x3c/div\x3e\r\n\t\t  \x3cdiv data-dojo-attach-point\x3d"fieldsContainer"\x3e\x3c/div\x3e\r\n\t\t\x3c/div\x3e\r\n\t\x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dijit/_WidgetBase dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin dojo/text!./PopupConfig.html dojo/_base/lang dojo/_base/html dojo/_base/array dojo/on dojo/query jimu/utils jimu/dijit/SimpleTable jimu/dijit/Popup dijit/TooltipDialog dijit/Menu dijit/MenuItem dijit/popup ./SortFields ../utils".split(" "),function(x,y,z,A,B,c,h,k,q,r,l,C,t,D,E,u,m,F,v){return x([y,z,A],{baseClass:"jimu-query-setting-popup-config",templateString:B,_currentOrderByFields:null,_validSortFieldTypes:"esriFieldTypeOID esriFieldTypeString esriFieldTypeDate esriFieldTypeSmallInteger esriFieldTypeInteger esriFieldTypeSingle esriFieldTypeDouble".split(" "),
nls:null,sqs:null,postCreate:function(){this.inherited(arguments);this.own(q(this.portalRadio,"change",c.hitch(this,this._updateClassWhenRadioChanged)));this._currentOrderByFields=[];this._initFieldsTable();this._initAddFields();this.onLayerChange(!0);this._updateClassWhenRadioChanged()},onLayerChange:function(a){this._clear();a?this.portalRadio.set("disabled",!1):this.portalRadio.set("disabled",!0);this._updateClassWhenRadioChanged();if(a=this._getLayerDefinition()){this._clear();var b={popupInfo:null,
orderByFields:[]};b.popupInfo=this._getDefaultPopupInfo();this.setConfig(b);this._updateSortingIcon(a)}},setConfig:function(a){this._clear();this.config=c.clone(a);var b=this._getLayerDefinition();b&&(this._updateSortingIcon(b),this._setPopupInfoForUI(a.popupInfo),this._setOrderByFields(a.orderByFields))},getConfig:function(){var a={popupInfo:this._getPopupInfoByUI(),orderByFields:this._getOrderByFields()};return a.popupInfo?a:null},destroy:function(){this.sqs=null;this.titleTextBox.focusNode.blur();
this.inherited(arguments)},_clear:function(){h.addClass(this.sortFieldsIcon,"jimu-state-disabled");this._currentOrderByFields=[];this.titleTextBox.set("value","");this.displayFieldsTextBox.set("value","");this.fieldsTable.clear();this._resetMenu();this._addEmptyMenuItem()},_getLayerDefinition:function(){return this.sqs._layerDefinition},_updateClassWhenRadioChanged:function(){!this.portalRadio.disabled&&this.portalRadio.checked?h.addClass(this.domNode,"portal-radio-selected"):h.removeClass(this.domNode,
"portal-radio-selected")},_setPopupInfoForUI:function(a){var b=this._getDefaultPopupInfo();this._setCustomPopupInfoForUI(b);!this.portalRadio.disabled&&a.readFromWebMap?(this.customRadio.set("checked",!1),this.portalRadio.set("checked",!0)):(this.portalRadio.set("checked",!1),this.customRadio.set("checked",!0),this._setCustomPopupInfoForUI(a));this._updateClassWhenRadioChanged()},_setCustomPopupInfoForUI:function(a){var b=this._getLayerDefinition(),d=v.getPortalFieldInfosWithoutShape(b,a.fieldInfos);
a.title&&"string"===typeof a.title?this.titleTextBox.set("value",a.title||""):this.titleTextBox.set("value","");this._updateDisplayFieldsTextBox(d);var g=[],e=k.map(b.fields,c.hitch(this,function(f){return f.name}));k.forEach(a.mediaInfos,c.hitch(this,function(f){if(0<e.length&&"image"===f.type&&f.value){var n=f.value.sourceURL,p=null;k.some(e,c.hitch(this,function(w){return"{"+w+"}"===n?(p=w,!0):!1}));p&&g.push(p)}}));this._resetMenu();this.fieldsTable.clear();0<d.length?k.forEach(d,c.hitch(this,
function(f){this._addMenuItem(f);var n=0<=g.indexOf(f.fieldName);this._addRow(f,n)})):this._addEmptyMenuItem()},_updateDisplayFieldsTextBox:function(a){a=k.filter(a,c.hitch(this,function(b){return b.visible}));a=k.map(a,function(b){return b.label}).join(";  ");this.displayFieldsTextBox.set("value",a)},_addRow:function(a,b){a=c.clone(a);a.specialType=b?"image":"none";this.fieldsTable.addRow(a)},_addMenuItem:function(a){var b=new u({label:a.fieldName+" {"+a.fieldName+"}",onClick:c.hitch(this,function(){var d=
this.titleTextBox.get("value")+"{"+a.fieldName+"}";this.titleTextBox.set("value",d);d=this.menu.getParent();h.setStyle(d.domNode.parentNode,"display","none")})});this.menu.addChild(b)},_addEmptyMenuItem:function(){var a=new u({label:this.nls.noField,onClick:c.hitch(this,function(){var b=this.menu.getParent();h.setStyle(b.domNode.parentNode,"display","none")})});this.menu.addChild(a)},_getPopupInfoByUI:function(){var a=null;if(this.customRadio.checked){if(a=this._getCustomPopupInfoByUI())a.readFromWebMap=
!1}else a={readFromWebMap:!0};return a},_getCustomPopupInfoByUI:function(){var a={title:"",fieldInfos:[],description:null,showAttachments:!1,mediaInfos:[]},b=this._getLayerDefinition();if(!this.titleTextBox.validate())return this.sqs.showResultsSetting(),this.sqs.scrollToDom(this.titleTextBox.domNode),l.showValidationErrorTipForFormDijit(this.titleTextBox),null;a.title=this.titleTextBox.get("value");a.showAttachments=!!b.hasAttachments;b=this._getPortalFieldInfosAndMediaInfosByUI();a.fieldInfos=b.portalFieldInfos;
a.mediaInfos=b.mediaInfos;return a},_getPortalFieldInfosAndMediaInfosByUI:function(){var a=this.fieldsTable.getData(),b=[];return{portalFieldInfos:k.map(a,c.hitch(this,function(d){var g=d.fieldName,e=this._getDefaultPortalFieldInfo(g);e.label=d.label||e.label;(e.visible=d.visible)&&"image"===d.specialType&&(d="{"+g+"}",b.push({title:"",type:"image",caption:g,value:{sourceURL:d,linkURL:d}}));return e})),mediaInfos:b}},_getDefaultPopupInfo:function(){var a=this._getLayerDefinition();return v.getDefaultPopupInfo(a,
!1)},_getDefaultPortalFieldInfo:function(a){a=this._getServiceFildInfo(a);return l.getDefaultPortalFieldInfo(a)},_getServiceFildInfo:function(a){var b=null;b=this._getLayerDefinition();return b=l.getFieldInfoByFieldName(b.fields,a)},_getSortedFieldInfos:function(a,b){var d=[],g={};k.forEach(b,c.hitch(this,function(f){g[f.name]=f}));var e=[];e=e.concat(a);k.forEach(b,c.hitch(this,function(f){f=f.name;0>e.indexOf(f)&&e.push(f)}));return d=k.map(e,c.hitch(this,function(f){return g[f]}))},_onBtnSetDisplayFieldsClicked:function(){var a=
new t({width:640,height:380,titleLabel:this.nls.setDisplayFields,content:this.displayFieldsDiv,onClose:c.hitch(this,function(){this.prevPortalFieldInfos&&this._setCustomPopupInfoForUI(this.prevPortalFieldInfos);h.place(this.displayFieldsDiv,this.displayFieldsSection);a.content=""}),buttons:[{label:this.nls.ok,onClick:c.hitch(this,function(){var b=this._getPortalFieldInfosAndMediaInfosByUI().portalFieldInfos;this._updateDisplayFieldsTextBox(b);this.prevPortalFieldInfos=null;a.close()})},{label:this.nls.cancel,
onClick:c.hitch(this,function(){a.close()})}]});setTimeout(c.hitch(this,function(){this.prevPortalFieldInfos=this._getPopupInfoByUI()}),200)},_setOrderByFields:function(a){a=a||[];var b=this.sortFieldsDiv.innerHTML="";a=k.map(a,c.hitch(this,function(d,g){var e=d.split(" ");d=e[0];var f="ASC";e[1]&&"string"===typeof e[1]&&(e[1]=e[1].toUpperCase(),"DESC"===e[1]&&(f="DESC"));e=f.toLowerCase();e="\x3cspan\x3e"+d+'\x3c/span\x3e\x3cspan class\x3d"sort-arrow '+e+'"\x3e\x3c/span\x3e';g!==a.length-1&&(e+=
"\x3cspan\x3e,\x26nbsp;\x3c/span\x3e");b+=e;return d+" "+f}));b&&(b="\x3cspan\x3e\x26nbsp;\x26nbsp;\x3c/span\x3e"+b);this.sortFieldsDiv.innerHTML=b;this._currentOrderByFields=a},_getOrderByFields:function(){var a=this._getLayerDefinition();return this._shouldEnableSorting(a)?this._currentOrderByFields:[]},_updateSortingIcon:function(a){this._shouldEnableSorting(a)?h.removeClass(this.sortFieldsIcon,"jimu-state-disabled"):h.addClass(this.sortFieldsIcon,"jimu-state-disabled")},_shouldEnableSorting:function(a){return this._isServiceSupportsPagination(a)&&
this._isServiceSupportsOrderBy(a)},_onBtnSortFieldsClicked:function(){var a=this._getLayerDefinition();if(a&&this._shouldEnableSorting(a))var b=new F({nls:this.nls,layerDefinition:a,orderByFields:c.clone(this._currentOrderByFields),validSortFieldTypes:this._validSortFieldTypes}),d=new t({width:640,height:380,titleLabel:this.nls.setSortingFields,content:b,onClose:c.hitch(this,function(){b.destroy()}),buttons:[{label:this.nls.ok,onClick:c.hitch(this,function(){var g=b.getOrderByFields();this._setOrderByFields(g);
d.close()})},{label:this.nls.cancel,onClick:c.hitch(this,function(){d.close()})}]})},_initFieldsTable:function(){var a={autoHeight:!1,style:"height:187px",fields:[{name:"visible",title:this.nls.visibility,type:"checkbox"},{name:"fieldName",title:this.nls.name,type:"text",editable:!1},{name:"label",title:this.nls.alias,type:"text",editable:!0},{name:"specialType",title:this.nls.specialType,type:"extension",create:c.hitch(this,this._createSpecialType),setValue:c.hitch(this,this._setValue4SpecialType),
getValue:c.hitch(this,this._getValueOfSpecialType)},{name:"actions",title:this.nls.actions,type:"actions",actions:["up","down"]}]};this.fieldsTable=new C(a);this.fieldsTable.placeAt(this.fieldsContainer);this.fieldsTable.startup()},_createSpecialType:function(a){a=h.create("select",{},a);h.create("option",{value:"none",label:this.nls.none,selected:!0,innerHTML:this.nls.none},a);h.create("option",{value:"image",label:this.nls.image,innerHTML:this.nls.image},a)},_setValue4SpecialType:function(a,b){r("select",
a)[0].value=b},_getValueOfSpecialType:function(a){return r("select",a)[0].value},_initAddFields:function(){var a=h.create("div");this.tooltipDialog=new D({style:"cursor:pointer",content:a});this.menu=new E;this.menu.placeAt(a);this.own(q(document.body,"click",c.hitch(this,function(){m.close(this.tooltipDialog)})))},_onAddClicked:function(a){a.stopPropagation();a.preventDefault();m.close(this.tooltipDialog);m.open({popup:this.tooltipDialog,around:this.btnAddFields})},_resetMenu:function(){var a=this.menu.getChildren();
k.forEach(a,c.hitch(this,function(b){this.menu.removeChild(b)}))},_isServiceSupportsPagination:function(a){var b=!1;a.advancedQueryCapabilities&&a.advancedQueryCapabilities.supportsPagination&&(b=!0);return b},_isServiceSupportsOrderBy:function(a){var b=!1;a.advancedQueryCapabilities&&a.advancedQueryCapabilities.supportsOrderBy&&(b=!0);return b}})});