import { Logger } from '@dvn/core/log/logger';
import { STORAGE_KEY_KIMLIK_TOKEN } from '@dvn/kimlik/api/kimlikApi';
import { InstanceStorage } from '@dvn/kimlik/storage/instance';
import { SozlukApi } from '@dvn/sozluk/api';
import { Component, getAssetPath, h, Host, Prop, State } from '@stencil/core';
import { AtamaApiDemo } from '../../api/AtamaApiDemo';
import { DataApiDemo } from '../../api/DataApiDemo';
import { KimlikApiDemo } from '../../api/KimlikApiDemo';
import { TakvimApiDemo } from '../../api/TakvimApiDemo';
import { UyeApiDemo } from '../../api/UyeApiDemo';
import { demoDB } from '../../data/_db';
const logLevel = 'debug';
export class KhanguruDemoMentorshipSpace {
  constructor() {
    this.path = '/';
    this.navigate = (config) => {
      this.logger.debugGroup('navigate', {
        from: this.path,
        to: config.path,
      });
      this.path = config.path;
    };
  }
  componentWillLoad() {
    const assetsPath = getAssetPath(`./assets`);
    const database = JSON.parse(JSON.stringify(demoDB({ assetsPath })));
    this.logger = new Logger('KhanguruDemoMentorshipSpace').setLevel(logLevel);
    this.logger.infoGroup('componentWillLoad', { storageKey: this.storageKey });
    this.storage = new InstanceStorage(this.storageKey, this.logger);
    this.storage.save(STORAGE_KEY_KIMLIK_TOKEN, 'kimlikUsers1-jwt');
    this.apiAtama = new AtamaApiDemo(database, this.logger);
    this.apiData = new DataApiDemo(database, this.logger);
    this.apiKimlik = new KimlikApiDemo(database, this.storage, this.logger);
    this.apiTakvim = new TakvimApiDemo(database, this.storage, this.logger);
    this.apiUye = new UyeApiDemo(database, this.storage, this.logger);
    this.path = this.initialPath || location.pathname;
    this.apiSozluk = new SozlukApi();
  }
  render() {
    return (h(Host, null,
      h("dvn-app-root", { apiAtama: this.apiAtama, apiData: this.apiData, apiKimlik: this.apiKimlik, apiSozluk: this.apiSozluk, apiTakvim: this.apiTakvim, apiUye: this.apiUye, navigate: this.navigate, path: this.path, logger: this.logger, storage: this.storage })));
  }
  static get is() { return "khanguru-demo-mentorship-space"; }
  static get encapsulation() { return "scoped"; }
  static get assetsDirs() { return ["assets"]; }
  static get properties() { return {
    "initialPath": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "initial-path",
      "reflect": false
    },
    "storageKey": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "storage-key",
      "reflect": false
    }
  }; }
  static get states() { return {
    "path": {}
  }; }
}
