import{__exports as t}from"../../../_virtual/DropdownItem.js";import e from"react";import{p as o}from"../../prop-types/index.js";import{c as r}from"../../classnames/index.js";import"./DropdownContext.js";import"./utils.js";import{__exports as n}from"../../../_virtual/DropdownContext.js";import{__exports as i}from"../../../_virtual/utils.js";!function(t){function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=d(e),l=d(o),c=d(r),s=n,f=i,p=["className","cssModule","divider","tag","header","active","text"];function d(t){return t&&t.__esModule?t:{default:t}}function b(){return b=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(t[r]=o[r])}return t},b.apply(this,arguments)}function y(t,e){if(null==t)return{};var o,r,n=function(t,e){if(null==t)return{};var o,r,n={},i=Object.keys(t);for(r=0;r<i.length;r++)o=i[r],e.indexOf(o)>=0||(n[o]=t[o]);return n}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)o=i[r],e.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(n[o]=t[o])}return n}function v(t,e){for(var o=0;o<e.length;o++){var r=e[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var o,r=O(t);if(e){var n=O(this).constructor;o=Reflect.construct(r,arguments,n)}else o=r.apply(this,arguments);return function(t,e){if(e&&("object"===u(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return g(t)}(this,o)}}function g(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function O(t){return O=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},O(t)}var j={children:l.default.node,active:l.default.bool,disabled:l.default.bool,divider:l.default.bool,tag:f.tagPropType,header:l.default.bool,onClick:l.default.func,className:l.default.string,cssModule:l.default.object,toggle:l.default.bool,text:l.default.bool},x=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}(i,t);var e,o,r,n=h(i);function i(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),(e=n.call(this,t)).onClick=e.onClick.bind(g(e)),e.getTabIndex=e.getTabIndex.bind(g(e)),e}return e=i,(o=[{key:"onClick",value:function(t){var e=this.props,o=e.disabled,r=e.header,n=e.divider,i=e.text;o||r||n||i?t.preventDefault():(this.props.onClick&&this.props.onClick(t),this.props.toggle&&this.context.toggle(t))}},{key:"getRole",value:function(){return"listbox"===this.context.menuRole?"option":"menuitem"}},{key:"getTabIndex",value:function(){var t=this.props,e=t.disabled,o=t.header,r=t.divider,n=t.text;return e||o||r||n?"-1":"0"}},{key:"render",value:function(){var t=this.getTabIndex(),e=t>-1?this.getRole():void 0,o=(0,f.omit)(this.props,["toggle"]),r=o.className,n=o.cssModule,i=o.divider,u=o.tag,l=o.header,s=o.active,d=o.text,v=y(o,p),m=(0,f.mapToCssModules)((0,c.default)(r,{disabled:v.disabled,"dropdown-item":!i&&!l&&!d,active:s,"dropdown-header":l,"dropdown-divider":i,"dropdown-item-text":d}),n);return"button"===u&&(l?u="h6":i?u="div":v.href?u="a":d&&(u="span")),a.default.createElement(u,b({type:"button"===u&&(v.onClick||this.props.toggle)?"button":void 0},v,{tabIndex:t,role:e,className:m,onClick:this.onClick}))}}])&&v(e.prototype,o),r&&v(e,r),Object.defineProperty(e,"prototype",{writable:!1}),i}(a.default.Component);x.propTypes=j,x.defaultProps={tag:"button",toggle:!0},x.contextType=s.DropdownContext;var w=x;t.default=w}(t);
//# sourceMappingURL=DropdownItem.js.map
