import { Component, Element, State, Prop, h } from '@stencil/core';
import { AssetsService, EnvironmentConfigService } from '../../services';
export class SparkleDiscussion {
  constructor() {
    this.allowPostToFeed = false;
    this.feedStartingText = 'My suggestions are:';
    this.isTeacherMode = false;
    this.quizData = [];
  }
  async componentDidLoad() {
    this.isTeacherMode = this.isTeacherMode == false ? window.location.href.indexOf('/presentation/course') > -1 : this.isTeacherMode;
    const config = EnvironmentConfigService.getInstance().get('sparkle');
    let allQuizData = await AssetsService.getInstance().loadJsonFile(config.quizPath);
    if (allQuizData) {
      if (this.questionIds) {
        let questionIds = this.questionIds.split(',');
        this.quizData = [];
        questionIds.forEach(id => {
          this.quizData = [...this.quizData, allQuizData[+id]];
        });
        console.log('QUIZ Data', this.quizData);
      }
    }
  }
  render() {
    return this.isTeacherMode ? (h("sparkle-discussion-results", { allowPostToFeed: this.allowPostToFeed, feedStartingText: this.feedStartingText, isTeacherMode: this.isTeacherMode, questions: this.quizData })) : (h("sparkle-discussion-questions", { allowPostToFeed: this.allowPostToFeed, feedStartingText: this.feedStartingText, isTeacherMode: this.isTeacherMode, questions: this.quizData }));
  }
  static get is() { return "sparkle-discussion"; }
  static get originalStyleUrls() { return {
    "$": ["sparkle-discussion.css"]
  }; }
  static get styleUrls() { return {
    "$": ["sparkle-discussion.css"]
  }; }
  static get properties() { return {
    "allowPostToFeed": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "allow-post-to-feed",
      "reflect": false,
      "defaultValue": "false"
    },
    "feedStartingText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "feed-starting-text",
      "reflect": false,
      "defaultValue": "'My suggestions are:'"
    },
    "isTeacherMode": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "is-teacher-mode",
      "reflect": false,
      "defaultValue": "false"
    },
    "questionIds": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "question-ids",
      "reflect": false
    }
  }; }
  static get states() { return {
    "quizData": {}
  }; }
  static get elementRef() { return "el"; }
}
