'use strict';

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

const index = require('./index-ce58ddc5.js');
const dark = require('./dark-18386f8e.js');
const dataApi = require('./dataApi-fbe22059.js');
const kimlikApi = require('./kimlikApi-f4f62100.js');
const index$1 = require('./index-4b96acc9.js');
const cookie = require('./cookie-ea977378.js');
const apiBase = require('./apiBase-b14a8285.js');
const services = require('./services-ebcf560b.js');
require('./colors-a0e2d25f.js');
require('./data-transfer-field-0ce05c1a.js');
require('./BaseField-d019ade6.js');
require('./filter-d5040f65.js');
require('./_commonjsHelpers-206db00d.js');

class DevingenApi {
  constructor(endpoint, defaultHeaders = {}) {
    // region products
    this.createProduct = (body) => this.api.post(`products`, body);
    this.getProducts = () => this.api.get('products');
    this.getProduct = (id) => this.api.get(`products/${id}`);
    this.updateProduct = (id, body) => this.api.put(`products/${id}`, body);
    this.deleteProduct = (id) => this.api.delete(`products/${id}`);
    // endregion
    // region workspace
    this.createWorkspace = (name) => this.api.post(`workspaces`, { name });
    this.updateWorkspace = (id, body) => this.api.put(`workspaces/${id}`, body);
    this.deleteWorkspace = (id) => this.api.delete(`workspaces/${id}`);
    // endregion
    this.getWorkspaceOwnerships = () => this.api.get('workspace-ownerships');
    this.api = new apiBase.APIBase(endpoint, defaultHeaders);
  }
}

const wrapContent = (content) => (index.h(index.Host, null, index.h("dvn-theme-provider", { theme: dark.dark, 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, 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;
