import{r as e,h as s,H as i}from"./p-cb5076d4.js";import{i as a}from"./p-bfaa9282.js";import{D as o}from"./p-944da115.js";import{S as n,a as t}from"./p-1c5c6afa.js";import{T as r}from"./p-0db2169b.js";import{F as d,M as c}from"./p-61301881.js";import{V as p}from"./p-ad6da9fe.js";import{A as m}from"./p-27da9105.js";import{I as l}from"./p-6cf8ecf7.js";import"./p-8a308033.js";import{D as v,a as w}from"./p-3b35e507.js";import{D as f}from"./p-d50d0ec8.js";import"./p-83f217d4.js";import"./p-eebad85b.js";import"./p-35c7f358.js";import"./p-4f99fb23.js";import"./p-0e4ae084.js";import"./p-97c18602.js";class u{constructor(e){this.api=e}onSubmit(e){const{values:{name:s,workspaceId:i,type:a}}=e.detail;return new Promise(((e,o)=>{this.api.createProduct(s,i,a).then((()=>{e({events:[new l("","")],navigation:{type:"navigation",direction:"back"}})})).catch((()=>{o(["Unexpected error"])}))}))}}const b={"devingen-workspaces":f.decode({_id:"devingen-workspaces",base:"devingen-dev",fields:[new v("_created","Created").setDataType(w.Unix).setDateFormat("DD MMM YYYY HH:mm"),new r("name","Name")],name:"devingen-workspaces"})},h=e=>d.decode({_id:"new-product-form",base:"devingen-dev",title:"New domain",table:b["devingen-workspaces"],type:m.FormView,handler:new u(e),ui:{fields:[{field:new o("workspaceId")},{field:new r("name","Name").addInterceptor("onSubmit",new p(2,32)).addInterceptor("onSubmit",new c).require()},{field:new n("type","Product Type",[new t("Damga","damga",void 0,"Proxy service that generates SSL certificate for your domains.")],"","radioCard").require()}]}});class g{constructor(e){this.api=e}onSubmit(e){const{values:{name:s}}=e.detail;return new Promise(((e,i)=>{this.api.createWorkspace(s).then((()=>{e({events:[new l("","")],navigation:{type:"navigation",direction:"back"}})})).catch((()=>{i(["Unexpected error"])}))}))}}const j=class{constructor(s){e(this,s),this.isCreateWorkspaceFormShown=!1,this.isCreateProductFormShown=!1}onInvalidation(e){this.isCreateWorkspaceFormShown=!1,this.isCreateProductFormShown=!1}componentWillLoad(){}render(){const{isCreateProductFormShown:e,isCreateWorkspaceFormShown:a,products:o,selectedWorkspaceToCreateProduct:n,workspaceOwnerships:t}=this;return t&&o?s(i,null,s("div",{class:"container"},s("div",{class:"row"},t.map((e=>{const{workspace:i}=e;return s("div",{class:"col-sm-12"},s("h2",{class:"mt-3"},i.name),s("div",{class:"row"},o.filter((e=>e.workspace._id===i._id)).map((e=>s("div",{class:"col-sm-12 col-md-4 mb-3"},s("stencil-route-link",{url:`/products/${e._id}`},s("dvn-card",{bodyLeaned:!0,elevation:0,leaned:!0,selectable:!0,tint:"primary"},s("devingen-product-card",{product:e})))))),s("div",{class:"col-sm-12 col-md-4"},s("dvn-card",{bodyLeaned:!0,elevation:0,leaned:!0,selectable:!0,tint:"primary"},s("devingen-product-card",{onClick:()=>{this.isCreateProductFormShown=!0,this.selectedWorkspaceToCreateProduct=i._id}})))))}))),s("div",{class:"row"},s("div",{class:"col-sm-12 col-md-4 mt-3 pt-3"},s("dvn-button",{leaned:!0,onClick:()=>this.isCreateWorkspaceFormShown=!0,view:"flat"},s("dvn-icon",{iconName:"uil uil-plus"}),"Add new workspace")))),a&&s("dvn-dialog",{raw:!0,shown:!0,onDismiss:()=>this.isCreateWorkspaceFormShown=!1},s("dvn-app-view-form-view",{view:(l=this.apiDevingen,d.decode({_id:"new-workspace-form",base:"devingen-dev",title:"New domain",table:b["devingen-workspaces"],type:m.FormView,handler:new g(l),ui:{fields:[{field:new r("name","Name").addInterceptor("onSubmit",new p(2,32)).addInterceptor("onSubmit",new c).require()}]}}))})),e&&s("dvn-dialog",{raw:!0,shown:!0,onDismiss:()=>this.isCreateProductFormShown=!1},s("dvn-app-view-form-view",{view:h(this.apiDevingen),params:{workspaceId:n,type:"damga"}}))):s("div",{class:"d-flex justify-content-center pt-3"},s("dvn-progress",{indefinite:!0}));var l}};a(j);export{j as devingen_home_page}