function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React, { useState, useEffect, useCallback, useMemo } from 'react';
import ResponsiveWrapper, { createResponsiveConfig } from "./ResponsiveWrapper";
import "./TestResponsiveWrapper.less";

// 数据类型定义

// 模拟数据生成器
var generateTestData = function generateTestData(count, category) {
  var categories = ['电子产品', '服装配饰', '家居用品', '运动户外', '美妆护肤'];
  var statuses = ['active', 'inactive', 'pending'];
  return Array.from({
    length: count
  }, function (_, index) {
    return {
      id: index + 1,
      title: "".concat(category || categories[Math.floor(Math.random() * categories.length)], " ").concat(index + 1),
      description: "\u8FD9\u662F\u7B2C ".concat(index + 1, " \u4E2A\u6D4B\u8BD5\u9879\u76EE\u7684\u8BE6\u7EC6\u63CF\u8FF0\uFF0C\u5305\u542B\u4E86\u4EA7\u54C1\u7684\u4E3B\u8981\u7279\u70B9\u548C\u4F18\u52BF"),
      category: category || categories[Math.floor(Math.random() * categories.length)],
      height: Math.random() * 200 + 100,
      // 随机高度，用于瀑布流测试
      price: Math.round(Math.random() * 1000 + 10),
      status: statuses[Math.floor(Math.random() * statuses.length)],
      createdAt: new Date(Date.now() - Math.random() * 30 * 24 * 60 * 60 * 1000) // 最近30天内的随机日期
    };
  });
};

// 带起始ID的数据生成器（用于分页数据）
var generateTestDataWithId = function generateTestDataWithId(count, category) {
  var startId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
  var categories = ['电子产品', '服装配饰', '家居用品', '运动户外', '美妆护肤'];
  var statuses = ['active', 'inactive', 'pending'];

  // 产品名称模板
  var productNames = {
    '电子产品': ['智能手机', '蓝牙耳机', '平板电脑', '智能手表', '充电器', '数据线', '移动电源', '音响'],
    '服装配饰': ['休闲外套', '牛仔裤', '连衣裙', '运动鞋', '手提包', '围巾', '帽子', 'T恤'],
    '家居用品': ['咖啡杯', '床上用品', '收纳盒', '台灯', '花瓶', '地毯', '抱枕', '装饰画'],
    '运动户外': ['运动鞋', '瑜伽垫', '哑铃', '背包', '帐篷', '水杯', '护膝', '跑步腰包'],
    '美妆护肤': ['面膜', '口红', '防晒霜', '洗面奶', '精华液', '粉底液', '眼影', '香水']
  };
  return Array.from({
    length: count
  }, function (_, index) {
    var targetCategory = category && category !== 'all' ? category : categories[Math.floor(Math.random() * categories.length)];
    var categoryProducts = productNames[targetCategory] || productNames['电子产品'];
    var productName = categoryProducts[Math.floor(Math.random() * categoryProducts.length)];
    var itemId = startId + index;
    return {
      id: itemId,
      title: "".concat(productName, " - \u578B\u53F7").concat(String(itemId).padStart(4, '0')),
      description: "".concat(productName, "\u7684\u8BE6\u7EC6\u4ECB\u7ECD\uFF1A\u91C7\u7528\u4F18\u8D28\u6750\u6599\u5236\u4F5C\uFF0C\u8BBE\u8BA1\u7CBE\u7F8E\uFF0C\u529F\u80FD\u5B9E\u7528\u3002\u9002\u5408\u65E5\u5E38\u4F7F\u7528\uFF0C\u6027\u4EF7\u6BD4\u6781\u9AD8\u3002\u7F16\u53F7\uFF1A").concat(String(itemId).padStart(6, '0')),
      category: targetCategory,
      height: Math.random() * 250 + 120,
      // 稍微增加高度变化范围
      price: Math.round(Math.random() * 2000 + 50),
      // 增加价格范围
      status: statuses[Math.floor(Math.random() * statuses.length)],
      createdAt: new Date(Date.now() - Math.random() * 60 * 24 * 60 * 60 * 1000) // 最近60天内的随机日期
    };
  });
};

// 固定的分类配置
var CATEGORIES = [{
  key: '电子产品',
  label: '电子产品',
  total: 150
}, {
  key: '服装配饰',
  label: '服装配饰',
  total: 125
}, {
  key: '家居用品',
  label: '家居用品',
  total: 100
}, {
  key: '运动户外',
  label: '运动户外',
  total: 75
}, {
  key: '美妆护肤',
  label: '美妆护肤',
  total: 50
}];

