import React from 'react';
import Title from "../components/Title";
import SubTitle from "../components/SubTitle";
import Price from "../components/Price";
import Tags from "../components/Tags";
import MemberPrice from "../components/MemberPrice";
import Countdown from "../components/Countdown";
import Stock from "../components/Stock";
import Capacity from "../components/Capacity";
import Duration from "../components/Duration";
import Time from "../components/Time";
import Resource from "../components/Resource";
import Promotions from "../components/Promotions";

// 组件映射表
var componentMap = {
  title: Title,
  subtitle: SubTitle,
  price: Price,
  memberPrice: MemberPrice,
  tags: Tags,
  countdown: Countdown,
  stock: Stock,
  capacity: Capacity,
  duration: Duration,
  time: Time,
  resource: Resource,
  promotions: Promotions
};
export var useDynamicComponents = function useDynamicComponents() {
  // 渲染组件
  var renderComponent = function renderComponent(key, props) {
    var Component = componentMap[key];
    if (!Component) {
      return null;
    }
    return /*#__PURE__*/React.createElement(Component, {
      key: key,
      props: props
    });
  };

  // 渲染组件列表
  var renderComponents = function renderComponents(props) {
    var sortKeys = (props === null || props === void 0 ? void 0 : props.sortKeys) || [];
    return sortKeys.map(function (key) {
      return renderComponent(key, props);
    });
  };
  return {
    renderComponent: renderComponent,
    renderComponents: renderComponents,
    componentMap: componentMap
  };
};