'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-1ee80297.js');
const dataApi = require('./dataApi-4c166e4e.js');
const kimlikApi = require('./kimlikApi-1cd43caf.js');
const index$1 = require('./index-4d4f2dcf.js');
const cookie = require('./cookie-c4d9848a.js');
const services = require('./services-895a8d1d.js');
require('./data-transfer-field-0ce05c1a.js');
require('./BaseField-d019ade6.js');
require('./filter-d5040f65.js');
require('./_commonjsHelpers-206db00d.js');

class DevingenApi {
  constructor(endpoint, defaultHeaders = {}) {
    this.createWorkspace = (name) => this.api.post(`workspaces`, { name });
    this.getWorkspaceOwnerships = () => this.api.get('workspace-ownerships');
    this.createProduct = (name, workspaceId, type) => this.api.post(`products`, { name, workspaceId, type });
    this.getProducts = () => this.api.get('products');
    this.getProduct = (id) => this.api.get(`products/${id}`);
    this.api = new kimlikApi.APIBase(endpoint, defaultHeaders);
  }
}

const wrapContent = (content) => (index.h(index.Host, null, index.h("dvn-theme-provider", { colorBackground: true, fitHeight: true }, index.h("dvn-global-table", null), index.h("dvn-global-grid", null), index.h("dvn-global-text", null), index.h("notifier-wrapper", null, content))));
let DevingenRoot = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
  }
  render() {
    const jwt = new cookie.CookieStorage().getAll().jwt;
    const headers = {
      Authorization: jwt ? `Bearer ${new cookie.CookieStorage().getAll().jwt}` : undefined,
    };
    const apiKimlik = new kimlikApi.KimlikApiImpl(`${services.prod.kimlik}/${services.prod.base}`, headers);
    const apiData = new dataApi.DataApiImpl(`${services.prod.data}/${services.prod.base}`, headers);
    const apiDevingen = new DevingenApi(`${services.prod.devingen}/${services.prod.base}`, headers);
    if (!index$1.isUserLoggedIn()) {
      return wrapContent(index.h("devingen-login-page", { apiKimlik: apiKimlik }));
    }
    return wrapContent(index.h("devingen-router", { apiKimlik: apiKimlik, apiDevingen: apiDevingen, apiData: apiData }));
  }
};

exports.devingen_root = DevingenRoot;
