import { InobyModule } from "@lib/inoby-module";
import * as $ from "jquery";

class MBFaqComponent extends InobyModule {
  public run() {
    $(".component-faq .faq-wrap .faq-item:first-child")
      .addClass("active")
      .children(".faq-answer")
      .slideDown(); //Remove this line if you dont want the first one to be opened automatically.
    $(".component-faq .faq-question").on("click", function () {
      if ($(this).parent().hasClass("active")) {
        $(this).next().slideUp();
        $(this).parent().removeClass("active");
      } else {
        $(".faq-answer").slideUp();
        $(".faq-item").removeClass("active");
        $(this).parent().addClass("active");
        $(this).next().slideDown();
      }
    });
  }
}

new MBFaqComponent().runOnReady();
