// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
require({cache:{"url:esri/dijit/geoenrichment/templates/OnDemandSelect.html":'\x3cdiv class\x3d"esriGEOnDemandSelect"\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"openButton" class\x3d"onDemandSelect_openButton"\x3e\r\n        \x3cdiv data-dojo-attach-point\x3d"arrow" class\x3d"onDemandSelect_arrow"\x3e\x26nbsp;\x3c/div\x3e\r\n        \x3cdiv data-dojo-attach-point\x3d"selectedLabel" class\x3d"onDemandSelect_selectedLabel TrimWithEllipses"\x3e\x3c/div\x3e\r\n        \x3cdiv data-dojo-attach-point\x3d"selectedItemHolder" class\x3d"onDemandSelect_selectedItem TrimWithEllipses"\x3e\x3c/div\x3e\r\n    \x3c/div\x3e\r\n\x3c/div\x3e'}});
define("esri/dijit/geoenrichment/OnDemandSelect","dojo/_base/declare dojo/on dojo/dom-construct dojo/dom-class dojo/dom-style dojo/dom-geometry dojo/store/Memory dijit/_WidgetBase dijit/_TemplatedMixin ./FlowList ./utils/DomUtil ./utils/MouseUtil ./utils/PopupUtil dojo/text!./templates/OnDemandSelect.html".split(" "),function(g,h,k,e,p,q,r,t,u,l,d,m,f,v){var n={_currentSelect:null,_keyHandler:null,_mouseMoveHandler:null,setFocusedSelect:function(a){this._currentSelect=a;this._updateHandlers()},_updateHandlers:function(){var a=
this;this._keyHandler&&this._keyHandler.remove();this._keyHandler=null;this._mouseMoveHandler&&this._mouseMoveHandler.remove();this._mouseMoveHandler=null;this._currentItemIndex=-1;this._currentSearchLetter=null;this._setNodeFocused(null);this._currentSelect&&(this._keyHandler=h(document.body,"keyup",function(b){b=String.fromCharCode(b.keyCode);1===b.length&&(b=b.toLowerCase(),a._tryHighlightNextItemForKey(b))}),this._mouseMoveHandler=h(this._currentSelect.popupList.domNode,"mousemove",function(){a._setNodeFocused(null)}))},
_currentItemIndex:-1,_currentSearchLetter:null,_tryHighlightNextItemForKey:function(a){a===this._currentSearchLetter?this._currentItemIndex++:this._currentItemIndex=0;this._currentSearchLetter=a;var b=this,c=this._currentSelect.store.query(function(c){return(c=c[b._currentSelect.labelProperty])&&c.toLowerCase().charAt(0)===a});if(c.length){this._currentItemIndex>c.length-1&&(this._currentItemIndex=0);var d=(c=c[this._currentItemIndex])&&this._currentSelect.popupList.getItemNode(c);c&&this._currentSelect.popupList.scrollToItem(c);
this._setNodeFocused(d)}},_currentFocusedNode:null,_setNodeFocused:function(a){this._currentFocusedNode&&(e.remove(this._currentFocusedNode,"listItemFocused"),this._currentFocusedNode=null);a&&(e.add(a,"listItemFocused"),this._currentFocusedNode=a)}};g=g([t,u],{templateString:v,value:null,popupList:null,listClass:null,idProperty:"value",labelProperty:"label",options:null,store:null,itemRenderer:null,placeHolder:null,requireSelection:!0,renderSelectionAsItem:!1,makePopupListWidthMatchOpenButtonWidth:!0,
orient:null,noPopupOverflow:!1,stopOpenEventPropagation:!1,stopPopupInteractionEventPropagation:!0,hasSelectableItems:!0,onClickComponent:null,labelTextToKeep:null,nodeToKeepAsSelected:null,openMouseEvent:null,toggleOnClick:!0,supportsKeyNavigation:!0,_closePopupOnChangeFunc:null,postCreate:function(){var a=this;this.inherited(arguments);this.__normalizeValue();this.labelTextToKeep?this.selectedLabel.innerHTML=this.labelTextToKeep:this.requireSelection||this._tryAssignPlaceholder();this.nodeToKeepAsSelected?
this._updateSelection():d.hide(this.selectedItemHolder);this._createPopupList();this.own(this.popupList);this.listClass&&e.add(this.popupList.domNode,this.listClass);this._popupCreationHandler=h(this.openButton,this.openMouseEvent||"click",function(b){a.stopOpenEventPropagation&&b.stopPropagation();a.openPopup()});this.popupList.startup();this._trySelectValue();h(this.popupList.domNode,"click, mouseup",function(b){a.stopPopupInteractionEventPropagation&&b.stopPropagation()})},_createPopupList:function(){var a=
this,b=this.itemRenderer||new l.itemRenderers.DefaultItemRenderer;this.popupList=new l({"class":"esriGEOnDemandSelectFlowList",idProperty:this.idProperty,labelProperty:this.labelProperty,itemRenderer:b,stopMouseEventPropagation:this.stopPopupInteractionEventPropagation,hasSelectableItems:this.hasSelectableItems,onChange:function(){a._processOnChangeEvent()}})},_processOnChangeEvent:function(){this.popupList.selectedItem&&(this.value=this.popupList.selectedItem[this.idProperty],this._updateSelection(),
this.onChange&&this.onChange({type:"change",value:this.value}));this._closePopupOnChangeFunc&&!this._closePopupOnChangeFunc(this.value)||f.close(this.popupList)},_makePopup:function(){if(this._popupCreationHandler){this._popupCreationHandler.remove();delete this._popupCreationHandler;var a=this;f.makePopup(this.popupList,this,this.openButton,{openMouseEvent:this.openMouseEvent,stopEventPropagation:this.stopOpenEventPropagation,toggleOnClick:this.toggleOnClick,wrapperClass:this.listClass?this.listClass.split(" ").map(function(a){return a+
"Popup"}).join(" "):null,orient:this.orient,allowAutoOrientation:this.allowAutoOrientation,noOverflow:this.noPopupOverflow,onClickComponent:this.onClickComponent,onPreShow:function(){a.onPopupListPreBuild();a.makePopupListWidthMatchOpenButtonWidth&&p.set(a.popupList.domNode,"minWidth",q.getContentBox(a.domNode).w+2+"px");a._updatePopupListStore();a.onPopupPreOpened()},onShow:function(){a.onPopupOpened();n.setFocusedSelect(a)},onClose:function(){a.onPopupClosed();n.setFocusedSelect(null)}})}},_tryAssignPlaceholder:function(){if(this.placeHolder&&
null===this.value)return this.selectedLabel.innerHTML=this.placeHolder,e.add(this.selectedLabel,"placeHolder"),!0;e.remove(this.selectedLabel,"placeHolder");return!1},__normalizeValue:function(){null!==this.value&&(void 0===this.value?this.value=null:("string"===typeof this.value&&(this.value=this.value.trim()),String(this.value)||(this.value=null)))},_trySelectValue:function(){var a=this;if((null===this.value||!this._setValueAttr(this.value))&&this.requireSelection){var b=this.store&&this.store.query();
b&&b.length&&(this.value&&b.some(function(b){return a.value===b[a.idProperty]})?this._setValueAttr(this.value):this._setValueAttr(b[0][this.idProperty]))}},_setValueAttr:function(a){this.value=a;this.__normalizeValue();if(!this.store||!this.popupList)return!1;var b=this;(a=this.store.query(function(a){return a[b.idProperty]===b.value})[0])&&this.popupList.setSelectedItem(a);this._updateSelection(a);return!!a},_setOptionsAttr:function(a){this.options=a;this.store=this._createStore(a);this._updatePopupListStore();
this._trySelectValue()},_setStoreAttr:function(a){this.options=(this.store=this._createStore(a))&&this.store.query();a.idProperty&&(this.idProperty=a.idProperty);this._updatePopupListStore();this._trySelectValue()},_createStore:function(a){return a instanceof Array?new r({data:a,idProperty:this.idProperty}):a},_updatePopupListStore:function(){this.popupList&&(this.popupList.store&&this.popupList.store===this.store||this.popupList.setStore(this.store,!0),this.popupList.setSelectedItem(this.getSelectedItem()))},
getSelectedItem:function(){if(!this.store)return null;var a=this.get("value"),b=this;return void 0!==a&&this.store.query(function(c){return c[b.idProperty]===a})[0]},setSelectedItem:function(a){this.store&&this.popupList&&a&&this._setValueAttr(a[this.idProperty])},getSelectedIndex:function(){var a=this,b=-1;if(this.store){var c=this.get("value");void 0!==c&&this.store.query().some(function(d,e){if(d[a.idProperty]==c)return b=e,!0})}return b},setSelectedIndex:function(a){this.setSelectedItem(this.store&&
this.store.data[a])},_nodeToKeepAsSelectedPlacedFlag:!1,_updateSelection:function(a){a=a||this.getSelectedItem();this.nodeToKeepAsSelected?this._nodeToKeepAsSelectedPlacedFlag||(d.hide(this.selectedLabel),d.show(this.selectedItemHolder),k.empty(this.selectedItemHolder),k.place(this.nodeToKeepAsSelected,this.selectedItemHolder),this._nodeToKeepAsSelectedPlacedFlag=!0):this.renderSelectionAsItem?(d.hide(this.selectedLabel),d.show(this.selectedItemHolder),k.empty(this.selectedItemHolder),a&&k.place(this.popupList.itemRenderer.createPresentation(a,
!1,null,this.popupList),this.selectedItemHolder)):(d.hide(this.selectedItemHolder),this.labelTextToKeep?this.selectedLabel.innerHTML=this.labelTextToKeep:(this.selectedLabel.innerHTML=a?a[this.labelProperty]:"",this.selectedLabel.innerHTML&&e.remove(this.selectedLabel,"placeHolder"),d[this.selectedLabel.innerHTML||this._tryAssignPlaceholder()?"show":"hide"](this.selectedLabel)))},refresh:function(){this.popupList.refresh();this._updateSelection()},isPopupOpen:function(){return f.isOpen(this.popupList)},
openPopup:function(){this.isPopupOpen()||(this._makePopup(),f.open(this.popupList))},closePopup:function(){this._popupCreationHandler||f.close(this.popupList)},refreshPopup:function(){this.isPopupOpen()&&f.refresh(this.popupList)},isMouseOver:function(){return m.isMouseOver(this.domNode)||this.popupList&&m.isMouseOver(this.popupList.domNode)},onPopupListPreBuild:function(){},onPopupPreOpened:function(){},onPopupOpened:function(){},onPopupClosed:function(){},onChange:function(a){},destroy:function(){this._popupCreationHandler&&
this._popupCreationHandler.remove();this.closePopup(this.popupList);this.popupList.destroy();this.inherited(arguments)}});g.itemRenderers=l.itemRenderers;return g});