var h=Object.defineProperty;var b=(a,t,e)=>t in a?h(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,eA as w,J as v,b as k,c as $,u as _}from"./outputWidgets.b9aa154a.js";import{a as I}from"./asyncComputed.9bda3979.js";import"./console.ee73e2aa.js";import{C as l}from"./gateway.5aa82c5f.js";import{A}from"./activeRecord.8939db5d.js";import"./index.4d631048.js";import{p as C}from"./icons.4ed83c58.js";import{_ as j}from"./CrudView.vue_vue_type_script_setup_true_lang.8866a12f.js";import"./index.ade1bec6.js";import"./Form.55f226f4.js";import"./Title.6cd833fd.js";import"./index.74d4e484.js";import"./index.6b140cad.js";import"./index.29aa7167.js";import"./dayjs.d2a09bae.js";import"./index.ea68e603.js";import"./index.bb85a084.js";import"./TabPane.3d00468a.js";import"./index.ab1855db.js";import"./index.14f3ef13.js";import"./index.eb23b22d.js";import"./index.45ef6041.js";import"./index.45ac8fb9.js";import"./index.004b987c.js";import"./index.23063916.js";import"./index.55488473.js";import"./pubsub.967f482a.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]="4eafe3fb-3b98-4fcc-9202-c4659f965a31",a._sentryDebugIdIdentifier="sentry-dbid-4eafe3fb-3b98-4fcc-9202-c4659f965a31")}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 o=new P;class s{constructor(t,e){u(this,"record");this.projectId=t,this.record=A.create(o,e,"id")}static async list(t){return(await o.list(t)).map(r=>new s(t,r))}static async create(t,e,r){const n=await o.create({projectId:t,name:e,value:r});return new s(t,n)}static async get(t,e){const r=await o.get(e);return new s(t,r)}static async update(t,e,r){const n=await o.update(e,r);return new s(t,n)}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 o.delete(this.projectId,this.key)}hasChanges(){return this.record.hasChanges()}}const rt=g({__name:"EnvVars",setup(a){const e=w().params.projectId,{loading:r,result:n,refetch:m}=I(()=>s.list(e)),d=[{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),m()}const f=v(()=>{var i,c;return{columns:[{name:"Key"},{name:"Actions",align:"right"}],rows:(c=(i=n.value)==null?void 0:i.map(p=>({key:p.key,cells:[{text:p.key},{text:"Actions",actions:[{icon:C,label:"Delete",async onClick(){await p.delete(),m()},dangerous:!0}]}]})))!=null?c:[]}});return(i,c)=>(k(),$(j,{"entity-name":"Env var",loading:_(r),title:"Environment Variables",description:"Set environment variables for your project.","empty-title":"No environment variables set",table:f.value,"create-button-text":"Add Environment Variable",fields:d,onCreate:y},null,8,["loading","table"]))}});export{rt as default};
//# sourceMappingURL=EnvVars.2d04bc1a.js.map
