import{r as e,h as t,H as s}from"./p-cb5076d4.js";import{U as i}from"./p-56d4255d.js";import{B as n,W as r,P as o}from"./p-b1bf76b5.js";import"./p-d50d0ec8.js";const c=class{constructor(t){e(this,t)}render(){return t(s,{class:"container-fluid"},t("div",{class:"row"},t("div",{class:"col d-flex justify-content-center mt-3"},t("dvn-card",null,t("kimlik-login-form",{api:this.apiKimlik,redirect:"/"})))))}};class a extends n{static decode(e){const t=Object.assign(Object.create(a.prototype),e);return t.user&&(t.user=i.decode(t.user)),t.workspace&&(t.workspace=r.decode(t.workspace)),t}}const p=class{constructor(t){e(this,t),this.fetchSession=async()=>{this.fetchSessionError=void 0;const e=await this.apiKimlik.getSession().catch((e=>{this.fetchSessionError=e}));e&&(this.user=i.decode(e.user))},this.fetchWorkspaces=async()=>{const e=await this.apiDevingen.getWorkspaceOwnerships().catch((e=>{this.fetchWorkspacesError=e}));if(!e)return;this.workspaceOwnerships=e.results.map((e=>a.decode(e)));const t=await this.apiDevingen.getProducts().catch((e=>{this.fetchWorkspacesError=e}));t&&(this.products=t.results.map((e=>o.decode(e))))}}onInvalidation(e){this.fetchWorkspaces()}componentWillLoad(){this.fetchSession(),this.fetchWorkspaces()}render(){const{apiData:e,apiDevingen:i,apiKimlik:n,fetchSessionError:r,fetchWorkspacesError:o,products:c,workspaceOwnerships:a,user:p}=this;return r?t(s,null,t("devingen-top-bar",{user:p}),t("div",{class:"d-flex justify-content-center"},t("devingen-error-card",{error:r,message:"Failed to get session info.",onRetry:this.fetchSession}))):o?t(s,null,t("div",{class:"d-flex justify-content-center"},t("devingen-error-card",{error:o,message:"Failed to get workspace info.",onRetry:this.fetchWorkspaces}))):t(s,null,t("devingen-top-bar",{user:p}),t("stencil-router",null,t("stencil-route-switch",{scrollTopOffset:0},t("stencil-route",{url:"/",component:"devingen-home-page",componentProps:{apiData:e,apiDevingen:i,apiKimlik:n,products:c,workspaceOwnerships:a},exact:!0}),t("stencil-route",{url:"/products/:id",component:"devingen-product-page",componentProps:{apiData:e,apiDevingen:i,apiKimlik:n,products:c,workspaceOwnerships:a}}),t("stencil-route",{component:"devingen-page-not-found"}))))}};export{c as devingen_login_page,p as devingen_router}