const path = require("path");
const { AssetsHelper } = require("./webpack/webpack-helpers.js");
const theme = new AssetsHelper(__dirname);

const config = {
  core: [
    ...theme.plugin("preloader", "webpack.entry", "show_preloader"),
    ...theme.assets([
      "css/theme.scss",
      "css/molecules/checkbox.scss",
      "css/molecules/radio-button.scss",
      "css/molecules/breadcrumbs.scss",
      "css/molecules/keen-arrows.scss",
      "css/molecules/keen-slider.scss",
      "js/app.ts",
      "js/sticky-scroll.ts",
      //
    ]),
    ...theme.plugin("header"),
    ...theme.plugin("footer", "webpack.entry", "show_footer"),
    ...theme.plugin("topbar", "webpack.entry", "show_topbar"),
    ...theme.plugin("contact-form", "webpack.entry", "contact_form"),
    ...theme.plugin("promo-banner", "webpack.entry", "promo_banner"),
    ...theme.plugin("wpbs-search", "webpack.entry", "wpbs_post_search"),
    ...theme.plugin(
      "wpbs-order-details",
      "webpack.entry",
      "wpbs_order_details"
    ),
    ...theme.plugin("wpbs-form-extend", "webpack.entry", "wpbs_extend"),
    ...theme.plugin(
      "wpbs-calendar-drag",
      "webpack.entry",
      "wpbs_calendar_drag"
    ),
    ...theme.plugin("cookies", "webpack.entry", "cookie_bar"),
    ...theme.plugin("mega-menu", "webpack.entry", "mega_menu"),
    ...theme.plugin("mobile-menu-slide", "webpack.entry", "mobile_menu_slide"),
    ...theme.plugin("order-by-wrap", "webpack.entry", "advanced_order_by_wrap"),
    ...theme.entry("components"),
  ],

  admin: [
    ...theme.plugin(
      "wpbs-order-details",
      "webpack-admin.entry",
      "wpbs_order_details"
    ),
    ...theme.plugin("mega-menu", "webpack-admin.entry", "mega_menu"),
    ...theme.assets(["css/admin.scss", "js/admin.ts"]),
    ...theme.assets(
      ["css/admin-styles.scss", "css/admin-login.scss", "js/admin-scripts.js"],
      "assets",
      "admin_styles"
    ),
    ...theme.assets(
      ["css/custom-theme-options-admin.scss"],
      "assets",
      "custom_theme_options"
    ),
  ],

  checkout: [
    ...theme.assets([
      "css/checkout.scss",
      "js/checkout.ts",
      //
    ]),
    ...theme.plugin("cart-upsell", "webpack.entry", "show_cart_upsells"),
    ...theme.plugin("wc-gift-cards", "webpack-checkout.entry"),
  ],

  myaccount: [
    ...theme.assets([
      "css/myaccount.scss",
      "js/myaccount.ts",
      //
    ]),
    ...theme.plugin("wc-gift-cards", "webpack-account.entry"),
  ],

  page_templates: {
    multitab_page: [...theme.template("multitab-page")],
    faq: [...theme.template("faq")],
    contact: [...theme.template("contact")],
    components: [...theme.template("components")],
    page404: theme.assets(["css/404.scss"]),
    wishlist: [...theme.template("wishlist")],
  },

  post_types: {
    product: [
      ...theme.post_type("product"),
      ...theme.post_type("product-b2b", 'b2b'),
      ...theme.plugin("wc-gift-cards", "webpack-single.entry"),
    ],
    post: [...theme.post_type("post")],
    accommodation: [...theme.post_type("accommodation")],
    downloads: [...theme.post_type("downloads")],
  },

  singles: [],

  gutenberg: [
    ...theme.assets(["css/gutenberg.scss"]),
    ...theme.entry("components"),
  ],

  config: [
    ...theme.assets(
      [
        "config.jsonc",
        "plugins.json",
        "checkout-fields.json",
        "image-sizes.json",
        "theme-fonts.json",
        "theme-color-schemes.json",
        "breakpoints.json",
        "wpbs.json",
      ],
      "config"
    ),
    ...theme.componentConfigs(),
  ],
};

module.exports = config;
