var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/PisellSuperTabs/PisellSuperTabs.tsx
var PisellSuperTabs_exports = {};
__export(PisellSuperTabs_exports, {
  default: () => PisellSuperTabs_default
});
module.exports = __toCommonJS(PisellSuperTabs_exports);
var import_classnames = __toESM(require("classnames"));
var import_react = __toESM(require("react"));
var import_PisellBasicGrid = __toESM(require("../PisellBasicGrid"));
var import_PisellScrollView = __toESM(require("../PisellScrollView"));
var import_PisellSuperTabs = require("./PisellSuperTabs.less");
var import_hooks = require("./hooks");
var import_utils = require("./utils");
var EMPTY_GRID_PROPS = {};
var EMPTY_SCROLL_VIEW_PROPS = {};
var PisellSuperTabs = (props, ref) => {
  var _a, _b, _c, _d;
  const {
    // 基础属性
    className,
    style,
    dataSource = [],
    rowKey = "key",
    value,
    id,
    defaultValue,
    onChange,
    renderItem,
    // Grid Props（已分组）
    gridProps = EMPTY_GRID_PROPS,
    // ScrollView Props（已分组）
    scrollViewProps = EMPTY_SCROLL_VIEW_PROPS,
    children,
    slotLeft,
    slotRight,
    slotTop,
    slotBottom,
    tabItemClassName,
    tabItemStyle,
    slotLeftClassName,
    slotRightClassName,
    slotTopClassName,
    slotBottomClassName,
    slotLeftStyle,
    slotRightStyle,
    slotTopStyle,
    slotBottomStyle,
    isControlled = true,
    __designMode
  } = props;
  const containerRef = (0, import_react.useRef)(null);
  const { activeKey, handleTabChange } = (0, import_hooks.useTabsState)({
    value,
    defaultValue,
    onChange,
    isControlled: isControlled ?? false
  });
  const scrollItemByRowKey = (key) => {
    const item = document.querySelector(`.pisell-super-tabs-item-${id}-${key}`);
    console.log(`.pisell-super-tabs-item-${id}-${key}`);
    if (item) {
      item.scrollIntoView({ behavior: "smooth" });
    }
  };
  (0, import_react.useImperativeHandle)(ref, () => {
    if (__designMode) {
      return containerRef.current;
    }
    return {
      scrollItemByRowKey
    };
  });
  const resolvedScrollViewProps = (0, import_react.useMemo)(
    () => scrollViewProps,
    [
      scrollViewProps.overflow,
      scrollViewProps.scrollbarStyle,
      scrollViewProps.style,
      (_a = scrollViewProps.scrollActionsConfig) == null ? void 0 : _a.show,
      (_b = scrollViewProps.scrollActionsConfig) == null ? void 0 : _b.type,
      (_c = scrollViewProps.snapScroll) == null ? void 0 : _c.enabled,
      (_d = scrollViewProps.snapScroll) == null ? void 0 : _d.type
    ]
  );
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)("pisell-super-tabs", className),
      style,
      id,
      ref: containerRef
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(
          "pisell-super-tabs-slot-top-" + id,
          slotTopClassName
        ),
        style: slotTopStyle
      },
      slotTop
    ),
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(
          "pisell-super-tabs-slot-left-" + id,
          slotLeftClassName
        ),
        style: slotLeftStyle
      },
      slotLeft
    ),
    /* @__PURE__ */ import_react.default.createElement(import_PisellScrollView.default, { ...resolvedScrollViewProps }, /* @__PURE__ */ import_react.default.createElement(
      import_PisellBasicGrid.default,
      {
        ...gridProps,
        dataSource,
        rowKey,
        renderItem: (item, index) => {
          const key = (0, import_utils.getRowKey)(item, index, rowKey);
          const active = key === String(activeKey);
          let content;
          if (renderItem) {
            if (typeof renderItem === "function") {
              content = renderItem({
                dataSource: item,
                index,
                onClick: () => {
                  if (item.customClick) {
                    return;
                  }
                  handleTabChange(key, item);
                },
                tabsState: {
                  activeKey,
                  handleTabChange
                },
                tabsProps: props,
                active: {
                  value: active
                }
              });
            } else {
              content = renderItem;
            }
          } else {
            content = item["label"];
          }
          return /* @__PURE__ */ import_react.default.createElement(
            "div",
            {
              key,
              className: (0, import_classnames.default)(
                "pisell-super-tabs-item",
                `pisell-super-tabs-item-${id}-${key}`,
                {
                  "pisell-super-tabs-item--active": active
                },
                tabItemClassName
              ),
              style: tabItemStyle
            },
            content
          );
        }
      }
    )),
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-super-tabs-content" }, children),
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(
          "pisell-super-tabs-slot-right-" + id,
          slotRightClassName
        ),
        style: slotRightStyle
      },
      slotRight
    ),
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(
          "pisell-super-tabs-slot-bottom-" + id,
          slotBottomClassName
        ),
        style: slotBottomStyle
      },
      slotBottom
    )
  );
};
PisellSuperTabs.displayName = "PisellSuperTabs";
var PisellSuperTabs_default = (0, import_react.forwardRef)(PisellSuperTabs);