// 简单的tab生成函数 - 根据模式生成不同的tab数据
var generateSimpleTabItems = function generateSimpleTabItems(tabStyle) {
  var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  if (tabStyle === 'switch') {
    // 切换模式：使用固定的分类结构，不显示动态数量
    var tabs = [{
      key: 'all',
      label: '全部'
    }];
    CATEGORIES.forEach(function (category) {
      tabs.push({
        key: category.key,
        label: category.label,
        group: category.key
      });
    });
    return tabs;
  } else {
    // 锚点模式：基于实际数据统计数量，提供多维度分类
    var categoryCount = data.reduce(function (acc, item) {
      acc[item.category] = (acc[item.category] || 0) + 1;
      return acc;
    }, {});
    var statusCount = data.reduce(function (acc, item) {
      acc[item.status] = (acc[item.status] || 0) + 1;
      return acc;
    }, {});
    var priceRangeCount = data.reduce(function (acc, item) {
      var price = item.price || 0;
      var range = '';
      if (price < 100) range = '100元以下';else if (price < 500) range = '100-500元';else if (price < 1000) range = '500-1000元';else range = '1000元以上';
      acc[range] = (acc[range] || 0) + 1;
      return acc;
    }, {});
    var _tabs = [{
      key: 'all',
      label: "\u5168\u90E8 (".concat(data.length, ")")
    }];

    // 按商品分类
    Object.entries(categoryCount).forEach(function (_ref) {
      var _ref2 = _slicedToArray(_ref, 2),
        category = _ref2[0],
        count = _ref2[1];
      _tabs.push({
        key: "category-".concat(category),
        label: "".concat(category, " (").concat(count, ")"),
        group: category
      });
    });

    // 按状态分类
    var statusLabels = {
      'active': '正常',
      'inactive': '停用',
      'pending': '待审核'
    };
    Object.entries(statusCount).forEach(function (_ref3) {
      var _ref4 = _slicedToArray(_ref3, 2),
        status = _ref4[0],
        count = _ref4[1];
      _tabs.push({
        key: "status-".concat(status),
        label: "".concat(statusLabels[status], " (").concat(count, ")"),
        group: status
      });
    });

    // 按价格区间分类
    Object.entries(priceRangeCount).forEach(function (_ref5) {
      var _ref6 = _slicedToArray(_ref5, 2),
        range = _ref6[0],
        count = _ref6[1];
      _tabs.push({
        key: "price-".concat(range),
        label: "".concat(range, " (").concat(count, ")"),
        group: range
      });
    });
    return _tabs;
  }
};

// 模拟API调用
var mockApiCall = /*#__PURE__*/function () {
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
    var pageSize, currentPage, category, _params$delay, delay, categoryTotals, totalCount, startId, data, hasMore;
    return _regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          pageSize = params.pageSize, currentPage = params.currentPage, category = params.category, _params$delay = params.delay, delay = _params$delay === void 0 ? 800 : _params$delay; // 模拟网络延迟（减少延迟以提升体验）
          _context.next = 3;
          return new Promise(function (resolve) {
            return setTimeout(resolve, delay);
          });
        case 3:
          if (!(Math.random() < 0.05)) {
            _context.next = 5;
            break;
          }
          throw new Error('网络请求失败，请重试');
        case 5:
          // 根据分类设置不同的总数，总计500条数据
          categoryTotals = {
            '电子产品': 150,
            // 30%
            '服装配饰': 125,
            // 25%
            '家居用品': 100,
            // 20%
            '运动户外': 75,
            // 15%
            '美妆护肤': 50 // 10%
          };
          totalCount = category && category !== 'all' ? categoryTotals[category] || 50 : 500; // 生成当前页的数据，为分类数据添加起始ID偏移
          startId = category && category !== 'all' ? Object.entries(categoryTotals).reduce(function (offset, _ref8) {
            var _ref9 = _slicedToArray(_ref8, 2),
              cat = _ref9[0],
              count = _ref9[1];
            if (cat === category) return offset;
            return offset + count;
          }, 0) + (currentPage - 1) * pageSize + 1 : (currentPage - 1) * pageSize + 1;
          data = generateTestDataWithId(pageSize, category, startId);
          hasMore = currentPage * pageSize < totalCount;
          return _context.abrupt("return", {
            data: data,
            total: totalCount,
            hasMore: hasMore
          });
        case 11:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return function mockApiCall(_x) {
    return _ref7.apply(this, arguments);
  };
}();

