import{r as e,h as t,H as s}from"./p-9f21f85f.js";import{U as n}from"./p-9c82afa0.js";import"./p-aa5ffe14.js";const i=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 r{}class o extends r{static decode(e){return Object.assign(Object.create(o.prototype),e)}}class c extends r{static decode(e){const t=Object.assign(Object.create(c.prototype),e);return t.user&&(t.user=n.decode(t.user)),t.workspace&&(t.workspace=o.decode(t.workspace)),t}}class a extends r{static decode(e){const t=Object.assign(Object.create(a.prototype),e);return t.user&&(t.user=n.decode(t.user)),t.workspace&&(t.workspace=o.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=n.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=>c.decode(e))).sort(((e,t)=>e.name.localeCompare(t.name))))}}onInvalidation(e){this.fetchWorkspaces()}componentWillLoad(){this.fetchSession(),this.fetchWorkspaces()}render(){const{apiData:e,apiDevingen:n,apiKimlik:i,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:n,apiKimlik:i,products:c,workspaceOwnerships:a},exact:!0}),t("stencil-route",{url:"/products/:id",component:"devingen-product-page",componentProps:{apiData:e,apiDevingen:n,apiKimlik:i,products:c,workspaceOwnerships:a},exact:!0}),t("stencil-route",{url:"/products/:id/api-keys",component:"devingen-product-api-keys-page",componentProps:{apiData:e,apiDevingen:n,apiKimlik:i,products:c,workspaceOwnerships:a},exact:!0}),t("stencil-route",{component:"devingen-page-not-found"}))))}};export{i as devingen_login_page,p as devingen_router}