var f=Object.defineProperty;var b=(a,t,e)=>t in a?f(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var u=(a,t,e)=>(b(a,typeof t!="symbol"?t+"":t,e),e);import{d as g,ez as w,H as v,b as k,c as $,u as C}from"./outputWidgets.d6334d0e.js";import{a as I}from"./asyncComputed.95fd0999.js";import"./router.c9839d0e.js";import{C as l}from"./gateway.78108c4a.js";import{A as _}from"./activeRecord.aa738a85.js";import"./columns.6b92da60.js";import{k as j}from"./icons.09e1f108.js";import{C as A}from"./CrudView.a040df87.js";import"./Form.afe8a620.js";import"./Title.132c3f7f.js";import"./transButton.97ae4a5a.js";import"./Text.2f6a30da.js";import"./index.85dd1fea.js";import"./pubsub.9d7d329e.js";import"./index.f4ac7424.js";import"./url.dce42ecb.js";import"./index.9476b093.js";import"./index.e0fb68fa.js";import"./index.98d66b02.js";import"./index.2221e01c.js";import"./index.6da051f8.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="c87c0b45-6c9c-4b6f-a84d-80996dd64fc5",a._sentryDebugIdIdentifier="sentry-dbid-c87c0b45-6c9c-4b6f-a84d-80996dd64fc5")}catch{}})();class P{constructor(){u(this,"urlPath","env-vars")}async create(t){return l.post(`projects/${t.projectId}/${this.urlPath}`,{name:t.name,value:t.value})}async delete(t,e){await l.delete(`projects/${t}/${this.urlPath}/${e}`)}async list(t){return l.get(`projects/${t}/${this.urlPath}`)}async get(t){return l.get(`${this.urlPath}/${t}`)}async update(t,e){return l.patch(`${this.urlPath}/${t}`,e)}}const n=new P;class s{constructor(t,e){u(this,"record");this.projectId=t,this.record=_.create(n,e,"id")}static async list(t){return(await n.list(t)).map(r=>new s(t,r))}static async create(t,e,r){const o=await n.create({projectId:t,name:e,value:r});return new s(t,o)}static async get(t,e){const r=await n.get(e);return new s(t,r)}static async update(t,e,r){const o=await n.update(e,r);return new s(t,o)}get key(){return this.record.get("name")}get value(){return this.record.get("value")}set value(t){this.record.set("value",t)}async save(){await this.record.save()}async delete(){await n.delete(this.projectId,this.key)}hasChanges(){return this.record.hasChanges()}}const Y=g({__name:"EnvVars",setup(a){const e=w().params.projectId,{loading:r,result:o,refetch:p}=I(()=>s.list(e)),m=[{label:"Variable name",key:"key"},{label:"Variable value",key:"value",type:"password"}];async function y({key:i,value:c}){await s.create(e,i,c),p()}const h=v(()=>{var i,c;return{columns:[{name:"Key"},{name:"Actions",align:"right"}],rows:(c=(i=o.value)==null?void 0:i.map(d=>({key:d.key,cells:[{text:d.key},{text:"Actions",actions:[{icon:j,label:"Delete",async onClick(){await d.delete(),p()},dangerous:!0}]}]})))!=null?c:[]}});return(i,c)=>(k(),$(A,{"entity-name":"Env var",loading:C(r),title:"Environment Variables",description:"Set environment variables for your project.","empty-title":"No environment variables set",table:h.value,"create-button-text":"Add Environment Variable",fields:m,onCreate:y},null,8,["loading","table"]))}});export{Y as default};
//# sourceMappingURL=EnvVars.a7c05c46.js.map