// 基础配置项接口

// 默认配置（优化大数据量显示）
var defaultDynamicConfig = {
  displayStyle: 'grid',
  columns: {
    pc: 4,
    pad: 3,
    mobile: 2
  },
  columnGap: {
    pc: 20,
    pad: 16,
    mobile: 12
  },
  rowGap: {
    pc: 20,
    pad: 16,
    mobile: 12
  },
  paginationType: {
    pc: 'pager',
    pad: 'more',
    mobile: 'scroll'
  },
  defaultPageSize: {
    pc: 20,
    pad: 15,
    mobile: 10
  },
  enableTab: false,
  tabStyle: 'none',
  stickyTop: false,
  enableEmpty: false
};

// 预设配置模板
var presetConfigs = [{
  name: '基础网格布局',
  description: '标准的网格布局，适合大数据量内容展示（500条数据）',
  config: {
    displayStyle: 'grid',
    columns: {
      pc: 4,
      pad: 3,
      mobile: 2
    },
    columnGap: {
      pc: 20,
      pad: 16,
      mobile: 12
    },
    rowGap: {
      pc: 20,
      pad: 16,
      mobile: 12
    },
    paginationType: {
      pc: 'pager',
      pad: 'pager',
      mobile: 'scroll'
    },
    defaultPageSize: {
      pc: 20,
      pad: 15,
      mobile: 10
    },
    enableTab: false,
    tabStyle: 'none',
    stickyTop: false,
    enableEmpty: false
  }
}, {
  name: '切换模式',
  description: '标签切换模式，点击标签会重新加载对应分类的数据',
  config: {
    displayStyle: 'grid',
    columns: {
      pc: 4,
      pad: 3,
      mobile: 2
    },
    columnGap: {
      pc: 18,
      pad: 15,
      mobile: 12
    },
    rowGap: {
      pc: 18,
      pad: 15,
      mobile: 12
    },
    paginationType: {
      pc: 'pager',
      pad: 'more',
      mobile: 'scroll'
    },
    defaultPageSize: {
      pc: 16,
      pad: 12,
      mobile: 8
    },
    enableTab: true,
    tabStyle: 'switch',
    stickyTop: true,
    enableEmpty: false
  }
}, {
  name: '锚点模式',
  description: '标签锚点模式，显示所有数据并按分类分组，点击标签会跳转到对应分组位置',
  config: {
    displayStyle: 'grid',
    columns: {
      pc: 4,
      pad: 3,
      mobile: 2
    },
    columnGap: {
      pc: 18,
      pad: 15,
      mobile: 12
    },
    rowGap: {
      pc: 18,
      pad: 15,
      mobile: 12
    },
    paginationType: {
      pc: 'all',
      pad: 'all',
      mobile: 'all'
    },
    defaultPageSize: {
      pc: 500,
      pad: 500,
      mobile: 500
    },
    enableTab: true,
    tabStyle: 'anchor',
    stickyTop: true,
    enableEmpty: false
  }
}];

/**
 * ResponsiveWrapper 测试组件
 * 用于测试ResponsiveWrapper组件在不同配置下的表现，支持动态配置和数据加载模拟
 */
