import { r as registerInstance, h, H as Host } from './index-55faf181.js';
import { D as DataApiImpl } from './dataApi-abfa358d.js';
import { A as APIBase, K as KimlikApiImpl } from './kimlikApi-7350588e.js';
import { i as isUserLoggedIn } from './index-36f6c00a.js';
import { C as CookieStorage } from './cookie-93ea205f.js';
import { p as prod } from './services-fc4ce8f3.js';
import './data-transfer-field-918730a3.js';
import './BaseField-461b6d0c.js';
import './filter-cbaa3d7d.js';
import './_commonjsHelpers-27f122dd.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 APIBase(endpoint, defaultHeaders);
  }
}

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

export { DevingenRoot as devingen_root };
