// 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/Preset.html":'\x3cdiv class\x3d"esriCTPresetPopUpDiv"\x3e\r\n    \x3cdiv class\x3d"esriCTWrapper"\x3e\r\n        \x3cdiv style\x3d"width:50%; float:left;"\x3e\r\n            \x3cdiv class\x3d"esriCTPresetPopUpLabel"\x3e${nls.intersectionPage.groupNameLabel}\x3c/div\x3e\r\n            \x3cdiv class\x3d"esriCTPresetPopupdijitWrapper"\x3e\r\n                \x3cdiv class\x3d"esriCTPresetPopupdijit" style\x3d"width: 100%" data-dojo-attach-point\x3d"groupNameDiv"\x3e\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n        \x3cdiv style\x3d"width:50%; float:left;"\x3e\r\n            \x3cdiv class\x3d"esriCTPresetPopUpLabel"\x3e${nls.intersectionPage.dataTypeLabel}\x3c/div\x3e\r\n            \x3cdiv class\x3d"esriCTPresetPopupdijitWrapper"\x3e\r\n                \x3cdiv class\x3d"esriCTPresetPopupdijit" style\x3d"width: 100%" data-dojo-attach-point\x3d"dataTypeDropdownDiv"\x3e\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"esriCTRowContainer row esriCTHidden"\x3e\r\n        \x3cdiv style\x3d"width: 100%;" data-dojo-attach-point\x3d"showOnlyDomainFieldsNode" class\x3d"esriCTPresetPopUpLabel"\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"esriCTWrapper"\x3e\r\n        \x3cfieldset class\x3d"esriCTFieldset"\x3e\r\n            \x3clegend class\x3d"esriCTLegendTitle"\x3e${nls.smartActionsPage.layerAndFieldsApplyLabel}\x3c/legend\x3e\r\n            \x3cdiv class\x3d"esriCTTableParentContainer" data-dojo-attach-point\x3d"tableParentContainer"\x3e\r\n            \x3c/div\x3e\r\n        \x3c/fieldset\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"esriCTWrapper"\x3e\r\n        \x3cdiv class\x3d"esriCTPresetPopUpLabel"\x3e${nls.presetPopup.presetValueLAbel}\x3c/div\x3e\r\n        \x3cdiv class\x3d"esriCTPresetPopupdijitWrapper" data-dojo-attach-point\x3d"presetValuedijitWrapper"\x3e\r\n            \x3cdiv class\x3d"esriCTPresetPopupdijit" style\x3d"width: 100%" data-dojo-attach-point\x3d"presetValueDiv"\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n        \x3cdiv class\x3d"jimu-btn esriCTSelectValueBtn" data-dojo-attach-point\x3d"selectPresetValueBtn"\r\n            data-dojo-attach-event\x3d"onClick:_onSelectPresetValueButtonClick"\x3e${nls.chooseFromLayer.selectValueLabel}\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n    \x3cdiv class\x3d"esriCTRowContainer row"\x3e\r\n        \x3cdiv style\x3d"width: 100%;" data-dojo-attach-point\x3d"hideInPresetDisplayNode" class\x3d"esriCTPresetPopUpLabel"\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/Evented dojo/_base/lang dojo/_base/array dojo/dom-construct dojo/on dojo/string dojo/mouse dojo/text!./Preset.html dijit/_TemplatedMixin jimu/BaseWidgetSetting jimu/dijit/Popup jimu/dijit/CheckBox jimu/dijit/Message dijit/form/Select dijit/form/ValidationTextBox ./ChooseFromLayer ./RelativeDates ./RelativeDomains dojo/dom-class dijit/form/NumberTextBox ./layersAndFieldsApplyOn ../presetUtils jimu/utils".split(" "),function(v,w,d,g,m,k,x,y,z,A,B,C,r,D,E,n,F,G,H,I,J,
K,p,t){return v([B,w,A],{baseClass:"jimu-widget-smartEditor-setting-presetPopup",templateString:z,groupNameTextBox:null,dataTypeDropdown:null,hasDomainField:null,presetValueDijitNode:null,presetValueTimeNode:null,_selectedRelativeDate:null,_selectedRelativeDomains:null,_selectedDomainFields:[],ValidFieldsByTypeToApplyOn:{esriFieldTypeInteger:["esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeSingle","esriFieldTypeDouble"],esriFieldTypeGUID:["esriFieldTypeGUID"],esriFieldTypeDate:["esriFieldTypeDate"],
esriFieldTypeString:["esriFieldTypeString"]},postCreate:function(){this.inherited(arguments);this._isDomainField();this._initControls();this.isDelete||this.showDialog()},_initControls:function(){this.groupNameTextBox=new n({required:!0,trim:!0,style:{width:"100%"}});this.groupNameTextBox.placeAt(this.groupNameDiv);this.groupNameTextBox.validator=d.hitch(this,function(b){return b?b!==this.prevName&&this.editUtils.isDuplicateGroupName(b,this.existingGroupNames)?(this.groupNameTextBox.set("invalidMessage",
this.nls.smartActionsPage.uniqueGroupNameMsg),!1):!0:(this.groupNameTextBox.set("invalidMessage",this.nls.smartActionsPage.requiredGroupNameMsg),!1)});this.groupNameTextBox.startup();this.name&&this.groupNameTextBox.set("value",this.name);this.dataTypeDropdown=new E({options:this._addDataTypeOptions(),style:{width:"100%"}});this.own(k(this.dataTypeDropdown,"change",d.hitch(this,function(b){var a;this.chooseFromLayerInfo&&(this.chooseFromLayerInfo=null);this.showOnlyDomainFieldsCB.getValue()||"esriFieldTypeDate"!==
b||(this._selectedRelativeDate=a={dateType:"fixed"});this._createValueDijit(b,a,!0);this._domainTableData=[];this._enableDisablePresetValueDijit()})));this.dataTypeDropdown.placeAt(this.dataTypeDropdownDiv);this.dataTypeDropdown.startup();this.showOnlyDomainFieldsCB=new r({label:this.nls.presetPage.showOnlyDomainFields},m.create("div",{},this.showOnlyDomainFieldsNode));this.showOnlyDomainFields&&this.showOnlyDomainFieldsCB.setValue(!0);this.own(k(this.showOnlyDomainFieldsCB,"change",d.hitch(this,
function(b){var a,c=this.dataTypeDropdown.get("value");b||"esriFieldTypeDate"!==c||(this._selectedRelativeDate=a={dateType:"fixed"});this._createValueDijit(c,a,!0);this._createLayersAndFields(c,b)})));this.dataType&&(this.dataTypeDropdown.set("value",this.dataType,!1),this.showOnlyDomainFields?this._selectedRelativeDomains=this._domainTableData=this.presetValue:"esriFieldTypeDate"===this.dataType&&(this._selectedRelativeDate=this.presetValue),this._createValueDijit(this.dataType,this.presetValue,
!0));this.hideInPresetDisplayCB=new r({label:this.nls.presetPage.hideInPresetDisplay},m.create("div",{},this.hideInPresetDisplayNode));this.hideInPresetDisplay&&this.hideInPresetDisplayCB.setValue(!0)},_createValueDijit:function(b,a,c){var e;if(e=this.createDijitOnDataTypeChange(b))this.presetValueDijitNode=e,this.own(k(this.presetValueDijitNode.domNode,y.enter,d.hitch(this,function(){if(this._selectedRelativeDate&&"esriFieldTypeDate"===this.dataTypeDropdown.get("value")&&!this._checkIfDomainFieldSelected()){var f=
p.getDateFromRelativeInfo(this._selectedRelativeDate,!0);""===f&&(f=this.nls.relativeDates.noDateDefinedTooltip);this.presetValueDijitNode.set("title",f)}else""!==this.presetValueDijitNode.get("value")?this.presetValueDijitNode.set("title",this.presetValueDijitNode.get("value")):this.presetValueDijitNode.set("title",this.nls.relativeDates.noDateDefinedTooltip)}))),this.presetValueDijitNode.placeAt(this.presetValueDiv),this.presetValueDijitNode.startup(),a&&(this.showOnlyDomainFields?this.presetValueDijitNode.set("value",
this._getDefaultDomain(a)):"esriFieldTypeDate"===b&&a.dateType?"fixed"===a.dateType?a.dateTime?this.presetValueDijitNode.set("value",p.getDateFromRelativeInfo(a,!0)):this.presetValueDijitNode.set("value",""):this.presetValueDijitNode.set("value",this.nls.relativeDates[a.dateType]):this.presetValueDijitNode.set("value",a)),c&&this._createLayersAndFields(b,!1)},_addDataTypeOptions:function(){return[{label:this.nls.dataType.esriFieldTypeString,value:"esriFieldTypeString"},{label:this.nls.dataType.esriFieldTypeInteger,
value:"esriFieldTypeInteger"},{label:this.nls.dataType.esriFieldTypeDate,value:"esriFieldTypeDate"},{label:this.nls.dataType.esriFieldTypeGUID,value:"esriFieldTypeGUID"}]},_isDomainField:function(){g.forEach(this._totalLayers,d.hitch(this,function(b){g.some(b.layerObject.fields,d.hitch(this,function(a){if(a.domain&&"codedValue"===a.domain.type)return this.hasDomainField=!0}))}))},_createLayerFieldsFilter:function(b,a){var c=[],e={};g.forEach(this._totalLayers,d.hitch(this,function(f){(!f.isTable||
f.isTable&&0<f.layerObject.relationships.length)&&g.forEach(f.layerObject.fields,d.hitch(this,function(h){this.ValidFieldsByTypeToApplyOn[b]&&(c=this.ValidFieldsByTypeToApplyOn[b],-1<c.indexOf(h.type)&&h.editable&&(!a||h.domain&&(!h.domain||"range"!==h.domain.type))&&(e[f.id]||(e[f.id]={}),e[f.id][h.name]=h))}))}));return e},_createLayersAndFields:function(b,a){this._layerAndFieldsApplyOnObj=new K({map:this.map,showDomainFieldIndicator:!0,layerInfos:this.layerInfos,_configInfos:this._configInfos,
actionName:"Preset",nls:this.nls,prevName:this.prevName,existingGroups:this.existingGroups,_configuredPresetInfos:this._configuredPresetInfos,layerDetails:this._createLayerFieldsFilter(b,a),appliedOn:this.appliedOn});m.empty(this.tableParentContainer);this._layerAndFieldsApplyOnObj.placeAt(this.tableParentContainer);this._layerAndFieldsApplyOnObj.startup();I.add(this._layerAndFieldsApplyOnObj.layerAndFieldsMainDiv,"esriCTOverrideForPreset");k(this._layerAndFieldsApplyOnObj,"layerFieldsUpdated",d.hitch(this,
function(c){this._fieldsToAppliedUpdated=!0;this.tableDomains=this._consolidateLayerDomains();this._domainTableData=this._createDomainData();this._checkIfDomainFieldSelected()||c||this._createValueDijit(this.dataTypeDropdown.get("value"),this.presetValueDijitNode.get("value"),!1);this._enableDisablePresetValueDijit(c)}))},_enableDisablePresetValueDijit:function(b){var a=this._checkIfDomainFieldSelected();this.presetValueDijitNode&&(a||"esriFieldTypeDate"===this.dataTypeDropdown.get("value")?(this.presetValueDijitNode.set("disabled",
!0),b=b?this.presetValue:this._domainTableData,b=this._getDefaultDomain(b),a&&this.presetValueDijitNode.set("value",b)):(this.presetValueDijitNode.set("disabled",!1),this.presetValueDijitNode.isValid()||this.presetValueDijitNode.set("value","")))},_isDomainValueSelected:function(){var b=!1,a;g.some(this._domainTableData,d.hitch(this,function(c){if(c.isDefault)return b=!0,a=c,!0}));return{isDomainSelected:b,selectedDomain:a}},deleteGroup:function(){this._layerAndFieldsApplyOnObj.deleteGroup()},showDialog:function(){this.presetPopup=
new C({titleLabel:this.nls.fieldsPage.fieldsSettingsTable.canPresetValue,width:950,maxHeight:600,autoHeight:!1,"class":this.baseClass,content:this,buttons:[{label:this.nls.ok,onClick:d.hitch(this,function(){var b=!0;var a={};if(this.groupNameTextBox.isValid()){a.name=t.stripHTML(this.groupNameTextBox.get("value"));a.dataType=this.dataTypeDropdown.get("value");"esriFieldTypeGUID"===a.dataType&&""===this.presetValueDijitNode.get("value")&&(b=!1);var c=this._checkIfDomainFieldSelected();!b||this.presetValueDijitNode.isValid()||
c?(a.showOnlyDomainFields=c,a.hideInPresetDisplay=this.hideInPresetDisplayCB.getValue(),c&&this._domainTableData?a.presetValue=d.clone(this._domainTableData):"esriFieldTypeDate"===a.dataType?a.presetValue=d.clone(this._selectedRelativeDate):this.presetValueDijitNode&&(a.presetValue=this.presetValueDijitNode.get("value")),this.chooseFromLayerInfo&&(a.chooseFromLayerInfo=this.chooseFromLayerInfo),a.appliedOn=this._layerAndFieldsApplyOnObj.getCheckedFields(a),this._hasFieldsInPresetGroup(a)?(this.emit("groupInfoUpdated",
a),this.presetPopup.close()):D({message:x.substitute(this.nls.attributeActionsPage.presetNoFieldWarningMsg,{groupName:a.name})})):this.presetValueDijitNode.focus()}else this.groupNameTextBox.focus()})},{label:this.nls.cancel,classNames:["jimu-btn-vacation"],onClick:d.hitch(this,function(){this.presetPopup.close()})}]});this.groupNameTextBox.focus()},_hasFieldsInPresetGroup:function(b){var a=!1,c;for(c in b.appliedOn)if(0<b.appliedOn[c].length){a=!0;break}return a},createDijitOnDataTypeChange:function(b){m.empty(this.presetValueDiv);
this.presetValueDijitNode=this.presetValueTimeNode=null;if(this._checkIfDomainFieldSelected()||"esriFieldTypeDate"===b)b=new n({required:!1,disabled:!0,trim:!0,style:{width:"100%"}});else switch(b){case "esriFieldTypeSmallInteger":case "esriFieldTypeInteger":case "esriFieldTypeSingle":case "esriFieldTypeDouble":b=new J({style:"width:100%"});break;case "esriFieldTypeGUID":b=new n({style:"width:100%"});b.validator=d.hitch(this,function(a){return""===a?!0:p.isGuid(a)});break;default:b=new n({required:!1,
trim:!0,style:{width:"100%"}})}return b},_onSelectPresetValueButtonClick:function(){var b=this.dataTypeDropdown.get("value");this._checkIfDomainFieldSelected()?(this._relativeDomainsObj=new H({nls:this.nls,layerInfos:this.layerInfos,domainTableData:this._domainTableData,dataType:this.dataTypeDropdown.get("value"),_selectedRelativeDomains:this._selectedRelativeDomains,selectedDomainFields:this._selectedDomainFields}),this.own(k(this._relativeDomainsObj,"updatePresetValue",d.hitch(this,function(a){this._selectedRelativeDomains=
this._domainTableData=a.domainData;this.presetValueDijitNode.set("value",a.defaultValue)})))):"esriFieldTypeDate"===b?(this._relativeDatesObj=new G({nls:this.nls,relativeDates:this._selectedRelativeDate,map:this.map,layerInfos:this.layerInfos,selectedPresetValue:this._selectedRelativeDate&&this._selectedRelativeDate.chooseFromLayerInfo?this._selectedRelativeDate.chooseFromLayerInfo.selectedValue:""}),this.own(k(this._relativeDatesObj,"updatePresetValue",d.hitch(this,function(a){this._selectedRelativeDate=
a;"fixed"===this._selectedRelativeDate.dateType?this._selectedRelativeDate.dateTime?this.presetValueDijitNode.set("value",p.getDateFromRelativeInfo(this._selectedRelativeDate,!0)):this.presetValueDijitNode.set("value",""):this.presetValueDijitNode.set("value",this.nls.relativeDates[a.dateType])})))):(this.ChooseFromLayerObj=new F({map:this.map,nls:this.nls,allLayers:this._totalLayers,dataType:this.dataTypeDropdown.get("value"),layerInfos:this.layerInfos,chooseFromLayerInfo:this.chooseFromLayerInfo?
this.chooseFromLayerInfo:null,selectedPresetValue:this.chooseFromLayerInfo?this.chooseFromLayerInfo.selectedValue:""}),k(this.ChooseFromLayerObj,"updatePresetValue",d.hitch(this,function(a){var c=a.selectedValue,e=this.layerInfos.getLayerOrTableInfoById(a.layerId).layerObject.getField(a.field);e.domain&&"esriFieldTypeString"===this.dataTypeDropdown.get("value")&&g.some(e.domain.codedValues,d.hitch(this,function(f){f.code.toString()===a.selectedValue.toString()&&(c=f.name)}));this.chooseFromLayerInfo=
a;this.presetValueDijitNode.set("value",c)})),k(this.ChooseFromLayerObj,"cancelButtonClicked",d.hitch(this,function(){})))},_getDefaultDomain:function(b){var a="";g.some(b,d.hitch(this,function(c){if(c.isDefault)return a=c.label,!0}));return a},_consolidateLayerDomains:function(){var b=[],a,c={};var e=this._layerAndFieldsApplyOnObj.getOnlyCheckedFields();this._selectedDomainFields=[];for(var f in e){var h=this.layerInfos.getLayerOrTableInfoById(f);g.forEach(e[f],d.hitch(this,function(q){(a=h.layerObject.getField(q))&&
a.domain&&a.domain.codedValues&&(q=t.getDefaultPortalFieldInfo(a),this._selectedDomainFields.push(q.label),g.forEach(a.domain.codedValues,d.hitch(this,function(l){c.hasOwnProperty(l.code)?0>c[l.code].indexOf(l.name)&&c[l.code].push(l.name):(c[l.code]=[],c[l.code].push(l.name))})))}))}for(var u in c)b.push({value:u,displayedLabel:c[u].join(" | ")});return b},_createDomainData:function(){var b=[];g.forEach(this._selectedRelativeDomains,d.hitch(this,function(a){for(var c,e=this.tableDomains.length-1;0<=
e;e--)if(c=this.tableDomains[e].value,"esriFieldTypeString"!==this.dataTypeDropdown.get("value")&&(c=Number(c)),a.value.toString()===c.toString()){b.push({showInList:a.showInList,value:this.tableDomains[e].value,label:this.tableDomains[e].displayedLabel,isDefault:a.isDefault});this.tableDomains.splice(e,1);break}}));g.forEach(this.tableDomains,d.hitch(this,function(a,c){b.push({showInList:!0,value:""+a.value,label:a.displayedLabel,isDefault:!1})}));return b},_checkIfDomainFieldSelected:function(){var b=
!1;this._domainTableData&&(b=0<this._domainTableData.length?!0:!1);return b}})});