// 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/SmartEditor/setting/ChooseFromLayer.html":'\x3cdiv data-dojo-attach-point\x3d"layerSelectorPopUpDiv" class\x3d"esriCTlayerSelectorPopUpDiv"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"layerSelectorWrapper" class\x3d"esriCTWrapper"\x3e\r\n        \x3cdiv class\x3d"esriCTPopUpLabel"\x3e${nls.layersPage.layerSettingsTable.label}\r\n        \x3c/div\x3e\r\n        \x3cdiv class\x3d"esriCTPopupSelect"\x3e\r\n            \x3cdiv class\x3d"esriCTLayerSelect" style\x3d"width: 100%" data-dojo-attach-point\x3d"layerSelectorDiv"\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"esriCTWrapper"\x3e\r\n        \x3cdiv class\x3d"esriCTPopUpLabel"\x3e${nls.chooseFromLayer.fieldLabel}\x3c/div\x3e\r\n        \x3cdiv class\x3d"esriCTPopupSelect"\x3e\r\n            \x3cdiv class\x3d"esriCTlayerField" style\x3d"width: 100%" data-dojo-attach-point\x3d"fieldsDropdownDiv"\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"esriCTWrapper"\x3e\r\n        \x3cdiv class\x3d"esriCTPopUpLabel"\x3e${nls.chooseFromLayer.valueLabel}\x3c/div\x3e\r\n        \x3cdiv class\x3d"esriCTPopupSelect"\x3e\r\n            \x3cdiv class\x3d"esriCTlayerFieldvalue" style\x3d"width: 100%" data-dojo-attach-point\x3d"valueProviderContainer"\x3e\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"esriCTDomainFieldHint esriCTHidden" data-dojo-attach-point\x3d"domainFieldHint"\x3e\x3c/div\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/on dojo/string dojo/dom-attr dojo/dom-style dojo/text!./ChooseFromLayer.html dijit/_TemplatedMixin jimu/BaseWidgetSetting jimu/dijit/Popup dijit/form/Select jimu/dijit/LayerChooserFromMap jimu/dijit/LayerChooserFromMapWithDropbox jimu/dijit/_filter/ValueProviderFactory dojo/Evented".split(" "),function(m,d,h,k,n,p,l,q,r,t,u,v,f,w,x,y){return m([t,y,r],{baseClass:"jimu-widget-smartEditor-setting-chooseFromLayer",templateString:q,layerSelector:null,
fieldsDropdown:null,chooseFromLayerPopup:null,valueProviderFactory:null,valueProvider:null,_isFirsTime:!0,postCreate:function(){this.inherited(arguments);this._createPopUp()},_addLayerSelectors:function(){var a=this._createLayerChooserMapArgs();a=new f(a);a.startup();this.layerSelector=new w({layerChooser:a});this.layerSelector.placeAt(this.layerSelectorDiv);this.layerSelector.startup();if(0<this.layerSelector.layerChooser.getAllItems().length)var c=this.layerSelector.layerChooser.getAllItems()[0].layerInfo.layerObject;
this.chooseFromLayerInfo&&this.chooseFromLayerInfo.layerId&&this._isFirsTime&&this.chooseFromLayerInfo.selectedValue==this.selectedPresetValue&&(a=this.layerInfos.getLayerInfoById(this.chooseFromLayerInfo.layerId))&&(c=a.layerObject);this.layerSelector.setSelectedLayer(c);this._addLayerFieldsOptions()},_createLayerChooserMapArgs:function(){return{multiple:!1,createMapResponse:this.map.webMapResponse,onlyShowWebMapLayers:!0,filter:this._createFiltersForLayerSelector()}},_createFiltersForLayerSelector:function(){var a=
f.createFeaturelayerFilter(["point","polyline","polygon"],!1,!1);var c=f.createImageServiceLayerFilter(!0);return f.orCombineFilters([a,c])},_addLayerFieldsOptions:function(){this.fieldsDropdown&&this.fieldsDropdown.destroy();this.valueProviderFactory&&(this.valueProviderFactory=null);this.valueProvider&&this.valueProvider.destroy();this.fieldsDropdown=new v({style:{width:"100%"}});this.fieldsDropdown.placeAt(this.fieldsDropdownDiv);this.fieldsDropdown.startup();this.fieldsDropdown.set("options",
this._createFieldsDropDownOpt());this.fieldsDropdown.options&&0<this.fieldsDropdown.options.length&&(this.fieldsDropdown.set("value",this.fieldsDropdown.options[0],!1),this.chooseFromLayerInfo&&this.chooseFromLayerInfo.field&&this._isFirsTime&&this.chooseFromLayerInfo.selectedValue==this.selectedPresetValue&&this.fieldsDropdown.set("value",this.chooseFromLayerInfo.field,!1),this._updateLabelForDomainField(this.selectedPresetValue),this._createValueProvider());this.own(k(this.fieldsDropdown,"change",
d.hitch(this,function(){l.set(this.domainFieldHint,"display","none");this._createValueProvider();this._updateLabelForDomainField("")})))},_createFieldsDropDownOpt:function(){var a=[];if(this.layerSelector.getSelectedItem()){var c=this.layerSelector.getSelectedItem().layerInfo.layerObject;h.forEach(c.fields,d.hitch(this,function(b){"esriFieldTypeString"!==this.dataType&&("esriFieldTypeGUID"!==this.dataType||b.type!==this.dataType&&"esriFieldTypeGlobalID"!==b.type)&&("esriFieldTypeInteger"!==this.dataType||
"esriFieldTypeSmallInteger"!==b.type&&"esriFieldTypeInteger"!==b.type&&"esriFieldTypeDouble"!==b.type&&"esriFieldTypeSingle"!==b.type&&"esriFieldTypeOID"!==b.type)||a.push({label:b.alias||b.name,value:b.name})}))}return a},_createValueProvider:function(){var a;this.layerSelector&&(a=this.layerSelector.getSelectedItem());if(a&&a.layerInfo&&a.layerInfo.layerObject){a=a.layerInfo;var c=a.layerObject;this.valueProviderFactory&&(this.valueProviderFactory=null);this.valueProvider&&this.valueProvider.destroy();
this.valueProviderFactory=new x({url:c.url,layerDefinition:c,featureLayerId:a.id});var b;var e=this.fieldsDropdown.getValue();h.some(c.fields,d.hitch(this,function(g){if(g.name===e)return b=g,!0}));if(e&&b){switch(b.type){case "esriFieldTypeString":a="string";c="stringOperatorIs";break;case "esriFieldTypeDate":a="date";c="dateOperatorIsOn";break;default:a="number",c="numberOperatorIs"}a={fieldObj:{name:e,label:e,dateFormat:"",shortType:a,type:b.type},operator:c,interactiveObj:"",caseSensitive:!1,
valueObj:{type:"unique"}};this.valueProvider=this.valueProviderFactory.getValueProvider(a,!1);this.own(k(this.valueProvider,"change",d.hitch(this,function(){var g=this.valueProvider.getPartObject()&&this.valueProvider.getPartObject().valueObj.value;this._updateLabelForDomainField(g)})));this.valueProvider&&(this.valueProvider.placeAt(this.valueProviderContainer),this.chooseFromLayerInfo&&this.chooseFromLayerInfo.selectedValue&&this._isFirsTime&&this.chooseFromLayerInfo.selectedValue==this.selectedPresetValue&&
(a.valueObj.value=this.chooseFromLayerInfo.selectedValue,this._isFirsTime=!1),this.valueProvider.setValueObject(a.valueObj),this.initialValue=a.valueObj.value?a.valueObj.value:"")}}},_updateLabelForDomainField:function(a){var c,b;(b=this.layerSelector?this.layerSelector.getSelectedItem():null)&&b.layerInfo&&b.layerInfo.layerObject&&(b=b.layerInfo.layerObject,b=b.getField(this.fieldsDropdown.getValue()),b.domain&&"esriFieldTypeString"!==this.dataType&&h.some(b.domain.codedValues,d.hitch(this,function(e){if(a===
e.code)return c=n.substitute(this.nls.chooseFromLayer.domainFieldHintLabel,{domainValue:e.code}),!0})));c?(p.set(this.domainFieldHint,"innerHTML",c),l.set(this.domainFieldHint,"display","block")):l.set(this.domainFieldHint,"display","none")},_createPopUp:function(){this._addLayerSelectors();this.chooseFromLayerPopup=new u({titleLabel:this.nls.chooseFromLayer.selectValueLabel,width:500,maxHeight:300,autoHeight:!0,"class":this.baseClass,content:this,buttons:[{label:this.nls.ok,onClick:d.hitch(this,
function(){this._getSelectedFieldValue();this.chooseFromLayerPopup.close()})},{label:this.nls.cancel,classNames:["jimu-btn-vacation"],onClick:d.hitch(this,function(){this.emit("cancelButtonClicked");this.chooseFromLayerPopup.close()})}]});this.own(k(this.layerSelector,"selection-change",d.hitch(this,function(){this._addLayerFieldsOptions()})))},_getSelectedFieldValue:function(){if(this.valueProvider&&this.valueProvider.checkedNameDiv){var a=this.valueProvider.getPartObject()?this.valueProvider.getPartObject().valueObj.value:
"- empty -"!==this.valueProvider.checkedNameDiv.innerHTML&&this.initialValue?this.initialValue:"";this.emit("updatePresetValue",{layerId:this.layerSelector.getSelectedItem().layerInfo.layerObject.id,field:this.fieldsDropdown.getValue(),selectedValue:a})}}})});