var TestResponsiveWrapper = function TestResponsiveWrapper() {
  var _useState = useState(0),
    _useState2 = _slicedToArray(_useState, 2),
    activePreset = _useState2[0],
    setActivePreset = _useState2[1];
  var _useState3 = useState(null),
    _useState4 = _slicedToArray(_useState3, 2),
    simulateDevice = _useState4[0],
    setSimulateDevice = _useState4[1];
  var _useState5 = useState(defaultDynamicConfig),
    _useState6 = _slicedToArray(_useState5, 2),
    dynamicConfig = _useState6[0],
    setDynamicConfig = _useState6[1];
  var _useState7 = useState(false),
    _useState8 = _slicedToArray(_useState7, 2),
    isCustomMode = _useState8[0],
    setIsCustomMode = _useState8[1];

  // 数据加载相关状态
  var _useState9 = useState([]),
    _useState10 = _slicedToArray(_useState9, 2),
    data = _useState10[0],
    setData = _useState10[1];
  var _useState11 = useState(false),
    _useState12 = _slicedToArray(_useState11, 2),
    loading = _useState12[0],
    setLoading = _useState12[1];
  var _useState13 = useState(null),
    _useState14 = _slicedToArray(_useState13, 2),
    error = _useState14[0],
    setError = _useState14[1];
  var _useState15 = useState(1),
    _useState16 = _slicedToArray(_useState15, 2),
    currentPage = _useState16[0],
    setCurrentPage = _useState16[1];
  var _useState17 = useState(0),
    _useState18 = _slicedToArray(_useState17, 2),
    total = _useState18[0],
    setTotal = _useState18[1];
  var _useState19 = useState('all'),
    _useState20 = _slicedToArray(_useState19, 2),
    activeTab = _useState20[0],
    setActiveTab = _useState20[1];
  var _useState21 = useState('pager'),
    _useState22 = _slicedToArray(_useState21, 2),
    currentPaginationType = _useState22[0],
    setCurrentPaginationType = _useState22[1];
  var _useState23 = useState(600),
    _useState24 = _slicedToArray(_useState23, 2),
    maxHeight = _useState24[0],
    setMaxHeight = _useState24[1]; // 默认600px最大高度
  var _useState25 = useState('vertical'),
    _useState26 = _slicedToArray(_useState25, 2),
    scrollDirection = _useState26[0],
    setScrollDirection = _useState26[1]; // 默认垂直滚动

  // 加载数据的方法
  var loadData = useCallback( /*#__PURE__*/function () {
    var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
      var response;
      return _regeneratorRuntime().wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            setLoading(true);
            setError(null);
            _context2.prev = 2;
            _context2.next = 5;
            return mockApiCall({
              currentPage: params.currentPage,
              pageSize: params.pageSize,
              category: params.activeTab === 'all' ? undefined : params.activeTab
            });
          case 5:
            response = _context2.sent;
            if (params.trigger === 'loadMore' || params.trigger === 'scroll') {
              setData(function (prev) {
                return [].concat(_toConsumableArray(prev), _toConsumableArray(response.data));
              });
            } else {
              setData(response.data);
            }
            setTotal(response.total);
            setCurrentPage(params.currentPage);
            setActiveTab(params.activeTab || 'all');
            _context2.next = 15;
            break;
          case 12:
            _context2.prev = 12;
            _context2.t0 = _context2["catch"](2);
            setError(_context2.t0 instanceof Error ? _context2.t0.message : '未知错误');
          case 15:
            _context2.prev = 15;
            setLoading(false);
            return _context2.finish(15);
          case 18:
          case "end":
            return _context2.stop();
        }
      }, _callee2, null, [[2, 12, 15, 18]]);
    }));
    return function (_x2) {
      return _ref10.apply(this, arguments);
    };
  }(), []);

  // 刷新数据
  var refreshData = useCallback(function () {
    var config = isCustomMode ? dynamicConfig : presetConfigs[activePreset].config;
    var deviceType = simulateDevice || 'pc';
    var pageSize = config.defaultPageSize[deviceType];
    loadData({
      trigger: 'pagination',
      currentPage: 1,
      pageSize: pageSize,
      activeTab: activeTab
    });
  }, [isCustomMode, dynamicConfig, activePreset, simulateDevice, activeTab, loadData]);

  // 初始化和配置变化时加载数据
  useEffect(function () {
    refreshData();
  }, [refreshData]);

  // 创建当前的响应式配置
  var currentResponsiveConfig = useMemo(function () {
    var config = isCustomMode ? dynamicConfig : presetConfigs[activePreset].config;

    // 生成简单的Tab数据
    var tabData = config.enableTab && config.tabStyle !== 'none' ? generateSimpleTabItems(config.tabStyle, data) : undefined;

    // 渲染项目的方法
    var renderItem = function renderItem(item, index) {
      var testItem = item;
      return /*#__PURE__*/React.createElement("div", {
        className: "test-item ".concat(testItem.status),
        key: testItem.id
      }, /*#__PURE__*/React.createElement("div", {
        className: "item-header"
      }, /*#__PURE__*/React.createElement("h4", {
        title: testItem.title
      }, testItem.title), /*#__PURE__*/React.createElement("span", {
        className: "status-badge ".concat(testItem.status)
      }, testItem.status === 'active' ? '正常' : testItem.status === 'inactive' ? '停用' : '待审核')), /*#__PURE__*/React.createElement("p", {
        className: "item-description",
        title: testItem.description
      }, testItem.description), /*#__PURE__*/React.createElement("div", {
        className: "item-meta"
      }, /*#__PURE__*/React.createElement("span", {
        className: "category"
      }, testItem.category), testItem.price && /*#__PURE__*/React.createElement("span", {
        className: "price"
      }, "\xA5", testItem.price)), /*#__PURE__*/React.createElement("div", {
        className: "item-footer"
      }, /*#__PURE__*/React.createElement("span", {
        className: "item-id"
      }, "#", testItem.id), /*#__PURE__*/React.createElement("span", {
        className: "created-time"
      }, testItem.createdAt.toLocaleDateString())), config.displayStyle === 'waterfall' && /*#__PURE__*/React.createElement("div", {
        className: "height-info"
      }, "\u9AD8\u5EA6: ", Math.round(testItem.height || 150), "px"));
    };

    // 基础配置
    var baseProps = {
      data: config.enableEmpty ? [] : data,
      loading: loading,
      displayStyle: config.displayStyle,
      layoutDirection: scrollDirection,
      tabStyle: config.enableTab ? config.tabStyle : 'none',
      tabGroup: 'category',
      // 指定使用category字段进行分组
      tabData: tabData,
      stickyTop: config.stickyTop,
      emptyConfig: config.enableEmpty ? {
        show: true,
        text: '暂无数据',
        description: '当前没有可显示的内容，请尝试刷新或调整筛选条件'
      } : undefined,
      renderItem: renderItem,
      onLoadData: loadData
    };

    // 创建响应式配置，使用createResponsiveConfig的新接口
    var responsiveConfig = createResponsiveConfig({
      pc: {
        columns: config.columns.pc,
        columnGap: config.columnGap.pc,
        rowGap: config.rowGap.pc,
        layoutDirection: scrollDirection,
        paginationType: currentPaginationType,
        defaultPageSize: config.defaultPageSize.pc,
        pagination: {
          current: currentPage,
          total: Math.ceil(total / config.defaultPageSize.pc),
          totalCount: total
        }
      },
      pad: {
        columns: config.columns.pad,
        columnGap: config.columnGap.pad,
        rowGap: config.rowGap.pad,
        layoutDirection: scrollDirection,
        paginationType: currentPaginationType,
        defaultPageSize: config.defaultPageSize.pad,
        pagination: {
          current: currentPage,
          total: Math.ceil(total / config.defaultPageSize.pad),
          totalCount: total
        }
      },
      mobile: {
        columns: config.columns.mobile,
        columnGap: config.columnGap.mobile,
        rowGap: config.rowGap.mobile,
        layoutDirection: scrollDirection,
        paginationType: currentPaginationType,
        defaultPageSize: config.defaultPageSize.mobile,
        pagination: {
          current: currentPage,
          total: Math.ceil(total / config.defaultPageSize.mobile),
          totalCount: total
        }
      }
    });

    // 返回完整的ResponsiveWrapperProps
    return _objectSpread(_objectSpread({}, baseProps), {}, {
      responsive: responsiveConfig
    });
  }, [isCustomMode, dynamicConfig, activePreset, data, loading, total, loadData, currentPaginationType, currentPage, scrollDirection]);

  // 处理预设配置切换
  var handlePresetChange = function handlePresetChange(index) {
    setActivePreset(index);
    setIsCustomMode(false);
    setDynamicConfig(presetConfigs[index].config);
  };

  // 处理自定义配置变化
  var handleConfigChange = function handleConfigChange(field, value) {
    setIsCustomMode(true);
    setDynamicConfig(function (prev) {
      return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, field, value));
    });
  };

  // 处理设备特定配置变化
  var handleDeviceConfigChange = function handleDeviceConfigChange(device, field, value) {
    setIsCustomMode(true);
    setDynamicConfig(function (prev) {
      var fieldValue = prev[field];
      return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, field, _objectSpread(_objectSpread({}, fieldValue), {}, _defineProperty({}, device, value))));
    });
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "test-responsive-wrapper"
  }, /*#__PURE__*/React.createElement("div", {
    className: "test-controls"
  }, /*#__PURE__*/React.createElement("div", {
    className: "preset-selector"
  }, /*#__PURE__*/React.createElement("h3", null, "\u9884\u8BBE\u914D\u7F6E\u6A21\u677F:"), /*#__PURE__*/React.createElement("div", {
    className: "preset-buttons"
  }, presetConfigs.map(function (preset, index) {
    return /*#__PURE__*/React.createElement("button", {
      key: index,
      className: "preset-button ".concat(index === activePreset && !isCustomMode ? 'active' : ''),
      onClick: function onClick() {
        return handlePresetChange(index);
      },
      title: preset.description
    }, preset.name);
  }))), /*#__PURE__*/React.createElement("div", {
    className: "device-simulator"
  }, /*#__PURE__*/React.createElement("h3", null, "\u8BBE\u5907\u7C7B\u578B:"), /*#__PURE__*/React.createElement("div", {
    className: "device-buttons"
  }, /*#__PURE__*/React.createElement("button", {
    className: "device-button ".concat(simulateDevice === null ? 'active' : ''),
    onClick: function onClick() {
      return setSimulateDevice(null);
    }
  }, "\u81EA\u52A8\u68C0\u6D4B"), ['pc', 'pad', 'mobile'].map(function (device) {
    return /*#__PURE__*/React.createElement("button", {
      key: device,
      className: "device-button ".concat(simulateDevice === device ? 'active' : ''),
      onClick: function onClick() {
        return setSimulateDevice(device);
      }
    }, device.toUpperCase());
  }))), /*#__PURE__*/React.createElement("div", {
    className: "data-controls"
  }, /*#__PURE__*/React.createElement("h3", null, "\u6570\u636E\u64CD\u4F5C:"), /*#__PURE__*/React.createElement("div", {
    className: "data-buttons"
  }, /*#__PURE__*/React.createElement("button", {
    onClick: refreshData,
    disabled: loading,
    className: "refresh-button"
  }, loading ? '加载中...' : '刷新数据'), /*#__PURE__*/React.createElement("button", {
    onClick: function onClick() {
      return handleConfigChange('enableEmpty', !dynamicConfig.enableEmpty);
    },
    className: "toggle-button ".concat(dynamicConfig.enableEmpty ? 'active' : '')
  }, dynamicConfig.enableEmpty ? '显示数据' : '显示空状态'))), /*#__PURE__*/React.createElement("div", {
    className: "pagination-controls"
  }, /*#__PURE__*/React.createElement("h3", null, "\u5206\u9875\u65B9\u5F0F:"), /*#__PURE__*/React.createElement("div", {
    className: "pagination-buttons"
  }, [{
    key: 'pager',
    label: '分页器',
    desc: '传统分页，适合精确导航'
  }, {
    key: 'more',
    label: '加载更多',
    desc: '点击按钮加载，适合移动端'
  }, {
    key: 'scroll',
    label: '滚动加载',
    desc: '自动无限滚动'
  }, {
    key: 'all',
    label: '全部显示',
    desc: '一次性显示所有数据'
  }].map(function (pagination) {
    return /*#__PURE__*/React.createElement("button", {
      key: pagination.key,
      className: "pagination-button ".concat(currentPaginationType === pagination.key ? 'active' : ''),
      onClick: function onClick() {
        return setCurrentPaginationType(pagination.key);
      },
      title: pagination.desc
    }, pagination.label, pagination.key === 'all' && total > 100 && /*#__PURE__*/React.createElement("span", {
      className: "warning-badge"
    }, "\u26A0\uFE0F"));
  })), /*#__PURE__*/React.createElement("div", {
    className: "pagination-description"
  }, /*#__PURE__*/React.createElement("small", null, "\u5F53\u524D: ", /*#__PURE__*/React.createElement("strong", null, currentPaginationType === 'pager' && '传统分页器 - 显示页码和跳转控件', currentPaginationType === 'more' && '加载更多 - 点击按钮加载下一页', currentPaginationType === 'scroll' && '滚动加载 - 滚动到底部自动加载', currentPaginationType === 'all' && '全部显示 - 一次性显示所有500条数据')))), /*#__PURE__*/React.createElement("div", {
    className: "height-controls"
  }, /*#__PURE__*/React.createElement("h3", null, "\u5217\u8868\u9AD8\u5EA6\u9650\u5236:"), /*#__PURE__*/React.createElement("div", {
    className: "height-buttons"
  }, [{
    value: 400,
    label: '400px',
    desc: '适合紧凑布局'
  }, {
    value: 600,
    label: '600px',
    desc: '默认高度，平衡体验'
  }, {
    value: 800,
    label: '800px',
    desc: '适合大屏幕浏览'
  }, {
    value: 'auto',
    label: '无限制',
    desc: '根据内容自适应高度'
  }].map(function (height) {
    return /*#__PURE__*/React.createElement("button", {
      key: height.value,
      className: "height-button ".concat(maxHeight === height.value ? 'active' : ''),
      onClick: function onClick() {
        return setMaxHeight(height.value);
      },
      title: height.desc
    }, height.label, height.value === 'auto' && currentPaginationType === 'all' && /*#__PURE__*/React.createElement("span", {
      className: "warning-badge"
    }, "\u26A0\uFE0F"));
  })), /*#__PURE__*/React.createElement("div", {
    className: "height-description"
  }, /*#__PURE__*/React.createElement("small", null, "\u5F53\u524D\u9AD8\u5EA6: ", /*#__PURE__*/React.createElement("strong", null, maxHeight === 'auto' ? '无限制 - 根据内容自适应' : "".concat(maxHeight, "px - \u8D85\u51FA\u90E8\u5206\u53EF\u6EDA\u52A8")), maxHeight === 'auto' && currentPaginationType === 'all' && /*#__PURE__*/React.createElement("span", {
    className: "performance-warning"
  }, " (\u26A0\uFE0F 500\u6761\u6570\u636E\u53EF\u80FD\u5F71\u54CD\u9875\u9762\u6027\u80FD)")))), /*#__PURE__*/React.createElement("div", {
    className: "scroll-direction-controls"
  }, /*#__PURE__*/React.createElement("h3", null, "\u6EDA\u52A8\u65B9\u5411:"), /*#__PURE__*/React.createElement("div", {
    className: "scroll-direction-buttons"
  }, [{
    key: 'vertical',
    label: '垂直滚动',
    desc: '上下滚动，传统列表布局',
    icon: '↕️',
    recommend: '推荐用于大多数场景'
  }, {
    key: 'horizontal',
    label: '水平滚动',
    desc: '左右滚动，卡片式布局',
    icon: '↔️',
    recommend: '适合图片展示或卡片浏览'
  }].map(function (direction) {
    return /*#__PURE__*/React.createElement("button", {
      key: direction.key,
      className: "scroll-direction-button ".concat(scrollDirection === direction.key ? 'active' : ''),
      onClick: function onClick() {
        return setScrollDirection(direction.key);
      },
      title: direction.desc
    }, /*#__PURE__*/React.createElement("span", {
      className: "direction-icon"
    }, direction.icon), direction.label, scrollDirection === direction.key && /*#__PURE__*/React.createElement("span", {
      className: "recommend-badge"
    }, "\u2713"));
  })))), /*#__PURE__*/React.createElement("div", {
    className: "test-container ".concat(simulateDevice ? "simulate-".concat(simulateDevice) : '')
  }, /*#__PURE__*/React.createElement(ResponsiveWrapper, _extends({}, currentResponsiveConfig, {
    className: "test-responsive-wrapper-instance scroll-".concat(scrollDirection),
    style: {
      border: '2px solid #e0e0e0',
      borderRadius: '8px',
      padding: '16px',
      backgroundColor: '#fafafa',
      position: 'relative',
      maxHeight: maxHeight === 'auto' ? 'none' : "".concat(maxHeight, "px"),
      overflowY: scrollDirection === 'vertical' ? maxHeight === 'auto' ? 'visible' : 'auto' : 'hidden',
      overflowX: scrollDirection === 'horizontal' ? 'auto' : 'hidden',
      maxWidth: scrollDirection === 'horizontal' ? '100%' : 'none'
    }
  })), loading && /*#__PURE__*/React.createElement("div", {
    className: "loading-overlay"
  }, /*#__PURE__*/React.createElement("div", {
    className: "loading-spinner"
  }, "\u52A0\u8F7D\u4E2D...")), maxHeight !== 'auto' && /*#__PURE__*/React.createElement("div", {
    className: "height-indicator"
  }, /*#__PURE__*/React.createElement("small", null, "\uD83D\uDCCF \u5217\u8868\u6700\u5927\u9AD8\u5EA6: ", maxHeight, "px"))));
};
export default TestResponsiveWrapper;