"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _useAccessNavigationManager = _interopRequireDefault(require("../access-navigation-manager/useAccessNavigationManager"));

var _focusVisible = _interopRequireDefault(require("../../accessibility-utils/focusVisible"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var useTabAriaProps = function useTabAriaProps(props, configuration) {
  var navigationProps = React.useCallback((0, _useAccessNavigationManager["default"])(props, configuration), []);
  var rootElementProps = navigationProps.rootElementProps,
      getItemProps = navigationProps.getItemProps,
      focusFirst = navigationProps.focusFirst; //let { focusVisible,focusProps } = useFocusVisible(props);

  return {
    tablistProps: function tablistProps(_ref) {
      var ariaLabel = _ref.ariaLabel;
      return _objectSpread({
        "role": "tablist",
        "aria-label": ariaLabel
      }, rootElementProps);
    },
    tabProps: function tabProps(props) {
      var id = props.id,
          selectedId = props.selectedId,
          ariaControls = props.ariaControls;

      var _getItemProps = getItemProps(id),
          dataAriaItem = _getItemProps.dataAriaItem,
          itemId = _getItemProps.itemId;

      return _objectSpread(_objectSpread({
        "role": "tab",
        "aria-selected": selectedId === itemId,
        "tabindex": selectedId === itemId ? "0" : "-1",
        //"tabindex" : "0",
        "aria-controls": ariaControls
      }, dataAriaItem), {}, {
        itemId: itemId //focusVisible

      });
    },
    tabpanelProps: function tabpanelProps(_ref2) {
      var ariaLabelledby = _ref2.ariaLabelledby;
      return {
        "role": "tabpanel",
        "aria-labelledby": ariaLabelledby,
        "tabindex": "0"
      };
    },
    focusFirst: focusFirst
  };
};

var _default = useTabAriaProps; //   let tagAriaProps= useTabAriaProps(props,{
//     activecss: style.popuplistFocus,
//     wrap: true,
//     onKeyDown: ()=>{}
//   });
//   let { tablistProps,tabProps,tabpanelProps } = tagAriaProps;
//   let { rootElementProps,inputProps,getItemProps,listElementProps,targetElementProps } = navigationProps;
//   <TabLayer {...tablistProps} {...rootElementProps}>
//       <TabItem {...tabProps} />
//       <TabItem />
//       <TabItem />
//       <TabPanel {...tabpanelProps} />
//       <TabPanel />
//       <TabPanel />
//   </TabLayer>
//   const TabLayer = (props)=>{
//     let  tagAriaProps= useTabAriaProps(props,{
//       activecss: style.popuplistFocus,
//       wrap: true
//     });
//     let { tablistProps,tabProps,tabpanelProps } = tagAriaProps;
//     return(
//       <TabLayer {...tablistProps}>
//           <TabItem {...tabProps} />
//           <TabItem />
//           <TabItem />
//           <TabPanel {...tabpanelProps} />
//           <TabPanel />
//           <TabPanel />
//       </TabLayer>
//     )
//   } 

exports["default"] = _default;