text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):e.Downshift=t(e.React,e.PropTypes)}(this,function(e,t){"use strict";var n="default"in e?e.default:e;t=t&&t.hasOwnProperty("default")?t.default:t;var o="undefined"==typeof document?null:document.getElementById("a11y-status-message"),i=[];function r(e){var t=i[i.length-1]===e;i=t?[].concat(i,[e]):[e];for(var n=function(){if(o)return o;return(o=document.createElement("div")).setAttribute("id","a11y-status-message"),o.setAttribute("role","status"),o.setAttribute("aria-live","assertive"),o.setAttribute("aria-relevant","additions text"),Object.assign(o.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),document.body.appendChild(o),o}();n.lastChild;)n.removeChild(n.firstChild);i.filter(Boolean).forEach(function(e,t){var o,r,s;n.appendChild((o=e,r=t===i.length-1?"block":"none",(s=document.createElement("div")).style.display=r,s.textContent=o,s))})}var s=0;function u(e){return"function"==typeof e?e:l}function l(){}var p=function e(t,n,o){return null!==n&&n!==o.parentNode?t(n)?n===document.body&&0===n.scrollTop?document.documentElement:n:e(t,n.parentNode,o):null}.bind(null,function(e){return e.scrollHeight>e.clientHeight});function a(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,o=Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return t.some(function(t){return t&&t.apply(void 0,[e].concat(o)),e.defaultPrevented})}}function d(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.find(function(e){return void 0!==e})}function h(e,t){return!(e=Array.isArray(e)?e[0]:e)&&t?t:e}function c(e){return e.nodeName?"string"==typeof e.nodeName:"string"==typeof e.type}function g(e){return e.props||e.attributes}var f=["highlightedIndex","inputValue","isOpen","selectedItem","type"];function m(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};return f.forEach(function(n){e.hasOwnProperty(n)&&(t[n]=e[n])}),t}var y=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},I=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},v=function(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n},_=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},w=function(e){function t(){y(this,t);for(var n=arguments.length,o=Array(n),i=0;i<n;i++)o[i]=arguments[i];var r=_(this,e.call.apply(e,[this].concat(o)));C.call(r);var u=r.getState({highlightedIndex:r.props.defaultHighlightedIndex,isOpen:r.props.defaultIsOpen,inputValue:r.props.defaultInputValue,selectedItem:r.props.defaultSelectedItem});return u.selectedItem&&(u.inputValue=r.props.itemToString(u.selectedItem)),r.state=u,r.id=r.props.id||"downshift-"+String(s++),r}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.getState=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state;return Object.keys(t).reduce(function(n,o){return n[o]=e.isControlledProp(o)?e.props[o]:t[o],n},{})},t.prototype.isControlledProp=function(e){return void 0!==this.props[e]},t.prototype.getItemCount=function(){return null!=this.itemCount?this.itemCount:void 0!==this.props.itemCount?this.props.itemCount:this.items.length},t.prototype.internalSetState=function(e,n){var o=this,i=void 0,r=void 0,s={},l="function"==typeof e;return!l&&e.hasOwnProperty("inputValue")&&this.props.onInputValueChange(e.inputValue,I({},this.getStateAndHelpers(),e)),this.setState(function(n){n=o.getState(n),e=l?e(n):e,e=o.props.stateReducer(n,e),i=e.hasOwnProperty("selectedItem");var u={},p={};return i&&e.selectedItem!==n.selectedItem&&(r=e.selectedItem),e.type=e.type||t.stateChangeTypes.unknown,Object.keys(e).forEach(function(t){n[t]!==e[t]&&(s[t]=e[t]),"type"!==t&&(p[t]=e[t],o.isControlledProp(t)||(u[t]=e[t]))}),l&&e.hasOwnProperty("inputValue")&&o.props.onInputValueChange(e.inputValue,I({},o.getStateAndHelpers(),e)),u},function(){u(n)(),Object.keys(s).length>1&&o.props.onStateChange(s,o.getStateAndHelpers()),i&&o.props.onSelect(e.selectedItem,o.getStateAndHelpers()),void 0!==r&&o.props.onChange(r,o.getStateAndHelpers()),o.props.onUserAction(s,o.getStateAndHelpers())})},t.prototype.getStateAndHelpers=function(){var e=this.getState(),t=e.highlightedIndex,n=e.inputValue,o=e.selectedItem,i=e.isOpen,r=this.props.itemToString,s=this.id,u=this.getRootProps,l=this.getButtonProps,p=this.getLabelProps,a=this.getInputProps,d=this.getItemProps,h=this.openMenu,c=this.closeMenu,g=this.toggleMenu,f=this.selectItem,m=this.selectItemAtIndex,y=this.selectHighlightedItem,I=this.setHighlightedIndex,v=this.clearSelection,_=this.clearItems;return{getRootProps:u,getButtonProps:l,getLabelProps:p,getInputProps:a,getItemProps:d,reset:this.reset,openMenu:h,closeMenu:c,toggleMenu:g,selectItem:f,selectItemAtIndex:m,selectHighlightedItem:y,setHighlightedIndex:I,clearSelection:v,clearItems:_,setItemCount:this.setItemCount,unsetItemCount:this.unsetItemCount,itemToString:r,id:s,highlightedIndex:t,inputValue:n,isOpen:i,selectedItem:o}},t.prototype.getItemId=function(e){return this.id+"-item-"+e},t.prototype.componentDidMount=function(){var e=this;this._isMounted=!0;var n=function(){e.isMouseDown=!0},o=function(n){var o=e.props.environment.document;e.isMouseDown=!1,n.target!==e._rootNode&&e._rootNode.contains(n.target)||!e.getState().isOpen||e.inputId&&o.activeElement.id===e.inputId||e.reset({type:t.stateChangeTypes.mouseUp},function(){return e.props.onOuterClick(e.getStateAndHelpers())})};this.props.environment.addEventListener("mousedown",n),this.props.environment.addEventListener("mouseup",o),this.cleanup=function(){e._isMounted=!1,e.props.environment.removeEventListener("mousedown",n),e.props.environment.removeEventListener("mouseup",o)}},t.prototype.componentDidUpdate=function(e,n){this.isControlledProp("selectedItem")&&this.props.selectedItemChanged(e.selectedItem,this.props.selectedItem)&&this.internalSetState({type:t.stateChangeTypes.controlledPropUpdatedSelectedItem,inputValue:this.props.itemToString(this.props.selectedItem)});var o=void 0===this.props.highlightedIndex?this.state:this.props,i=void 0===e.highlightedIndex?n:e;o.highlightedIndex===i.highlightedIndex||this.avoidScrolling||this.scrollHighlightedItemIntoView(),this.updateStatus()},t.prototype.componentWillUnmount=function(){this.cleanup()},t.prototype.render=function(){var e=h(this.props.render||this.props.children,l);this.clearItems(),this.getRootProps.called=!1,this.getRootProps.refKey=void 0,this.getRootProps.suppressRefError=void 0,this.getLabelProps.called=!1,this.getInputProps.called=!1;var t=h(e(this.getStateAndHelpers()));if(!t)return null;if(this.getRootProps.called)return this.getRootProps.suppressRefError||function(e,t){var n=t.refKey,o="ref"!==n,i=!c(e);{if(i&&!o)throw new Error("downshift: You returned a non-DOM element. You must specify a refKey in getRootProps");if(!i&&o)throw new Error('downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified "'+n+'"')}if(!g(e)[n])throw new Error('downshift: You must apply the ref prop "'+n+'" from getRootProps onto your root element.')}(t,this.getRootProps),t;if(c(t))return n.cloneElement(t,this.getRootProps(g(t)));throw new Error("downshift: If you return a non-DOM element, you must use apply the getRootProps function")},t}(e.Component);w.defaultProps={defaultHighlightedIndex:null,defaultSelectedItem:null,defaultInputValue:"",defaultIsOpen:!1,getA11yStatusMessage:function(e){var t=e.isOpen,n=e.highlightedItem,o=e.selectedItem,i=e.resultCount,r=e.previousResultCount,s=e.itemToString;return t?i?n&&i===r?s(n):i+" "+(1===i?"result is":"results are")+" available, use up and down arrow keys to navigate.":"No results.":o?s(o):""},itemToString:function(e){return null==e?"":String(e)},onStateChange:function(){},onInputValueChange:function(){},onUserAction:function(){},onChange:function(){},onSelect:function(){},onOuterClick:function(){},selectedItemChanged:function(e,t){return e!==t},environment:"undefined"==typeof window?{}:window,stateReducer:function(e,t){return t},breakingChanges:{}},w.stateChangeTypes={unknown:"__autocomplete_unknown__",mouseUp:"__autocomplete_mouseup__",itemMouseEnter:"__autocomplete_item_mouseenter__",keyDownArrowUp:"__autocomplete_keydown_arrow_up__",keyDownArrowDown:"__autocomplete_keydown_arrow_down__",keyDownEscape:"__autocomplete_keydown_escape__",keyDownEnter:"__autocomplete_keydown_enter__",clickItem:"__autocomplete_click_item__",blurInput:"__autocomplete_blur_input__",changeInput:"__autocomplete_change_input__",keyDownSpaceButton:"__autocomplete_keydown_space_button__",clickButton:"__autocomplete_click_button__",blurButton:"__autocomplete_blur_button__",controlledPropUpdatedSelectedItem:"__autocomplete_controlled_prop_updated_selected_item__"};var C=function(){var e,t,n,o=this;this.input=null,this.items=[],this.itemCount=null,this.previousResultCount=0,this.setItemCount=function(e){return o.itemCount=e},this.unsetItemCount=function(){return o.itemCount=null},this.getItemNodeFromIndex=function(e){return o.props.environment.document.getElementById(o.getItemId(e))},this.setHighlightedIndex=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.props.defaultHighlightedIndex,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t=m(t),o.internalSetState(I({highlightedIndex:e},t))},this.scrollHighlightedItemIntoView=function(){!function(e,t){var n=p(e,t);if(null!==n){var o=getComputedStyle(n),i=n.getBoundingClientRect(),r=parseInt(o.borderTopWidth,10),s=r+parseInt(o.borderBottomWidth,10),u=i.top+r,l=e.getBoundingClientRect();if(l.top<0&&i.top<0)n.scrollTop+=l.top;else if(l.top<0)n.scrollTop+=l.top-u;else if(l.top>0&&i.top<0)i.bottom>0&&l.bottom+s>i.bottom&&(n.scrollTop+=l.bottom-i.bottom+s);else{var a=l.top+n.scrollTop-u;a<n.scrollTop?n.scrollTop=a:a+l.height+s>n.scrollTop+i.height&&(n.scrollTop=a+l.height-i.height+s)}}}(o.getItemNodeFromIndex(o.getState().highlightedIndex),o._rootNode)},this.openAndHighlightDefaultIndex=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o.setHighlightedIndex(void 0,I({isOpen:!0},e))},this.highlightDefaultIndex=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o.setHighlightedIndex(void 0,e)},this.moveHighlightedIndex=function(e,t){o.getState().isOpen?o.changeHighlightedIndex(e,t):o.openAndHighlightDefaultIndex(t)},this.changeHighlightedIndex=function(e,t){var n=o.getItemCount()-1;if(!(n<0)){var i=o.getState().highlightedIndex;null===i&&(i=e>0?-1:n+1);var r=i+e;r<0?r=n:r>n&&(r=0),o.setHighlightedIndex(r,t)}},this.clearSelection=function(e){o.internalSetState({selectedItem:null,inputValue:"",isOpen:!1},e)},this.selectItem=function(e,t,n){t=m(t),o.internalSetState(I({isOpen:!1,highlightedIndex:o.props.defaultHighlightedIndex,selectedItem:e,inputValue:o.isControlledProp("selectedItem")&&o.props.breakingChanges.resetInputOnSelection?o.props.defaultInputValue:o.props.itemToString(e)},t),n)},this.selectItemAtIndex=function(e,t,n){var i=o.items[e];null!=i&&o.selectItem(i,t,n)},this.selectHighlightedItem=function(e,t){return o.selectItemAtIndex(o.getState().highlightedIndex,e,t)},this.rootRef=function(e){return o._rootNode=e},this.getRootProps=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).suppressRefError,i=void 0!==n&&n,r=t.refKey,s=void 0===r?"ref":r,u=v(t,["refKey"]);return o.getRootProps.called=!0,o.getRootProps.refKey=s,o.getRootProps.suppressRefError=i,I(((e={})[s]=o.rootRef,e),u)},this.keyDownHandlers={ArrowDown:function(e){e.preventDefault();var t=e.shiftKey?5:1;this.moveHighlightedIndex(t,{type:w.stateChangeTypes.keyDownArrowDown})},ArrowUp:function(e){e.preventDefault();var t=e.shiftKey?-5:-1;this.moveHighlightedIndex(t,{type:w.stateChangeTypes.keyDownArrowUp})},Enter:function(e){this.getState().isOpen&&(e.preventDefault(),this.selectHighlightedItem({type:w.stateChangeTypes.keyDownEnter}))},Escape:function(e){e.preventDefault(),this.reset({type:w.stateChangeTypes.keyDownEscape})}},this.buttonKeyDownHandlers=I({},this.keyDownHandlers,{" ":function(e){e.preventDefault(),this.toggleMenu({type:w.stateChangeTypes.keyDownSpaceButton})}}),this.getButtonProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onClick,n=e.onKeyDown,i=e.onBlur,r=v(e,["onClick","onKeyDown","onBlur"]),s=o.getState().isOpen,u={onClick:a(t,o.button_handleClick),onKeyDown:a(n,o.button_handleKeyDown),onBlur:a(i,o.button_handleBlur)},l=r.disabled?{}:u;return I({type:"button",role:"button","aria-label":s?"close menu":"open menu","aria-expanded":s,"aria-haspopup":!0},l,r)},this.button_handleKeyDown=function(e){o.buttonKeyDownHandlers[e.key]&&o.buttonKeyDownHandlers[e.key].call(o,e)},this.button_handleClick=function(e){e.preventDefault(),o.props.environment.document.activeElement===o.props.environment.document.body&&e.target.focus(),o.toggleMenu({type:w.stateChangeTypes.clickButton})},this.button_handleBlur=function(){o.isMouseDown||o.reset({type:w.stateChangeTypes.blurButton})},this.getLabelProps=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(o.getLabelProps.called=!0,o.getInputProps.called&&e.htmlFor&&e.htmlFor!==o.inputId)throw new Error('downshift: You provided the htmlFor of "'+e.htmlFor+'" for your label, but the id of your input is "'+o.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');return o.inputId=d(o.inputId,e.htmlFor,o.id+"-input"),I({},e,{htmlFor:o.inputId})},this.getInputProps=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onKeyDown,i=t.onBlur,r=t.onChange,s=t.onInput,u=v(t,["onKeyDown","onBlur","onChange","onInput"]);if(o.getInputProps.called=!0,o.getLabelProps.called&&u.id&&u.id!==o.inputId)throw new Error('downshift: You provided the id of "'+u.id+'" for your input, but the htmlFor of your label is "'+o.inputId+'". You must either remove the id from your input or set the htmlFor of the label equal to the input id.');o.inputId=d(o.inputId,u.id,o.id+"-input");var l=o.getState(),p=l.inputValue,h=l.isOpen,c=l.highlightedIndex,g=u.disabled?{}:((e={}).onChange=a(r,s,o.input_handleChange),e.onKeyDown=a(n,o.input_handleKeyDown),e.onBlur=a(i,o.input_handleBlur),e);return I({role:"combobox","aria-autocomplete":"list","aria-expanded":h,"aria-activedescendant":h&&"number"==typeof c&&c>=0?o.getItemId(c):null,autoComplete:"off",value:p},g,u,{id:o.inputId})},this.input_handleKeyDown=function(e){e.key&&o.keyDownHandlers[e.key]&&o.keyDownHandlers[e.key].call(o,e)},this.input_handleChange=function(e){o.internalSetState({type:w.stateChangeTypes.changeInput,isOpen:!0,inputValue:e.target.value})},this.input_handleBlur=function(){o.isMouseDown||o.reset({type:w.stateChangeTypes.blurInput})},this.getItemProps=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onMouseMove,i=t.onMouseDown,r=t.onClick,s=t.index,u=t.item,l=void 0===u?function(e,t){throw new Error('The property "'+t+'" is required in "'+e+'"')}("getItemProps","item"):u,p=v(t,["onMouseMove","onMouseDown","onClick","index","item"]);void 0===s?(o.items.push(l),s=o.items.indexOf(l)):o.items[s]=l;return I(((e={id:o.getItemId(s),onMouseMove:a(n,function(){s!==o.getState().highlightedIndex&&(o.setHighlightedIndex(s,{type:w.stateChangeTypes.itemMouseEnter}),o.avoidScrolling=!0,setTimeout(function(){return o.avoidScrolling=!1},250))}),onMouseDown:a(i,function(e){e.preventDefault()})}).onClick=a(r,function(){o.selectItemAtIndex(s,{type:w.stateChangeTypes.clickItem})}),e),p)},this.clearItems=function(){o.items=[]},this.reset=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];e=m(e),o.internalSetState(function(t){var n=t.selectedItem;return I({isOpen:!1,highlightedIndex:o.props.defaultHighlightedIndex,inputValue:o.props.itemToString(n)},e)},u(t))},this.toggleMenu=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];e=m(e),o.internalSetState(function(t){var n=t.isOpen;return I({isOpen:!n},e)},function(){o.getState().isOpen&&o.highlightDefaultIndex(),u(t)()})},this.openMenu=function(e){o.internalSetState({isOpen:!0},u(e))},this.closeMenu=function(e){o.internalSetState({isOpen:!1},u(e))},this.updateStatus=(e=function(){if(o._isMounted){var e=o.getState(),t=o.items[e.highlightedIndex],n=o.getItemCount(),i=o.props.getA11yStatusMessage(I({itemToString:o.props.itemToString,previousResultCount:o.previousResultCount,resultCount:n,highlightedItem:t},e));o.previousResultCount=n,r(i)}},t=200,n=void 0,function(){for(var o=arguments.length,i=Array(o),r=0;r<o;r++)i[r]=arguments[r];n&&clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,i)},t)})};return w.default=w,w.resetIdCounter=function(){s=0},w});
  //# sourceMappingURL=downshift.umd.min.js.map
  